Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Running multiple ALs on one server or multiple ALs on multiple server instances

99 views
Skip to first unread message

Victor Apetri

unread,
Jan 26, 2010, 6:50:02 AM1/26/10
to
Hello,
I have on the same server
an RMI Dispatcher for the TAM Combo Adapter and my AL with ADchangelog
- TIM update. If i start the AL on the server, when i try to start the
RMI says something like the 1099 port is alrady in use.
Again after awhile i find the RMI down, and the connection between TIM
and TAM interrupted.
how can i force my al to start on a second server defined on the same
machine ?
or how to move the RMI dispatcher on a second server on the same
machine?
Thank you

Eddie Hartman

unread,
Jan 27, 2010, 8:14:25 AM1/27/10
to
Glad you asked that, Victor. Johan is writing a paper
on the subject so expect an inspired answer :)

Adding failover to a solution is not difficult. But there is
a cost: your ALs have to die. Do not set timeout in Iterators
to "never time out". Instead your ALs stop and you have
a script to re-launch them. That is step one.

Secondly you need a way for your AL to tell your script
what has happened. The simplest approach would be to
use an exit code, although support for this in TDI is not
very elegant.

You can use main.shutdownServer(7) to stop the AL and
Server with exit code = 7. Note that the AL's Shutdown
Request Hook is called during shutdown as well as the
AL Success Hook. So if you do this from an Error Hook
then you are "swallowing" the error and will not end up in
the AL Failure Hooks - unless you re-throw the exception:

throw error.message;
// or throw error.getString("message"); for 6.1.1

You will also have to edit the ibmdisrv script/batch-file so
that it is not using local environment settings. For example, I
have this at the end of my ibmdisrv.bat, after the
endlocal command.
-----
...
endlocal

IF ERRORLEVEL 0 SET ERRORLEV=0
IF ERRORLEVEL 1 SET ERRORLEV=1
IF ERRORLEVEL 2 SET ERRORLEV=2
IF ERRORLEVEL 3 SET ERRORLEV=3
IF ERRORLEVEL 4 SET ERRORLEV=4
IF ERRORLEVEL 5 SET ERRORLEV=5
IF ERRORLEVEL 6 SET ERRORLEV=6
IF ERRORLEVEL 7 SET ERRORLEV=7
IF ERRORLEVEL 8 SET ERRORLEV=8
IF ERRORLEVEL 9 SET ERRORLEV=9
echo IBMDISRV - ERRORLEVEL='%ERRORLEV%'
-----
So after invoking the startup batch-file I can examine
the "ERRORLEV" environment variable and act
accordingly.

Kinda brutal, but it works.

You can also launch ALs on a running Server with
the bin/tdisrvctl utility. However, this guy does not
support return codes (yet).

As an alternative to shutdownServer() you could
do something like writing the exit status to a file.

Here is a script I use in my AssemblyLine. Drop it in
the Script library (Resources > Scripts for TDI 7) and
then and then in AL Settings > Include Additional Prologs
select it to load when the AL starts up.
----
function setExitCode( exitCode ) {
if (system.isValidInt(String(exitCode)))
exitCode = String(java.lang.Integer.parseInt(exitCode));

var resFile = system.openFileForOutput("c:/temp/" +
task.getShortName() +
".bat");

exitCode = "SET TDI_EXITCODE=" + exitCode.toString();
resFile.write(exitCode.toCharArray(), 0, exitCode.length);
resFile.newLine();
resFile.close();

// debug output to the stdout
java.lang.System.out.println("--> setting " + exitCode)
}
----
From the AL Prolog - Before Init Hook I do:
setExitCode(0)
end then from Error Hooks I do
setExitCode(7); // lucky number :)
or
setExitCode("Some error message")

Then in the batch-file that calls ibmdisrv you do this
at the end (Note my AL is called "1_ExitCode"):
-----
call c:\temp\1_ExitCode.bat
echo TDI_EXITCODE='%TDI_EXITCODE%'
-----
Now you can examine %TDI_EXITCODE% and decide
to launch point your solution at a different server. The
easiest way to do this with a command line option
when you start ibmdisrv. The options 0 through 9 are
reserved for custom use, so you could use -0 to
specify a parameter value. Back in your AssemblyLine
you put code like this in the Prolog - Before Init Hook
of the Connector:
-----
newParamVal = main.commandLineParam("0");
if (newParamVal != null)
thisConnector.getConnector().setParam("paramName", newParamVal);
-----

Ok, so now your ALs are set to time out and status is
passed back to your calling batch-file. All you do now is add
logic in the batch-file to detect a connection failure exit code
and re-launch ibmdisrv with a different -0 argument value.

Whew! And perhaps someone could grace us with an example
of the above for Unix as well?

-Eddie

0 new messages