org.objectweb.proactive.core.body
Class AbstractBody

java.lang.Object
  extended byorg.objectweb.proactive.core.body.AbstractUniversalBody
      extended byorg.objectweb.proactive.core.body.AbstractBody
All Implemented Interfaces:
Body, Job, LocalBodyStrategy, MessageEventProducer, NFEProducer, SecurityEntity, java.io.Serializable, UniversalBody
Direct Known Subclasses:
BodyImpl, HalfBody

public abstract class AbstractBody
extends AbstractUniversalBody
implements Body, java.io.Serializable

**For internal use only**

This class gives a common implementation of the Body interface. It provides all the non specific behavior allowing sub-class to write the detail implementation.

Each body is identify by an unique identifier.

All active bodies that get created in one JVM register themselves into a table that allows to tack them done. The registering and deregistering is done by the AbstractBody and the table is managed here as well using some static methods.

In order to let somebody customize the body of an active object without subclassing it, AbstractBody delegates lot of tasks to satellite objects that implements a given interface. Abstract protected methods instantiate those objects allowing subclasses to create them as they want (using customizable factories or instance).

Since:
ProActive 0.9
Version:
1.0, 2001/10/23
Author:
ProActive Team
See Also:
Body, UniqueID, Serialized Form

Field Summary
protected  FTManager ftmanager
           
protected  InternalBodySecurity internalBodySecurity
           
protected  boolean isInterfaceSecureImplemented
           
protected  boolean isSecurityOn
           
protected  LocalBodyStrategy localBodyStrategy
           
protected  java.util.Hashtable openedSessions
           
protected  ProActiveSecurityManager psm
           
protected  ProActiveSPMDGroupManager spmdManager
           
protected  ThreadStore threadStore
           
 
Fields inherited from class org.objectweb.proactive.core.body.AbstractUniversalBody
bodyID, jobID, location, nodeURL, remoteBody, remoteBodyFactory, shortcuts
 
Fields inherited from interface org.objectweb.proactive.core.body.UniversalBody
bodyLogger
 
Constructor Summary
AbstractBody()
          Creates a new AbstractBody.
AbstractBody(java.lang.Object reifiedObject, java.lang.String nodeURL, MetaObjectFactory factory, java.lang.String jobId)
          Creates a new AbstractBody for an active object attached to a given node.
 
Method Summary
 void acceptCommunication()
          Signals the body to accept all incoming communications.
protected  void activityStarted()
          Signals that the activity of this body, managed by the active thread has just started.
protected  void activityStopped()
          Signals that the activity of this body, managed by the active thread has just stopped.
 void blockCommunication()
          blocks all incoming communications.
 UniversalBody checkNewLocation(UniqueID bodyID)
          Tries to find a local version of the body of id uniqueID.
 void disableAC()
          Disables automatic continuation mechanism for this body
 void enableAC()
          Enables automatic continuation mechanism for this body
 void enterInThreadStore()
          Allows the calling thread to enter in the ThreadStore of this body.
 void exitFromThreadStore()
          Allows the calling thread to exit from the ThreadStore of this body.
 java.security.cert.X509Certificate getCertificate()
          entity certificate
 byte[] getCertificateEncoded()
          Entity's X509Certificate as byte array
 java.util.ArrayList getEntities()
          Retrieves all the entity's ID which contain this entity plus this entity ID.
 FTManager getFTManager()
          To get the FTManager of this body
 FuturePool getFuturePool()
          Returns the future pool of this body
 java.lang.String getName()
          Returns the name of this body that can be used for displaying information
 SecurityContext getPolicy(SecurityContext securityContext)
          Ask the entity to fill the securityContext parameters with its own policy according to the communication details contained in the given securityContext
 ProActiveSecurityManager getProActiveSecurityManager()
           
 ProActiveSPMDGroupManager getProActiveSPMDGroupManager()
           
 java.security.PublicKey getPublicKey()
          entity public key
 java.lang.Object getReifiedObject()
          Returns the reified object that body is for The reified object is the object that has been turned active.
 BlockingRequestQueue getRequestQueue()
          Returns the request queue associated to this body
 UniversalBody getShortcutTargetBody(FunctionalInterfaceID functionalItfID)
          Returns the body that is the target of this shortcut for this component interface
 java.lang.Object getSPMDGroup()
          Returns the SPMD group of the active object
 int getSPMDGroupSize()
          Returns the size of of the SPMD group
protected abstract  int internalReceiveReply(Reply reply)
          Receives a reply in response to a former request.
protected abstract  int internalReceiveRequest(Request request)
          Receives a request for later processing.
 boolean isActive()
          Returns whether the body is active or not.
 boolean isAlive()
          Returns whether the body is alive or not.
 byte[][] publicKeyExchange(long sessionID, byte[] myPublicKey, byte[] myCertificate, byte[] signature)
          exchange entity certificate and/or public key if certificate are not available
 byte[] randomValue(long sessionID, byte[] clientRandomValue)
          Exchange random value between client and server entity
 java.lang.Object receiveFTMessage(FTMessage fte)
          For sending a non fonctional message to the FTManager linked to this object.
 int receiveReply(Reply reply)
          Receives a reply in response to a former request.
 int receiveRequest(Request request)
          Receives a request for later processing.
 void registerIncomingFutures()
          This method effectively register futures (ie in the futurePool) that arrive in this active object (by parameter or by result).
 void renegociateSessionIfNeeded(long sID)
           
 byte[][] secretKeyExchange(long sessionID, byte[] encodedAESKey, byte[] encodedIVParameters, byte[] encodedClientMacKey, byte[] encodedLockData, byte[] parametersSignature)
          this method sends encoded secret parameters to the target entity
 void sendRequest(MethodCall methodCall, Future future, UniversalBody destinationBody)
          Sends the request request with the future future to the local body body.
 void serve(Request request)
          Serves the request.
 void setFTManager(FTManager ftm)
          To set the FTManager of this body
protected  void setLocalBodyImpl(LocalBodyStrategy localBody)
           
 void setPolicyServer(PolicyServer server)
          set the policy server of the active object
 void setSPMDGroup(java.lang.Object o)
          Set the SPMD group for the active object
protected  void startDefaultProActiveSecurityManager()
           
 long startNewSession(Communication policy)
          start an unvalidated empty session
 void terminate()
          Terminate the body.
 void terminateSession(long sessionID)
          terminate a given session
 java.lang.String toString()
          Returns a string representation of this object.
 
Methods inherited from class org.objectweb.proactive.core.body.AbstractUniversalBody
addNFEListener, createShortcut, fireNFE, getID, getJobID, getNodeURL, getRemoteAdapter, removeNFEListener, updateLocation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.objectweb.proactive.Body
updateNodeURL
 
Methods inherited from interface org.objectweb.proactive.core.body.UniversalBody
createShortcut, getID, getNodeURL, getRemoteAdapter, removeImmediateService, setImmediateService, setImmediateService, updateLocation
 
Methods inherited from interface org.objectweb.proactive.core.exceptions.manager.NFEProducer
addNFEListener, fireNFE, removeNFEListener
 
Methods inherited from interface org.objectweb.proactive.Job
getJobID
 
Methods inherited from interface org.objectweb.proactive.core.body.message.MessageEventProducer
addMessageEventListener, removeMessageEventListener
 

Field Detail

threadStore

protected ThreadStore threadStore

localBodyStrategy

protected LocalBodyStrategy localBodyStrategy

psm

protected ProActiveSecurityManager psm

isSecurityOn

protected boolean isSecurityOn

internalBodySecurity

protected transient InternalBodySecurity internalBodySecurity

openedSessions

protected java.util.Hashtable openedSessions

isInterfaceSecureImplemented

protected boolean isInterfaceSecureImplemented

spmdManager

protected ProActiveSPMDGroupManager spmdManager

ftmanager

protected FTManager ftmanager
Constructor Detail

AbstractBody

public AbstractBody()
Creates a new AbstractBody. Used for serialization.


AbstractBody

public AbstractBody(java.lang.Object reifiedObject,
                    java.lang.String nodeURL,
                    MetaObjectFactory factory,
                    java.lang.String jobId)
Creates a new AbstractBody for an active object attached to a given node.

Parameters:
reifiedObject - the active object that body is for
nodeURL - the URL of the node that body is attached to
factory - the factory able to construct new factories for each type of meta objects needed by this body
Method Detail

toString

public java.lang.String toString()
Returns a string representation of this object.

Returns:
a string representation of this object

receiveRequest

public int receiveRequest(Request request)
                   throws java.io.IOException,
                          RenegotiateSessionException
Description copied from interface: UniversalBody
Receives a request for later processing. The call to this method is non blocking unless the body cannot temporary receive the request.

Specified by:
receiveRequest in interface UniversalBody
Parameters:
request - the request to process
Returns:
value for fault-tolerance protocol
Throws:
java.io.IOException - if the request cannot be accepted
RenegotiateSessionException

receiveReply

public int receiveReply(Reply reply)
                 throws java.io.IOException
Description copied from interface: UniversalBody
Receives a reply in response to a former request.

Specified by:
receiveReply in interface UniversalBody
Parameters:
reply - the reply received
Returns:
value for fault-tolerance procotol
Throws:
java.io.IOException - if the reply cannot be accepted

registerIncomingFutures

public void registerIncomingFutures()
This method effectively register futures (ie in the futurePool) that arrive in this active object (by parameter or by result). Incoming futures have been registered in the static table FuturePool.incomingFutures during their deserialization. This effective registration must be perform AFTER entering in the ThreadStore.


enableAC

public void enableAC()
Description copied from interface: UniversalBody
Enables automatic continuation mechanism for this body

Specified by:
enableAC in interface UniversalBody

disableAC

public void disableAC()
Description copied from interface: UniversalBody
Disables automatic continuation mechanism for this body

Specified by:
disableAC in interface UniversalBody

renegociateSessionIfNeeded

public void renegociateSessionIfNeeded(long sID)
                                throws RenegotiateSessionException,
                                       SecurityNotAvailableException,
                                       java.io.IOException
Throws:
RenegotiateSessionException
SecurityNotAvailableException
java.io.IOException

terminateSession

public void terminateSession(long sessionID)
                      throws SecurityNotAvailableException,
                             java.io.IOException
Description copied from interface: SecurityEntity
terminate a given session

Specified by:
terminateSession in interface SecurityEntity
Parameters:
sessionID -
Throws:
SecurityNotAvailableException - id security is not available
java.io.IOException

getCertificate

public java.security.cert.X509Certificate getCertificate()
                                                  throws SecurityNotAvailableException,
                                                         java.io.IOException
Description copied from interface: SecurityEntity
entity certificate

Specified by:
getCertificate in interface SecurityEntity
Returns:
returns entity certificate
Throws:
java.io.IOException - if communication fails
SecurityNotAvailableException - if security is not available

getProActiveSecurityManager

public ProActiveSecurityManager getProActiveSecurityManager()
                                                     throws java.io.IOException,
                                                            SecurityNotAvailableException
Throws:
java.io.IOException
SecurityNotAvailableException

getProActiveSPMDGroupManager

public ProActiveSPMDGroupManager getProActiveSPMDGroupManager()

startNewSession

public long startNewSession(Communication policy)
                     throws RenegotiateSessionException,
                            SecurityNotAvailableException,
                            java.io.IOException
Description copied from interface: SecurityEntity
start an unvalidated empty session

Specified by:
startNewSession in interface SecurityEntity
Parameters:
policy - policy associated to the session
Returns:
session ID
Throws:
RenegotiateSessionException - if the session immediatly expires
SecurityNotAvailableException - if security is not available
java.io.IOException

getPublicKey

public java.security.PublicKey getPublicKey()
                                     throws SecurityNotAvailableException,
                                            java.io.IOException
Description copied from interface: SecurityEntity
entity public key

Specified by:
getPublicKey in interface SecurityEntity
Returns:
returns entity public key
Throws:
SecurityNotAvailableException
java.io.IOException

randomValue

public byte[] randomValue(long sessionID,
                          byte[] clientRandomValue)
                   throws SecurityNotAvailableException,
                          RenegotiateSessionException,
                          java.io.IOException
Description copied from interface: SecurityEntity
Exchange random value between client and server entity

Specified by:
randomValue in interface SecurityEntity
Parameters:
sessionID - the session ID
clientRandomValue - client random value
Returns:
server random value
Throws:
RenegotiateSessionException - if the session has expired
SecurityNotAvailableException - if the security is not available
java.io.IOException

publicKeyExchange

public byte[][] publicKeyExchange(long sessionID,
                                  byte[] myPublicKey,
                                  byte[] myCertificate,
                                  byte[] signature)
                           throws SecurityNotAvailableException,
                                  RenegotiateSessionException,
                                  KeyExchangeException,
                                  java.io.IOException
Description copied from interface: SecurityEntity
exchange entity certificate and/or public key if certificate are not available

Specified by:
publicKeyExchange in interface SecurityEntity
Parameters:
sessionID - the session ID
myPublicKey - encoded public key
myCertificate - encoded certificate
signature - encoded signature of previous paramaters
Returns:
an array containing : - server certificate and/or server public key - encoded signature of these parameters
Throws:
SecurityNotAvailableException - if the security is not available
KeyExchangeException - if a key data/length/algorithm is not supported
RenegotiateSessionException - if the session has expired
java.io.IOException

secretKeyExchange

public byte[][] secretKeyExchange(long sessionID,
                                  byte[] encodedAESKey,
                                  byte[] encodedIVParameters,
                                  byte[] encodedClientMacKey,
                                  byte[] encodedLockData,
                                  byte[] parametersSignature)
                           throws SecurityNotAvailableException,
                                  RenegotiateSessionException,
                                  java.io.IOException
Description copied from interface: SecurityEntity
this method sends encoded secret parameters to the target entity

Specified by:
secretKeyExchange in interface SecurityEntity
Parameters:
sessionID - session ID
encodedAESKey - the AES key use to exchange secret message
encodedIVParameters - Initilization parameters for the AES key
encodedClientMacKey - MAC key for checking signature of future messages
encodedLockData - random value to prevent message replays by an external attacker
parametersSignature - encoded signature of the previous parameters
Returns:
an array containing : - encoded server AES key - encoded IV parameters - encoded server MAC key - encoded lock data to prevent message replays - encoded signature of previous parameters
Throws:
java.io.IOException - if communication fails
RenegotiateSessionException - if the session has expired or has been cancelled during this exchange
SecurityNotAvailableException - if this entity does not support security

getPolicy

public SecurityContext getPolicy(SecurityContext securityContext)
                          throws SecurityNotAvailableException,
                                 java.io.IOException
Description copied from interface: SecurityEntity
Ask the entity to fill the securityContext parameters with its own policy according to the communication details contained in the given securityContext

Specified by:
getPolicy in interface SecurityEntity
Parameters:
securityContext - communication details allowing the entity to look for a matching policy
Returns:
securityContext filled with this entity's policy
Throws:
SecurityNotAvailableException - thrown the entity doest not support the security
java.io.IOException

getCertificateEncoded

public byte[] getCertificateEncoded()
                             throws SecurityNotAvailableException,
                                    java.io.IOException
Description copied from interface: SecurityEntity
Entity's X509Certificate as byte array

Specified by:
getCertificateEncoded in interface SecurityEntity
Returns:
entity's X509Certificate as byte array
Throws:
SecurityNotAvailableException
java.io.IOException

startDefaultProActiveSecurityManager

protected void startDefaultProActiveSecurityManager()

getEntities

public java.util.ArrayList getEntities()
                                throws SecurityNotAvailableException,
                                       java.io.IOException
Description copied from interface: SecurityEntity
Retrieves all the entity's ID which contain this entity plus this entity ID.

Specified by:
getEntities in interface SecurityEntity
Returns:
returns all the entity's ID which contain this entity plus this entity ID.
Throws:
SecurityNotAvailableException - if the target entity does not support security
java.io.IOException

terminate

public void terminate()
Description copied from interface: UniversalBody
Terminate the body. After this call the body is no more alive and no more active although the active thread is not interrupted. The body is unuseable after this call.

Specified by:
terminate in interface UniversalBody

blockCommunication

public void blockCommunication()
Description copied from interface: Body
blocks all incoming communications. After this call, the body cannot receive any request or reply.

Specified by:
blockCommunication in interface Body

acceptCommunication

public void acceptCommunication()
Description copied from interface: Body
Signals the body to accept all incoming communications. This call undo a previous call to blockCommunication.

Specified by:
acceptCommunication in interface Body

enterInThreadStore

public void enterInThreadStore()
Description copied from interface: Body
Allows the calling thread to enter in the ThreadStore of this body.

Specified by:
enterInThreadStore in interface Body

exitFromThreadStore

public void exitFromThreadStore()
Description copied from interface: Body
Allows the calling thread to exit from the ThreadStore of this body.

Specified by:
exitFromThreadStore in interface Body

isAlive

public boolean isAlive()
Description copied from interface: Body
Returns whether the body is alive or not. The body is alive as long as it is processing request and reply

Specified by:
isAlive in interface Body
Returns:
whether the body is alive or not.

isActive

public boolean isActive()
Description copied from interface: Body
Returns whether the body is active or not. The body is active as long as it has an associated thread running to serve the requests by calling methods on the active object.

Specified by:
isActive in interface Body
Returns:
whether the body is active or not.

checkNewLocation

public UniversalBody checkNewLocation(UniqueID bodyID)
Description copied from interface: Body
Tries to find a local version of the body of id uniqueID. If a local version is found it is returned. If not, tries to find the body of id uniqueID in the known body of this body. If a body is found it is returned, else null is returned.

Specified by:
checkNewLocation in interface Body
Parameters:
bodyID - the id of the body to lookup
Returns:
the last known version of the body of id uniqueID or null if not known

getShortcutTargetBody

public UniversalBody getShortcutTargetBody(FunctionalInterfaceID functionalItfID)
Description copied from interface: Body
Returns the body that is the target of this shortcut for this component interface

Specified by:
getShortcutTargetBody in interface Body
Parameters:
functionalItfID - the id of the interface on which the shortcut is available
Returns:
the body that is the target of this shortcut for this interface

setPolicyServer

public void setPolicyServer(PolicyServer server)
Description copied from interface: Body
set the policy server of the active object

Specified by:
setPolicyServer in interface Body
Parameters:
server - the policy server

getFuturePool

public FuturePool getFuturePool()
Description copied from interface: LocalBodyStrategy
Returns the future pool of this body

Specified by:
getFuturePool in interface LocalBodyStrategy
Returns:
the future pool of this body

getRequestQueue

public BlockingRequestQueue getRequestQueue()
Description copied from interface: LocalBodyStrategy
Returns the request queue associated to this body

Specified by:
getRequestQueue in interface LocalBodyStrategy
Returns:
the request queue associated to this body

getReifiedObject

public java.lang.Object getReifiedObject()
Description copied from interface: LocalBodyStrategy
Returns the reified object that body is for The reified object is the object that has been turned active.

Specified by:
getReifiedObject in interface LocalBodyStrategy
Returns:
the reified object that body is for

getName

public java.lang.String getName()
Description copied from interface: LocalBodyStrategy
Returns the name of this body that can be used for displaying information

Specified by:
getName in interface LocalBodyStrategy
Returns:
the name of this body

serve

public void serve(Request request)
Serves the request. The request should be removed from the request queue before serving, which is correctly done by all methods of the Service class. However, this condition is not ensured for custom calls on serve.

Specified by:
serve in interface LocalBodyStrategy
Parameters:
request - the request to serve

sendRequest

public void sendRequest(MethodCall methodCall,
                        Future future,
                        UniversalBody destinationBody)
                 throws java.io.IOException,
                        RenegotiateSessionException
Description copied from interface: LocalBodyStrategy
Sends the request request with the future future to the local body body.

Specified by:
sendRequest in interface LocalBodyStrategy
Parameters:
methodCall - the methodCall to send
future - the future associated to the request
destinationBody - the body the request is sent to
Throws:
java.io.IOException - if the request cannot be sent to the destination body
RenegotiateSessionException

receiveFTMessage

public java.lang.Object receiveFTMessage(FTMessage fte)
Description copied from interface: UniversalBody
For sending a non fonctional message to the FTManager linked to this object.

Specified by:
receiveFTMessage in interface UniversalBody
Parameters:
fte - the message to send
Returns:
depends on the message meaning

internalReceiveRequest

protected abstract int internalReceiveRequest(Request request)
                                       throws java.io.IOException,
                                              RenegotiateSessionException
Receives a request for later processing. The call to this method is non blocking unless the body cannot temporary receive the request.

Parameters:
request - the request to process
Throws:
java.io.IOException - if the request cannot be accepted
RenegotiateSessionException

internalReceiveReply

protected abstract int internalReceiveReply(Reply reply)
                                     throws java.io.IOException
Receives a reply in response to a former request.

Parameters:
reply - the reply received
Throws:
java.io.IOException - if the reply cannot be accepted

setLocalBodyImpl

protected void setLocalBodyImpl(LocalBodyStrategy localBody)

activityStopped

protected void activityStopped()
Signals that the activity of this body, managed by the active thread has just stopped.


activityStarted

protected void activityStarted()
Signals that the activity of this body, managed by the active thread has just started.


setSPMDGroup

public void setSPMDGroup(java.lang.Object o)
Set the SPMD group for the active object

Parameters:
o - - the new SPMD group

getSPMDGroup

public java.lang.Object getSPMDGroup()
Returns the SPMD group of the active object

Returns:
the SPMD group of the active object

getSPMDGroupSize

public int getSPMDGroupSize()
Returns the size of of the SPMD group

Returns:
the size of of the SPMD group

getFTManager

public FTManager getFTManager()
To get the FTManager of this body

Returns:
Returns the ftm.

setFTManager

public void setFTManager(FTManager ftm)
To set the FTManager of this body

Parameters:
ftm - The ftm to set.


Copyright 2001-2005 INRIA All Rights Reserved.