org.ourgrid.mygrid.replicaexecutor
Class EBReplicaManager

java.lang.Object
  extended by org.ourgrid.mygrid.replicaexecutor.EBReplicaManager
All Implemented Interfaces:
Shutdownable

public class EBReplicaManager
extends java.lang.Object
implements Shutdownable

Description: This is the main manager of the replica executor module. It coordinates the ThreadManager and the PermissionManager to do the main job of the module: provide a way to execute a replica.

Version:
1.0 Created on 08/07/2004

Nested Class Summary
 class EBReplicaManager.KillerThread
           
 
Constructor Summary
EBReplicaManager(EBSchedulerFacade ebSchedulerFacade, ReplicaExecutorThreadManager replicaExecutorThreadManager, PermissionManager permissionManager)
          Creates a EBReplicaManager with a EBSchedulerFacade, a ThreadManager and a PermissionManager.
 
Method Summary
protected  void abortReplicasOfTask(int jobId, int taskId)
          Abort all replicas of a given Task
 void cancelReplicasOfJob(int jobId)
          Cancel all replicas of a given Job
 void executeReplica(ReplicaEntry replica, GumClient gumClient)
          Assign the specified Replica to be executed int the given GridMachine
 long getNumberOfAbortedReplicas()
          Returns the number of replicas aborted.
 long getNumberOfCancelledReplicas()
          Returns the number of replicas cancelled.
 long getNumberOfFailedReplicas()
          Returns the number of replicas failed.
 long getNumberOfFinishedReplicas()
          Returns the number of replicas finished.
 long getNumberOfRunningReplicas()
          Returns the number of replicas running.
 void replicaAborted(ReplicaEntry replica)
          Notifies the PermissioManager and the ThreadManager that the given replica has been aborted.
 void replicaCanceled(ReplicaEntry replica)
          Notifies the PermissionManager and the ThreadManager that the given replica has been cancelled.
 void replicaFailed(ReplicaEntry replica)
          Notifies the EBSchedulerFacade, the PermissioManager and the ThreadManager that the given replica has failed.
 void replicaFinished(ReplicaEntry replica)
          Notifies the EBSchedulerFacade, the PermissioManager and the ThreadManager that the given replica has finished.
 void requestPermission(ReplicaEntry replica, EventQueue<ResponseEvent<java.lang.Boolean>> responseQueue)
          Request permission to access the task's critical region.
 void shutdown()
          Shuts down the replica manager
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EBReplicaManager

public EBReplicaManager(EBSchedulerFacade ebSchedulerFacade,
                        ReplicaExecutorThreadManager replicaExecutorThreadManager,
                        PermissionManager permissionManager)
Creates a EBReplicaManager with a EBSchedulerFacade, a ThreadManager and a PermissionManager.

Parameters:
ebSchedulerFacade - The EBSchedulerFacade
replicaExecutorThreadManager - The ThreadManager
permissionManager - The PermissionManager
Method Detail

executeReplica

public void executeReplica(ReplicaEntry replica,
                           GumClient gumClient)
Assign the specified Replica to be executed int the given GridMachine

Parameters:
replica - The Replica to be executed
gumClient - The GridMachine where the replica will be executed.

replicaCanceled

public void replicaCanceled(ReplicaEntry replica)
Notifies the PermissionManager and the ThreadManager that the given replica has been cancelled.


replicaFailed

public void replicaFailed(ReplicaEntry replica)
Notifies the EBSchedulerFacade, the PermissioManager and the ThreadManager that the given replica has failed.


replicaFinished

public void replicaFinished(ReplicaEntry replica)
Notifies the EBSchedulerFacade, the PermissioManager and the ThreadManager that the given replica has finished. When a replica is Finished all the other replicas of the same task should be aborted.


replicaAborted

public void replicaAborted(ReplicaEntry replica)
Notifies the PermissioManager and the ThreadManager that the given replica has been aborted.


cancelReplicasOfJob

public void cancelReplicasOfJob(int jobId)
Cancel all replicas of a given Job

Parameters:
jobId - The id of the job whose replicas should be canceled.

abortReplicasOfTask

protected void abortReplicasOfTask(int jobId,
                                   int taskId)
Abort all replicas of a given Task

Parameters:
jobId - The id of the job whose replicas should be aborted.
taskId - The id of the task whose replicas should be aborted.

requestPermission

public void requestPermission(ReplicaEntry replica,
                              EventQueue<ResponseEvent<java.lang.Boolean>> responseQueue)
Request permission to access the task's critical region.

Parameters:
replica - The replica who wants to access it's task's critical region.
responseQueue - The replica's response queue.

shutdown

public void shutdown()
Shuts down the replica manager

Specified by:
shutdown in interface Shutdownable

getNumberOfRunningReplicas

public long getNumberOfRunningReplicas()
Returns the number of replicas running.

Returns:
the number of replicas running.

getNumberOfAbortedReplicas

public long getNumberOfAbortedReplicas()
Returns the number of replicas aborted.

Returns:
the number of replicas aborted.

getNumberOfFinishedReplicas

public long getNumberOfFinishedReplicas()
Returns the number of replicas finished.

Returns:
the number of replicas Finished.

getNumberOfFailedReplicas

public long getNumberOfFailedReplicas()
Returns the number of replicas failed.

Returns:
the number of replicas failed.

getNumberOfCancelledReplicas

public long getNumberOfCancelledReplicas()
Returns the number of replicas cancelled.

Returns:
the number of replicas cancelled.