org.ourgrid.peer.manager.request
Class RequestManager

java.lang.Object
  extended by org.ourgrid.peer.manager.request.RequestManager

public class RequestManager
extends java.lang.Object

Keeps track of all the requests and manage them.


Method Summary
 RequestEntry createRequestEntry(RequestSpec requestSpec)
          Creates and stores a request.
 void deleteConsumerRequests(ObjectID consumerID)
           
 void deleteRequest(long requestID)
          Informs that this request was canceled by its consumer.
 java.util.Collection<RequestEntry> getAliveRequests(RequestSpec.RequestSource source)
           
 java.util.Collection<RequestEntry> getConsumerRequests(ObjectID peerID)
          Recovers a Collection containing all PeerID local RequestEntry
 java.util.Collection<java.lang.Long> getConsumerRequestsIDs(ObjectID consumerID)
          Recovers a Collection containing all PeerID local RequestEntry
 java.util.Collection<GumpClient> getConsumers(RequestSpec.RequestSource source)
          Gets a Collection containing all consumers (local or remote)
 java.util.Collection<ObjectID> getConsumersIDs(RequestSpec.RequestSource source)
          Gets a Collection containing all Id's of current consumers
 GumpClient getGumpClient(long requestID)
          Get the GumpClient of the given request id.
 java.util.Collection<GumID> getGums(GumpClient gumpClient)
           
 java.util.Collection<GumID> getGums(GumpClient gumpClient, AllocationEntry.GumSource source)
           
 java.util.Collection<GumID> getGums(ObjectID peerID)
           
 java.util.Collection<GumID> getGums(ObjectID peerID, AllocationEntry.GumSource source)
           
static RequestManager getInstance()
           
 java.util.Collection<GumID> getRequestGums(long requestID)
           
 int getRequestNeededGums(long requestId)
           
 java.util.Collection<RequestEntry> getRequests(GumpClient gumpClient)
          Recovers a Collection containing all GumpClient local RequestEntry
 RequestSpec getRequestSpec(long requestID)
           
 java.util.Collection<RequestEntry> getRequestsThatNeedGums(java.util.Collection<RequestEntry> requestList)
          Selects the requests that still need Gums.
 java.util.Collection<RequestEntry> getRequestsWithAllocatedGums(RequestSpec.RequestSource source)
           
 java.util.Set<GumID> getUnwantedGumsForRequest(long requestID)
           
 void hereIsGumToRequest(long requestID, GumID gumID)
          Refresh this request about the hereIsGuM() command.
 void pauseRequestGums(long requestID)
          Indicates that a request does not want more gums as far.
 void removeGumFromRequest(long requestID, GumID gumID)
          Refresh this request about the dispose instruction.
 boolean requestExists(long requestID)
           
 boolean requestHasGum(long requestId, GumID gumID)
           
 boolean requestIsLocal(long requestID)
           
 boolean requestIsPaused(long requestId)
           
 boolean requestNeedMoreGums(long requestId)
           
 boolean requestWantsGum(long requestID, GumID gumID)
           
static void reset()
           
 void resumeRequestGums(long requestID)
          Indicates that a request needs gums again.
 void unwantedGum(long requestID, GumID gumID)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static RequestManager getInstance()

createRequestEntry

public RequestEntry createRequestEntry(RequestSpec requestSpec)
                                throws RequestAlreadyExistsException
Creates and stores a request.

Throws:
RequestAlreadyExistsException

requestExists

public boolean requestExists(long requestID)

getGumpClient

public GumpClient getGumpClient(long requestID)
                         throws RequestDoesNotExistException
Get the GumpClient of the given request id.

Throws:
RequestDoesNotExistException

deleteRequest

public void deleteRequest(long requestID)
Informs that this request was canceled by its consumer.


pauseRequestGums

public void pauseRequestGums(long requestID)
                      throws RequestDoesNotExistException
Indicates that a request does not want more gums as far. The request was paused.

Throws:
RequestDoesNotExistException

resumeRequestGums

public void resumeRequestGums(long requestID)
                       throws RequestDoesNotExistException
Indicates that a request needs gums again.

Throws:
RequestDoesNotExistException

hereIsGumToRequest

public void hereIsGumToRequest(long requestID,
                               GumID gumID)
                        throws RequestDoesNotExistException
Refresh this request about the hereIsGuM() command.

Throws:
RequestDoesNotExistException

removeGumFromRequest

public void removeGumFromRequest(long requestID,
                                 GumID gumID)
Refresh this request about the dispose instruction.


getAliveRequests

public java.util.Collection<RequestEntry> getAliveRequests(RequestSpec.RequestSource source)

getRequestsWithAllocatedGums

public java.util.Collection<RequestEntry> getRequestsWithAllocatedGums(RequestSpec.RequestSource source)

getRequests

public java.util.Collection<RequestEntry> getRequests(GumpClient gumpClient)
Recovers a Collection containing all GumpClient local RequestEntry

Returns:
The collection containing the local requests.

getConsumerRequests

public java.util.Collection<RequestEntry> getConsumerRequests(ObjectID peerID)
Recovers a Collection containing all PeerID local RequestEntry

Returns:
The collection containing the requests from PeerID.

getConsumerRequestsIDs

public java.util.Collection<java.lang.Long> getConsumerRequestsIDs(ObjectID consumerID)
Recovers a Collection containing all PeerID local RequestEntry

Returns:
The collection containing the requests from PeerID.

getGums

public java.util.Collection<GumID> getGums(GumpClient gumpClient,
                                           AllocationEntry.GumSource source)

getGums

public java.util.Collection<GumID> getGums(GumpClient gumpClient)

getGums

public java.util.Collection<GumID> getGums(ObjectID peerID)

getGums

public java.util.Collection<GumID> getGums(ObjectID peerID,
                                           AllocationEntry.GumSource source)

getConsumers

public java.util.Collection<GumpClient> getConsumers(RequestSpec.RequestSource source)
Gets a Collection containing all consumers (local or remote)

Parameters:
source - Choose if the list to be returned will be composed by local or remote consumers
Returns:
A collection with the selected consumers

getConsumersIDs

public java.util.Collection<ObjectID> getConsumersIDs(RequestSpec.RequestSource source)
Gets a Collection containing all Id's of current consumers

Parameters:
source - Choose if the list to be returned will be composed by local or remote consumers
Returns:
A collection with the selected consumers Id's

getRequestsThatNeedGums

public java.util.Collection<RequestEntry> getRequestsThatNeedGums(java.util.Collection<RequestEntry> requestList)
Selects the requests that still need Gums.

Returns:
The collection containing the selected requests

unwantedGum

public void unwantedGum(long requestID,
                        GumID gumID)
                 throws RequestDoesNotExistException
Throws:
RequestDoesNotExistException

getUnwantedGumsForRequest

public java.util.Set<GumID> getUnwantedGumsForRequest(long requestID)
                                               throws RequestDoesNotExistException
Throws:
RequestDoesNotExistException

reset

public static void reset()

getRequestGums

public java.util.Collection<GumID> getRequestGums(long requestID)
                                           throws RequestDoesNotExistException
Throws:
RequestDoesNotExistException

requestIsLocal

public boolean requestIsLocal(long requestID)
                       throws RequestDoesNotExistException
Throws:
RequestDoesNotExistException

deleteConsumerRequests

public void deleteConsumerRequests(ObjectID consumerID)

getRequestSpec

public RequestSpec getRequestSpec(long requestID)
                           throws RequestDoesNotExistException
Throws:
RequestDoesNotExistException

requestWantsGum

public boolean requestWantsGum(long requestID,
                               GumID gumID)
                        throws RequestDoesNotExistException
Throws:
RequestDoesNotExistException

requestNeedMoreGums

public boolean requestNeedMoreGums(long requestId)
                            throws RequestDoesNotExistException
Throws:
RequestDoesNotExistException

getRequestNeededGums

public int getRequestNeededGums(long requestId)
                         throws RequestDoesNotExistException
Throws:
RequestDoesNotExistException

requestIsPaused

public boolean requestIsPaused(long requestId)
                        throws RequestDoesNotExistException
Throws:
RequestDoesNotExistException

requestHasGum

public boolean requestHasGum(long requestId,
                             GumID gumID)
                      throws RequestDoesNotExistException
Throws:
RequestDoesNotExistException