org.ourgrid.peer.manager.allocation
Class AllocationManager

java.lang.Object
  extended by org.ourgrid.peer.manager.allocation.AllocationManager

public class AllocationManager
extends java.lang.Object

Keeps track of all the machines available to the peer.


Constructor Summary
protected AllocationManager()
           
 
Method Summary
 void allocateGumToRequest(GumID gumID, long requestID, boolean requestIsLocal)
           
 void deallocateAndRemove(GumID gumID)
          A gum has to be disposed.
 void deallocateGum(GumID gumID)
          Deallocates a gum from the current user.
 java.util.Collection<AllocationEntry> getAllocationEntries(AllocationEntry.GumSource gumSource, AllocationStatus status)
           
 AllocationEntry getAllocationEntry(GumID gumID)
           
static AllocationManager getInstance()
           
 java.util.Collection<AllocationEntry> getLocalDonated()
           
 java.util.Collection<AllocationEntry> getLocalGums()
           
 java.util.Collection<AllocationEntry> getLocalIdle()
           
 java.util.Collection<AllocationEntry> getLocalInUse()
           
 int getNumberOfLocalGums()
           
 java.util.Collection<AllocationEntry> getRemoteGums()
           
 java.util.Collection<AllocationEntry> getRemoteIdle()
           
 java.util.Collection<AllocationEntry> getRemoteInUse()
           
 boolean gumExists(GumID gumID)
           
 AllocationEntry gumReceived(EBGum ebGum, GumSpec gumSpec)
          A new gum has been received
static void reset()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AllocationManager

protected AllocationManager()
Method Detail

getInstance

public static AllocationManager getInstance()

gumReceived

public AllocationEntry gumReceived(EBGum ebGum,
                                   GumSpec gumSpec)
A new gum has been received

Parameters:
ebGum - The event-base gum object representing the grid machine
gumSpec - The grid machine specification
Returns:
The newly created allocation, or an already existent, if any.

gumExists

public boolean gumExists(GumID gumID)

deallocateAndRemove

public void deallocateAndRemove(GumID gumID)
A gum has to be disposed.

Parameters:
gumID - the Id of the gum to be disposed.

allocateGumToRequest

public void allocateGumToRequest(GumID gumID,
                                 long requestID,
                                 boolean requestIsLocal)

deallocateGum

public void deallocateGum(GumID gumID)
Deallocates a gum from the current user. If the machine isn't allocate or doesn't exist at the allocations map the operation won't be concluded.

Parameters:
gumID - The GridMachine name.

getAllocationEntries

public java.util.Collection<AllocationEntry> getAllocationEntries(AllocationEntry.GumSource gumSource,
                                                                  AllocationStatus status)

getNumberOfLocalGums

public int getNumberOfLocalGums()

getLocalGums

public java.util.Collection<AllocationEntry> getLocalGums()

getLocalInUse

public java.util.Collection<AllocationEntry> getLocalInUse()
Returns:
All local machines with AllocationStatus.IN_USE status.

getLocalDonated

public java.util.Collection<AllocationEntry> getLocalDonated()
Returns:
All local machines with AllocationStatus.DONATED status.

getLocalIdle

public java.util.Collection<AllocationEntry> getLocalIdle()
Returns:
All local machines with AllocationStatus.IDLE status.

getRemoteGums

public java.util.Collection<AllocationEntry> getRemoteGums()

getRemoteInUse

public java.util.Collection<AllocationEntry> getRemoteInUse()
Returns:
All remote machines with AllocationStatus.IN_USE status.

getRemoteIdle

public java.util.Collection<AllocationEntry> getRemoteIdle()
Returns:
All remote machines with AllocationStatus.IDLE status.

getAllocationEntry

public AllocationEntry getAllocationEntry(GumID gumID)

reset

public static void reset()