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

java.lang.Object
  extended byorg.objectweb.proactive.core.body.future.FutureProxy
All Implemented Interfaces:
Future, 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 static long futureMaxDelay
          Max timeout when waiting for a future Can be set with the property proactive.future.maxdelay
protected  long ID
          ID of the future In fact, the sequence number of the request that generate this future
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  FutureResult 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
 boolean equals(java.lang.Object obj)
           
protected  void finalize()
           
static int futureLength(java.lang.Object future)
           
 UniqueID getCreatorID()
          To get the creatorID.
 ExceptionMaskLevel getExceptionLevel()
           
static FutureEventProducer getFutureEventProducer()
          Returns the FutureEventProducer that is responsible for the FutureProxys of this VM.
static FutureProxy getFutureProxy()
           
 FutureResult getFutureResult()
          Get the encapsulation of the result and the potential exception.
 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 isAvailable()
           
 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(FutureResult 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 setExceptionLevel(ExceptionMaskLevel exceptionLevel)
           
 void setID(long l)
          To set the sequence id of this future.
protected  void setMigrationTag()
           
 void setOriginatingProxy(AbstractProxy p)
           
 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()
           
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 FutureResult 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).


futureLevel

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


futureMaxDelay

protected static long futureMaxDelay
Max timeout when waiting for a future Can be set with the property proactive.future.maxdelay

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(FutureResult 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.

isAvailable

public boolean isAvailable()
Returns:
true iff the future has arrived.

getFutureResult

public FutureResult getFutureResult()
Description copied from interface: Future
Get the encapsulation of the result and the potential exception.

Specified by:
getFutureResult in interface Future

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

setOriginatingProxy

public void setOriginatingProxy(AbstractProxy p)

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 ?).

finalize

protected void finalize()

setMigrationTag

protected void setMigrationTag()

unsetMigrationTag

protected void unsetMigrationTag()

setContinuationTag

public void setContinuationTag()

unsetContinuationTag

public void unsetContinuationTag()

getExceptionLevel

public ExceptionMaskLevel getExceptionLevel()
Returns:
Returns the exceptionLevel.

setExceptionLevel

public void setExceptionLevel(ExceptionMaskLevel exceptionLevel)
Parameters:
exceptionLevel - The exceptionLevel to set.

futureLength

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


Copyright 2001-2005 INRIA All Rights Reserved.