darx
Class RemoteTask

java.lang.Object
  extended by darx.RemoteTask
All Implemented Interfaces:
java.io.Serializable

public class RemoteTask
extends java.lang.Object
implements java.io.Serializable

This is the local proxy that allows user application tasks to handle other tasks. This class defines the core services Darx provides to user applications for handling the different tasks (or agents) of the distributed system. It includes replication management and message sending. At length, the replication management scheme should become transparent to the user, and therefore might disappear from the current services provided herein.

See Also:
Serialized Form

Constructor Summary
RemoteTask(ReplicantInfo new_leader_info)
          Constructs a user-sufficient definition of a remote task.
RemoteTask(ReplicantInfo new_leader_info, DarxHandle handle)
          Constructs a user-sufficient definition of a remote task.
 
Method Summary
 ReplicationPolicy getReplicationPolicy()
          Get the current replication policy of the remote task
 void killReplicantAt(java.lang.String url)
          Starts the mechanism to destroy a specific replica of the remote task on a given server.
 void killReplicantAt(java.lang.String url, int port_nb)
          Starts the mechanism to destroy a specific replica of the remote task on a given server.
 void killTask()
          Terminates the execution of this replication group.
 void replicateTo(java.lang.String url)
          Starts the mechanism to create a new replica of the remote task at a specified URL.
 void replicateTo(java.lang.String url, int port_nb)
          Starts the mechanism to create a new replica of the remote task on a specified server.
 void replicateTo(java.lang.String url, int port_nb, ReplicationStrategy rs)
          Starts the mechanism to create a new replica of the remote task on a specified server following a given replication strategy.
(package private)  void sendAsyncMessage(DarxMessage msg)
          Sends a message asynchronously to the remote task, that is to the leader of the corresponding replication group.
(package private)  java.lang.Object sendSyncMessage(DarxMessage msg)
          Sends a message synchronously to the remote task, that is to the leader of the corresponding replication group.
 void setLeaderAt(java.lang.String url, int port_nb)
          Sets the replica at the given location as the new leader for its group.
(package private)  void setLeaderInfo(ReplicantInfo new_leader_info)
          Sets the information concerning the leader of the remote task.
 void switchReplicationStrategy(java.lang.String url, int port_nb, ReplicationStrategy strategy)
          Modifies the current replication policy of the group, by applying a new strategy to a given replica.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RemoteTask

RemoteTask(ReplicantInfo new_leader_info,
           DarxHandle handle)
Constructs a user-sufficient definition of a remote task. This is the unique class constructor. It is not supposed to be called from user applications, however; instances of this class are obtained when starting the corresponding DarxTask.

Parameters:
new_leader_info - the information concerning the leader of the task which this instance references.
handle - the interface to access the leader in charge of this task.
See Also:
DarxHandle, TaskShell

RemoteTask

RemoteTask(ReplicantInfo new_leader_info)
     throws java.rmi.RemoteException
Constructs a user-sufficient definition of a remote task. This is the unique class constructor. It is not supposed to be called from user applications, however; instances of this class are obtained when starting the corresponding DarxTask.

Parameters:
new_leader_info - the information concerning the leader of the task which this instance references.
Throws:
java.rmi.RemoteException
See Also:
DarxHandle, TaskShell
Method Detail

setLeaderInfo

void setLeaderInfo(ReplicantInfo new_leader_info)
             throws java.rmi.RemoteException
Sets the information concerning the leader of the remote task.

Parameters:
new_leader_info - the information concerning the current leader.
Throws:
java.rmi.RemoteException

sendAsyncMessage

void sendAsyncMessage(DarxMessage msg)
Sends a message asynchronously to the remote task, that is to the leader of the corresponding replication group. If the first emission fails, the thread is interrupted for a while and a second emission attempt is initiated. On a second failure, a new leader selection is asked from the NameServer and the whole emission procedure is restarted.

Parameters:
msg - the contents of the emission.
See Also:
DarxHandle.deliverAsyncMessage(DarxMessage msg)

sendSyncMessage

java.lang.Object sendSyncMessage(DarxMessage msg)
Sends a message synchronously to the remote task, that is to the leader of the corresponding replication group.

Parameters:
msg - the contents of the emission.
See Also:
DarxHandle.deliverSyncMessage(DarxMessage msg)

replicateTo

public void replicateTo(java.lang.String url)
                 throws java.rmi.RemoteException
Starts the mechanism to create a new replica of the remote task at a specified URL. The default port (6789) is used and the default (active) replication strategy is applied.

Parameters:
url - the URL of the remote DARX server where the new replica is created
Throws:
java.rmi.RemoteException
See Also:
DarxHandle, Darx.createReplicant(darx.ReplicantInfo, darx.DarxTask), TaskShell.replicateTo(java.lang.String, int, darx.ReplicationStrategy)

replicateTo

public void replicateTo(java.lang.String url,
                        int port_nb)
                 throws java.rmi.RemoteException
Starts the mechanism to create a new replica of the remote task on a specified server. The default (active) replication strategy is applied. This method enables to specify the server's port number; it is mandatory to use it instead of its homonym when there are several DARX servers concurrently running on the same host.

Parameters:
url - the URL of the remote DARX server where the new replica is created
port_nb - the port number of the remote DARX server where the new replica is created
Throws:
java.rmi.RemoteException
See Also:
DarxHandle, Darx.createReplicant(darx.ReplicantInfo, darx.DarxTask), TaskShell.replicateTo(java.lang.String, int, darx.ReplicationStrategy)

replicateTo

public void replicateTo(java.lang.String url,
                        int port_nb,
                        ReplicationStrategy rs)
                 throws java.rmi.RemoteException,
                        IllegalReplicationException
Starts the mechanism to create a new replica of the remote task on a specified server following a given replication strategy. This method enables to specify the server's port number; it is mandatory to use it instead of its homonym when there are several DARX servers concurrently running on the same host.

Parameters:
url - the URL of the remote DARX server where the new replica is created
port_nb - the port number of the remote DARX server where the new replica is created
rs - the replication strategy applied to the new replica
Throws:
java.rmi.RemoteException
IllegalReplicationException
See Also:
DarxHandle, Darx.createReplicant(darx.ReplicantInfo, darx.DarxTask), TaskShell.replicateTo(java.lang.String, int, darx.ReplicationStrategy)

killReplicantAt

public void killReplicantAt(java.lang.String url)
                     throws java.rmi.RemoteException,
                            UnknownReplicantException
Starts the mechanism to destroy a specific replica of the remote task on a given server.

Parameters:
url - the URL of the remote DARX server hosting the doomed replica
Throws:
java.rmi.RemoteException
UnknownReplicantException
See Also:
DarxHandle

killReplicantAt

public void killReplicantAt(java.lang.String url,
                            int port_nb)
                     throws java.rmi.RemoteException,
                            UnknownReplicantException
Starts the mechanism to destroy a specific replica of the remote task on a given server. This method enables to specify the server's port number; it is mandatory to use it instead of its homonym when there are several DARX servers concurrently running on the same host.

Parameters:
url - the URL of the remote DARX server supporting the doomed replica
port_nb - the port number of the same remote DARX server
Throws:
java.rmi.RemoteException
UnknownReplicantException
See Also:
DarxHandle

killTask

public void killTask()
              throws java.rmi.RemoteException
Terminates the execution of this replication group.

Throws:
java.rmi.RemoteException

switchReplicationStrategy

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

Parameters:
url - the URL of the replica to which the new strategy applies
port_nb - the port number of the replica to which the new strategy applies
strategy - the new strategy to be applied
Throws:
java.rmi.RemoteException
See Also:
DarxHandle, ReplicationStrategy, TaskShell.switchReplicationStrategy(java.lang.String, int, darx.ReplicationStrategy)

getReplicationPolicy

public ReplicationPolicy getReplicationPolicy()
                                       throws java.rmi.RemoteException
Get the current replication policy of the remote task

Returns:
the current replication policy of the remote task
Throws:
java.rmi.RemoteException
See Also:
ReplicationPolicy

setLeaderAt

public void setLeaderAt(java.lang.String url,
                        int port_nb)
                 throws java.rmi.RemoteException
Sets the replica at the given location as the new leader for its group. NB: This includes triggering the notification of the new group hierarchy to the concerned members (the old and the new leader)

Parameters:
url - the url of the server hosting the new leader
port_nb - the port nb of the server hosting the new leader
Throws:
java.rmi.RemoteException