org.ourgrid.peer.manager
Class EBPeerManager

java.lang.Object
  extended by org.ourgrid.peer.manager.EBPeerManager
All Implemented Interfaces:
EBGump, EBGumpClient

public class EBPeerManager
extends java.lang.Object
implements EBGump, EBGumpClient

The EBPeerManager is responsible to manage the peer resources (Gums). It is important to distribute the gums to the correct request and keep the grid machines distributed steadily.


Field Summary
protected  AllocationManager allocationManager
           
protected  EBCommunityObtainerFacade ebCommunityObtainer
           
protected  EBGumManagerImpl ebGumManager
           
protected  RequestManager requestManager
           
 
Constructor Summary
  EBPeerManager(GumpClientThreadManager consumerThreadManager, ObjectID remoteAccessID, ObjectID brokerAccessID, UIManager uiManager)
          Default constructor.
protected EBPeerManager(RequestManager reqManager, AllocationManager allocationManager, GumpClientThreadManager consumerThreadManager, UIManager uiManager)
          This constructor should be directly used only by tests.
 
Method Summary
 void adviceFailureDetector(GumID gumID)
           
protected  void computeCommunityRedistribution(java.util.List<DistributionHelpEntry> redistributionList, int numberOfGumsInUseByCommunity)
          Calculates the new distribution of local gums allocated to the community according to Network of Favors balances.
 void config(EBCommunityObtainerFacade communityObtainerFacade, EBGumManagerImpl gumManager)
          Configure internal modules.
 void consumerIsDead(ObjectID consumerID)
           
 void disposeGum(long requestID, GumID gumID)
           
 void finishRequestGums(long requestID)
           
 void gumWasLost(GumID gumID)
           
 void hereIsGum(EBGum receivedGum, ObjectID gumOwnerObjectID, long requestID)
           
 void hereIsLocalGum(EBGum ebGum, GumSpec gumSpec)
          When a machine is set at EBGumManagerImpl at it state is up, a hereIsLocalGuM is received at this entity.
 void lostGum(GumID gumID, long requestID)
           
 void pauseRequestGums(long requestID)
           
protected  void preemptGum(GumID gumID)
          Preempts a grid machine, that is, deallocate the grid machine from a request.
protected  void redistributeLocalGumsForLocalRequests(long newRequestId)
           
protected  void redistributeLocalGumsForRemoteRequests(long newRequestId)
           
 void requestGums(RequestSpec requestSpec)
           
protected  void respondRequest(long newRequestId)
          Tries to serve a request with local deallocated gums.
 void resumeRequestGums(long requestID)
           
 void unwantedGum(long requestID, GumID gumID)
          Notifies the request that the given gum is not wanted.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

requestManager

protected RequestManager requestManager

allocationManager

protected AllocationManager allocationManager

ebGumManager

protected EBGumManagerImpl ebGumManager

ebCommunityObtainer

protected EBCommunityObtainerFacade ebCommunityObtainer
Constructor Detail

EBPeerManager

public EBPeerManager(GumpClientThreadManager consumerThreadManager,
                     ObjectID remoteAccessID,
                     ObjectID brokerAccessID,
                     UIManager uiManager)
Default constructor.

Parameters:
consumerThreadManager - a thread manager to control the operations done in separate threads (for example: delivering a machine to to a remote consumer)
remoteAccessID - the identification of the remote object used by remote peer to access this peer
brokerAccessID - the identification of the remote object used by local brokers to access this peer

EBPeerManager

protected EBPeerManager(RequestManager reqManager,
                        AllocationManager allocationManager,
                        GumpClientThreadManager consumerThreadManager,
                        UIManager uiManager)
This constructor should be directly used only by tests.

Parameters:
reqManager - RequestManager created by the test
allocationManager - AllocationManager created by the test
consumerThreadManager - GumpClientThreadManager created by the test
Method Detail

config

public void config(EBCommunityObtainerFacade communityObtainerFacade,
                   EBGumManagerImpl gumManager)
Configure internal modules.


requestGums

public void requestGums(RequestSpec requestSpec)
                 throws RequestAlreadyExistsException
Specified by:
requestGums in interface EBGump
Throws:
RequestAlreadyExistsException
See Also:
Gump.requestGums(RequestSpec)

redistributeLocalGumsForLocalRequests

protected void redistributeLocalGumsForLocalRequests(long newRequestId)
                                              throws RequestDoesNotExistException
Throws:
RequestDoesNotExistException

redistributeLocalGumsForRemoteRequests

protected void redistributeLocalGumsForRemoteRequests(long newRequestId)
                                               throws RequestDoesNotExistException
Throws:
RequestDoesNotExistException

computeCommunityRedistribution

protected void computeCommunityRedistribution(java.util.List<DistributionHelpEntry> redistributionList,
                                              int numberOfGumsInUseByCommunity)
Calculates the new distribution of local gums allocated to the community according to Network of Favors balances.

Parameters:
redistributionList - a list containing information about consumers. It will be modified by this method.
numberOfGumsInUseByCommunity - the total number of gums currently allocated to the community

respondRequest

protected void respondRequest(long newRequestId)
                       throws RequestDoesNotExistException
Tries to serve a request with local deallocated gums.

Parameters:
newRequestId - the request to be served
Throws:
RequestDoesNotExistException

finishRequestGums

public void finishRequestGums(long requestID)
Specified by:
finishRequestGums in interface EBGump
See Also:
Gump.finishRequestGums(long)

disposeGum

public void disposeGum(long requestID,
                       GumID gumID)
Specified by:
disposeGum in interface EBGump
See Also:
Gump.disposeGum(long, GumID)

lostGum

public void lostGum(GumID gumID,
                    long requestID)

adviceFailureDetector

public void adviceFailureDetector(GumID gumID)

gumWasLost

public void gumWasLost(GumID gumID)

hereIsGum

public void hereIsGum(EBGum receivedGum,
                      ObjectID gumOwnerObjectID,
                      long requestID)
Specified by:
hereIsGum in interface EBGumpClient
See Also:
GumpClient.hereIsGum(GumResponseEntry)

hereIsLocalGum

public void hereIsLocalGum(EBGum ebGum,
                           GumSpec gumSpec)
When a machine is set at EBGumManagerImpl at it state is up, a hereIsLocalGuM is received at this entity.


pauseRequestGums

public void pauseRequestGums(long requestID)
Specified by:
pauseRequestGums in interface EBGump
See Also:
Gump.pauseRequestGums(long)

resumeRequestGums

public void resumeRequestGums(long requestID)
Specified by:
resumeRequestGums in interface EBGump
See Also:
Gump.resumeRequestGums(long)

preemptGum

protected void preemptGum(GumID gumID)
Preempts a grid machine, that is, deallocate the grid machine from a request.

Parameters:
gumID - the identification of the grid machine to be preempted

consumerIsDead

public void consumerIsDead(ObjectID consumerID)

unwantedGum

public void unwantedGum(long requestID,
                        GumID gumID)
Notifies the request that the given gum is not wanted.

Specified by:
unwantedGum in interface EBGump
Parameters:
requestID - ID of the request to notify.
gumID - ID of the gum that is not wanted.
See Also:
Gump.unwantedGum(long, GumID)