edu.wpi.prc.server.transitioner
Class RemoteTransitionerProxy

java.lang.Object
  extended by edu.wpi.prc.server.transitioner.RemoteTransitionerProxy
All Implemented Interfaces:
Transitioner

public class RemoteTransitionerProxy
extends java.lang.Object
implements Transitioner

The RemoteTransitionerProxy is used when the Transitioner component is executed on a different machine than the PRCServer. The RemoteTransitionerProxy uses XML-RPC calls to communicate with the Transitioner process on another machine. If the Transitioner will be run on the same machine, use the LocalTransitioner instead.

Author:
James Baldassari

Field Summary
private static int RETRY_DELAY
           
private  org.apache.xmlrpc.XmlRpcClient xmlrpcClient
           
 
Constructor Summary
RemoteTransitionerProxy(java.lang.String transitionerURI)
          Private constructor ensures that only one instance of RemoteTransitionerProxy exists.
 
Method Summary
 void addIngressResult(Result r)
          Adds a result to the tail of the pending result queue.
 void addIngressWorkUnit(WorkUnit wu)
          Adds a work unit to the tail of 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.
private  Result[] getAssociatedResults(WorkUnit wu, java.lang.String resultType)
          Gets the set of results associated with the given work unit.
 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.
private  TransitionerQueue<Result> getResultQueue(java.lang.String queueType)
          Gets a result queue from the remote transitioner.
 TransitionerQueue<Result> getRetiredResultQueue()
           
 TransitionerQueue<WorkUnit> getRetiredWorkQueue()
           
 TransitionerQueue<Result> getValidResultQueue()
           
private  TransitionerQueue<WorkUnit> getWorkQueue(java.lang.String queueType)
          Gets a work queue from the remote transitioner.
 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.
private  java.lang.Object sendRPC(java.lang.String methodName, java.util.Vector params)
          Executes an XML-RPC on the remote transitioner.
 void shutdown()
          Performs any necessary tasks to safely shut down the Transitioner.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RETRY_DELAY

private static final int RETRY_DELAY
See Also:
Constant Field Values

xmlrpcClient

private org.apache.xmlrpc.XmlRpcClient xmlrpcClient
Constructor Detail

RemoteTransitionerProxy

public RemoteTransitionerProxy(java.lang.String transitionerURI)
                        throws java.net.MalformedURLException
Private constructor ensures that only one instance of RemoteTransitionerProxy exists. Use the getTransitioner() method to get access to the RemoteTransitionerProxy.

Throws:
java.net.MalformedURLException
Method Detail

getIngressWorkQueue

public TransitionerQueue<WorkUnit> getIngressWorkQueue()
Specified by:
getIngressWorkQueue in interface Transitioner
Returns:
Returns the ingressWorkQueue.

getPendingWorkQueue

public TransitionerQueue<WorkUnit> getPendingWorkQueue()
Specified by:
getPendingWorkQueue in interface Transitioner
Returns:
Returns the pendingWorkQueue.

getCanonicalWorkQueue

public TransitionerQueue<WorkUnit> getCanonicalWorkQueue()
Specified by:
getCanonicalWorkQueue in interface Transitioner
Returns:
Returns the work units that have enough results to select a canonical result.

getRetiredWorkQueue

public TransitionerQueue<WorkUnit> getRetiredWorkQueue()
Specified by:
getRetiredWorkQueue in interface Transitioner
Returns:
Returns the retiredWorkQueue.

getIngressResultQueue

public TransitionerQueue<Result> getIngressResultQueue()
Specified by:
getIngressResultQueue in interface Transitioner
Returns:
Returns the ingressResultQueue.

getPendingResultQueue

public TransitionerQueue<Result> getPendingResultQueue()
Specified by:
getPendingResultQueue in interface Transitioner
Returns:
Returns the pendingResultQueue.

getValidResultQueue

public TransitionerQueue<Result> getValidResultQueue()
Specified by:
getValidResultQueue in interface Transitioner
Returns:
Returns the validResultQueue.

getRetiredResultQueue

public TransitionerQueue<Result> getRetiredResultQueue()
Returns:
Returns the retiredResultQueue.

addIngressWorkUnit

public void addIngressWorkUnit(WorkUnit wu)
Adds a work unit to the tail of the ingress work queue.

Specified by:
addIngressWorkUnit in interface Transitioner
Parameters:
wu - The work unit to add.

addIngressResult

public void addIngressResult(Result r)
Adds a result to the tail of the pending result queue.

Specified by:
addIngressResult in interface Transitioner
Parameters:
r - The result to add.

getAssociatedIngressResults

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

Specified by:
getAssociatedIngressResults in interface Transitioner
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

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

Specified by:
getAssociatedPendingResults in interface Transitioner
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

public 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.

Specified by:
getWorkUnit in interface Transitioner
Parameters:
v - The volunteer who will receive t
Returns:
The next work unit to be processed.
Throws:
EmptyQueueException

getCanonicalWorkUnit

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

Specified by:
getCanonicalWorkUnit in interface Transitioner
Returns:
The first WorkUnit in the canonical work queue.
Throws:
EmptyQueueException

getResult

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

Specified by:
getResult in interface Transitioner
Returns:
The first result in the ingress queue.
Throws:
EmptyQueueException

markResultValid

public 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.

Specified by:
markResultValid in interface Transitioner
Parameters:
validResult - The result from the ingress result queue to be marked valid.

markResultInvalid

public 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.

Specified by:
markResultInvalid in interface Transitioner
Parameters:
invalidResult - The result to be marked invalid.

selectCanonicalResult

public 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.

Specified by:
selectCanonicalResult in interface Transitioner
Parameters:
canonicalResult - The canonical result to select.

getWorkQueue

private TransitionerQueue<WorkUnit> getWorkQueue(java.lang.String queueType)
Gets a work queue from the remote transitioner.

Parameters:
queueType - The type of queue to get: IngressWorkQueue, PendingWorkQueue, CanonicalWorkQueue, RetiredWorkQueue
Returns:
Returns the work queue that was returned by the remote transitioner.

getResultQueue

private TransitionerQueue<Result> getResultQueue(java.lang.String queueType)
Gets a result queue from the remote transitioner.

Parameters:
queueType - The type of queue to get: IngressResultQueue, PendingResultQueue, ValidResultQueue, or RetiredResultQueue
Returns:
Returns the result queue that was returned by the remote transitioner.

getAssociatedResults

private Result[] getAssociatedResults(WorkUnit wu,
                                      java.lang.String resultType)
Gets the set of results associated with the given work unit.

Parameters:
wu - The work unit for which to find associated results.
resultType - The type of results to get: Ingress or Pending.
Returns:
Returns the set of results returned by the remote transitioner.

sendRPC

private java.lang.Object sendRPC(java.lang.String methodName,
                                 java.util.Vector params)
Executes an XML-RPC on the remote transitioner.

Parameters:
methodName - The name of the method to execute.
params - Parameters to pass to the method.
Returns:
Returns whatever value was returned by the XML-RPC.

shutdown

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

Specified by:
shutdown in interface Transitioner