The Artima Developer Community
Sponsored Link

Observing JavaSpace-Based Systems, Part II
How to Log and Analyze a Space-Based Distributed System
by Philip Bishop & Nigel Warren
October 14, 2002

<<  Page 6 of 6


Analyzing the logging data

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 toString() 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 descriptive information.

You could also record the time taken to execute a method on the JavaSpace and store it in the SpaceOperation class. 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.

Overview and tips

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:

  1. Some space implementations have both debugging modes and debugging tools. If you have these tools available, we suggest you use whatever you find the easiest and most informative.
  2. Always build a small subset of the system that you intend to deploy in order to test your assumptions of its behavior against what you can observe.
  3. A simple local logging proxy can be useful for single client testing, but is more trouble than it's worth when multiple clients are involved.
  4. Using a JavaSpaces (Jini) Logging Service along the lines described in this article can help to identify problems more quickly than writing application-specific debugging code.
  5. Implementing a JDBC (Java Database Connectivity) strategy lets you use SQL to query the log and filter on particular method types, hosts, or template parameters.

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.

Talk Back!

Discuss this article in the News & Ideas Forum topic, Observing JavaSpace-Based Systems.

About the authors

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 Addison-Wesley.


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 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 at:

The source code for the examples appearing in this article can be downloaded here:

The Jini Community, the central site for signers of the Jini Sun Community Source License to interact:

Download JavaSpaces from:

Make Room for JavaSpaces, Part I - An introduction to JavaSpaces, a simple and powerful distributed programming tool:

Make Room for JavaSpaces, Part II - Build a compute server with JavaSpaces, Jini's coordination service:

Make Room for JavaSpaces, Part III - Coordinate your Jini applications with JavaSpaces:

Make Room for JavaSpaces, Part IV - Explore Jini transactions with JavaSpaces:

Make Room for JavaSpaces, Part V - Make your compute server robust and scalable with Jini and JavaSpaces:

Make Room for JavaSpaces, Part VI - Build and use distributed data structures in your JavaSpaces programs:

<<  Page 6 of 6

Sponsored Links

Copyright © 1996-2017 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us