Re: JavaSpace.notify() "not reliable"

Timur Mehrvarz <[email protected]> Mon, 21 May 2007 16:14:55 +0200
Newsgroups gmane.comp.java.sun.javaspaces
Message-ID <[email protected]>
On 20.05.2007, at 11:51, Dan Creswell wrote:

> Or better yet a test case or a pseudocode description of what's
> going on?
>
> Such a description would include lease renewals (and how you're doing
> them and how big of a lease you ask for), takes and reads as well as
> writes and transactions.

I always register the notification with a 30 second lease. Before, I
also did a wait(30000) for the notify() to come. But this way, when a
notification was dropped, I was having a problem, because in such a
case, there was simply nothing happening for 30 seconds.

Now, I am still registering the notification with a 30 second lease.
But now, I wait(1000) ms for up to 30 times in a polling loop, in
order to be able to call readIfExists() in between the wait's, to
see, if an object I am waiting for can be found in space already. If
notifications come in, the time spend in the wait() function is below
1000 ms. If a notification is dropped, the wait() functions times out
after 1000 ms.

> You should also state whether or not you're using
> registerForAvailabilityEvent as opposed to notify.

I'm afraid, I have not yet tried using any of the JavaSpace05 API,
yet. I also didn't have a chance to try this with Blitz. I plan on
playing with Blitz soon. And I may also try using
registerForAvailabilityEvent.

> Also of interest is that your writes are every 200ms and you say every
> 50th or so is dropped which I reckon is every 10 seconds - have you
> got
> anything else happening on a 10 second boundary?

The dropping of notifications is not distributed as even as this.
It's not predictable. Sometimes, a notification is dropped sooner
than 50 write operations. Sometimes no notification is dropped for,
say, 500 or 1000 write operations. (But then you know, that at least
two notifications will be dropped in a row ;) Well, this is what I am
seeing.)

Notification dropping seems to be completely independent of what I
do. (Which, of course, doesn't mean, I am *not* causing the problem
in some way.)

> And finally, what's are you calling a master and a slave and what are
> their relationships between each other and the JavaSpace?

The "master" is the one process, writing objects to space. The
"slaves" (or consumers) are those, waiting to read and process the
written objects. I'm running multiple consumers in parallel. All of
them need to read all written objects. This is why I really like to
use notify() together with read(), instead of take().

Timur

===========================================================================
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff JAVASPACES-USERS".  For general help, send email to
[email protected] and include in the body of the message "help".

To view past JAVASPACES-USERS postings, please see:
http://archives.java.sun.com/archives/javaspaces-users.html