org.objectweb.proactive.p2p.service
Class P2PService

java.lang.Object
  extended byorg.objectweb.proactive.p2p.service.P2PService
All Implemented Interfaces:
Active, InitActive, P2PConstants, ProActiveInternalObject, java.io.Serializable

public class P2PService
extends java.lang.Object
implements InitActive, P2PConstants, java.io.Serializable, ProActiveInternalObject

ProActive Peer-to-Peer Service.

This class is made to be actived.

Author:
Alexandre di Costanzo
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_LOAD_BAL, 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
P2PService()
          The empty constructor.
 
Method Summary
 boolean amIUnderloaded()
           
 boolean amIUnderloaded(double ranking)
          Ask to the Load Balancer object if the state is underloaded
 void askingNode(int ttl, UniversalUniqueID uuid, P2PService remoteService, int numberOfNodes, P2PNodeLookup lookup, java.lang.String vnName, java.lang.String jobId)
          Method automaticly forwarded by run activity if needed.
 void askingNode(int ttl, UniversalUniqueID uuid, P2PService remoteService, int numberOfNodes, P2PNodeLookup lookup, java.lang.String vnName, java.lang.String jobId, boolean underloadedOnly)
          Method called on Load Balanced enviroments.
 void balanceWithMe(P2PService sender, double ranking)
          This method is remotely called by an overloaded peer, looking for a balance.
 void exploring(int ttl, UniversalUniqueID uuid, P2PService remoteService)
          Method automaticly forwarded by run activity if needed.
 void firstContact(java.util.Vector peers)
          Contact all specified peers to enter in the existing P2P network.
 java.lang.String getAddress()
          For load balancing.
 P2PNodeLookup getMaximunNodes(java.lang.String vnName, java.lang.String jobId)
          Put in a P2PNodeLookup all available nodes during all the time where it is actived.
 P2PNodeLookup getNodes(int numberOfNodes, java.lang.String vnName, java.lang.String jobId)
          Put in a P2PNodeLookup, the number of asked nodes.
 P2PNodeLookup getNodes(int numberOfNodes, java.lang.String vnName, java.lang.String jobId, boolean onlyUnderloaded)
           
 P2PAcquaintanceManager getP2PAcquaintanceManager()
           
 void heartBeat()
          Just to test if the peer is alive.
 void ImStealingYou(double ranking, java.lang.String remoteNodeAddress)
          This method is remotely called by an underloaded peer, looking for a balance.
 void initActivity(Body body)
          Initializes the activity of the active object.
 void P2PloadBalance(Node destNode)
          This method is remotely called by an underloaded peer to start the load balancing.
 void register(P2PService service)
          Add the remote P2P service in the local acquaintances group if NOA is not yet reached.
 void removeWaitingAccessor(P2PNodeLookup accessorToRemove)
          /** Remove a no more waiting nodes accessor.
 void startStealingNeighbors(double ranking, java.lang.String myNodeAddress)
          This method is called by the LoadBalancer object in order to start the work stealing
 void tellToMyNeighborsThatIWantToShareActiveObjects(double ranking)
          This method is called by the LoadBalancer object in order to send the balance request to its neighbors
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

P2PService

public P2PService()
The empty constructor.

See Also:
ProActive
Method Detail

firstContact

public void firstContact(java.util.Vector peers)
Contact all specified peers to enter in the existing P2P network.

Parameters:
peers - a list of peers URL.

register

public void register(P2PService service)
Add the remote P2P service in the local acquaintances group if NOA is not yet reached.

Parameters:
service - the remote P2P service.

heartBeat

public void heartBeat()
Just to test if the peer is alive.


exploring

public void exploring(int ttl,
                      UniversalUniqueID uuid,
                      P2PService remoteService)
Method automaticly forwarded by run activity if needed.

Using a random fonction to choose if this peer should be know by the remote peer or not.

Parameters:
ttl - Time to live of the message, in number of hops.
uuid - UUID of the message.
remoteService - The original sender.

askingNode

public void askingNode(int ttl,
                       UniversalUniqueID uuid,
                       P2PService remoteService,
                       int numberOfNodes,
                       P2PNodeLookup lookup,
                       java.lang.String vnName,
                       java.lang.String jobId)
Method automaticly forwarded by run activity if needed.

Booking a free node.

Parameters:
ttl - Time to live of the message, in number of hops.
uuid - UUID of the message.
remoteService - The original sender.
numberOfNodes - Number of asked nodes.
lookup - The P2P nodes lookup.
vnName - Virtual node name.
jobId -

askingNode

public void askingNode(int ttl,
                       UniversalUniqueID uuid,
                       P2PService remoteService,
                       int numberOfNodes,
                       P2PNodeLookup lookup,
                       java.lang.String vnName,
                       java.lang.String jobId,
                       boolean underloadedOnly)
Method called on Load Balanced enviroments.

Booking a free node.

Parameters:
ttl - Time to live of the message, in number of hops.
uuid - UUID of the message.
remoteService - The original sender.
numberOfNodes - Number of asked nodes.
lookup - The P2P nodes lookup.
vnName - Virtual node name.
jobId -
underloadedOnly - determines if it replies with normal "askingNode" method or discard the call

getNodes

public P2PNodeLookup getNodes(int numberOfNodes,
                              java.lang.String vnName,
                              java.lang.String jobId)
Put in a P2PNodeLookup, the number of asked nodes.

Parameters:
numberOfNodes - the number of asked nodes.
vnName - Virtual node name.
jobId - of the vn.
Returns:
the number of asked nodes.

getNodes

public P2PNodeLookup getNodes(int numberOfNodes,
                              java.lang.String vnName,
                              java.lang.String jobId,
                              boolean onlyUnderloaded)

getMaximunNodes

public P2PNodeLookup getMaximunNodes(java.lang.String vnName,
                                     java.lang.String jobId)
Put in a P2PNodeLookup all available nodes during all the time where it is actived.

Parameters:
vnName - Virtual node name.
jobId -
Returns:
an active object where nodes are received.

getAddress

public java.lang.String getAddress()
For load balancing.

Returns:
URL of the node where the P2P service is running.

removeWaitingAccessor

public void removeWaitingAccessor(P2PNodeLookup accessorToRemove)
/** Remove a no more waiting nodes accessor.

Parameters:
accessorToRemove - the accessor to remove.

getP2PAcquaintanceManager

public P2PAcquaintanceManager getP2PAcquaintanceManager()
Returns:
a reference to the local acquaintance manager.

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)

amIUnderloaded

public boolean amIUnderloaded()
Returns:
Answer to remote machines if I'm underloaded.

amIUnderloaded

public boolean amIUnderloaded(double ranking)
Ask to the Load Balancer object if the state is underloaded

Parameters:
ranking -
Returns:
true if the state is underloaded, false else.

balanceWithMe

public void balanceWithMe(P2PService sender,
                          double ranking)
This method is remotely called by an overloaded peer, looking for a balance.

Parameters:
sender - the reference of the overloaded machine
ranking - the ranking of the caller

ImStealingYou

public void ImStealingYou(double ranking,
                          java.lang.String remoteNodeAddress)
This method is remotely called by an underloaded peer, looking for a balance.

Parameters:
ranking - the ranking of the caller
remoteNodeAddress - the reference to the remote machine

P2PloadBalance

public void P2PloadBalance(Node destNode)
This method is remotely called by an underloaded peer to start the load balancing.

Parameters:
destNode - is the new place for the active objects

tellToMyNeighborsThatIWantToShareActiveObjects

public void tellToMyNeighborsThatIWantToShareActiveObjects(double ranking)
This method is called by the LoadBalancer object in order to send the balance request to its neighbors

Parameters:
ranking - the ranking of the caller

startStealingNeighbors

public void startStealingNeighbors(double ranking,
                                   java.lang.String myNodeAddress)
This method is called by the LoadBalancer object in order to start the work stealing

Parameters:
ranking - the ranking of the caller
myNodeAddress - addres of the local node


Copyright 2001-2005 INRIA All Rights Reserved.