Class Trawler

java.lang.Object
  extended by Trawler

public class Trawler
extends java.lang.Object

   
 Manages the emulated nodes. 
 It works by listening for new TCP connections. Each new connecting node sends the UDP port
 it is using for listening to peers. Also multiple emulated nodes might be running on the same machine
 so this lets us disambiguate them.
 The Trawler replies with the fishnet address that the emulated node should use, as well as the current 
 neighbor list for that node as  pairs.
 The trawler updates this list as it changes.

 Usage: java Trawler  [topo file]
       
        Topo file is the topology file. It is an optional argument. By default all nodes will be neighbors.
 


Method Summary
 void exit()
          Stop the Trawler
 void failEdge(int fishAddrA, int fishAddrB)
          An edge was removed.
 void failNode(int fishAddr)
          A node was removed from the topology.
static Trawler GetInstance()
          Static method to get an instance of trawler.
static Trawler GetInstance(int port)
          Static method to get an instance of trawler.
static void main(java.lang.String[] args)
          Entry point to start Trawler
 void remove(EmulatedNode dyingNode)
          An emulated node has quit so notify its neighbors
 void restartNode(int fishAddr)
          A node rejoined the topology, so we add back in all of its edges.
 void start(java.lang.String topofile)
           Wait for a node to connect, then: find out if any nodes have left while we were waiting (and if so, update their neighbors so they stop sending them packets) find a free fishnet Address to assign to the new node, and send it to them (by writing to the node's TCP socket) find out which UDP port they are listening to (by reading from the node's TCP socket) tell the node about all its neighbors' IP addresses and port #'s tell all their neighbors with their IP address and port # loop
 void startEdge(int fishAddrA, int fishAddrB)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

GetInstance

public static Trawler GetInstance()
Static method to get an instance of trawler. It will return null if the trawler has not been initialized with the port and topofile first

Returns:
An instance of this Trawler class

GetInstance

public static Trawler GetInstance(int port)
                           throws java.io.IOException
Static method to get an instance of trawler.

Parameters:
port - The port the trawler should listen for incoming connections on
Returns:
An instance of this Trawler class
Throws:
java.io.IOException - If an I/O error occurs when opening the socket

failEdge

public void failEdge(int fishAddrA,
                     int fishAddrB)
An edge was removed. Notify both ends if they are alive other wise ignore. They will find out themselves anyway

Parameters:
fishAddrA - Address of one node of the edge
fishAddrB - Address of the other node of the edge

startEdge

public void startEdge(int fishAddrA,
                      int fishAddrB)

failNode

public void failNode(int fishAddr)
A node was removed from the topology. We just remove the node's edges; the user has to kill the emulated node directly. NOTE: this must be called *BEFORE* the change to the topology!

Parameters:
fishAddr - Address of the node to be failed

restartNode

public void restartNode(int fishAddr)
A node rejoined the topology, so we add back in all of its edges.

Parameters:
fishAddr - Address of node that is restarting

start

public void start(java.lang.String topofile)
           throws java.io.FileNotFoundException,
                  java.lang.Exception
          
 Wait for a node to connect, then:
        find out if any nodes have left while we were waiting
                (and if so, update their neighbors so they stop sending them packets)
        find a free fishnet Address to assign to the new node, and send it to them
                (by writing to the node's TCP socket)
        find out which UDP port they are listening to
                (by reading from the node's TCP socket)
        tell the node about all its neighbors' IP addresses and port #'s
        tell all their neighbors with their IP address and port #
        loop
 

Parameters:
topofile - Name of the topology filename. If it is null then all nodes are neighbors by default
Throws:
java.io.FileNotFoundException - If the filename could not be found
java.lang.Exception - Any other exception that might occur while the Trawler is running

remove

public void remove(EmulatedNode dyingNode)
An emulated node has quit so notify its neighbors

Parameters:
dyingNode - The node that has quit

exit

public void exit()
Stop the Trawler


main

public static void main(java.lang.String[] args)
Entry point to start Trawler