darx
Class PassiveReplicationStrategy

java.lang.Object
  extended by darx.ReplicationStrategy
      extended by darx.PassiveReplicationStrategy
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable, java.lang.Runnable

public class PassiveReplicationStrategy
extends ReplicationStrategy
implements java.lang.Runnable, java.io.Serializable

This is the replication group manager specialisation which implements the passive replication strategy.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class darx.ReplicationStrategy
ACTIVE_STRATEGY, BACKUP, EMPTY_STRATEGY, info, LEADER, PASSIVE_STRATEGY, QUORUM_STRATEGY, rep_number, replicants, role, type
 
Constructor Summary
PassiveReplicationStrategy(int ud)
          Constructs a new instance of the passive replication strategy.
 
Method Summary
 void activateUpdating(int ud)
          Starts the backup process.
 int compareTo(ReplicationStrategy other_strat)
          Compares this replication strategy to another.
 void deliverAsyncMessage(TaskShell shell, DarxMessage msg)
          Spreads the delivery of an asynchronous message throughout the replication group.
 java.io.Serializable deliverSyncMessage(TaskShell shell, DarxMessage msg)
          Spreads the delivery of a synchronous message throughout the replication group.
 int getUpdateDelay()
          Returns the update delay.
 void resume()
          Spreads the resumption of the encapsulated task execution throughout the replication group.
 void run()
          Executes the backup mechanism.
 void setUpdateDelay(int ud)
          Sets the update delay.
 void stop()
          Stops the activity regarding consistency maintenance within the replication group (e.g. updater thread in the passive strategy.)
 void suspend()
          Spreads the suspension of the encapsulated task execution throughout the replication group.
 void terminate()
          Spreads the termination of the task execution throughout the replication group.
protected  void update()
          Updates the replication group.
 
Methods inherited from class darx.ReplicationStrategy
compareTo, contains, display, equals, findReplicantAt, getRemoteShellHandle, getReplicantHandle, getReplicantInfo, getReplicantRole, getReplicants, getReplicationNumber, getReplicationType, handleUnreachableReplicant, hashCode, registerReplicant, setLeaderInfo, setReplicantRole, setReplicants, setReplicantType, setReplicationNumber, unregisterReplicant
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PassiveReplicationStrategy

public PassiveReplicationStrategy(int ud)
Constructs a new instance of the passive replication strategy.

Parameters:
ud - the delay between every backup.
Method Detail

compareTo

public int compareTo(ReplicationStrategy other_strat)
Description copied from class: ReplicationStrategy
Compares this replication strategy to another.

Specified by:
compareTo in class ReplicationStrategy
Parameters:
other_strat - the strategy to be compared
Returns:
0 if both strategies are equivalent, a positive integer if this strategy is more pessimistic than the compared strategy, a negative integer otherwise.

getUpdateDelay

public int getUpdateDelay()
Returns the update delay.

Returns:
the update delay.

setUpdateDelay

public void setUpdateDelay(int ud)
Sets the update delay.

Parameters:
ud - the new update delay.

update

protected void update()
Updates the replication group. Sends a fresh copy of the leading DarxTask to replace the one held in the TaskShell of the backups.


activateUpdating

public void activateUpdating(int ud)
Starts the backup process. This method will only be called if the owner of the strategy is a leader.

Parameters:
ud - the update delay.
See Also:
resume()

suspend

public void suspend()
Description copied from class: ReplicationStrategy
Spreads the suspension of the encapsulated task execution throughout the replication group. This method is used by the leader of the replication group only.

Specified by:
suspend in class ReplicationStrategy

resume

public void resume()
Description copied from class: ReplicationStrategy
Spreads the resumption of the encapsulated task execution throughout the replication group. This method is used by the leader of the replication group only.

Specified by:
resume in class ReplicationStrategy

run

public void run()
Executes the backup mechanism.

Specified by:
run in interface java.lang.Runnable

stop

public void stop()
Description copied from class: ReplicationStrategy
Stops the activity regarding consistency maintenance within the replication group (e.g. updater thread in the passive strategy.) This method is used by the leader of the replication group only.

Overrides:
stop in class ReplicationStrategy

terminate

public void terminate()
               throws java.rmi.RemoteException
Description copied from class: ReplicationStrategy
Spreads the termination of the task execution throughout the replication group. This method is used by the leader of the replication group only.

Overrides:
terminate in class ReplicationStrategy
Throws:
java.rmi.RemoteException

deliverAsyncMessage

public void deliverAsyncMessage(TaskShell shell,
                                DarxMessage msg)
Description copied from class: ReplicationStrategy
Spreads the delivery of an asynchronous message throughout the replication group. This method is used by the leader of the replication group only.

Specified by:
deliverAsyncMessage in class ReplicationStrategy
Parameters:
shell - the shell corresponding to the present strategy (used to process the message locally)
msg - the message to deliver

deliverSyncMessage

public java.io.Serializable deliverSyncMessage(TaskShell shell,
                                               DarxMessage msg)
Description copied from class: ReplicationStrategy
Spreads the delivery of a synchronous message throughout the replication group. This method is used by the leader of the replication group only.

Specified by:
deliverSyncMessage in class ReplicationStrategy
Parameters:
shell - the shell corresponding to the present strategy (used to process the message locally)
msg - the message to deliver
Returns:
the reply to be sent back