Information Technology Reference
In-Depth Information
public void foo(String name) throws java.rmi.RemoteException {
boolean done = false;
do {
try {
IFooFoo stub = (IFooFoo)getRegistry().lookup( "registry" );
stub.foo(name);
return;
} catch (java.rmi.RemoteException e) {
findAlternateServer();
}
} while (!done);
return;
}
Figure 5.4.
RMI client generated method.
To implement the recovery scenarios, we use helper classes in the client pro-
tocol implementation, which consists of generic recovery code. The code in the
helper class is merged with the client classes (the classes matched in the DDL
statements) and each matching method referred to in the DDL is wrapped with
code that calls the remote implementation and, in the event of an error, the user-
defined recovery routine. For example, for the RMI implementation, the call to a
remote method called foo(String name) with the nextServer recovery method
defined in the DDL, results in the code in Figure 5.4 being generated:
In the case where a recovery statement has been defined in the DDL,
the findAlternateServer() method call in Figure 5.4 is replaced by the user-
defined code. If the abort or continue statement has been defined, then
findAlternateServer() is replaced with System.exit(1); and done = true;
respectively.
The implementation of the DDL recovery routine nextServer cycles through
a list of comma-separated host names or IP addresses that have either been defined
in the DDL or in the system property, remotej.servers . If the system property
remotej.servers has been defined it overrides values specified in the DDL. To
guard against a continuous loop, if all hosts have been tried in sequence and
communication to all hosts is unsuccessful, the application will be terminated as
we consider this an unrecoverable error.
For user-defined recovery routines, in addition to the Transfer object we
provide access to three methods, getCurrentHost() , findAlternateServer()
(thesamemethodusedbythe nextServer DDL statement implementation) and
setHosts(String[] hosts) that can be used to aid the programmer in binding to
an alternate server. This, used in conjunction with programmer-provided classes
that may be used alongside generated classes, allows for highly configurable user-
defined recovery scenarios.
Search WWH ::




Custom Search