tapestry.patchwork
Class RecalcPatch

java.lang.Object
  |
  +--tapestry.patchwork.Patch
        |
        +--tapestry.patchwork.RecalcPatch

public class RecalcPatch
extends Patch

A Patch that recalculate the PatchworkTable and sends out deltas.

Also, it currently is hardcoded to send out messages when it notices that a node is down (loss rate > 95%).

Version:
$Id: RecalcPatch.java,v 1.1.1.1 2004/03/26 19:57:10 hweather Exp $
Author:
Jeremy Stribling

Nested Class Summary
 
Nested classes inherited from class tapestry.patchwork.Patch
Patch.SeqNo
 
Field Summary
 
Fields inherited from class tapestry.patchwork.Patch
_classifier, _fault_admin, _period, _probe_times, _queue, _quick_stats, _self_node_id, _seq_nos, _table, _type, _udp_lock, _udp_socket, _userdata_sinks, _write_selitem, _write_selset, class_tag, DEBUG, NUM_TYPES, sim_running, TYPE_BANDWIDTH, TYPE_LATENCY, TYPE_LOSS, TYPE_RECALC, use_tcp
 
Constructor Summary
RecalcPatch(NodeId self_node_id, Classifier classifier, PatchworkTable table, FaultAdmin fault_admin, Period period)
           
 
Method Summary
 void addMonitorAll(Object userData, SinkIF sink)
          Tells this patch that a node wants to hear about status messages from everyone.
 void addNode(NodeId node, int level, Object userData, SinkIF sink)
          Tell this Patch to begin monitoring a node at some probing level
protected  void addToQueue(NodeId node)
          Add this node back on the queue.
protected  int getAndUpdateSeqNo(NodeId node)
          Get the next sequence number for this node, and update it for next time.
protected  void handleAlarm(AlarmMsg alarm)
           
protected  void handleNetworkNodeStatusMsg(NetworkNodeStatusMsg msg)
           
protected  void handleProbe(ProbeMsg inProbe)
           
protected  void handleProbeResponse(ProbeMsg response, long timeRecvd)
          Handle the response to a probe.
protected  void handleTimeout(ProbeTimeout timeout)
           
protected  void makeObservation(NodeId peer, long value, byte type)
          Record an observation (of arbitrary type) in the table
protected  long registerResponse(ProbeMsg response)
          We received a response, so figure out state
protected  boolean registerTimeout(ProbeTimeout pt)
          Got a timeout for a probe.
 void removeNode(NodeId node, Object userData, SinkIF sink)
          Tell this Patch to stop monitoring a node
protected  void sendProbe(ProbeMsg probe)
          Send a probe to another node, expecting a response back.
protected  void setNextAlarm()
          Pick the node from the queue that needs to be probed the soonest, and set the alarm for it.
 
Methods inherited from class tapestry.patchwork.Patch
dispatch, dispatch, enqueue, handleEvent, handleQuickStatProbeResp, handleQuickStatReq, handleQuickStatTimeout, handleUnknown, makeObservation, sendQuickStatProbe
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RecalcPatch

public RecalcPatch(NodeId self_node_id,
                   Classifier classifier,
                   PatchworkTable table,
                   FaultAdmin fault_admin,
                   Period period)
Method Detail

addNode

public void addNode(NodeId node,
                    int level,
                    Object userData,
                    SinkIF sink)
Description copied from class: Patch
Tell this Patch to begin monitoring a node at some probing level

Overrides:
addNode in class Patch
Parameters:
node - the node to begin monitoring
level - the probing level for that node
userData - an object that will identify this monitoring instance to the calling application
sink - the sink on which to enqueue status responses

addMonitorAll

public void addMonitorAll(Object userData,
                          SinkIF sink)
Description copied from class: Patch
Tells this patch that a node wants to hear about status messages from everyone.

Overrides:
addMonitorAll in class Patch
Parameters:
userData - an object that will identify this monitoring instance to the calling application
sink - the sink on which to enqueue status responses

removeNode

public void removeNode(NodeId node,
                       Object userData,
                       SinkIF sink)
Description copied from class: Patch
Tell this Patch to stop monitoring a node

Overrides:
removeNode in class Patch
Parameters:
node - the node to stop monitoring
userData - an object that will identify this monitoring instance to the calling application
sink - the sink on which to enqueue status responses

addToQueue

protected void addToQueue(NodeId node)
Description copied from class: Patch
Add this node back on the queue. If it is supposed to be probed before the node that currently has the alarm set, interrupt that alarm and set it for the new guy.

Overrides:
addToQueue in class Patch
Parameters:
node - the node to add

setNextAlarm

protected void setNextAlarm()
Description copied from class: Patch
Pick the node from the queue that needs to be probed the soonest, and set the alarm for it.

Overrides:
setNextAlarm in class Patch

makeObservation

protected void makeObservation(NodeId peer,
                               long value,
                               byte type)
Description copied from class: Patch
Record an observation (of arbitrary type) in the table

Overrides:
makeObservation in class Patch
Parameters:
peer - the node being observed
value - the value of the observed measurement
type - the type of the observation

handleProbeResponse

protected void handleProbeResponse(ProbeMsg response,
                                   long timeRecvd)
Description copied from class: Patch
Handle the response to a probe.

Specified by:
handleProbeResponse in class Patch
Parameters:
response - the response
timeRecvd - the absolute time the repsonse was received (in microseconds)

handleAlarm

protected void handleAlarm(AlarmMsg alarm)
Specified by:
handleAlarm in class Patch

handleTimeout

protected void handleTimeout(ProbeTimeout timeout)
Specified by:
handleTimeout in class Patch

handleProbe

protected void handleProbe(ProbeMsg inProbe)
Overrides:
handleProbe in class Patch

sendProbe

protected void sendProbe(ProbeMsg probe)
Description copied from class: Patch
Send a probe to another node, expecting a response back.

Overrides:
sendProbe in class Patch

registerResponse

protected long registerResponse(ProbeMsg response)
Description copied from class: Patch
We received a response, so figure out state

Overrides:
registerResponse in class Patch
Returns:
the time the probe was sent to which this was a response (in microseconds)

registerTimeout

protected boolean registerTimeout(ProbeTimeout pt)
Description copied from class: Patch
Got a timeout for a probe.

Overrides:
registerTimeout in class Patch
Returns:
true iff a response was not yet received for the probe connected with this timeout

getAndUpdateSeqNo

protected int getAndUpdateSeqNo(NodeId node)
Description copied from class: Patch
Get the next sequence number for this node, and update it for next time.

Overrides:
getAndUpdateSeqNo in class Patch
Returns:
the sequence number to use for the next probe.

handleNetworkNodeStatusMsg

protected void handleNetworkNodeStatusMsg(NetworkNodeStatusMsg msg)