org.objectweb.proactive.core.body.future
Class FutureProxy

java.lang.Object
  extended byorg.objectweb.proactive.core.body.future.FutureProxy
All Implemented Interfaces:
Future, Handlerizable, LocalFuture, Proxy, java.io.Serializable

public class FutureProxy
extends java.lang.Object
implements Future, Proxy, java.io.Serializable

This proxy class manages the semantic of future objects

Author:
Julien Vayssi?re - INRIA
See Also:
Proxy, Serialized Form

Field Summary
protected  boolean continuation
          To mark the proxy before sending this future by parameter or by result
protected  UniqueID creatorID
          UniqueID of the body which create this future
protected  java.util.HashMap futureLevel
          This table is needed for the NFE mechanism
protected  long ID
          ID of the future In fact, the sequence number of the request that generate this future
protected  boolean isAvailable
          This flag indicates the status of the future object
protected  boolean isException
          Indicates if the returned object is an exception
protected  boolean isNFE
          Indicates if the returned object is a Non Functional Exception (thus the communication failed)
protected static org.apache.log4j.Logger logger
          Get NFE logger
protected  boolean migration
          To mark the Proxy before migration Usually, the Proxy cannot be serialized if the result is not available (no automatic continuation) but if we migrate, we don't want to wait for the result
static int RECYCLE_POOL_SIZE
          The size of the pool we use for recycling FutureProxy objects.
protected  UniqueID senderID
          Unique ID of the sender (in case of automatic continuation).
protected  java.lang.Object target
          The object the proxy sends calls to
 
Constructor Summary
FutureProxy()
          As this proxy does not create a reified object (as opposed to BodyProxy for example), it is the noargs constructor that is usually called.
FutureProxy(ConstructorCall c, java.lang.Object[] p)
          This constructor is provided for compatibility with other proxies.
 
Method Summary
 void clearHandlersLevel()
          Clear the local map of handlers
 boolean equals(java.lang.Object obj)
           
protected  void finalize()
           
static int futureLength(java.lang.Object future)
           
 UniqueID getCreatorID()
          To get the creatorID.
static FutureEventProducer getFutureEventProducer()
          Returns the FutureEventProducer that is responsible for the FutureProxys of this VM.
static FutureProxy getFutureProxy()
           
 java.lang.String getHandlerizableInfo()
          Get information about the handlerizable object
 java.util.HashMap getHandlersLevel()
          Give a reference to a local map of handlers
 long getID()
          To get the sequence id of this future.
 java.lang.Throwable getRaisedException()
          Returns the result this future is for as an exception if an exception has been raised or null if the result is not an exception.
 java.lang.Object getResult()
          Returns the result this future is for.
 boolean isAwaited()
          Tests the status of the returned object
static boolean isAwaited(java.lang.Object obj)
          Tests if the object obj is awaited or not.
 void receiveReply(java.lang.Object obj)
          Invoked by a thread of the skeleton that performed the service in order to tie the result object to the proxy.
 java.lang.Object reify(MethodCall c)
          Blocks until the future object is available, then executes Call c on the now-available object.
 void setContinuationTag()
           
 void setCreatorID(UniqueID i)
          To set the creatorID, ie the UniqueID of the body which create this future
 void setExceptionHandler(Handler handler, java.lang.Class exception)
          Set a new handler within the table of the Handlerizable Object
 void setID(long l)
          To set the sequence id of this future.
protected  void setMigrationTag()
           
 void setResult(java.lang.Object o)
           
 void setSenderID(UniqueID i)
          To set the senderID, ie the UniqueID of the body that will send this future, in case of automatic continuation.
 void unsetContinuationTag()
           
 Handler unsetExceptionHandler(java.lang.Class exception)
          Remove a handler from the table of the Handlerizable Object
protected  void unsetMigrationTag()
           
 void waitFor()
          Blocks the calling thread until the future object is available.
 void waitFor(long timeout)
          Blocks the calling thread until the future object is available or the timeout expires
 
Methods inherited from class java.lang.Object
clone, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RECYCLE_POOL_SIZE

public static final int RECYCLE_POOL_SIZE
The size of the pool we use for recycling FutureProxy objects.

See Also:
Constant Field Values

target

protected java.lang.Object target
The object the proxy sends calls to


migration

protected boolean migration
To mark the Proxy before migration Usually, the Proxy cannot be serialized if the result is not available (no automatic continuation) but if we migrate, we don't want to wait for the result


continuation

protected boolean continuation
To mark the proxy before sending this future by parameter or by result


creatorID

protected UniqueID creatorID
UniqueID of the body which create this future


ID

protected long ID
ID of the future In fact, the sequence number of the request that generate this future


senderID

protected UniqueID senderID
Unique ID of the sender (in case of automatic continuation).


isAvailable

protected boolean isAvailable
This flag indicates the status of the future object


isException

protected boolean isException
Indicates if the returned object is an exception


isNFE

protected boolean isNFE
Indicates if the returned object is a Non Functional Exception (thus the communication failed)


futureLevel

protected java.util.HashMap futureLevel
This table is needed for the NFE mechanism


logger

protected static org.apache.log4j.Logger logger
Get NFE logger

Constructor Detail

FutureProxy

public FutureProxy()
            throws ConstructionOfReifiedObjectFailedException
As this proxy does not create a reified object (as opposed to BodyProxy for example), it is the noargs constructor that is usually called.


FutureProxy

public FutureProxy(ConstructorCall c,
                   java.lang.Object[] p)
            throws ConstructionOfReifiedObjectFailedException
This constructor is provided for compatibility with other proxies. More precisely, this permits proxy instanciation via the Meta.newMeta method.

Method Detail

isAwaited

public static boolean isAwaited(java.lang.Object obj)
Tests if the object obj is awaited or not. Always returns false if obj is not a future object.


getFutureProxy

public static FutureProxy getFutureProxy()

getFutureEventProducer

public static FutureEventProducer getFutureEventProducer()
Returns the FutureEventProducer that is responsible for the FutureProxys of this VM. Listeners can register themselves here.


equals

public boolean equals(java.lang.Object obj)

receiveReply

public void receiveReply(java.lang.Object obj)
                  throws java.io.IOException
Invoked by a thread of the skeleton that performed the service in order to tie the result object to the proxy. If the execution of the call raised an exception, this exception is put into an object of class InvocationTargetException and returned, just like for any returned object

Specified by:
receiveReply in interface LocalFuture
Throws:
java.io.IOException

getRaisedException

public java.lang.Throwable getRaisedException()
Returns the result this future is for as an exception if an exception has been raised or null if the result is not an exception. The method blocks until the result is available.

Specified by:
getRaisedException in interface Future
Returns:
the exception raised once available or null if no exception.

getResult

public java.lang.Object getResult()
Returns the result this future is for. The method blocks until the future is available

Specified by:
getResult in interface Future
Returns:
the result of this future object once available.

setResult

public void setResult(java.lang.Object o)

isAwaited

public boolean isAwaited()
Tests the status of the returned object

Specified by:
isAwaited in interface Future
Returns:
true if the future object is NOT yet available, false if it is.

waitFor

public void waitFor()
Blocks the calling thread until the future object is available.

Specified by:
waitFor in interface Future

waitFor

public void waitFor(long timeout)
             throws ProActiveException
Blocks the calling thread until the future object is available or the timeout expires

Specified by:
waitFor in interface Future
Parameters:
timeout -
Throws:
ProActiveException - if the timeout expires

getID

public long getID()
Description copied from interface: Future
To get the sequence id of this future.

Specified by:
getID in interface Future

setID

public void setID(long l)
Description copied from interface: Future
To set the sequence id of this future.

Specified by:
setID in interface Future

setCreatorID

public void setCreatorID(UniqueID i)
Description copied from interface: Future
To set the creatorID, ie the UniqueID of the body which create this future

Specified by:
setCreatorID in interface Future

getCreatorID

public UniqueID getCreatorID()
Description copied from interface: Future
To get the creatorID.

Specified by:
getCreatorID in interface Future

setSenderID

public void setSenderID(UniqueID i)
Description copied from interface: Future
To set the senderID, ie the UniqueID of the body that will send this future, in case of automatic continuation.

Specified by:
setSenderID in interface Future

reify

public java.lang.Object reify(MethodCall c)
                       throws java.lang.reflect.InvocationTargetException
Blocks until the future object is available, then executes Call c on the now-available object. As future and process behaviors are mutually exclusive, we know that the invocation of a method on a future objects cannot lead to wait-by necessity. Thus, we can propagate all exceptions raised by this invocation

Specified by:
reify in interface Proxy
Parameters:
c - The MethodCall object corresponding to the method
Returns:
The object returned by the method [wrapper class if it is a primitive or null if no return]
Throws:
java.lang.reflect.InvocationTargetException - If the invokation of the method represented by the Call object c on the reified object throws an exception, this exception is thrown as-is here. The stub then throws this exception to the calling thread after checking that it is declared in the throws clause of the reified method. Otherwise, the stub does nothing except print a message on System.err (or out ?).

getHandlerizableInfo

public java.lang.String getHandlerizableInfo()
                                      throws java.io.IOException
Get information about the handlerizable object

Specified by:
getHandlerizableInfo in interface Handlerizable
Returns:
information about the handlerizable object
Throws:
java.io.IOException

getHandlersLevel

public java.util.HashMap getHandlersLevel()
                                   throws java.io.IOException
Give a reference to a local map of handlers

Specified by:
getHandlersLevel in interface Handlerizable
Returns:
A reference to a map of handlers
Throws:
java.io.IOException

clearHandlersLevel

public void clearHandlersLevel()
                        throws java.io.IOException
Clear the local map of handlers

Specified by:
clearHandlersLevel in interface Handlerizable
Throws:
java.io.IOException

setExceptionHandler

public void setExceptionHandler(Handler handler,
                                java.lang.Class exception)
                         throws java.io.IOException
Set a new handler within the table of the Handlerizable Object

Specified by:
setExceptionHandler in interface Handlerizable
Parameters:
handler - A handler associated with a class of non functional exception.
exception - A class of non functional exception. It is a subclass of NonFunctionalException.
Throws:
java.io.IOException

unsetExceptionHandler

public Handler unsetExceptionHandler(java.lang.Class exception)
                              throws java.io.IOException
Remove a handler from the table of the Handlerizable Object

Specified by:
unsetExceptionHandler in interface Handlerizable
Parameters:
exception - A class of non functional exception. It is a subclass of NonFunctionalException.
Returns:
The removed handler or null
Throws:
java.io.IOException

finalize

protected void finalize()

setMigrationTag

protected void setMigrationTag()

unsetMigrationTag

protected void unsetMigrationTag()

setContinuationTag

public void setContinuationTag()

unsetContinuationTag

public void unsetContinuationTag()

futureLength

public static int futureLength(java.lang.Object future)


Copyright ? October 2004 INRIA All Rights Reserved.