Class Manager

java.lang.Object
  extended by Manager
Direct Known Subclasses:
Emulator, Simulator

public abstract class Manager
extends java.lang.Object

   
 Abstract class defining generic routines for running network code under Fishnet
 


Method Summary
 void addTimer(int nodeAddr, long deltaT, Callback callback)
          Adds a timer to be fired at deltaT milliseconds in the future
 void addTimerAt(int nodeAddr, long t, Callback callback)
          Adds a timer to be fired at time t
abstract  long now()
          Retrieve current time in milliseconds
abstract  boolean sendNodeMsg(int nodeAddr, java.lang.String msg)
          Sends the msg to the the specified node
 boolean sendPkt(int from, int to, byte[] pkt)
          Send the pkt to the specified node
 void setFishnetFile(java.lang.String filename)
          Sets the fishnet file that commands should be read from
 void setTimescale(double timescale)
          Sets the amount to scale real time by.
abstract  void start()
          Starts the Manager.
 void stop()
          Stops Fishnet.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

start

public abstract void start()
Starts the Manager. This runs in an infinite loop until network is stopped Instantiates nodes and gets them running


stop

public void stop()
Stops Fishnet. Normally this method should not return


setFishnetFile

public void setFishnetFile(java.lang.String filename)
                    throws java.io.FileNotFoundException
Sets the fishnet file that commands should be read from

Parameters:
filename - The name of the file that commands should be read from
Throws:
java.io.FileNotFoundException - If the named filed does not exist, is a directory rather than a regular file, or for some other reason cannot be opened for reading

sendPkt

public boolean sendPkt(int from,
                       int to,
                       byte[] pkt)
                throws java.lang.IllegalArgumentException
Send the pkt to the specified node

Parameters:
from - The node that is sending the packet
to - Int spefying the destination node
pkt - The packet to be sent, serialized to a byte array
Returns:
True if the packet was sent, false otherwise
Throws:
java.lang.IllegalArgumentException - If the arguments are invalid

addTimerAt

public void addTimerAt(int nodeAddr,
                       long t,
                       Callback callback)
Adds a timer to be fired at time t

Parameters:
nodeAddr - Addr of node that is registering this timer
t - The time when the timer should fire. In milliseconds
callback - The callback to be invoked when the timer fires

addTimer

public void addTimer(int nodeAddr,
                     long deltaT,
                     Callback callback)
Adds a timer to be fired at deltaT milliseconds in the future

Parameters:
nodeAddr - Addr of node that is registering this timer
deltaT - The time interval after which the timer should fire. In milliseconds
callback - The callback to be invoked when the timer fires

now

public abstract long now()
Retrieve current time in milliseconds

Returns:
Current time in milliseconds

sendNodeMsg

public abstract boolean sendNodeMsg(int nodeAddr,
                                    java.lang.String msg)
Sends the msg to the the specified node

Parameters:
nodeAddr - Address of the node to whom the message should be sent
msg - The msg to send to the node
Returns:
True if msg sent, false if address is not valid

setTimescale

public void setTimescale(double timescale)
Sets the amount to scale real time by. Is only valid for simiulator

Parameters:
timescale - The amount to scale real time by