ZetaGrid v1.9

zeta.handler
Class RequestWorkUnitHandler

java.lang.Object
  |
  +--zeta.handler.RequestWorkUnitHandler
All Implemented Interfaces:
GetHandler

public class RequestWorkUnitHandler
extends java.lang.Object
implements GetHandler

Handles a GET request for new work units. The request must contains the following parameters:

The response contains the parameters (work_unit_id, size) of the new work units. The new work units are generated by the following algorithm:
  1. Set the number requested work units equal to the number of defined processors of the specified hostname if the number of defined processors is larger than the number of requested work units.
  2. Add all active work units which are reserved for the specified task, hostname and hostaddr to the response. Note: the global parameter 'work_unit_id_complete' was used to reduce the evaluation time.
  3. Add all active work units which are reserved for the specified task, hostname, user and email to the response. This is important for resources which used DHCP. Note: the global parameter 'work_unit_id_complete' was used to reduce the evaluation time.
  4. Register a new resource provider if the pair (user, email) is unknown.
  5. Update the registered TCP/IP address of the resource hostname by hostaddr if the hostaddr is different to the registered address and the resource provider is equal to the pair (user, email).
  6. Register a new resource (hostname,hostaddr,os_name,os_version,os_arch) if the pair (hostname,hostaddr) is unknown.
  7. Add and reserve work units for the task from the recomputation pool if the resource provider is activated for recomputations.
  8. Add and reserve new work units for the specified task, resource and his provider. The new identifications of the work units depend on the largest known identification, the size and the globale parameter 'work_unit_id_overlap'. Note: The sizes of the new work units can be different whether they have the same size.


Field Summary
private static int DEFAULT_WORK_UNIT_SIZE
          Default size of a new work unit.
private static int MAX_WORK_UNITS_TRUST0
          Maximal number of work units which can be requested by one client.
private static int MAX_WORK_UNITS_TRUST1
           
private static int MAX_WORK_UNITS_TRUST2
           
private  ZetaServlet servlet
          Servlet which owns this handler.
private  java.util.Map userMap
          Maps a key (server-ID,name,email) of an user to the user-ID.
private  java.util.Map workstationMap
          Maps a key (server-ID,user-ID) of a workstation to a list of workstation-IDs.
private  java.util.Map workUnitSize
          Defined sizes for specified tasks and work unit sizes.
 
Constructor Summary
RequestWorkUnitHandler(ZetaServlet servlet)
           
 
Method Summary
 void doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
          Handles a GET request for new work units.
private  int getWorkUnitSize(int taskId, java.lang.String sizeOfWorkUnit, long workUnitId, java.sql.Statement stmt)
          Returns the size of a work unit for a specified taskId, size and workUnitId.
private  void insertWorkUnitsIntoDatabase(WorkUnit[] workUnits, TaskRequestWorkUnitProcessor processor, int taskId, int serverId, int workstationId, java.lang.String version, int userId)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_WORK_UNIT_SIZE

private static final int DEFAULT_WORK_UNIT_SIZE
Default size of a new work unit.

See Also:
Constant Field Values

MAX_WORK_UNITS_TRUST0

private static final int MAX_WORK_UNITS_TRUST0
Maximal number of work units which can be requested by one client.

See Also:
Constant Field Values

MAX_WORK_UNITS_TRUST1

private static final int MAX_WORK_UNITS_TRUST1
See Also:
Constant Field Values

MAX_WORK_UNITS_TRUST2

private static final int MAX_WORK_UNITS_TRUST2
See Also:
Constant Field Values

workUnitSize

private java.util.Map workUnitSize
Defined sizes for specified tasks and work unit sizes.


userMap

private java.util.Map userMap
Maps a key (server-ID,name,email) of an user to the user-ID.


workstationMap

private java.util.Map workstationMap
Maps a key (server-ID,user-ID) of a workstation to a list of workstation-IDs.


servlet

private ZetaServlet servlet
Servlet which owns this handler.

Constructor Detail

RequestWorkUnitHandler

public RequestWorkUnitHandler(ZetaServlet servlet)
Parameters:
servlet - servlet which owns this handler.
Method Detail

doGet

public void doGet(javax.servlet.http.HttpServletRequest req,
                  javax.servlet.http.HttpServletResponse resp)
           throws javax.servlet.ServletException,
                  java.sql.SQLException,
                  java.io.IOException
Handles a GET request for new work units. The request req must contains the following parameters: The response resp contains the parameters (work_unit_id, size) of the new work units.

Specified by:
doGet in interface GetHandler
javax.servlet.ServletException
java.sql.SQLException
java.io.IOException

insertWorkUnitsIntoDatabase

private void insertWorkUnitsIntoDatabase(WorkUnit[] workUnits,
                                         TaskRequestWorkUnitProcessor processor,
                                         int taskId,
                                         int serverId,
                                         int workstationId,
                                         java.lang.String version,
                                         int userId)
                                  throws javax.servlet.ServletException,
                                         java.sql.SQLException
javax.servlet.ServletException
java.sql.SQLException

getWorkUnitSize

private int getWorkUnitSize(int taskId,
                            java.lang.String sizeOfWorkUnit,
                            long workUnitId,
                            java.sql.Statement stmt)
                     throws java.sql.SQLException
Returns the size of a work unit for a specified taskId, size and workUnitId.

Parameters:
taskId - identification of the task.
workUnitId - id of the work unit
Returns:
the size of a work unit for a specified taskId, size and workUnitId.
java.sql.SQLException

ZetaGrid v1.9

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