This blog is subject the DISCLAIMER below.

Sunday, March 04, 2007

JavaSpaces-The Big Picture

JavaSpaces
The big picture


introduction
JavaSpaces is a technology that is mainly directed for parallel processing environments, although it is not a heavy used technology, it is very effective in terms of usage and performance.
you can think of JavaSpaces as a client/server map that contains data waiting for processing; these data have a set of defined rules that controls how these data can be accessed.

JavaSpaces has many usage scenarios, for example; a job producer program, that simply produce task list that needs to be handled by different processors in a parallel enviroment, JavaSpaces allows a high-powered CPU to grab a complex task and another Low-powered CPU to execute less complex tasks.

Getting into action
JavaSpaces is built on JINI, so the first approach to try JavaSpaces is to download JINI starter kit which contains sun's implementation of JavaSpaces called OuTrigger. Another better implementation of JavaSpaces is Blitz, which is much more effective and easy to use than Outrigger, however, blitz is an addition to JINI, that means it is downloaded separately.

Query by example (QBE)
JavaSpaces uses a simple but a smart way for data retrieval called Query By Example ( QBE ). QBE is another language for querying to create and modify relational data, it is different from other query languages in having a GUI that enables users to create example tables on screen.
we will not go much deeper in explaining QBE, but lets say it is a simple way of data access that adds a lot to JavaSpaces. for more information about QBE click here.

Using JavaSpaces
To use JavaSpaces you need first to have an instance of a JavaSpaces implementation to be running to provide a working JavaSpaces workspace to deal with.Once the JavaSpaces implementation is running it is very easy to add entries to it.

Entries in a JavaSpace are basically simple Java Objects that follow a few simple rules:
  • All data persisted in the space must be exposed in public fields.
  • The Entry interface must be implemented. This is a marker interface, requiring no methods to conform to the interface contract.
  • Objects must be used for the properties (i.e., no primitive fields.).
An entry can contain data and/or functionality, and can implement any interface or class that conforms to the requirements for JavaSpaces. Thus, a fairly common pattern is:
  • Implement a Command interface in an Entry, along with any data required to perform the command
  • Store the Command into the JavaSpace
  • Have a computing resource retrieve the Command and execute it, storing any results back into the JavaSpace for consumption if necessary
Connecting to a JavaSpace is very simple, either by using the simple Lookup class to search for JavaSpace05.class which will return a reference to the first JavaSpace it finds or by using methods provided by the JavaSpaces implementation it self (if it is available).

There are five basic operations associated with JavaSpaces. They are:
  1. Read an entry matching a template, leaving it in the JavaSpace
  2. Take an entry matching a template from the space, removing it from the JavaSpace
  3. Write an entry into the JavaSpace
  4. Register a callback for events in the JavaSpace
  5. Issue an event in the JavaSpace
Templates in JavaSpaces are instances of classes implementing the Entry interface (i.e., they're entries) that use “null” as a wildcard. Thus, if an Entry implementation has string properties A, B, and C, a template might populate A with “data” while leaving B and C null; a take operation would retrieve the first entry of that class that had “data” in the “A” property. (The list form of take() would return all entries that had “data” in the “A” property.)

References
TheServerSide
WikiPedia - the free encyclopedia

Links
You can Download Blitz here.

No comments: