sg.edu.nus.peer
Class Bootstrap

java.lang.Object
  extended by sg.edu.nus.peer.AbstractPeer
      extended by sg.edu.nus.peer.Bootstrap

public class Bootstrap
extends AbstractPeer

Implement a bootstrap.

Version:
1.0 2006-2-1
Author:
Xu Linhao

Field Summary
 
Fields inherited from class sg.edu.nus.peer.AbstractPeer
CAPACITY, LOCAL_SERVER_PORT
 
Constructor Summary
Bootstrap(AbstractMainFrame gui, java.lang.String peerType)
           
 
Method Summary
 void forceOut(java.lang.String ip, int port)
          Force a peer out the network with its IP address and port.
 java.lang.String getLogStore()
          Returns the directory of the system logs.
static void load()
          Load system-defined value.
 int sendSchema(java.lang.String schema)
          The method reads the schema from the 'BestPeer' database and sends it to all the super-peers that the bootstrap node knows of.
 boolean startEventManager(int port, int capacity)
          Start the network monitoring service.
 boolean startUDPServer(int port, int capacity, long period)
          Starts the UDP service by specify the port and the number of threads that can handle incoming and outgoing UDP packets at the same time.
 void troubleshoot(boolean toBoot, boolean toServer, boolean toClient)
          When the peer exits the system for some reason, it will broadcast a TROUBLESHOOT message to all relevant peers for its leave.
static void write()
          Write user-defined values to file.
 
Methods inherited from class sg.edu.nus.peer.AbstractPeer
checkInet, clearSession, createLogStore, getMainFrame, getPeerType, getPhysicalInfo, initSession, isEventManagerAlive, isUDPServerAlive, scheduleUDPSender, sendMessage, stopEventManager, stopUDPServer
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Bootstrap

public Bootstrap(AbstractMainFrame gui,
                 java.lang.String peerType)
Method Detail

load

public static void load()
Load system-defined value.


write

public static void write()
Write user-defined values to file. Notice that this function must be called after user applies the change.


startEventManager

public boolean startEventManager(int port,
                                 int capacity)
Description copied from class: AbstractPeer
Start the network monitoring service.

Specified by:
startEventManager in class AbstractPeer
Parameters:
port - the port used for monitoring network events
capacity - the maximum capacity that serves the incoming socket connections at the same time
Returns:
if success, return true; otherwise, return false

startUDPServer

public boolean startUDPServer(int port,
                              int capacity,
                              long period)
Description copied from class: AbstractPeer
Starts the UDP service by specify the port and the number of threads that can handle incoming and outgoing UDP packets at the same time.

Specified by:
startUDPServer in class AbstractPeer
Parameters:
port - the port to be used for starting the UDP service
capacity - the number of threads that can handle incoming and outgoing UDP packets at the same time
Returns:
true if the UDP service is started; otherwise, return false

troubleshoot

public void troubleshoot(boolean toBoot,
                         boolean toServer,
                         boolean toClient)
Description copied from class: AbstractPeer
When the peer exits the system for some reason, it will broadcast a TROUBLESHOOT message to all relevant peers for its leave.

Specified by:
troubleshoot in class AbstractPeer
Parameters:
toBoot - if true, send messages to bootstrapper
toServer - if true, send messages to server peers
toClient - if true, send messages to client peers

forceOut

public void forceOut(java.lang.String ip,
                     int port)
Description copied from class: AbstractPeer
Force a peer out the network with its IP address and port.

Specified by:
forceOut in class AbstractPeer
Parameters:
ip - the IP address of the peer to be forced out the network
port - the port where the network service is running

getLogStore

public java.lang.String getLogStore()
Description copied from class: AbstractPeer
Returns the directory of the system logs.

Specified by:
getLogStore in class AbstractPeer
Returns:
returns the directory of the system logs

sendSchema

public int sendSchema(java.lang.String schema)
The method reads the schema from the 'BestPeer' database and sends it to all the super-peers that the bootstrap node knows of.

Returns:
the number of servers that failed to receive the schema (0 means everything is ok)