org.ourgrid.mygrid.replicaexecutor
Class PermissionManager

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

public class PermissionManager
extends java.lang.Object
implements Shutdownable

Description: This class is responsible for managing the access of a replica to it's task's critical region.
The critical region of a task is composed by it's two final tasks. Only one replica of each task should be capable to execute it's critical region. Once a replica has finished, no other replica of the same task should be allowed to execute it's critical region.

Version:
1.0 Created on 09/07/2004

Constructor Summary
PermissionManager()
          Creates a PermissionManager
 
Method Summary
 java.util.Collection<org.ourgrid.mygrid.replicaexecutor.PermissionManager.Pair> getBlockedReplicas()
           
protected  java.util.Collection<org.ourgrid.mygrid.replicaexecutor.PermissionManager.Pair> getBlockedReplicas(ReplicaEntry replica)
           
 java.util.Collection<ReplicaEntry> getRunningReplicas()
           
 void replicaAborted(ReplicaEntry replica)
          If a replica has been aborted, all replicas of the same task will be aborted too soon.
 void replicaCanceled(ReplicaEntry replica)
          If a replica has been cancelled, all replicas of the same task will be cancelled too soon.
 void replicaFailed(ReplicaEntry replica)
          If a replica fails inside it's critical region and there are other replicas waiting to access it's critical region the PermissionManager should allow the first replica of the queue to access it's critical region.
 void replicaFinished(ReplicaEntry replica)
          If a replica has finished, all replicas of the same task will be aborted soon.
 void requestPermission(ReplicaEntry replica, EventQueue<ResponseEvent<java.lang.Boolean>> responseQueue)
          Ask the PermissionManager to verify if a given replica can access it's task's critical region.
 void shutdown()
          Shutdown the PermissionManager
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PermissionManager

public PermissionManager()
Creates a PermissionManager

Method Detail

getBlockedReplicas

protected java.util.Collection<org.ourgrid.mygrid.replicaexecutor.PermissionManager.Pair> getBlockedReplicas(ReplicaEntry replica)
Returns:
A collection with all replica of a task that are blocked, waiting to access it's task's critical region.

getBlockedReplicas

public java.util.Collection<org.ourgrid.mygrid.replicaexecutor.PermissionManager.Pair> getBlockedReplicas()
Returns:
A collection with all replica that are blocked, waiting to access it's task's critical region.

getRunningReplicas

public java.util.Collection<ReplicaEntry> getRunningReplicas()
Returns:
A collection with all replicas that are currently inside it's taks's critical region.

requestPermission

public void requestPermission(ReplicaEntry replica,
                              EventQueue<ResponseEvent<java.lang.Boolean>> responseQueue)
Ask the PermissionManager to verify if a given replica can access it's task's critical region. If no replica of the same task is already inside it's critical region, the permission is granted, otherwise, the replica will be blocked until the task's critical region is free.

Parameters:
replica - The replica that asks for permission
responseQueue - The replica's response queue

replicaFailed

public void replicaFailed(ReplicaEntry replica)
If a replica fails inside it's critical region and there are other replicas waiting to access it's critical region the PermissionManager should allow the first replica of the queue to access it's critical region. Elsewhere, if a replica fails outside it's critical region, the PermissionManager should remove it from the waiting queue.

Parameters:
replica - The replica who has failed.

replicaAborted

public void replicaAborted(ReplicaEntry replica)
If a replica has been aborted, all replicas of the same task will be aborted too soon. So, the PermissionManager should remove all references for replicas of the same task from it's internal data structures.

Parameters:
replica -

replicaFinished

public void replicaFinished(ReplicaEntry replica)
If a replica has finished, all replicas of the same task will be aborted soon. So, the PermissionManager should remove all references for replicas of the same task from it's internal data structures.

Parameters:
replica -

replicaCanceled

public void replicaCanceled(ReplicaEntry replica)
If a replica has been cancelled, all replicas of the same task will be cancelled too soon. So, the PermissionManager should remove all references for replicas of the same task from it's internal data structures.

Parameters:
replica -

shutdown

public void shutdown()
Shutdown the PermissionManager

Specified by:
shutdown in interface Shutdownable