ZetaGrid v1.9

zeta.processor
Class DefaultWorkUnitProcessor

java.lang.Object
  |
  +--zeta.processor.DefaultWorkUnitProcessor
All Implemented Interfaces:
TaskProcessor, TaskRequestWorkUnitProcessor, TaskResultProcessor
Direct Known Subclasses:
SimpleFileProcessor, WorkUnitFileProcessor

public class DefaultWorkUnitProcessor
extends java.lang.Object
implements TaskRequestWorkUnitProcessor, TaskResultProcessor

The default processor for work units which are received through the request and the result handler.


Constructor Summary
DefaultWorkUnitProcessor()
           
 
Method Summary
 int activateWorkUnit(java.sql.Statement stmt, WorkUnit workUnit)
          Activates the specified work unit for the requested client.
 void checkResult(WorkUnit workUnit, byte[] result)
          Checks work units received through the result handler
 java.lang.String getParameters(WorkUnit workUnit)
          Returns the parameters which are associated with the specified work unit; are separated by the character ','
 WorkUnit getWorkUnit(int taskId, long workUnitId, int size)
          Returns a Zeta work unit for the specified parameters.
 void init(ZetaServlet servlet, java.sql.Statement stmt, java.util.Map parameter)
          Initializes the processor
 boolean processResult(java.sql.Statement stmt, WorkUnit workUnit, byte[] result, boolean recomputation)
          Processes work units received through the result handler
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultWorkUnitProcessor

public DefaultWorkUnitProcessor()
Method Detail

init

public void init(ZetaServlet servlet,
                 java.sql.Statement stmt,
                 java.util.Map parameter)
          throws java.sql.SQLException
Initializes the processor

Specified by:
init in interface TaskProcessor
Parameters:
servlet - surrounding servlet
stmt - statement object's database
Throws:
java.sql.SQLException - if a database access error occurs.

checkResult

public void checkResult(WorkUnit workUnit,
                        byte[] result)
                 throws java.lang.Exception
Checks work units received through the result handler

Specified by:
checkResult in interface TaskResultProcessor
Parameters:
workUnit - work unit which should be checked
result - buffer with the zipped result
java.lang.Exception

processResult

public boolean processResult(java.sql.Statement stmt,
                             WorkUnit workUnit,
                             byte[] result,
                             boolean recomputation)
                      throws javax.servlet.ServletException,
                             java.sql.SQLException,
                             java.io.IOException
Processes work units received through the result handler

Specified by:
processResult in interface TaskResultProcessor
Parameters:
stmt - statement object's database
workUnit - work unit which should be processed
result - buffer with the zipped result
recomputation - if the result was recomputed
Returns:
true if the ResultHandler shall save the result into the database.
Throws:
java.io.IOException - if an I/O error occurs.
javax.servlet.ServletException
java.sql.SQLException

getWorkUnit

public WorkUnit getWorkUnit(int taskId,
                            long workUnitId,
                            int size)
Returns a Zeta work unit for the specified parameters.

Specified by:
getWorkUnit in interface TaskProcessor
Parameters:
taskId - ID of the task
workUnitId - ID of the work unit
size - size of the work unit
Returns:
a Zeta work unit for the specified parameters.

getParameters

public java.lang.String getParameters(WorkUnit workUnit)
Returns the parameters which are associated with the specified work unit; are separated by the character ','

Specified by:
getParameters in interface TaskRequestWorkUnitProcessor
Parameters:
workUnit - work unit
Returns:
parameters which are associated with the specified work unit; are separated by the character ','

activateWorkUnit

public int activateWorkUnit(java.sql.Statement stmt,
                            WorkUnit workUnit)
                     throws javax.servlet.ServletException,
                            java.sql.SQLException
Activates the specified work unit for the requested client.

Specified by:
activateWorkUnit in interface TaskRequestWorkUnitProcessor
Parameters:
stmt - statement object's database
workUnit - work unit
Returns:
less than 0 if an error occurs, 0 if the specified work unit is activated but no further work unit can be activated, and greater 0 if the specified work unit is activated and further work units can be activated.
Throws:
java.sql.SQLException - if a database access error occurs.
javax.servlet.ServletException

ZetaGrid v1.9

For further technical papers, see ZetaGrid Technical Documentation.
 
Copyright © 2001,2002 Sebastian Wedeniwski. All Rights Reserved.