org.glite.wmsui.apij
Class JobCollection

java.lang.Object
  extended byorg.glite.wmsui.apij.JobCollection
All Implemented Interfaces:
java.lang.Runnable

public class JobCollection
extends java.lang.Object
implements java.lang.Runnable

The JobCollection Class is a container class for Job objects .

A JobCollection has the main purpose of allowing the execution of collective operations on sets of independent jobs. The JobCollection class is just a logical container, and both not yet submitted and already submitted jobs can be inserted in it. A job collection is somehow orthogonal wrt a job cluster being a set of dependent jobs (e.g. all jobs spawned by the same father process). The allowed operations are:

Version:
0.1
Author:
Alessandro Maraschini
See Also:
Job

Field Summary
protected  java.util.Vector jobs
          The Job in the collection are stored in a vector
 
Constructor Summary
JobCollection()
          Instantiates an empty JobCollection object
JobCollection(Job[] jobs)
          Instantiates a JobCollection object from an array of Job
JobCollection(Job job, int n)
          Instantiates a collection with n copies of a job (the Job has to be of JOB__AD type)
JobCollection(java.util.Vector jobs)
          Instantiates a JobCollection object from a vector of Job
 
Method Summary
protected  void appendJob(int number, Result result)
          Update the Job Result info into the Collection inner result vector.
 java.util.Vector cancel()
          Cancel the job from the NS
 void clear()
          Deletes all elements from the collection.
 boolean contains(Job job)
          Test wheter the specified job is already present in the collection
 boolean empty()
          Check the size of the collection
 java.util.Vector getOutput(java.lang.String dirPath)
          Get the output files of the jobs (SYNC)
 java.util.Vector getStatus()
          Retrieve the status information from the LB
 void insert(Job job)
          Insert a new Job to the collection
 void insertAd(org.glite.jdl.JobAd jobAd)
          Insert a new Job (of JobAd type) into the collection
 void insertId(JobId jobId)
          Insert a new Job (of JobvId type) into the collection
 java.util.Iterator jobs()
           
 void logDefaultValues(boolean set)
          Decide whether to log or not some UI default values such as: UI node name information in UserTags attribute
 Result notify(int[] states, int timeout)
          Retrieves the status of the first Jobs of the collection once it enters one of the specified status code
 void remove(Job job)
          Remove a specified Job from the collection Delete the specified job from the collection (if the id has been set) Delete the last occurrence of the job from the collection (if the ad has not been set)
 void run()
           
 void setCredPath(java.io.File cp)
          Set a different Proxy certificate from the default one
 void setLoggerLevel(int level)
          Set the NS verbosity level
 void setMaxThreadNumber(int maxThread)
          This method is used to override the MAX_THREAD_NUMBER macro variable
 int size()
           
 java.util.Vector submit(Url ns, java.util.Vector lbs, java.lang.String ceId)
          Submit method
 void unsetCredPath()
          Set the Proxy certificate as default
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

jobs

protected java.util.Vector jobs
The Job in the collection are stored in a vector

Constructor Detail

JobCollection

public JobCollection()
Instantiates an empty JobCollection object


JobCollection

public JobCollection(Job job,
                     int n)
              throws JobCollectionException
Instantiates a collection with n copies of a job (the Job has to be of JOB__AD type)

Parameters:
job - the source Job (of JOB_TYPE) instancies
n - the number of copies to be filled in the collection
Throws:
JobCollectionException - The job is not of JOB__AD type

JobCollection

public JobCollection(java.util.Vector jobs)
              throws JobCollectionException,
                     java.lang.NoSuchFieldException
Instantiates a JobCollection object from a vector of Job

Parameters:
jobs - the vector of Job instances that have to be inserted
Throws:
JobCollectionException - Unable to add duplicate JobId
java.lang.NoSuchFieldException - One of the Job is of JOB_NONE type

JobCollection

public JobCollection(Job[] jobs)
              throws JobCollectionException,
                     java.lang.NoSuchFieldException
Instantiates a JobCollection object from an array of Job

Parameters:
jobs - the array of Job instances that have to be inserted
Throws:
JobCollectionException - Unable to add duplicate JobId
java.lang.NoSuchFieldException - One of the Job is of JOB_NONE type
Method Detail

empty

public boolean empty()
Check the size of the collection

Returns:
true if the collection's size is empty (length = 0)

size

public int size()
Returns:
the lenght of the inserted Jobs

contains

public boolean contains(Job job)
Test wheter the specified job is already present in the collection


insertId

public void insertId(JobId jobId)
              throws JobCollectionException
Insert a new Job (of JobvId type) into the collection

Parameters:
jobId - the JobId instance that has to be inserted
Throws:
JobCollectionException - Unable to add duplicate JobId

insertAd

public void insertAd(org.glite.jdl.JobAd jobAd)
Insert a new Job (of JobAd type) into the collection

Parameters:
jobAd - the JobAd instance that has to be inserted
Throws:
JobCollectionException - Unable to insert the Job

insert

public void insert(Job job)
            throws JobCollectionException,
                   java.lang.NoSuchFieldException
Insert a new Job to the collection

Parameters:
job - tht Job instance that has to be inserted
Throws:
JobCollectionException - Unable to add duplicate JobId
java.lang.NoSuchFieldException - If the Job is of JOB_NONE type

remove

public void remove(Job job)
            throws java.lang.NoSuchFieldException
Remove a specified Job from the collection Delete the specified job from the collection (if the id has been set) Delete the last occurrence of the job from the collection (if the ad has not been set)

Parameters:
job - the Job that has to be removed
Throws:
java.lang.NoSuchFieldException - Unable to remove the Job

clear

public void clear()
Deletes all elements from the collection.


setLoggerLevel

public void setLoggerLevel(int level)
Set the NS verbosity level

Parameters:
level - minimum (no verbosity) level = 0. Maximum (full verbosity) = 6

logDefaultValues

public void logDefaultValues(boolean set)
Decide whether to log or not some UI default values such as: UI node name information in UserTags attribute

Parameters:
set - if set to true the UI will automatically log its default values, otherwise not

setCredPath

public void setCredPath(java.io.File cp)
                 throws org.globus.gsi.GlobusCredentialException,
                        java.io.IOException
Set a different Proxy certificate from the default one

Parameters:
cp - The full path of the proxy certificate file to be set
Throws:
java.io.IOException - Unable to find-load-read the specified path
org.globus.gsi.GlobusCredentialException - Unable to get the specified proxy certificate

unsetCredPath

public void unsetCredPath()
                   throws org.globus.gsi.GlobusCredentialException,
                          java.io.IOException
Set the Proxy certificate as default

Throws:
java.io.IOException - Unable to find-load-read the default proxy file
org.globus.gsi.GlobusCredentialException - Unable to get the default proxy certificate

jobs

public java.util.Iterator jobs()
Returns:
an iterator pointing to the beginning of the collection

submit

public java.util.Vector submit(Url ns,
                               java.util.Vector lbs,
                               java.lang.String ceId)
                        throws java.lang.NoSuchFieldException,
                               JobCollectionException,
                               java.lang.InterruptedException,
                               org.globus.gsi.GlobusCredentialException,
                               java.io.FileNotFoundException
Submit method

Parameters:
ns - The Network Server address
lbs - a vector of Urls containing all the logging and bookkeeping addresses
ceId - The Computing Element Identificator where to perform the job
Returns:
a Vector of Result, one for each Job in the collection (with the same order as inserted)
Throws:
org.globus.gsi.GlobusCredentialException - Unable to get proxy certificate information
FileNotFoundException - - Unable to find proxy certificate file.
JobCollectionException - Some error occurred while executing the operation
java.lang.InterruptedException - An Error occurred while waiting for a thread to finish
java.lang.NoSuchFieldException - if the LB vector is empty

cancel

public java.util.Vector cancel()
                        throws JobCollectionException,
                               java.lang.InterruptedException,
                               org.globus.gsi.GlobusCredentialException,
                               java.io.FileNotFoundException
Cancel the job from the NS

Returns:
a Vector of Result, one for each Job in the collection (with the same order as inserted)
Throws:
JobCollectionException - Some error occurred while executing the operation
java.lang.InterruptedException - An Error occurred while waiting for a thread to finish
org.globus.gsi.GlobusCredentialException - Unable to get proxy certificate information
FileNotFoundException - - Unable to find proxy certificate file.

notify

public Result notify(int[] states,
                     int timeout)
              throws JobCollectionException,
                     java.lang.InterruptedException,
                     org.globus.gsi.GlobusCredentialException,
                     java.io.FileNotFoundException,
                     java.lang.NoSuchFieldException
Retrieves the status of the first Jobs of the collection once it enters one of the specified status code

Parameters:
states - an array of JobStatus status codes
timeout - seconds the method has to wait for notification. After that period the methods returns anyway. If 0 specified it hangs untill notify arrives
Returns:
a Success Result containing the JobStatus (or empty when timeout reached)
Throws:
java.lang.UnsupportedOperationException - The Operation required is not allowed for the Job
FileNotFoundException - Unable to find certificates files
gsi.GlobusCredentialException - error while checking certificates validity
JobCollectionException
java.lang.InterruptedException
org.globus.gsi.GlobusCredentialException
java.lang.NoSuchFieldException
See Also:
Result.TIMEOUT_REACHED

getStatus

public java.util.Vector getStatus()
                           throws JobCollectionException,
                                  java.lang.InterruptedException,
                                  org.globus.gsi.GlobusCredentialException,
                                  java.io.FileNotFoundException
Retrieve the status information from the LB

Returns:
a Vector of Result, one for each Job in the collection (with the same order as inserted)
Throws:
JobCollectionException - Some error occurred while executing the operation
java.lang.InterruptedException - An Error occurred while waiting for a thread to finish
org.globus.gsi.GlobusCredentialException - Unable to get proxy certificate information
FileNotFoundException - - Unable to find proxy certificate file.

getOutput

public java.util.Vector getOutput(java.lang.String dirPath)
                           throws JobCollectionException,
                                  java.lang.InterruptedException,
                                  org.globus.gsi.GlobusCredentialException,
                                  java.io.FileNotFoundException
Get the output files of the jobs (SYNC)

Parameters:
dirPath - the path where to retrieve the OutputSandbox files
Returns:
a Vector of Result, one for each Job in the collection (with the same order as inserted)
Throws:
JobCollectionException - Some error occurred while executing the operation
java.lang.InterruptedException - An Error occurred while waiting for a thread to finish
org.globus.gsi.GlobusCredentialException - Unable to get proxy certificate information
FileNotFoundException - - Unable to find proxy certificate file.

setMaxThreadNumber

public void setMaxThreadNumber(int maxThread)
This method is used to override the MAX_THREAD_NUMBER macro variable

Parameters:
maxThread - the max number or simultaneous threads allowed (unless the -DWITHOUT_THREAD option is specified while compiling)

appendJob

protected void appendJob(int number,
                         Result result)
Update the Job Result info into the Collection inner result vector. this method can be overriden in order to graphicalli manipulate each result

Parameters:
number - the number of the job insied the collection
result - the result of thte required operation

run

public void run()
Specified by:
run in interface java.lang.Runnable