river-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Trasuk <tras...@stratuscom.com>
Subject Re: JavaSpace.notify() "not reliable"
Date Tue, 15 May 2007 20:28:35 GMT
Hi all:

See comments below.



On Tue, 2007-05-15 at 15:09, Dan Creswell wrote:
> Mark Brouwer wrote:
> > Gregg Wonderly wrote:
> >
> >>
> >
> > Due to the ease of implementing distributed events as part of your
> > service with Seven (both Jini distributed events as the inverted JSC
> > event model) I've used distribute events a lot (next to the ordinary
> > query methods for bootstrapping etc.) but I always ended up with an
> > 'alive' notification scheme. As part of the remote events to be received
> > one should expect a NOOP remote event top indicating the server is alive
> > and kicking if it has no actual remote event to send and also for the
> > first remote event to validate whether callback in case of the Jini
> > Distributed Event Model does work, if not one could decide to switch to
> > the 'inverted' event model.
> >
> Hmmmmm as yet I'm not clear - what are these NOOP events intended to convey?
> Is it a liveness test or simply an indication that probably no events
> have been dropped or something else?

I can help with that:  Often in real-time or communications systems the
protocol sends a message (maybe a byte down a serial line, or a packet
over the network) that simply says "I'm here".  These are sometimes
called "heartbeat" or "supervisory" packets.  The idea is that there is
now a guarantee that some data will be sent within a fixed time
interval.  As such, if you go past that time interval, the receiver can
reasonably assume the link has failed somehow and take some reasonable
action (definitions of reasonable can vary widely).

This can be implemented pretty easily thanks to the Jini Remote Event
Specification; remember that Jini events are designed to be processed by
intermediaries (i.e. RemoteEventListener doesn't actually care what kind
of event it sees).  Normally, we think of these intermediaries as
network services (like Mercury), but you can also use the concept in the
local VM to interpose a listener that just counts idle ticks and takes
some fault action when idle ticks exceed a failure threshold.  In
Harvester there's a RemoteEventSupervisor class that does just this
(abbreviated source attached below).

> > I wonder whether such a 'I'm alive' notifications have ever been
> > considered as part of the event protocol for JavaSpaces and Lookup
> > Server. I think it is not too late to add these to the event protocols
> > by making them optional and to enabled them through the usage of some
> > invocation constraint. So far I always coded the 'I'm alive'
> > notification scheme myself but this could even be shifted to the
> > framework part, although that is totally irrelevant for the discussion
> > whether such a scheme would be worth 'standardizing'.
> > --
> > Mark
> >

I'm not sure about ServiceRegistrar; you could argue either way whether
ServiceDiscoveryManager should be able to tell if the registrars go
away.  But for JavaSpaces, I'd say I'd generally want to know that
whatever is generating the entries is alive, rather than just know that
the Space is alive.  As such, I'd be more inclined to generate a
supervisory entry (which triggers a notify event) rather than have the
Space generate a supervisory event.

(source code begins)

 * RemoteEventSupervisor.java
 * Created on October 11, 2006, 5:04 PM

package org.jini.project.harvester.tools;

import java.rmi.RemoteException;
import net.jini.core.event.RemoteEvent;
import net.jini.core.event.RemoteEventListener;
import net.jini.core.event.UnknownEventException;

 * @author trasukg
public class RemoteEventSupervisor implements RemoteEventListener {
    private int idleTickCount=0;
    private boolean enabled=true;
    /** Creates a new instance of RemoteEventSupervisor */
    public RemoteEventSupervisor() {
    private int threshold=1;
    private RemoteEventListener listener=null;

    private Runnable faultAction=null;
    public int getThreshold() {
        return threshold;

    public void setThreshold(int threshold) {
        this.threshold = threshold;

    public RemoteEventListener getListener() {
        return listener;

    public void setListener(RemoteEventListener listener) {
        this.listener = listener;
    public synchronized void notify(RemoteEvent event) 
        throws UnknownEventException, RemoteException {

    public Runnable getFaultAction() {
        return faultAction;

    public void setFaultAction(Runnable faultAction) {
        this.faultAction = faultAction;
    public synchronized void tick() {
        if (enabled && getIdleTickCount() > threshold) {
            if (faultAction != null) {

    public synchronized int getIdleTickCount() {
        return idleTickCount;

    public synchronized boolean isEnabled() {
        return enabled;

    public synchronized void setEnabled(boolean enabled) {
        this.enabled = enabled;

Greg Trasuk, President
StratusCom Manufacturing Systems Inc. - We use information technology to
solve business problems on your plant floor.

View raw message