WELCOME TO SCALABILITI
We're a UK Collective, doing our bit to help increase that distribution, by bringing the future that already exists to a wider audience.

Crunch, save time, save tax, save money
London Tech Jobs at Career 2.0

Table of Contents

Back to Library

Blitz

Blitz is an open-source Javapsaces implementation for grid-oriented distribution platform.

Blitz provides a datastore and some tools organized around JavaSpaces. It's not required to have Blitz use JavaSpaces; the JINI reference implementation is entirely usable, but Blitz shortens many of the configuration steps and makes JavaSpace orientation far easier.

Installation

Installation of Blitz is pretty straigh forward. From the Sourceforge download page, simply grab the installation jar file and run it; this will start up a very simple GUI that asks where the JDK directory is, where to install Blitz, where the JINI installation is, and the runtime HTTPD port. This will create a directory with a number of runtime scripts and examples (and a few libraries as well).

The simplest way to run Blitz at this point is simply to run “blitz.bat” (on Windows, of course, although this reviewer can vouch that Blitz runs on other OSes as well, with OS-specific scripts provided.) This will start a number of JINI services, most of which are fairly esoteric and specific to JINI internals. (It's wise to spend time understanding JINI's specific models, although that's beyond the scope of this review.) After starting Blitz, you now have a fully functional grid, although it's not a distributed store yet. It is, however, ready for use by any machine on your network.

Another tool provided by Blitz is the Dashboard; this is a simple GUI that shows the number of active transactions, space operations (takes, writes, reads), the number of blocks, the number of instances, and the amount of memory used. This can show you what operations are taking place in your grid as it runs.

Using

Writing JavaSpace producers and consumers is quite easy. I used the Lookup.java class from Blitz' examples (specifically, the helloworld example, although any of them would work.) My project added jsk-platform.jar and jsk-lib.jar from the JINI installation, and looked up

  "jini://localhost:8085"; 

the Blitz console then showed that a client had registered. At this point, I had a grid client and a service to connect it to.

I then created two entry implementations: a Person (with a name and age) and an Article (with a status, a title, and a list of Person references for authors.) I created two instances of each: one article had one author, the other article had both authors. Running the code showed the entries in the diagnostics tool, although it was unable to show the entries cleanly, as it didn't have access to the class definitions. Therefore, it could show their existence, their types, and even some data in them, but it couldn't show the entries themselves.

I was then able to store and retrieve entries based on template data. The stores were quick and accurate.

JavaSpaces programming requires some different approaches compared to what most enterprise programmers are used to. For example, in the above case, it's trivial to get the first article that matches the criteria - to wit, the first article of a given status - but getting a list of all articles is a little more problematic, involving one of a few patterns. One possibility, for example, is storage of a list containing all of the titles of articles, and then a programmer could use those to look for articles with matching titles and statuses (i.e., by refining the search).

That said, JavaSpaces usually are better at working on individual elements rather than lists of elements, in my experience. Therefore, most would set up a loop to process a given template, and consume the matching entries one by one until all jobs were done.

This is also how the command pattern is applied via JavaSpaces, a very common and extremely useful pattern for grids. An Entry implementing a Command interface (much like a Runnable, for example) is stored into the space, and consumers look for any available Command, then call the execution method to execute the task, possibly storing a result or another command back into the Space.

Most of this isn't necessarily Blitz-related, but it should be noted that Blitz is the implementation being used. It's very easy to run, shows useful data about the Space in question, is open source, and is very servicable in providing an easy on-ramp to space-based programming.