org.objectweb.proactive.p2p.service.node
Class P2PNodeLookup

java.lang.Object
  extended by org.objectweb.proactive.p2p.service.node.P2PNodeLookup
All Implemented Interfaces:
java.io.Serializable, Active, EndActive, InitActive, P2PConstants, ProActiveInternalObject, RunActive

public class P2PNodeLookup
extends java.lang.Object
implements InitActive, RunActive, EndActive, P2PConstants, java.io.Serializable, ProActiveInternalObject

Author:
Alexandre di Costanzo Created on Jan 18, 2005
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.objectweb.proactive.p2p.service.util.P2PConstants
HIDE_P2PNODE_MONITORING, MAX_NODE, P2P_NODE_NAME, PROPERPY_XML_PATH, PROPERTY_ACQUISITION, PROPERTY_EXPLORING_MSG, PROPERTY_LOOKUP_FREQ, PROPERTY_MSG_MEMORY, PROPERTY_MULTI_PROC_NODES, PROPERTY_NO_SHARING, PROPERTY_NOA, PROPERTY_NODES_ACQUISITION_T0, PROPERTY_PORT, PROPERTY_TTL, PROPERTY_TTU, SHARED_NODE_NAME, VN_NAME
 
Constructor Summary
P2PNodeLookup()
           
P2PNodeLookup(java.lang.Integer numberOfAskedNodes, P2PService localP2pService, java.lang.String vnName, java.lang.String jobId, java.lang.String nodeFamilyRegexp)
           
 
Method Summary
 boolean allArrived()
          Check if all asked nodes are arrived.
 void endActivity(Body body)
          Remove this nodes accessor from the waiting node accessors list in the local P2P service.
 java.util.Vector getAndRemoveNodes()
           
 java.util.Vector getNodes()
          Reurn all nodes asked.
 java.util.Vector getNodes(long timeout)
          Reurn all nodes asked until the timeout.
 IntWrapper giveNode(Node givenNode, P2PNodeManager remoteNodeManager)
          Receipt a reference to a shared node.
 void giveNodeForMax(java.util.Vector<Node> givenNodes, P2PNodeManager remoteNodeManager)
           
 void initActivity(Body body)
          Initializes the activity of the active object.
 boolean isActive()
          Returns whether the node accessor is active or not.
 void killAllNodes()
          Kill all received node.
 void killNode(java.lang.String node)
          Kill the given node.
 void moveTo(java.lang.String nodeUrl)
          Migrate the P2P node lookup tyo a new node.
 boolean nArrived(int n)
          Check if n nodes are arrived.
 void runActivity(Body body)
          Runs the activity of the active object.
 void wakeUp()
          Wake up the active object, to send asking node message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

P2PNodeLookup

public P2PNodeLookup()

P2PNodeLookup

public P2PNodeLookup(java.lang.Integer numberOfAskedNodes,
                     P2PService localP2pService,
                     java.lang.String vnName,
                     java.lang.String jobId,
                     java.lang.String nodeFamilyRegexp)
Method Detail

allArrived

public boolean allArrived()
Check if all asked nodes are arrived. false for asking all available nodes.

Returns:
true if all asked nodes are arrived, false else.

nArrived

public boolean nArrived(int n)
Check if n nodes are arrived.

Parameters:
n - number of needed nodes.
Returns:
true if n nodes are available, false

killNode

public void killNode(java.lang.String node)
Kill the given node.

Parameters:
node - the node url to kill.

killAllNodes

public void killAllNodes()

Kill all received node.

Warning: if nodes are removed from the Collection, these nodes will be not kill.


wakeUp

public void wakeUp()
Wake up the active object, to send asking node message.


giveNode

public IntWrapper giveNode(Node givenNode,
                           P2PNodeManager remoteNodeManager)
Receipt a reference to a shared node.

Parameters:
givenNode - the shared node.
remoteNodeManager - the remote node manager for the given node.
Returns:
the total number of nodes still needed.

giveNodeForMax

public void giveNodeForMax(java.util.Vector<Node> givenNodes,
                           P2PNodeManager remoteNodeManager)

isActive

public boolean isActive()

Returns whether the node accessor is active or not. The nodes accessor is active as long as it has an associated thread running to serve the requests by calling methods on the active object and looking for asked nodes.

If the nodes accessor is not active, looking for nodes is stopped.

Returns:
whether the nodes accessor is active or not.

getAndRemoveNodes

public java.util.Vector getAndRemoveNodes()
Returns:
all available and node and remove them from the lookup.

getNodes

public java.util.Vector getNodes()
Reurn all nodes asked. This method waits for all nodes are arrived before returning.

Returns:
A Collection of nodes.

getNodes

public java.util.Vector getNodes(long timeout)
Reurn all nodes asked until the timeout.

Parameters:
timeout - the timeout in milliseconds.
Returns:
A Collection of nodes.

moveTo

public void moveTo(java.lang.String nodeUrl)
Migrate the P2P node lookup tyo a new node.

Parameters:
nodeUrl - the URL of the destination node.

initActivity

public void initActivity(Body body)
Description copied from interface: InitActive
Initializes the activity of the active object.

Specified by:
initActivity in interface InitActive
Parameters:
body - the body of the active object being initialized
See Also:
InitActive.initActivity(org.objectweb.proactive.Body)

runActivity

public void runActivity(Body body)
Description copied from interface: RunActive
Runs the activity of the active object.

Specified by:
runActivity in interface RunActive
Parameters:
body - the body of the active object being started
See Also:
RunActive.runActivity(org.objectweb.proactive.Body)

endActivity

public void endActivity(Body body)
Remove this nodes accessor from the waiting node accessors list in the local P2P service.

Specified by:
endActivity in interface EndActive
Parameters:
body - the body of the active object being finalized.
See Also:
EndActive.endActivity(org.objectweb.proactive.Body)


Copyright 2001-2007 INRIA All Rights Reserved.