The Artima Developer Community
Sponsored Link

Make Room for JavaSpaces, Part I
Ease the Development of Distributed Apps with JavaSpaces
by Eric Freeman and Susan Hupfer
First Published in JavaWorld, November 1999

<<  Page 5 of 9  >>


JavaSpaces in Context

Our description so far has been a little abstract, so let's consider a few examples of real distributed applications that you can model as processes exchanging objects through spaces.

Chat systems
Consider a simple multiuser chat system, in which a space serves as a chat area that holds all the messages making up a discussion. To talk, a participant deposits message objects into the space. All chat members wait for new message objects to appear, read them, and display their contents. Late arrivals can examine the existing message objects in the space to review previous discussion. In fact, since the space is persistent, a new participant can view the discussion long after everyone else has gone away, and participants can even come back much later to pick up the conversation where they left off. The list of chat participants can also be kept in the space and updated whenever someone joins or leaves the conversation.

Compute servers
Now consider analyzing realtime radio telescope data for signs of extraterrestrial life (much as the SETI@home project does). Such data is voluminous, and analyzing it is a computationally intensive job that is well suited to parallel computation by a network of computers -- in other words, a "compute server." Using the JavaSpaces technology, a series of tasks -- for instance, one task per chunk of data that needs to be analyzed -- is written into the space. Each participating computer searches the space for a task, removes it, completes the necessary computational work, drops the result back into the space, and then continues to look for more tasks. This approach scales naturally: it works the same way whether there are 10 computers available or 1,000. The approach also provides natural load balancing, since each worker picks up exactly as much work as it can handle in a given time, with slow computers doing less work and fast computers doing more.

Broker systems
As a third example, consider an online auction system that brings buyers and sellers of goods and services together. Suppose you, as a potential buyer, describe the item (such as a car) you'd like to buy and the price you're willing to pay, wrap the information in an entry, and write the resulting wanted-to-buy entry to a space. At the same time, potential sellers continually monitor the space for the arrival of wanted-to-buy entries that match items in their inventory. For example, Mazda dealers monitor the space for entries that describe Mazdas, while used-car dealers monitor the space for all used-car requests. When a matching request is found and read, a potential seller writes a bid entry into the space, stating an offering price. As a potential buyer, you continually monitor the space for bids on your outstanding requests, and, when you find one that's acceptable, you remove the bids and contact the seller (possibly through the space via another entry).

<<  Page 5 of 9  >>

Sponsored Links

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