edu.wpi.prc.server.transitioner
Class RemoteTransitioner

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

public class RemoteTransitioner
extends java.lang.Object
implements Transitioner

The RemoteTransitoner is intended to run on a different machine than the PRCServer to reduce the load on that machine. The RemoteTransitioner maintains its own connections to the database, performs all localTransitioner functions, and communicates with the PRCServer via XML-RPC calls. Since HSQLDB only allows a single process to access the database at any given time, projects that use the HSQLDB database cannot use a RemoteTransitioner. These projects should use the LocalTransitioner instead.

Author:
James Baldassari

Field Summary
private static int EXIT_ERROR
           
private static int EXIT_SUCCESS
           
private  Transitioner localTransitioner
           
private  Project project
           
private static RemoteTransitioner remoteTransitioner
           
private  boolean running
           
private  org.apache.xmlrpc.WebServer xmlrpcServer
           
 
Constructor Summary
private RemoteTransitioner()
          Initializes the remote transitioner.
 
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.
private  void initXmlRpcServer()
          Initializes the XML-RPC server.
static RemoteTransitioner instance()
          Hibernate must be configured before getting the singleton instance of this class.
 boolean isRunning()
           
static void main(java.lang.String[] args)
          Main control for the remote transitioner.
 void markResultInvalid(Result invalidResult)
          Marks a result as invalid.
 void markResultValid(Result validResult)
          Marks a Result as valid.
 void run()
          Starts the remote transitioner.
 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 tasks necessary to clearnly shut down the remote transitioner.
 void stopServer()
          Stops the XML-RPC server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EXIT_SUCCESS

private static final int EXIT_SUCCESS
See Also:
Constant Field Values

EXIT_ERROR

private static final int EXIT_ERROR
See Also:
Constant Field Values

remoteTransitioner

private static RemoteTransitioner remoteTransitioner

localTransitioner

private Transitioner localTransitioner

project

private Project project

xmlrpcServer

private org.apache.xmlrpc.WebServer xmlrpcServer

running

private boolean running
Constructor Detail

RemoteTransitioner

private RemoteTransitioner()
                    throws MissingConfigurationFileException
Initializes the remote transitioner. Hibernate must be configured before this constructor is called.

Throws:
MissingConfigurationFileException
Method Detail

initXmlRpcServer

private void initXmlRpcServer()
Initializes the XML-RPC server.


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.

addIngressWorkUnit

public void addIngressWorkUnit(WorkUnit wu)
Description copied from interface: Transitioner
Enqueues a work unit in the ingress work queue.

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

addIngressResult

public void addIngressResult(Result r)
Description copied from interface: Transitioner
Enqueues a result in the ingress result queue.

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

getAssociatedIngressResults

public Result[] getAssociatedIngressResults(WorkUnit wu)
Description copied from interface: Transitioner
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)
Description copied from interface: Transitioner
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
Description copied from interface: Transitioner
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
Description copied from interface: Transitioner
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
Description copied from interface: Transitioner
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)
Description copied from interface: Transitioner
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)
Description copied from interface: Transitioner
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)
Description copied from interface: Transitioner
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.

run

public void run()
Starts the remote transitioner.


isRunning

public boolean isRunning()
Returns:
Returns true if the remote transitioner is running, false otherwise.

shutdown

public void shutdown()
Performs any tasks necessary to clearnly shut down the remote transitioner.

Specified by:
shutdown in interface Transitioner

stopServer

public void stopServer()
Stops the XML-RPC server.


instance

public static RemoteTransitioner instance()
                                   throws MissingConfigurationFileException
Hibernate must be configured before getting the singleton instance of this class.

Returns:
Returns an instance of the RemoteTransitioner class.
Throws:
MissingConfigurationFileException

main

public static void main(java.lang.String[] args)
Main control for the remote transitioner.

Parameters:
args - Command-line arguments.