darx
Class TaskShell

java.lang.Object
  extended by java.rmi.server.RemoteObject
      extended by java.rmi.server.RemoteServer
          extended by java.rmi.server.UnicastRemoteObject
              extended by darx.TaskShell
All Implemented Interfaces:
DarxHandle, TaskShellHandle, java.io.Serializable, java.rmi.Remote

 class TaskShell
extends java.rmi.server.UnicastRemoteObject
implements TaskShellHandle

This is the wrapper that transparently performs FT-specific operations for each task/agent.

The FT services provided here are :

The TaskShell is also responsible for relaying user commands concerning the task/agent's execution.


Field Summary
(package private)  DarxTask task
          The task/agent for which the current shell provides FT support.
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
TaskShell(DarxTask task, ReplicantInfo info)
          Constructs a shell that provides transparent FT for a given task/agent.
 
Method Summary
(package private)  boolean acceptMsg(DarxMessage msg)
          Checks the validity of a received message.
 void deliverAsyncMessage(DarxMessage msg)
          Sends an asynchronous message to the remote task.
 java.io.Serializable deliverSyncMessage(DarxMessage msg)
          Sends a synchronous message to the remote task.
 void demoteFromGroupLeader()
          Demotes this replicant from the status of leader to that of a simple replica within its group.
 ReplicantInfo getInfo()
           
 ReplicationManager getReplicationManager()
           
 ReplicationPolicy getReplicationPolicy()
           
 DarxTask getTask()
           
 void killReplicantAt(java.lang.String url, int port_nb)
          Deletes the replicant residing at the given location, provided it belongs to the replication group.
 void killTask()
          Ends the generic task execution.
 void processDeliverAsyncMessage(DarxMessage msg)
          Starts the processing of an asynchronous message.
 java.io.Serializable processDeliverSyncMessage(DarxMessage msg)
          Starts the processing of a synchronous message.
 void replicateTo(java.lang.String url, int port_nb, ReplicationStrategy rs)
          Creates a new replicant inside the replication group at a given location.
 void resume()
          Resumes the local execution of the encapsulated task.
 void setAsGroupLeader()
          Sets this replicant as the leader of its group.
 void setInfo(ReplicantInfo info)
          Sets the information concerning the current TaskShell.
 void setPolicy(ReplicationPolicy rep_policy)
          Sets the information concerning the replication policy applied to the current TaskShell.
 void setTask(DarxTask task)
          Inserts a given task inside the current TaskShell.
 void suspend()
          Suspends the local execution of the encapsulated task.
 void switchReplicationStrategy(java.lang.String url, int port_nb, ReplicationStrategy rs)
          Modifies the replication policy by applying a different strategy to a given replica.
 void terminate()
          Terminates the execution of the encapsulated task.
 void terminateTask()
          Terminates the task execution.
 
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
 

Field Detail

task

DarxTask task
The task/agent for which the current shell provides FT support.

Constructor Detail

TaskShell

TaskShell(DarxTask task,
          ReplicantInfo info)
    throws java.rmi.RemoteException
Constructs a shell that provides transparent FT for a given task/agent. This is the only constructor for this class.
It is not supposed to be called from user applications, however; instances of this class are created when starting the corresponding DarxTask.

Parameters:
task - the task/agent to provide FT for
name - the complete DARX path name for this task; it includes the location and the replicant number
strategy - the current replication group information
Throws:
java.rmi.RemoteException
See Also:
DarxTask, ReplicationStrategy
Method Detail

getInfo

public ReplicantInfo getInfo()
                      throws java.rmi.RemoteException
Specified by:
getInfo in interface TaskShellHandle
Returns:
the information concerning the present replicant
Throws:
java.rmi.RemoteException

getTask

public DarxTask getTask()
                 throws java.rmi.RemoteException
Specified by:
getTask in interface TaskShellHandle
Returns:
the encapsulated task
Throws:
java.rmi.RemoteException

getReplicationPolicy

public ReplicationPolicy getReplicationPolicy()
                                       throws java.rmi.RemoteException
Specified by:
getReplicationPolicy in interface DarxHandle
Specified by:
getReplicationPolicy in interface TaskShellHandle
Returns:
the replication policy of the local task
Throws:
java.rmi.RemoteException
See Also:
ReplicationPolicy

getReplicationManager

public ReplicationManager getReplicationManager()
                                         throws java.rmi.RemoteException
Returns:
the replication manager of the local task
Throws:
java.rmi.RemoteException
See Also:
ReplicationManager

setTask

public void setTask(DarxTask task)
             throws java.rmi.RemoteException
Inserts a given task inside the current TaskShell. NB: Its current use is exclusively that of the passive replication strategy backup.

Specified by:
setTask in interface TaskShellHandle
Parameters:
task - the new task to encapsulate
Throws:
java.rmi.RemoteException
See Also:
DarxTask, PassiveReplicationStrategy.update()

setInfo

public void setInfo(ReplicantInfo info)
             throws java.rmi.RemoteException
Sets the information concerning the current TaskShell.

Specified by:
setInfo in interface TaskShellHandle
Parameters:
info - the info to set
Throws:
java.rmi.RemoteException
See Also:
ReplicantInfo

setPolicy

public void setPolicy(ReplicationPolicy rep_policy)
               throws java.rmi.RemoteException
Sets the information concerning the replication policy applied to the current TaskShell.

Specified by:
setPolicy in interface TaskShellHandle
Parameters:
rep_policy - the info to set
Throws:
java.rmi.RemoteException
See Also:
ReplicationPolicy

setAsGroupLeader

public void setAsGroupLeader()
                      throws java.rmi.RemoteException
Sets this replicant as the leader of its group.

Specified by:
setAsGroupLeader in interface TaskShellHandle
Throws:
java.rmi.RemoteException
See Also:
ReplicationStrategy

demoteFromGroupLeader

public void demoteFromGroupLeader()
                           throws java.rmi.RemoteException
Demotes this replicant from the status of leader to that of a simple replica within its group.

Specified by:
demoteFromGroupLeader in interface TaskShellHandle
Throws:
java.rmi.RemoteException
See Also:
ReplicationStrategy

switchReplicationStrategy

public void switchReplicationStrategy(java.lang.String url,
                                      int port_nb,
                                      ReplicationStrategy rs)
                               throws java.rmi.RemoteException,
                                      UnknownReplicantException
Modifies the replication policy by applying a different strategy to a given replica.

Specified by:
switchReplicationStrategy in interface DarxHandle
Parameters:
url - the url of the location which hosts the given replica
port_nb - the port nb of the same location
rs - the strategy to apply to the given replica
Throws:
java.rmi.RemoteException
UnknownReplicantException - if there is no replicant from the group at the given location
See Also:
ReplicationStrategy

acceptMsg

boolean acceptMsg(DarxMessage msg)
Checks the validity of a received message.
This method discards messages for which the serial number is obsolete relatively to the sender, that is a message with a superior serial has already been received from the same sender. If a message is accepted, its serial number is recorded for later checks.


processDeliverAsyncMessage

public void processDeliverAsyncMessage(DarxMessage msg)
                                throws java.rmi.RemoteException
Description copied from interface: TaskShellHandle
Starts the processing of an asynchronous message.

Specified by:
processDeliverAsyncMessage in interface TaskShellHandle
Parameters:
msg - the message to be processed
Throws:
java.rmi.RemoteException
See Also:
DarxMessage

processDeliverSyncMessage

public java.io.Serializable processDeliverSyncMessage(DarxMessage msg)
                                               throws java.rmi.RemoteException
Description copied from interface: TaskShellHandle
Starts the processing of a synchronous message.

Specified by:
processDeliverSyncMessage in interface TaskShellHandle
Parameters:
msg - the message to be processed
Returns:
the reply to the message
Throws:
java.rmi.RemoteException
See Also:
DarxMessage

deliverAsyncMessage

public void deliverAsyncMessage(DarxMessage msg)
                         throws java.rmi.RemoteException
Description copied from interface: DarxHandle
Sends an asynchronous message to the remote task.

Specified by:
deliverAsyncMessage in interface DarxHandle
Parameters:
msg - the message destined to the remote task.
Throws:
java.rmi.RemoteException
See Also:
deliverAsyncMessage(DarxMessage msg)

deliverSyncMessage

public java.io.Serializable deliverSyncMessage(DarxMessage msg)
                                        throws java.rmi.RemoteException
Description copied from interface: DarxHandle
Sends a synchronous message to the remote task.

Specified by:
deliverSyncMessage in interface DarxHandle
Parameters:
msg - the message destined to the remote task.
Returns:
the message sent in reply.
Throws:
java.rmi.RemoteException
See Also:
deliverSyncMessage(DarxMessage msg)

replicateTo

public void replicateTo(java.lang.String url,
                        int port_nb,
                        ReplicationStrategy rs)
                 throws java.rmi.RemoteException,
                        IllegalReplicationException
Creates a new replicant inside the replication group at a given location.

This action includes informing the replication group of the replicant's creation.
This can involve suspending the whole replication group, thus justifying a synchronized policy.

Specified by:
replicateTo in interface DarxHandle
Parameters:
url - the location where the new replicant is to be created
port_nb - the port corresponding to the server
rs - the replication strategy applied to the new replicant
Throws:
java.rmi.RemoteException
IllegalReplicationException - if a replica of the same group already exists at the location
See Also:
DarxServer, ReplicationStrategy

killReplicantAt

public void killReplicantAt(java.lang.String url,
                            int port_nb)
                     throws java.rmi.RemoteException,
                            UnknownReplicantException
Deletes the replicant residing at the given location, provided it belongs to the replication group.
This action includes informing the replication group of the deletion.
This can involve suspending the whole replication group, thus justifying a synchronized policy.
NB: It is assumed that only one replicant of a given task can exist on a given host.

Specified by:
killReplicantAt in interface DarxHandle
Parameters:
url - the location where the new replicant is to be created
port_nb - the port corresponding to the server
Throws:
java.rmi.RemoteException
UnknownReplicantException - if there is no replicant from the group at the given location
See Also:
DarxServer, ReplicationStrategy

killTask

public void killTask()
              throws java.rmi.RemoteException
Ends the generic task execution. This method spreads the termination process throughout the replication group.

Specified by:
killTask in interface DarxHandle
Throws:
java.rmi.RemoteException

suspend

public void suspend()
             throws java.rmi.RemoteException
Description copied from interface: TaskShellHandle
Suspends the local execution of the encapsulated task. N.B: This does not involve suspending the local replication policy.

Specified by:
suspend in interface TaskShellHandle
Throws:
java.rmi.RemoteException

resume

public void resume()
            throws java.rmi.RemoteException
Description copied from interface: TaskShellHandle
Resumes the local execution of the encapsulated task. N.B: This does not involve resuming the local replication policy.

Specified by:
resume in interface TaskShellHandle
Throws:
java.rmi.RemoteException

terminate

public void terminate()
               throws java.rmi.RemoteException
Description copied from interface: TaskShellHandle
Terminates the execution of the encapsulated task. This includes the removal of the global application information concerning the shell.

Specified by:
terminate in interface TaskShellHandle
Throws:
java.rmi.RemoteException

terminateTask

public void terminateTask()
                   throws java.rmi.RemoteException
Terminates the task execution.
This method does not remove the references to the encapsulation shell.

Specified by:
terminateTask in interface TaskShellHandle
Throws:
java.rmi.RemoteException