org.ourgrid.peer.community
Class RemoteAccessImpl

java.lang.Object
  extended by java.rmi.server.RemoteObject
      extended by java.rmi.server.RemoteServer
          extended by java.rmi.server.UnicastRemoteObject
              extended by org.ourgrid.common.rmi.OurgridUnicastRemoteObject
                  extended by org.ourgrid.peer.community.RemoteAccessImpl
All Implemented Interfaces:
java.io.Serializable, java.rmi.Remote, Gump, GumpClient, RemoteAccess

public class RemoteAccessImpl
extends OurgridUnicastRemoteObject
implements RemoteAccess

See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
RemoteAccessImpl(ObjectID peerID, EBCommunityObtainerFacade ebCommunityObtainerFacade, EBPeerManagerFacade ebPeerManagerFacade)
          Creates a peerImpl
 
Method Summary
 void disposeGum(long requestID, GumID gumID)
          Informs the provider that a given grid machine is not needed anymore.
 void finishRequestGums(long requestID)
          Informs the provider that it must stop providing grid machines for the consumer who made a given request.
 ObjectID getObjectID()
          Returns the identification object related to this GridMachineProvider.
 java.util.Collection<ObjectID> getPeerList()
           
 void hereIsGum(GumResponseEntry gumResponseEntry)
           Delivers a grid machine (Gum) to this consumer.
 void hereIsPeerList(java.util.Collection<ObjectID> peerListReceived)
          Receives the know peer list.
 void joinCommunity()
          Joins the OurGrid Community.
 void pauseRequestGums(long requestID)
          Suspends a request for gums.
 void requestGums(RequestSpec requestSpec)
          Requests grid machines according to the specification contained in a RequestSpec.
 void resumeRequestGums(long requestID)
          Resumes a request for gums.
 void setPeerID(ObjectID peerID)
          Sets this peer's ID.
 void setPeerList(java.util.List<ObjectID> peerList)
           
 void unwantedGum(long requestID, GumID gumID)
          Informs the provider that a given grid machine is not needed anymore.
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RemoteAccessImpl

public RemoteAccessImpl(ObjectID peerID,
                        EBCommunityObtainerFacade ebCommunityObtainerFacade,
                        EBPeerManagerFacade ebPeerManagerFacade)
                 throws java.rmi.RemoteException
Creates a peerImpl

Parameters:
peerID - This peer's ID
ebCommunityObtainerFacade - This peer's community obtainer
ebPeerManagerFacade - This peer's community proxy
Throws:
java.rmi.RemoteException - If couldn't create the peer.
Method Detail

getObjectID

public ObjectID getObjectID()
                     throws java.rmi.RemoteException
Description copied from interface: Gump
Returns the identification object related to this GridMachineProvider.

Specified by:
getObjectID in interface Gump
Specified by:
getObjectID in interface GumpClient
Returns:
the provider identification.
Throws:
java.rmi.RemoteException - if some RMI error occurs during the method invocation.

hereIsPeerList

public void hereIsPeerList(java.util.Collection<ObjectID> peerListReceived)
                    throws java.rmi.RemoteException
Description copied from interface: RemoteAccess
Receives the know peer list.

Specified by:
hereIsPeerList in interface RemoteAccess
Parameters:
peerListReceived - A list of peer ids
Throws:
java.rmi.RemoteException
See Also:
RemoteAccess.hereIsPeerList(Collection)

getPeerList

public java.util.Collection<ObjectID> getPeerList()
Returns:
Return the know peer list.

setPeerList

public void setPeerList(java.util.List<ObjectID> peerList)

setPeerID

public void setPeerID(ObjectID peerID)
Sets this peer's ID.

Parameters:
peerID - The peer's ID

joinCommunity

public void joinCommunity()
                   throws java.rmi.RemoteException
Joins the OurGrid Community.

Specified by:
joinCommunity in interface RemoteAccess
Throws:
java.rmi.RemoteException - If could not contact the core peer.

hereIsGum

public void hereIsGum(GumResponseEntry gumResponseEntry)
               throws java.rmi.RemoteException
Description copied from interface: GumpClient

Delivers a grid machine (Gum) to this consumer. The grid machine satisfies the requirements of a specific request made by this consumer. The respective request is informed through a requestID which travels inside the parameter of type GumResponseEntry, which also contains a reference to the Gum, a gum specification (GumSpec) and a ID of the grid machine provider.

The grid machine availability has no guarantees. It may become unavailable due to failures or to the provider's will. For example, the provider may decide to schedule the grid machine to another consumer.

Also, it is expected that the consumer releases the Gum when it does not need it anymore. To do this the consumer must invoke the method Gump.finishRequestGums() .

Specified by:
hereIsGum in interface GumpClient
Parameters:
gumResponseEntry - an object containing the information about the delivery. It contains a reference to the Gum, a gum specification (GumSpec) and a ID of the grid machine provider.
Throws:
java.rmi.RemoteException - if some RMI error occurs during the method invocation.

requestGums

public void requestGums(RequestSpec requestSpec)
                 throws java.rmi.RemoteException
Description copied from interface: Gump
Requests grid machines according to the specification contained in a RequestSpec. This event must be broadcasted to the entire Ourgrid community (that is, all know peers).

Specified by:
requestGums in interface Gump
Parameters:
requestSpec - specification of the request
Throws:
java.rmi.RemoteException - if some RMI error occurs during the method invocation.

finishRequestGums

public void finishRequestGums(long requestID)
                       throws java.rmi.RemoteException
Description copied from interface: Gump
Informs the provider that it must stop providing grid machines for the consumer who made a given request. This event must be broadcasted to the entire Ourgrid community (that is, all know peers).

Specified by:
finishRequestGums in interface Gump
Parameters:
requestID - the unique ID that represents the request that needs no more grid machines.
Throws:
java.rmi.RemoteException - if some RMI error occurs during the method invocation.

disposeGum

public void disposeGum(long requestID,
                       GumID gumID)
                throws java.rmi.RemoteException
Description copied from interface: Gump
Informs the provider that a given grid machine is not needed anymore. Thus, the grid machine can be rescheduled to other requests. The same machine may scheduled to the same consumer in the future, for the same request in case it needs machines again or for a completely new request. If it is required that the given request no longer receives the grid machine being disposed, the unwantedGum(long, org.ourgrid.common.id.GumID) call should be used.

This event must be forwarded to the gum owner, only.

Specified by:
disposeGum in interface Gump
Parameters:
requestID - the unique ID that represents the request that wants to dispose the grid machine.
gumID - identification of the grid machine
Throws:
java.rmi.RemoteException - if some RMI error occurs during the method invocation.
See Also:
Gump.unwantedGum(long, GumID)

pauseRequestGums

public void pauseRequestGums(long requestID)
                      throws java.rmi.RemoteException
Description copied from interface: Gump
Suspends a request for gums. This event must be broadcasted to the entire Ourgrid community (that is, all know peers).

Specified by:
pauseRequestGums in interface Gump
Parameters:
requestID - the identification of the request that will be suspended.
Throws:
java.rmi.RemoteException - if some RMI error occurs during the method invocation.

resumeRequestGums

public void resumeRequestGums(long requestID)
                       throws java.rmi.RemoteException
Description copied from interface: Gump
Resumes a request for gums. This event must be broadcasted to the entire Ourgrid community (that is, all know peers).

Specified by:
resumeRequestGums in interface Gump
Parameters:
requestID - the identification of the request that will be resumed.
Throws:
java.rmi.RemoteException - if some RMI error occurs during the method invocation.

unwantedGum

public void unwantedGum(long requestID,
                        GumID gumID)
                 throws java.rmi.RemoteException
Description copied from interface: Gump
Informs the provider that a given grid machine is not needed anymore. Thus, the grid machine can be rescheduled to other requests. Different from the disposeGum(long, org.ourgrid.common.id.GumID), when a Peer receives this call it will no longer deliver this machines to the same request.

This event must be forwarded to the gum owner, only.

Specified by:
unwantedGum in interface Gump
Parameters:
requestID - the unique ID that represents the request which no longer wants this grid machine.
gumID - identification of the grid machine
Throws:
java.rmi.RemoteException - if some RMI error occurs during the method invocation.
See Also:
Gump.disposeGum(long, GumID)