Sponsored Link •
Now that we have built a Jini service for logging information showing what methods have been invoked on the space and by whom, how do we go about using it?
Well this really depends on whether we're trying to identify a bug
or just analyze the space's usage patterns. For example, one of the
most common errors we encounter is where a client has been written
to perform a
read() when it should have used
take() or visa-versa, thus leaving or removing entries
from the space that other clients are dependent on.
To identify this type of bug quickly, stop the logging service, rename or delete the previous log file and then run the client against the logging service. Once you have the logging data, say in CSV format, you can open it in a spreadsheet application and count up the reads, writes and takes to determine what interactions actually occurred within the space between the client programs. If on the other hand you go ahead and implement a JDBC strategy then querying the logging data becomes much simpler—in fact you could go even further and write another Jini service with a Service UI that provides analytics and ad hoc querying of the logging data.
The code we have presented here needs few important enhancements/improvements for use in real-world cases. The most obvious enhancement is to pass the space name and logging service names to the proxies to identify the correct services. This will let you have multiple logging services and spaces running within a Jini environment.
A more advanced enhancement is to make the logging service a
"well-behaved Jini service;" thus, supporting the
JoinAdmin interface, which allows remote
configuration of groups, look up locators, and attributes.
Logging information based on the
representation of parameters passed to the JavaSpaces API may not
be sufficient. You may therefore build on this article's concepts by
adding fields to the
SpaceOperation class that contain
the actual parameters as objects, such as transactions and entries.
This would allow an advanced
LoggingStrategy to log
transaction IDs and use reflection on the entries to store more
You could also record the time taken to execute a method on the
JavaSpace and store it in the
Another option would be to examine the return value from the call to
the JavaSpace, which could a useful logging enhancement for
determining whether a read or take succeeded, that is, a non-
null value was returned.
Although using JavaSpaces simplifies many aspects of writing and deploying distributed systems, debugging can be tricky. Therefore, we provide the following review of tips and suggestions:
So there you have it. We have used Jini's ability to export proxies into a remote system to allow us to remotely observe the behavior of any number of remote JavaSpace clients. Of course you can also use this technique to observe the behavior of other systems, or to develop a generalized 'observer' for Jini has whole. If you found this information useful and have developed any of the ideas or idioms further please let us know. Good luck and happy debugging.
Philip Bishop is an independent distributed systems consultant, specializing in the design and implementation of large-scale systems for organizations ranging from utility companies to investment banks.
Nigel Warren is cofounder and director of technology at IntaMission Ltd., where he researches and designs agile and evolvable software infrastructures for next-generation distributed systems.
Philip and Nigel are also the joint authors of JavaSpaces in
Practice and Java in Practice, both published by
Observing JavaSpace-Based Systems, Part I,
by Philip Bishop & Nigel Warren, is the first part of this two part series on
logging and analyzing JavaSpace-based distributed systems:
JavaSpaces in Practice, a new book by
by Philip Bishop and Nigel Warren,
is at Amazon.com at:
The website for JavaSpaces in Practice is here:
JavaSpaces: Principles, Patterns, and Practice
by Eric Freeman, Susanne Hupfer, and Ken Arnold,
an introduction to JavaSpaces,
is at Amazon.com at:
The source code for the examples appearing in this article can be
The Jini Community, the central site for signers of the Jini Sun Community Source License to interact:
Download JavaSpaces from:
Room for JavaSpaces, Part I - An introduction to JavaSpaces, a simple and powerful distributed programming tool:
Room for JavaSpaces, Part II - Build a compute server with JavaSpaces, Jini's coordination service:
Room for JavaSpaces, Part III - Coordinate your Jini applications with JavaSpaces:
Room for JavaSpaces, Part IV - Explore Jini transactions with JavaSpaces:
Room for JavaSpaces, Part V - Make your compute server robust and scalable with Jini and JavaSpaces:
Room for JavaSpaces, Part VI - Build and use distributed data structures in your JavaSpaces programs: