ZetaGrid v1.9

zeta.handler
Class GetClientHandler

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

public class GetClientHandler
extends java.lang.Object
implements GetHandler

Handles a GET request for the needed environment of a task. The request must contains the following parameters:

The response contains a ZIP file with digital signatures 'signature.txt' and the needed environment, e.g. libraries. The environment is generated by the following algorithm:
  1. Creates an empty ZIP file and add all digital signatures.
  2. Checks if the requested resource which is defined by hostname and hostaddr can retrieve an environment for computation.
  3. Checks if the requested resource which is defined by hostname can retrieve an environment for computation.
  4. Checks if an unregistered resource can retrieve an environment for computation.
  5. Add all programs to the ZIP file which are specified by the task_id, os_name, os_arch and the local files depend on last update of the requested resource. Note: Programs are added earlier in the ZIP file which are platform independent.
  6. Update the parameters files, hostaddr, os_name, os_version, os_arch with the current timestamt on the back-end database for the requested resource.


Field Summary
private  java.lang.String contentLastZip1
          Filenames of one last transferred ZIP file.
private  java.lang.String contentLastZip2
          Filenames of one last transferred ZIP file.
private static java.util.Map lastKeys
          Queue containing the keys of the last 1000 requested clients.
(package private)  long lastRefreshSignature
          Timestamp in milliseconds when the last refresh of the signature occurs.
private static java.util.TreeMap lastTimestampsOfKeys
           
private  java.io.ByteArrayOutputStream lastZip1
          Data of one last transferred ZIP file.
private  java.io.ByteArrayOutputStream lastZip2
          Data of one last transferred ZIP file.
private static int MAX_QUEUE_KEY_SIZE
           
private  java.util.List programs
          List of the current programs except the file 'signature.txt': task_id,name,os_name,os_arch,last_update where size = 0 mod 5
private  ZetaServlet servlet
          Servlet which owns this handler.
private  java.sql.Timestamp signatureLastUpdate
          Timestamp of the last update of the file 'signature.txt'.
private  java.io.ByteArrayOutputStream signatureStream
          Data of the file 'signature.txt'.
private  java.lang.String signatureVersion
          Version of the file 'signature.txt'.
private  int usageLastZip1
          Number of using lastZip1.
private  int usageLastZip2
          Number of using lastZip2.
 
Constructor Summary
GetClientHandler(ZetaServlet servlet)
           
 
Method Summary
 void doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
          Handles a GET request for the needed environment of a task.
(package private) static long getKeyTimestamp(java.lang.String key)
          Checks if the specified key of a client retrieved an environment of the last 1000 clients.
private static void putKey(java.lang.String key)
          Stores the specified key of a client on a queue for at least 10 minutes.
private  boolean refreshSignature(java.sql.Statement stmt)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_QUEUE_KEY_SIZE

private static final int MAX_QUEUE_KEY_SIZE
See Also:
Constant Field Values

lastKeys

private static java.util.Map lastKeys
Queue containing the keys of the last 1000 requested clients.


lastTimestampsOfKeys

private static java.util.TreeMap lastTimestampsOfKeys

lastRefreshSignature

long lastRefreshSignature
Timestamp in milliseconds when the last refresh of the signature occurs.


signatureVersion

private java.lang.String signatureVersion
Version of the file 'signature.txt'.


signatureLastUpdate

private java.sql.Timestamp signatureLastUpdate
Timestamp of the last update of the file 'signature.txt'.


signatureStream

private java.io.ByteArrayOutputStream signatureStream
Data of the file 'signature.txt'.


programs

private java.util.List programs
List of the current programs except the file 'signature.txt': task_id,name,os_name,os_arch,last_update where size = 0 mod 5


contentLastZip1

private java.lang.String contentLastZip1
Filenames of one last transferred ZIP file.


contentLastZip2

private java.lang.String contentLastZip2
Filenames of one last transferred ZIP file.


usageLastZip1

private int usageLastZip1
Number of using lastZip1.


usageLastZip2

private int usageLastZip2
Number of using lastZip2.


lastZip1

private java.io.ByteArrayOutputStream lastZip1
Data of one last transferred ZIP file.


lastZip2

private java.io.ByteArrayOutputStream lastZip2
Data of one last transferred ZIP file.


servlet

private ZetaServlet servlet
Servlet which owns this handler.

Constructor Detail

GetClientHandler

public GetClientHandler(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 the needed environment of a task. The request req must contains the following parameters: The response resp contains a ZIP file with digital signatures 'signature.txt' and the needed environment, e.g. libraries.

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

refreshSignature

private boolean refreshSignature(java.sql.Statement stmt)
                          throws java.io.IOException,
                                 javax.servlet.ServletException,
                                 java.sql.SQLException
java.io.IOException
javax.servlet.ServletException
java.sql.SQLException

putKey

private static void putKey(java.lang.String key)
Stores the specified key of a client on a queue for at least 10 minutes.

Parameters:
key - key of a client which retrieved an environment

getKeyTimestamp

static long getKeyTimestamp(java.lang.String key)
Checks if the specified key of a client retrieved an environment of the last 1000 clients.

Parameters:
key - key of a client which retrieved an environment
Returns:
timestamp when the client with the specified key retrieved an environment of the last 1000 clients, 0 if this key is not one of the last 1000 clients.

ZetaGrid v1.9

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