The Distributed Calculator: |
Scaling Up - Enterprise Concernsby Bill Murray and Yoonju Kim Remote Method Invocation was introduced with the 1.1 release of Java. Aside from general performance concerns, the most immediate short-coming noted were
Though garbage collection has always been an issue with Java, it is more acute in distributed applications because one is never sure if the object is truly no longer needed, if the fault lies with a dropped network connection or if the client VM crashed. It such cases, a server object can be garbage-collected even though the client still has need for it. Or, in the other extreme, a server object may persist even though the client VM has crashed and been restarted. This also gets in the issues of server binding and object persistence. In Java 2, several changes were introduced to address these changes. Garbage Collection is now done on an "expirable lease" basis. This works by having the Reference Layer keep expirable lease on an object. The object becomes a candidate for garbage collection when:
Though expirable leases helps conserve resources, it alone does not adequately address the issues of server binding. The other major RMI-related improvement in Java 2 is the ability for a client to instantiate a server object(s) by one of two ways:
Specifically, when a server registers itself, it may declare the calling method that can instantiate it. Thus, the act of registering does not instantiate the server object until the specific client method to invoke it is made. This can also be accomplished using Activation Groups -- a collection of objects that become instantiated in one virtual machine upon a call from a client. Once activated, these objects may be restarted they exit normally, be destroyed by garbage collection or destroyed by a network/system failure. On a practical scale, improved programming techniques have lead to changes in how the RMI registry is managed. In this snipet of code from a banking example in Java Enterprise In A Nutshell, each time a new account is created, each time a new account is created for remote management, it is bound to the registry
Because its not possible to know ahead of time how many accounts will be created this is a very impractical method, registry overhead not withstanding. As a solution, programming technique has been improved to use factory classes to dynamically create objects in such circumstances. Using remote method calls on factory classes, clients can create dynamically request creation of new remote objects without needing to individually register with the server registry Here's the banking example using factory classes:
RMI and JNI (Java Native Interface)
RMI and IIOP?
|