ostore.dispatch
Class Signal

java.lang.Object
  |
  +--ostore.dispatch.Signal

public class Signal
extends Object

Contains a few static methods to mimic UNIX signals. This class provides a unified interface for OceanStore- and SandStorm-specific signals. It sits atop both the Classifier and SignalMgr. TODO: Coallesce all signals into single class with a "type" field. Intercept SandStorm signals and replace with local equivalent.

Version:
$Id: Signal.java,v 1.14 2003/03/27 20:58:24 strib Exp $
Author:
Dennis Geels

Nested Class Summary
static class Signal.AlarmSignal
          The OceanStore equivalent of SIGALRM
static class Signal.RebuildSignal
          This signal tells the receivers to resynchronize/optimize their internal data structures.
 
Field Summary
static int ALRM
          The code for Signal.AlarmSignal.
static int INIT
          The code for StagesInitializedSignal.
static int RBLD
          The code for Signal.RebuildSignal.
 
Constructor Summary
Signal(NodeId node_id)
           
 
Method Summary
 Object alarm(String target, long millis)
          Dispatch an AlarmSignal at a specified time This method has similar functionality to the alarm function in C.
 void cancel(Object token)
          Cancel an AlarmSignal scheduled by alarm.
static Signal getSignal(NodeId node_id)
          Returns the Signal instance corresponding to a NodeId.
 boolean register(int type, String target, SinkIF sink)
          Subscribes the specified sink to signals of the specified type which have the specified target.
static void removeSignal(NodeId node_id)
          Deletes the Signal instance corresponding to a NodeId.
 void signal_lossy(int type, String target)
          Dispatches a signal of the specified type with the specified target.
 void signal(int type, String target)
          Dispatches a signal of the specified type with the specified target.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INIT

public static final int INIT
The code for StagesInitializedSignal. Dispatched when the init method of each stage has completed.

See Also:
Constant Field Values

RBLD

public static final int RBLD
The code for Signal.RebuildSignal. This signal tells the receivers to resynchronize/optimize their internal data structures. Useful for starting time-consuming optimizations when machine load is low.

See Also:
Constant Field Values

ALRM

public static final int ALRM
The code for Signal.AlarmSignal. Dispatched by alarm.

See Also:
Constant Field Values
Constructor Detail

Signal

public Signal(NodeId node_id)
Method Detail

getSignal

public static Signal getSignal(NodeId node_id)
Returns the Signal instance corresponding to a NodeId.

Parameters:
node_id - The NodeId which parameterizes a virtual SandStorm instance.
Returns:
the (possibly new) Signal instance corresponding to node_id.

removeSignal

public static void removeSignal(NodeId node_id)
Deletes the Signal instance corresponding to a NodeId. Should be called only when a node is going down and going to come up again with a new node id. Use very carefully!

Parameters:
node_id - The NodeId which parameterizes a virtual SandStorm instance.

register

public boolean register(int type,
                        String target,
                        SinkIF sink)
Subscribes the specified sink to signals of the specified type which have the specified target. If target is null, all signals of the specified type will be enqueued on the sink. For some signals (such as INIT), the target parameter is ignored.

Parameters:
type - currently one of INIT or ALRM.
target - the name of the StageIF to which the signals are directed, or null.
sink - the SinkIF to receive the SignalIFs.
Returns:
true iff subscription succeeded.

signal

public void signal(int type,
                   String target)
            throws SinkFullException
Dispatches a signal of the specified type with the specified target. For some signals, the target parameter is ignored. For others, it is required to be non-null.

Parameters:
type - currently must be RBLD or ALRM.
target - the name of the StageIF to which the signals are directed, or null.
Throws:
SinkFullException - if the signal could not be dispatched.
See Also:
Classifier.dispatch(seda.sandStorm.api.QueueElementIF)

signal_lossy

public void signal_lossy(int type,
                         String target)
Dispatches a signal of the specified type with the specified target. All SinkFullExceptions are quietly dropped.

Parameters:
type - currently must be RBLD or ALRM.
target - the name of the StageIF to which the signals are directed, or null.
See Also:
signal(int, java.lang.String)

alarm

public Object alarm(String target,
                    long millis)
Dispatch an AlarmSignal at a specified time This method has similar functionality to the alarm function in C.

Parameters:
target - The name of the target StageIF. May not be null.
millis - The number of milliseconds from now to dispatch the event.
Returns:
a token to pass to cancel in order to cancel the alarm before it is dispatched.
See Also:
cancel(java.lang.Object)

cancel

public void cancel(Object token)
Cancel an AlarmSignal scheduled by alarm. If the alarm has already been signaled, this method has no effect.

Parameters:
token - The Object returned by alarm.
Throws:
IllegalArgumentException - if token is not a token returned by the internal timer.
See Also:
alarm(java.lang.String, long)