edu.wpi.prc.server.transitioner
Interface Transitioner

All Known Implementing Classes:
LocalTransitioner, RemoteTransitioner, RemoteTransitionerProxy

public interface Transitioner

State machine for tasks. It controls transitions of tasks between work and result queues.

Author:
James Baldassari

Method Summary
 void addIngressResult(Result r)
          Enqueues a result in the ingress result queue.
 void addIngressWorkUnit(WorkUnit wu)
          Enqueues a work unit in the ingress work queue.
 Result[] getAssociatedIngressResults(WorkUnit wu)
          Finds all ingress Results associated with a given WorkUnit.
 Result[] getAssociatedPendingResults(WorkUnit wu)
          Finds all pending Results associated with a given WorkUnit.
 TransitionerQueue<WorkUnit> getCanonicalWorkQueue()
           
 WorkUnit getCanonicalWorkUnit()
          Gets the first WorkUnit that has enough Results.
 TransitionerQueue<Result> getIngressResultQueue()
           
 TransitionerQueue<WorkUnit> getIngressWorkQueue()
           
 TransitionerQueue<Result> getPendingResultQueue()
           
 TransitionerQueue<WorkUnit> getPendingWorkQueue()
           
 Result getResult()
          Gets the first result that needs to be validated.
 TransitionerQueue<WorkUnit> getRetiredWorkQueue()
           
 TransitionerQueue<Result> getValidResultQueue()
           
 WorkUnit getWorkUnit(Volunteer v)
          Gets the next work unit to be processed.
 void markResultInvalid(Result invalidResult)
          Marks a result as invalid.
 void markResultValid(Result validResult)
          Marks a Result as valid.
 void selectCanonicalResult(Result canonicalResult)
          Designates a canonical Result by removing all related results from the ingress and pending queues, adding the canonical result to the valid queue, and retiring the canonical result's work unit.
 void shutdown()
          Performs any necessary tasks to safely shut down the Transitioner.
 

Method Detail

getIngressWorkQueue

TransitionerQueue<WorkUnit> getIngressWorkQueue()
Returns:
Returns the ingressWorkQueue.

getPendingWorkQueue

TransitionerQueue<WorkUnit> getPendingWorkQueue()
Returns:
Returns the pendingWorkQueue.

getCanonicalWorkQueue

TransitionerQueue<WorkUnit> getCanonicalWorkQueue()
Returns:
Returns the work units that have enough results to select a canonical result.

getRetiredWorkQueue

TransitionerQueue<WorkUnit> getRetiredWorkQueue()
Returns:
Returns the retiredWorkQueue.

getIngressResultQueue

TransitionerQueue<Result> getIngressResultQueue()
Returns:
Returns the ingressResultQueue.

getPendingResultQueue

TransitionerQueue<Result> getPendingResultQueue()
Returns:
Returns the pendingResultQueue.

getValidResultQueue

TransitionerQueue<Result> getValidResultQueue()
Returns:
Returns the validResultQueue.

addIngressWorkUnit

void addIngressWorkUnit(WorkUnit wu)
Enqueues a work unit in the ingress work queue.

Parameters:
wu - The work unit to add.

addIngressResult

void addIngressResult(Result r)
Enqueues a result in the ingress result queue.

Parameters:
r - The result to add.

getAssociatedIngressResults

Result[] getAssociatedIngressResults(WorkUnit wu)
Finds all ingress Results associated with a given WorkUnit.

Parameters:
wu - The WorkUnit for which to find all associated ingress Results.
Returns:
Array of ingress Results associated with the given WorkUnit or null if none were found.

getAssociatedPendingResults

Result[] getAssociatedPendingResults(WorkUnit wu)
Finds all pending Results associated with a given WorkUnit.

Parameters:
wu - The WorkUnit for which to find all associated pending Results.
Returns:
Array of pending Results associated with the given WorkUnit or null if none were found.

getWorkUnit

WorkUnit getWorkUnit(Volunteer v)
                     throws EmptyQueueException
Gets the next work unit to be processed. First, it will try to find a work unit in the pending work queue that has not already been sent to the given volunteer. If there are no satisfiable work units in the pending work queue, it will try to return a work unit from the ingress work queue. If there are no work units in the ingress work queue, an EmptyQueueException will be thrown.

Parameters:
v - The volunteer who will receive t
Returns:
The next work unit to be processed.
Throws:
EmptyQueueException

getCanonicalWorkUnit

WorkUnit getCanonicalWorkUnit()
                              throws EmptyQueueException
Gets the first WorkUnit that has enough Results.

Returns:
The first WorkUnit in the canonical work queue.
Throws:
EmptyQueueException

getResult

Result getResult()
                 throws EmptyQueueException
Gets the first result that needs to be validated.

Returns:
The first result in the ingress queue.
Throws:
EmptyQueueException

markResultValid

void markResultValid(Result validResult)
Marks a Result as valid. If the minimum number of valid results for the Result's associated WorkUnit, the Result is moved from the ingress result queue to the pending result queue. If the minimum number of valid results for the Result's associated WorkUnit has been reached, all Results for that WorkUnit are removed from the pending result queue, a canonical result is chosen, and the canonical result is moved to the valid result queue.

Parameters:
validResult - The result from the ingress result queue to be marked valid.

markResultInvalid

void markResultInvalid(Result invalidResult)
Marks a result as invalid. This will remove the result from the ingress queue and delete it from the database. If the result is a spot check result, additional steps may be taken depending on the project's spot check failure action.

Parameters:
invalidResult - The result to be marked invalid.

selectCanonicalResult

void selectCanonicalResult(Result canonicalResult)
Designates a canonical Result by removing all related results from the ingress and pending queues, adding the canonical result to the valid queue, and retiring the canonical result's work unit.

Parameters:
canonicalResult - The canonical result to select.

shutdown

void shutdown()
Performs any necessary tasks to safely shut down the Transitioner.