p2pMapReduce.networkModule
Interface NetworkModuleIF

All Known Implementing Classes:
JxtaNetworkModule, NetworkModulePrototipe

public interface NetworkModuleIF

A NetworkModuleIF is the manager of all the network interaction of the node in the P2PMapReduce framework. It gives a way to:
- join the P2PMapReduce network
- search the network for some nodes
- obtain connections between nodes
- obtain an FTPManager


Method Summary
 void addEventListener(EventListener eventListener)
          Used to add a EventListener to which forward all the MessageEvent received by the network connections
 void becomeMaster()
          Invoked by the node module to notify that the node has changed its role from Slave to Master
 void becomeSlave()
          Invoked by the node module to notify that the node has changed its role from Master to Slave
 NodeInfo find(java.lang.String nodeID)
          Perform a search in the network for the NodeInfo of the node identified by nodeID
 java.util.Set<NodeInfo> getAllMasters()
          Return all the visible master nodes in the network by this network module at the moment
 java.util.Set<NodeInfo> getAllNodes()
          Return all the visible nodes in the network by this network module at the moment
 java.util.Set<NodeInfo> getAllSlaves()
          Return all the visible slave nodes in the network by this network module at the moment
 ConnectionIF getConnection(NodeInfo connectionEndPoint)
          Returns a connection between this network module and the network module relative to the node described by the NodeInfo connectionEndPoint
 ConnectionIF getConnection(java.lang.String nodeID)
          Returns a connection between this network module and the network module relative to the node identified by nodeID.
 FTPManager getFtpManager()
          Return an FTPManager for this node
 NodeInfo getNodeInfo()
          Return the same instance of NodeInfo returned by the joinNetwork() method.
 NodeModuleIF getNodeModule()
          Returns the NodeModuleIF associated to this network module
 int getNumMasters()
          Returns the number of all the visible master nodes from this network module at the moment
 int getNumNodes()
          Returns the number of all the visible nodes from this network module at the moment
 int getNumSlaves()
          Returns the number of all the visible slave nodes from this network module at the moment
 java.util.Set<NodeInfo> getOtherMasters()
          Return all the visible slaves nodes in the network by this network module at the moment, except this node if it is a master
 java.util.Set<NodeInfo> getOtherSlaves()
          Return all the visible slaves nodes in the network by this network module at the moment, except this node if it is a slave
 boolean isAlive(java.lang.String nodeID)
          Indicate if the node identified by 'nodeID' is alive.
 NodeInfo joinNetwork()
          Call this method once to enter the P2PMapReduce network.
 void publish()
          Used to send the information of the NodeInfo instance associated to this network module across the P2PMapReduce network.
 void send(NodeInfo endPoint, java.io.Serializable msg)
          Send the object msg to the node specified by endPoint If no connection is already available to this node, try to create a new one using the provided NodeInfo
 void send(java.lang.String destID, java.io.Serializable msg)
          Send the object msg to the node identified by destID.
 void setNodeModule(NodeModuleIF nodeModule)
           
 

Method Detail

joinNetwork

NodeInfo joinNetwork()
Call this method once to enter the P2PMapReduce network. The method returns an instance of NodeInfo containing all the information about the node associated to this network module. A reference to this NodeInfo instance will be maintained from this module and can be retrieved in the future by calling getNodeInfo(). All the updates to the node information will affect this NodeInfo instance. It also: - publishes this NodeInfo by calling publish() - make this NetworkModule capable to receive remote connection from other nodes. - starts an FTP server

Returns:

getNodeInfo

NodeInfo getNodeInfo()
Return the same instance of NodeInfo returned by the joinNetwork() method.

Returns:
the same instance of NodeInfo returned by joinNetwork() or null if joinNetwork() has never be executed with success.

getFtpManager

FTPManager getFtpManager()
Return an FTPManager for this node

Returns:

publish

void publish()
Used to send the information of the NodeInfo instance associated to this network module across the P2PMapReduce network. It must be called after every update to the NodeInfo of this network module in order to make all node known about .


becomeSlave

void becomeSlave()
Invoked by the node module to notify that the node has changed its role from Master to Slave


becomeMaster

void becomeMaster()
Invoked by the node module to notify that the node has changed its role from Slave to Master


getNumMasters

int getNumMasters()
Returns the number of all the visible master nodes from this network module at the moment

Returns:

getNumSlaves

int getNumSlaves()
Returns the number of all the visible slave nodes from this network module at the moment

Returns:

getNumNodes

int getNumNodes()
Returns the number of all the visible nodes from this network module at the moment

Returns:

find

NodeInfo find(java.lang.String nodeID)
Perform a search in the network for the NodeInfo of the node identified by nodeID

Parameters:
nodeID -
Returns:

isAlive

boolean isAlive(java.lang.String nodeID)
Indicate if the node identified by 'nodeID' is alive.

Parameters:
nodeID -
Returns:
true if a NodeInfo is founded by calling find(java.lang.String)
See Also:
find(String)

getAllNodes

java.util.Set<NodeInfo> getAllNodes()
Return all the visible nodes in the network by this network module at the moment

Returns:

getAllSlaves

java.util.Set<NodeInfo> getAllSlaves()
Return all the visible slave nodes in the network by this network module at the moment

Returns:

getAllMasters

java.util.Set<NodeInfo> getAllMasters()
Return all the visible master nodes in the network by this network module at the moment

Returns:

getOtherSlaves

java.util.Set<NodeInfo> getOtherSlaves()
Return all the visible slaves nodes in the network by this network module at the moment, except this node if it is a slave

Returns:

getOtherMasters

java.util.Set<NodeInfo> getOtherMasters()
Return all the visible slaves nodes in the network by this network module at the moment, except this node if it is a master

Returns:

send

void send(NodeInfo endPoint,
          java.io.Serializable msg)
          throws java.io.IOException
Send the object msg to the node specified by endPoint If no connection is already available to this node, try to create a new one using the provided NodeInfo

Parameters:
endPoint -
msg -
Throws:
java.io.IOException

send

void send(java.lang.String destID,
          java.io.Serializable msg)
          throws java.io.IOException
Send the object msg to the node identified by destID. If no connection is already available to this node, try to retrieve the NodeInfo for this node and to create a new connection.

Parameters:
destID -
msg -
Throws:
java.io.IOException

getConnection

ConnectionIF getConnection(NodeInfo connectionEndPoint)
                           throws java.io.IOException
Returns a connection between this network module and the network module relative to the node described by the NodeInfo connectionEndPoint

Parameters:
connectionEndPoint -
Returns:
Throws:
java.io.IOException

getConnection

ConnectionIF getConnection(java.lang.String nodeID)
                           throws java.io.IOException
Returns a connection between this network module and the network module relative to the node identified by nodeID. If no connection is already available to this node try to retrieve the NodeInfo for this node and to create a new connection. IOException is thrown instead or in consequence of errors.

Parameters:
connectionEndPoint -
Returns:
Throws:
java.io.IOException

getNodeModule

NodeModuleIF getNodeModule()
Returns the NodeModuleIF associated to this network module

Returns:

setNodeModule

void setNodeModule(NodeModuleIF nodeModule)

addEventListener

void addEventListener(EventListener eventListener)
Used to add a EventListener to which forward all the MessageEvent received by the network connections

Parameters:
eventListener -