Why Javaspaces are not for me

In 2001/2002 I worked for 18 months at the now defunct UK Javaspace vendor Intamission, building their Javaspace implementation Autevo, which went on to  … er… “inspire” the open source Blitz product , released by Intamission co-founder & lead programmer Dan Creswell after he left the company.

One of the less satisfying aspects of that project was that, as I worked with Javaspace/Tuplespace -based systems, I came to believe in them less and less. I now believe that while Javaspaces have some great qualities, they also have some serious flaws. Here’s a brief outline of what I think these flaws are.

Some background for the layman

Javaspaces pride themselves on having a simple API based on 4 methods

  • write puts an object into the shared distributed space
  • read returns a copy of one object matching some provided query criteria. There are blocking and polling variants.
  • take returns a copy of one object matching some provided query criteria and removes it from the space. There are blocking and polling variants.
  • notify registers interest in being notified should an object enter the space matching the provided criteria.

Javaspaces use a Query by Example mechanism to query the state of the space. One presents an template Entry to the space, with zero or more public, non-primitive, serializable fields, any of which may be null, and the space matches any Entry in the space whose fields are equals() to the template’s field, while treating null fields of the Entry as wildcards that match anything. Thinking of Entry as being a tuple is a good analogy.

I subscribe to the design aesthetic as simple as possible, but no simpler. Unfortunately,  the Javaspace query mechanism is too simplistic, and not sufficiently powerful to solve practical distributed systems problems with:

No Range Queries

The query API allows one to specify either an exact value, or any value, but nothing in between. You can say “a Person of Age == 25″, or “a Person of any Age”, but not “a Person of Age 25- 34″. This is a result of Javaspace’s fixation with a flawed query-by-example model. As you might imagine, this limitation quickly becomes problematic when you try to build real applications.

Use of Null as Wildcard

Another nasty side-effect of the query-by-example model is that null becomes overloaded as a wildcard value. Accordingly, Entry fields cannot be primitive, and may not be null for any legitimate application purpose.

Lack of a readAll Operation

readAll would be the Javaspace analog of a SQL Select statement; ie find me all Entries in the space matching the provided criteria. Sorry, no can do. A Javaspace can give you one of them, but not all of them.

So for example, if we want to ask our space-based application, “How many tasks are in the queue?” , it can only reply “All I can tell you is that there is at least one.”

The Future

Someone should combine the best ideas from Javaspaces – a focus on high-performance, short-term storage of self-contained objects/messages, leases, and event notification, with a decent, extensible query mechanism. Now that would fly. (Maybe someone already has? … I havent been following this field closely in recent years)

About these ads

3 Comments

  1. Nati Shalom said,

    May 28, 2009 at 10:23 am

    Have you considered GigaSpaces?
    We fully support JavaSpaces and extended it to support extended query, POJO data Entry with annotation, Spring and many other capabilities that will make the development and learning curve significantly simple.
    You can see more detailes on our online docs.

    Nati S
    CTO GigaSpaces

  2. Greg Lenehan said,

    June 2, 2009 at 11:23 am

    Ben, my name is Greg Lenehan Regional Director APAC for Gigaspaces, my mbile number is (AUZ) 0419 145 340, I am now in Melbourne for a couple of days, if you have time please call me, would like to chat with you.

    Greg Lenehan

  3. June 12, 2009 at 12:23 am

    I’d invite you to check out the Oracle Coherence query capability, which addresses all of the short-comings that you mention. For example, you can use a BetweenFilter to do a range query. Even more powerful is the fact that you can provide your own predicates (custom filters), so that if the normal set of SQL operators isn’t sufficient, you can provide exactly what you need.

    Also, not only can you easily “read all” (using the NamedCache getAll method), but you can execute processing (scalar or aggregate) against a query result, even if the results come from multiple servers in a partitioned system (in which case the operations occur in parallel, a la map/reduce). That’s done through the InvocableMap interface (part of NamedCache), and has the benefit of sand-box processing the data “in place”, as opposed to the space model, which copies the data out of the space.

    Peace,

    Cameron Purdy | Oracle

    http://coherence.oracle.com

    p.s. Curious why my previous comment didn’t show up ..


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: