darx
Class DarxTask

java.lang.Object
  extended by darx.DarxTask
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class DarxTask
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

This is the wrapper that represents an agent's replica at the DARX level. It provides control over the replica's execution, thus DARX can:


IMPORTANT: Agents must extend this class in order to beneficiate from DARX's functionalities .

See Also:
TaskShell, Serialized Form

Field Summary
protected  boolean leader
          the status of this replica in the group.
 
Constructor Summary
protected DarxTask(java.lang.String name)
          Constructs a new agent replica from scratch.
 
Method Summary
 RemoteTask activateTask(java.lang.String url, int port_nb)
          Requests a new task activation on a specific DARX server.
protected  DarxTask cloneTask()
          Constructs a new agent replica from an existing replica.
 RemoteTask findTask(java.lang.String task_name)
          Generates a remote reference to the current leader of the task which corresponds to the given generic name.
 java.lang.String getTaskName()
          Returns the name of the generic task pursued by this replica.
 void receiveAsyncMessage(java.lang.Object msg)
          Starts the reception of an asynchronous message.
 java.io.Serializable receiveSyncMessage(java.lang.Object msg)
          Starts the reception of a synchronous message.
 void resume()
          resumes the replica's execution
 void setHandle(RemoteTask remote)
          Sets the handle attribute (RemoteTask) of this task.
 void start()
          starts the replica's execution
 void suspend()
          suspends the replica's execution
 void terminate()
          Ends the execution of this specific replica.
 void terminateTask()
          Ends the generic task execution.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

leader

protected boolean leader
the status of this replica in the group.

Constructor Detail

DarxTask

protected DarxTask(java.lang.String name)
Constructs a new agent replica from scratch.

Parameters:
name - the name of the generic agent.
Method Detail

cloneTask

protected DarxTask cloneTask()
Constructs a new agent replica from an existing replica.


getTaskName

public java.lang.String getTaskName()
Returns the name of the generic task pursued by this replica.

Returns:
the name of the generic task pursued by this replica

setHandle

public void setHandle(RemoteTask remote)
Sets the handle attribute (RemoteTask) of this task.


receiveAsyncMessage

public void receiveAsyncMessage(java.lang.Object msg)
Starts the reception of an asynchronous message.


receiveSyncMessage

public java.io.Serializable receiveSyncMessage(java.lang.Object msg)
Starts the reception of a synchronous message.

Returns:
the serialized message containing the reply

activateTask

public RemoteTask activateTask(java.lang.String url,
                               int port_nb)
                        throws java.rmi.RemoteException
Requests a new task activation on a specific DARX server.

Parameters:
url - the url of the chosen location (port nb not included)
port_nb - the port number of the chosen server
Returns:
the remote reference to the activated, leading replica
Throws:
java.rmi.RemoteException

findTask

public RemoteTask findTask(java.lang.String task_name)
                    throws DarxException
Generates a remote reference to the current leader of the task which corresponds to the given generic name. If the current leader cannot be contacted, it is assumed that the host has failed, and therefore a new leader election is launched through the NameServer services.

Throws:
DarxException
See Also:
Darx.findTask(String task_name)

start

public void start()
starts the replica's execution


suspend

public void suspend()
suspends the replica's execution


resume

public void resume()
resumes the replica's execution


terminate

public void terminate()
Ends the execution of this specific replica.


terminateTask

public void terminateTask()
Ends the generic task execution. This method spreads the termination process throughout the replication group. It is used by the programmer to end the life cycle of the represented agent.