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

java.lang.Object
  extended by edu.wpi.prc.example.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 INT_SIZE
           
private  int nextEndRange
           
private  int nextStartRange
           
private static int POINTS
           
private static int PRIORITY
           
private static int RANGE_LENGTH
           
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  int recoverStartRange()
          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

RANGE_LENGTH

private static final int RANGE_LENGTH
See Also:
Constant Field Values

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

INT_SIZE

private static final int INT_SIZE
See Also:
Constant Field Values

workUnitID

private int workUnitID

nextStartRange

private int nextStartRange

nextEndRange

private int nextEndRange
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

recoverStartRange

private int recoverStartRange()
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.