Activatable Jini services, Part 2: Patterns of use
The RMI activation framework can produce self-sufficient and flexible Jini services
By Frank Sommers, JavaWorld.com, 10/27/00
- Digg
- Reddit
- SlashDot
- Stumble
- del.icio.us
- Technorati
- dzone
In Part 1 of this series, I defined activation as the process of creating and exporting an object via the RMI activation system,
making it available for remote method calls. I also presented the chief goal of the RMI activation system: to help remote
objects manage their computational resources. The JDK's activation mechanism does just that; it
helps objects manage their computational resources, it does not do it for them. It is up to the developer of Jini services to properly
utilize RMI activation to support resource management. In Part 2, I will present the consequences of Jini activation and some
helpful patterns of use. The first important area to consider is deactivation.
TEXTBOX:
TEXTBOX_HEAD: Activatable Jini services: Read the whole series!
:END_TEXTBOX
When to deactivate
An object informs the activation group that it is no longer active by calling Activatable.inactive(), which essentially calls the current activation group's inactiveObject() method. If no remote method calls to the object are pending -- i.e., the object really is inactive -- the group unexports
the object and notifies its monitor. Thereafter, the activation monitor will consider the object's remote references as stale,
causing activate() requests with the object's activation ID to trigger the activation protocol (described in Part 1).
If Activatable.inactive() succeeds, and if the group has no more active objects and is not activating objects, the activation system will shut down
the group's Java VM. If an object fails to call Activatable.inactive(), it will never be garbage-collected because the activation group holds strong references to every object it creates. (Hence,
if that object is the last one running in the Java VM, the Java VM will not shut down either.) The rules for garbage collection
still hold, though: the object needs to make sure that it has no nondaemon threads running, and that it nulls out enough references
to be eligible for garbage collection.
The remote object decides when to call inactive(); this decision warrants some stipulations. One requirement for calling this method is that the remote object should not handle
remote method calls. Also, reactivating the object should not require more effort than keeping it active for long periods
of time. For instance, if a server only runs a few activatable Jini service implementations -- each of which might receive
a remote method call once every few hours -- and the server is loaded lightly, running those objects continually would be
the best option.
The last deactivation issue we'll consider is leases. In the Jini programming model, services typically lease their resources.
For instance, not only does LoanApprovalService lease its residency in lookup services, but clients that wish to use this service lease their access to it as well. When
first contacted by a client, the service should return a Registration object that contains a lease and the remote service reference, not a direct remote reference to itself.
- Digg
- Reddit
- SlashDot
- Stumble
- del.icio.us
- Technorati
- dzone
Resources
- Sun's John McClain offers some insight on inactivation in the Jini context, and talks about remote references,
unreferenced(), and distributed garbage collection in this message to the Jini Users list
http://archives.java.sun.com/cgi-bin/wa?A2=ind0008&L=jini-users&P=R23315.
- "Cleaning up after Jini services," Bill Venners (JavaWorld, March 2000) -- Venners discusses finalization in the Jini context. While he focuses mainly on Jini service proxies, the issues
are equally relevant to service implementations
http://www.javaworld.com/javaworld/jw-03-2000/jw-0324-jiniology.html
- Some ideas and questions about maintaining state in a long-lived Jini federation are mentioned in this email message to the
Jini list by Sun's William O'Connor
http://archives.java.sun.com/cgi-bin/wa?A2=ind0006&L=jini-users&P=R35395.
- Sun Lab's Forest Project has information about orthogonally persistent Java (PJama), and a VM implementing orthogonal persistence,
opj. While orthogonal persistence may not be desirable and correct in many environments, VMs of this sort can generate ideas
about low startup latency of Java programs (including activatable Jini services) and preserving execution state across program
restarts
http://www.sun.com/research/forest
- The Sun technical report TR-95-46, Simple Activation for Distributed Objects, by Jim Waldo, Ann Wollrath, and Geoff Wyant, is available from Sun's Website
http://www.sun.com/research/techrep/1995/abstract-46.html
- The RMI Specification
http://java.sun.com/j2se/1.3/docs/guide/rmi/spec/rmiTOC.html
- Chapter 7 of the RMI Specification specifically describes remote object activation
http://java.sun.com/j2se/1.3/docs/guide/rmi/spec/rmi-activation.html
- Sun's RMI home page has many useful pointers for all things RMI
http://java.sun.com/products/jdk/rmi
- Sun's RMI team presents a useful activation tutorial
http://java.sun.com/j2se/1.3/docs/guide/rmi/activation.html
- "The End of Potocols," Jim Waldo (Java Developer Connection, September 2000) -- Jini's chief architect describes the end of protocols, and highlights, among other things, why Jini is
not tied to RMI (free registration to the Java Developer Connection required)
http://developer.java.sun.com/developer/technicalArticles/jini/protocols.html
- The Sun technical report TR-94-29, A Note on Distributed Computing, by Samuel C. Kendall, Jim Waldo, Ann Wollrath, and Geoff Wyant, describes the role of
RemoteException, why it is a checked exception and not a runtime exception, and the basic difference between remote and local method invocations
http://www.sun.com/research/techrep/1994/abstract-29.html
- Sun's John McClain posted The Process Architecture of the JSK and JSTK to the Jini-users list. The message presents a clear explanation of the role of RMI activation in Sun's implementation of
the services that come with the JSK. Part 1
http://archives.java.sun.com/cgi-bin/wa?A2=ind9903&L=jini-users&P=R14099
- Part II
http://archives.java.sun.com/cgi-bin/wa?A2=ind9903&L=jini-users&P=R36142
- Ann Wollrath explains different ways to implement persistent remote references in a message posted to the RMI-users list.
She also discusses how to use
ActivationGroupDesc to set up a common environment for a group
http://archives.java.sun.com/cgi-bin/wa?A2=ind0007&L=rmi-users&P=R13480
- The Jini home page contains links to all of the Jini technical documentation
http://www.jini.org
- Jini Specifications
http://www.sun.com/jini/specs
- Bill Venners maintains the Jini FAQ
http://www.artima.com/jini/faq.html
- Venners also manages Jini Corner on his Website
http://www.artima.com/jini/index.html
- The Directory of Jini Resources on the Net
http://www.litefaden.com/sv/jd