theLink 10.0
|
Documentation of the Filter6 tool used for trans2.test
.
The Filer6 tool is used to test the filter-feature of atlmqmsgque.
To run the filter test, a first client, one or more filters and a final server are created. All are connected to the atlmqmsgque protocol.
The trans2.test
carries out common filter tests and special stress tests. A stress test is performed by exiting one or more filters or servers and observing the response and behavior when reconnecting.
The GOAL for this test is:
#!/usr/bin/env atlsh #+ #: @file NHI1/example/atl/Filter6.atl #: @brief tag: nhi1-release-250425 #: @copyright (C) NHI - #1 - Project - Group #: This software has NO permission to copy, #: please contact AUTHOR for additional information #: package require lib_85 package require atlmqmsgque ::myooX::ClassN ::Filter6 { SuperI ::MqContextC proc Filter6 { myNs {tmpl ""} } { MqContextC $myNs $tmpl ConfigSetIgnoreExit $myNs yes ConfigSetServerSetup $myNs FilterSetup ConfigSetServerCleanup $myNs FilterCleanup ConfigSetEvent $myNs FilterEvent } ## [filter_service_example] proc FilterSetup { myNs } { set ftr [SlaveGetFilter $myNs] namespace upvar $myNs FH FH set FH "" ServiceCreate $myNs "LOGF" LOGF ServiceCreate $myNs "EXIT" EXIT ServiceCreate $myNs "SOEX" SOEX ServiceCreate $myNs "ERR1" ERR1 ServiceStorage $myNs "PRNT" ServiceStorage $myNs "PRN2" ServiceCreate $myNs "+ALL" FilterIn MqContextC::ServiceCreate $ftr "WRIT" WRIT ServiceCreate $myNs "WRIT" WRIT MqContextC::ServiceProxy $ftr "WRT2" MASTER } ## [filter_service_example] proc FilterCleanup { myNs } { namespace upvar $myNs FH FH if {$FH ne ""} {close $FH} unset FH } proc errorWrite { ctx } { namespace upvar $ctx FH FH set err [MqContextC::ErrorFORMAT $ctx] try { puts $FH "ERROR: [MkErrorC::GetText $err]" flush $FH } on error "" { MkerrorC::Println $err } MkErrorC::Reset $err } proc LOGF { myNs } { set ftr [SlaveGetFilter $myNs] if {[regexp {^(?:Filter6-1|Filter6|fs1.*)$} [MqContextC::ConfigGetName $ftr]]} { namespace upvar $myNs FH FH set FH [open [ReadSTR $myNs] a] } else { ProxyForward $myNs $ftr } SendRETURN $myNs } proc WRIT { myNs } { set master [SlaveGetMaster $myNs] if {[regexp {^(?:Filter6-1|Filter6|fs1.*)$} [MqContextC::ConfigGetName $master]]} { namespace upvar $master FH FH puts $FH [ReadSTR $myNs] flush $FH } else { ProxyForward $myNs $master } SendRETURN $myNs } proc EXIT { myNs } { Exit $myNs } proc ERR1 { myNs } { # simulate a scripting BUG MkErrorC::SetEXIT $myNs } proc SOEX { myNs } { MkErrorC::SetEXIT [ErrorFORMAT $myNs] } proc FilterIn { myNs } { StorageExport $myNs SendRETURN $myNs } proc FilterEvent { myNs } { if {[StorageCount $myNs] == 0} { # no data -> nothing to do MkErrorC::SetCONTINUE [ErrorFORMAT $myNs] } else { try { # with data -> try to send set ftr [SlaveGetFilter $myNs] # read package from storage set Id [StorageImport $myNs] #StorageLog $myNs #LogC $myNs "StorageLog-id = $Id\n" # forward the entire BDY data to the ftr-target try { ProxyForward $myNs $ftr } trap {MkExceptionC} {errorMessage} { set err [StorageErrCnt $myNs $Id] if {$err < 3} { StorageDecrRef $myNs $Id return } else { error $errorMessage $::errorInfo $::errorCode } } trap * {} { error $errorMessage $::errorInfo $::errorCode } } on error {} { # on "error" do the following: ErrorCatch $myNs # on "normal-error" -> write message to file and ignore # continue and delete data in next step Filter6::errorWrite $myNs } # on "success" or on "error" delete item from storage StorageDelete $myNs $Id } } } # [error_example] MqMsgque::Main { set srv [MqFactoryC::New [MqFactoryC::Add ::Filter6]] try { MqContextC::LinkCreate $srv {*}$argv MqContextC::ProcessEvent $srv MQ_WAIT_FOREVER } on error {} { MqContextC::ErrorCatch $srv } finally { MqContextC::Exit $srv } } # [error_example]