Common Issues

My JavaSpace seems to be losing Entry's

It's always possible that there's a bug in your JavaSpace implementation resulting in lost Entry's but there is a common problem which many developers encounter.

When a client requests a blocking take (a take with a non-zero timeout) and there are no current matches, the 'space server makes a note of the outstanding take on an internal list. Whenever a new Entry arrives, the list is checked and if there's a match, one of the takes will be removed from the list, the Entry is returned to the client which will then be unblocked.

This all seems sensible but there's a potential problem:

  1. Client requests blocking take with timeout of 2 minutes and a null transaction.
  2. Client dies after 1 minute.
  3. Entry matching the blocking take arrives after 1.5 minutes.
  4. Blocking take is removed from list, Entry is marked taken, Entry is returned.

That last step is doomed to failure because the client is dead. Unfortunately, the 'space will have marked the Entry taken (it doesn't know the client has died). So, when a later supposedly matching take is executed, it will fail to match giving the impression that an Entry has been lost.

This behaviour is a subset of the problem where a client takes an Entry successfully makes some modifications but then crashes before it writes the Entry back to the JavaSpace. The solution is to pass a Transaction instance to the take. A Transaction is leased so that should the client die, it will be aborted when the lease expires. This ensures that any erroneously executed takes (or writes) are undone and so Entry's are not lost. Note that with a large transaction's lease, it may still appear that an Entry has gone missing for a considerable length of time (because the lease takes a long time to expire and abort the transaction).

Is my JavaSpace leaking memory?

Probably not (though it's always possible) - read the following to learn more about why your JavaSpace might look like it's leaking but is actually healthy:

How do I set the service name for Outrigger in JINI 2.0?

This can be achieved via the configuration file mechanism. You should set the "initialLookupAttributes" using something like:

import net.jini.core.entry.Entry;
import net.jini.lookup.entry.Name;

initialLookupAttributes = new Entry[] {new Name("MySpaceName")};

For more information see the outrigger man page in the JINI 2.0 distribution and this posting