edu.wpi.prc.templates.java.generator
Class WorkUnitGenerator

java.lang.Object
  extended by edu.wpi.prc.templates.java.generator.WorkUnitGenerator

public class WorkUnitGenerator
extends java.lang.Object

The WorkUnitGenerator contains the project-specific code to generate work units. It uses the WorkGeneratorClient to send them to the project server.

Author:
James Baldassari

Field Summary
private static double EXPIRATION_TIME
           
private static int POINTS
           
private static int PRIORITY
           
private  int workUnitID
           
 
Constructor Summary
WorkUnitGenerator()
          Default constructor.
 
Method Summary
 void generateAndSend(int numWorkUnits)
          Generates the specified number of work units, and sends them to the project server.
private  byte[] generateWorkUnit()
          Generates the next work unit.
private  void recoverState()
          If the work unit generator were shut down, then started back up, it would need to determine the last work unit that was generated so that it would know where to resume generating new ranges.
private  void sendWorkUnit(byte[] workUnit)
          Adds a new work unit to the server by calling the server.addWorkUnit XML-RPC.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PRIORITY

private static final int PRIORITY
See Also:
Constant Field Values

POINTS

private static final int POINTS
See Also:
Constant Field Values

EXPIRATION_TIME

private static final double EXPIRATION_TIME
See Also:
Constant Field Values

workUnitID

private int workUnitID
Constructor Detail

WorkUnitGenerator

public WorkUnitGenerator()
Default constructor. Gets last work unit generated via XML-RPC so that it can resume generating from that point.

Method Detail

recoverState

private void recoverState()
If the work unit generator were shut down, then started back up, it would need to determine the last work unit that was generated so that it would know where to resume generating new ranges. This method asks the server for the last work unit that was generated. If the server throws an Exception, it means that no work units had ever been generated, in which case the work unit generator is starting for the first time.


generateWorkUnit

private byte[] generateWorkUnit()
Generates the next work unit.

Returns:
Returns a byte array representing the generated work unit.

sendWorkUnit

private void sendWorkUnit(byte[] workUnit)
Adds a new work unit to the server by calling the server.addWorkUnit XML-RPC.

Parameters:
workUnit - The work unit to send to the server.

generateAndSend

public void generateAndSend(int numWorkUnits)
Generates the specified number of work units, and sends them to the project server.

Parameters:
numWorkUnits - The number of work units to generate and send.