Note: www.cdegroot.com is in rebuild. Please accept my apologies for broken links, missing stuff, etcetera - more
  Home

JavaSpaces, part 2

Last week, I promised that could enter complex computation objects without changing the workers. I think you guessed why, but here's the explanation anyway: as long as all the entries in the space are Computation objects, the worker will fetch them one by one (because it asks the space for Computation type objects), execute them, and write the results back without much consideration for the actual computation that the object encapsulates.

Meanwhile, all the various masters ask the space for their particular result objects (so the MeanComputation master would ask the space for objects of type MeanComputationResult, etcetera), and so a cluster of processors with a JavaSpace "in front" is all you need to do large-scale parallel computations. JavaOne 1998 proved that point nicely by computing a Mandelbrot graph on a huge "cluster" of participant's Java rings coordinated by a JavaSpace.

Computation is just the start, however. JavaSpaces is also great for solving workflow problems.

Assume that every letter that arrives at the mail department is scanned in by some machine. The scans are stored in a Space as "UnprocessedIncomingMail" objects. Clerks run software on their desktop that continuously fetches the next UnprocessedIncomingMail object from the Space; they scan the letter and select a destination department. The result of selecting, say, "Support" as the destination department would be that the scan is written back as an UnprocessedMailForSupport object. At Support, someone runs software that fetches the next UnprocessedMailForSupport object, and reads it - etcetera. By coordinating multiple JavaSpaces (through Jini), the scans could physically "hop" from department Space to department Space, always staying in close proximity to the people that are processing the mail - this would ease the load on the network compared with the situation where every scan would come from a central server.

In "JavaSpaces Principles, Patterns and Practice" the authors of the JavaSpaces specification discuss a lot of such applications, and also show the way in how to do more complex things by applying distributed algorithms tricks to build up complex data structures from multiple entries in the space. It takes the same sort of shift in thinking that you need when you go from procedural to object-oriented programming: hard at first, but immensely powerful when you "get it". A lot of distributed problems, be they mathematics or workflow management, can be solved in a very reliable and elegant way by using JavaSpaces in your application.

[Cover image - click for larger version] JavaSpaces Principles, Patterns and Practice
Eric Freeman, Susanne Hupfer, Ken Arnold
Addison Wesley 2000
ISBN 0-201-30955-6


 
Copyright (C)2000-2011 Cees de Groot -- All rights reserved.