|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.novell.zos.jdl.GridObjectInfo com.novell.zos.jdl.Joblet
public class Joblet
The Joblet class defines execution on the resource.
A Job writer constructs a subclass of Joblet to define code to
run on a resource. The method joblet_started_event
is
required to be implemented. joblet_started_event
is invoked on the resource.
The Job writer invokes the schedule()
function in the Job subclass to define
when, where and which resource the Joblet is executed.
Each Joblet instance has the Job instance (jobinstance.*,job.*,jobargs.*,user.*),
Resource (resource.*) and Joblet (joblet.*,jobletargs.*) fact sets available using the
base GridObjectInfo
fact functions. For example, you can use
self.getFact()
to retrieve a Joblet fact. Use the getMatrix()
built-in function to retrieve facts for other Grid Objects that are not in the context
of this Joblet instance's fact set.
Defined Joblet Facts:
joblet.id Unique identifier for this joblet joblet.instancename A human readable name for this joblet instance. joblet.memo An (optional) memo field for this joblet that can be displayed in the management console. joblet.number The joblet number (0 is the first Joblet). joblet.retrynumber The number of retries for this joblet (0 on first attempt). joblet.timeout The time after which this joblet will be cancelled/retried (seconds, defaults to job.joblet.timeout). joblet.preemptible Indicates whether this joblet is willing or able to be preempted. joblet.autoterminate Whether the joblet ends when all events for the joblet ends. joblet.state The numeric state of this joblet instance. joblet.state.string String representation of the current state of this joblet instance. joblet.errors The List of Error Dictionaries encapsulating the error history for this joblet. Dictionary keys: 'ts' timestamp in milliseconds, 'node' the node name where execution failed, 'error' the error message. *Interaction with the Job and a SDK client is accomplished using event methods on the Joblet class such as
self.sendEvent()
and self.sendClientEvent()
.
ParameterSpace
has been defined for this Joblet,
the self.getParamterSpace()
method retrieves the Joblet's
JobletParameterSpace
.
Example of a Joblet that runs a command line and forces a Joblet failure if the command line returns an exit code greater than zero:
class MyJoblet(Joblet): def joblet_started_event(self): e = Exec() e.setCommand("ls -la") rslt = e.execute() if rslt > 0: self.fail("ls command failed")In the above example, the Joblet may be retried on another resource depending on the value of the fact
job.joblet.maxfailures
and how many times
the Joblet has already been retried.
Field Summary | |
---|---|
static int |
CANCELLED_STATE
Joblet cancelled end state. |
static int |
CANCELLING_STATE
Joblet cancelling. |
static int |
COMPLETED_STATE
Joblet completed end state. |
static int |
COMPLETING_STATE
Joblet completing state. |
static int |
CONTRACTED_STATE
Joblet contracted to a resource. |
static int |
FAILED_STATE
Joblet failed end state. |
static int |
FAILING_STATE
Joblet failing state. |
static int |
INITIAL_STATE
Joblet initial state. |
static int |
POST_CANCEL_STATE
Joblet finishing cancellation. |
static int |
PRE_CANCEL_STATE
Joblet starting cancellation. |
static int |
STARTED_STATE
Joblet started on a resource. |
static int |
WAITING_RETRY_STATE
Joblet waiting for a resource for retry. |
static int |
WAITING_STATE
Joblet waiting for a resource. |
Method Summary | |
---|---|
void |
cancel()
Cancel this joblet if it is waiting or running. |
void |
cancel(java.lang.String reason)
Cancel this joblet if it is running. |
void |
cancelAllTimers()
Cancel all timers for this joblet instance. |
void |
fail()
Fail a running joblet to force failover to another resource. |
void |
fail(java.lang.String reason)
Fail a running joblet to force failover to another resource. |
java.lang.String |
getcwd()
Retrieve the path of the current working directory in which this Joblet is running. |
JobletParameterSpace |
getParameterSpace()
Retrieve the JobletParameterSpace defined for this Joblet instance. |
boolean |
isValidUser(java.lang.String username)
Test if a supplied username is valid on a resource. |
void |
joblet_cancelled_event()
The joblet_failed_event is fired when Joblet execution has
failed either by code, runtime errors or by the self.fail() function. |
void |
joblet_pre_cancel_event()
The joblet_pre_cancel_event is fired when Joblet execution is about
to be interrupted. |
void |
joblet_started_event()
joblet_started_event is fired when Joblet execution is started on a resource. |
void |
retry()
Retry this joblet elsewhere if it is running. |
void |
retry(java.lang.String reason)
Retry this joblet if it is running. |
void |
sendClientEvent(java.lang.String name,
org.python.core.PyDictionary params)
Send an event to a client. |
void |
sendEvent(java.lang.String name,
org.python.core.PyDictionary params)
Send an event to the Job that scheduled this Joblet. |
void |
sendEvent(java.lang.String jobID,
java.lang.String name,
org.python.core.PyDictionary params)
Send an event to the supplied Job instance. |
void |
terminate()
Terminate a joblet that is running. |
Methods inherited from class com.novell.zos.jdl.GridObjectInfo |
---|
deleteFact, factExists, getFact, getFactLastModified, getFactNames, refresh, setArrayFact, setBooleanArrayFact, setDateArrayFact, setDateFact, setFact, setIntegerArrayFact, setRealArrayFact, setStringArrayFact, setTimeArrayFact, setTimeFact |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int INITIAL_STATE
public static final int WAITING_STATE
public static final int WAITING_RETRY_STATE
public static final int CONTRACTED_STATE
public static final int STARTED_STATE
public static final int PRE_CANCEL_STATE
public static final int CANCELLING_STATE
public static final int POST_CANCEL_STATE
public static final int COMPLETING_STATE
public static final int FAILING_STATE
public static final int FAILED_STATE
public static final int CANCELLED_STATE
public static final int COMPLETED_STATE
Method Detail |
---|
public void cancelAllTimers()
Any running Timer
instances are cancelled.
A running Timer
will keep the joblet instance in a
Running state.
public java.lang.String getcwd()
public void joblet_started_event()
joblet_started_event
is fired when Joblet execution is started on a resource.
The Job writer is required to implement this function.
public void joblet_pre_cancel_event()
joblet_pre_cancel_event
is fired when Joblet execution is about
to be interrupted.
Example to send a signal to a running process before joblet is cancelled:
class MyJoblet(Joblet): def joblet_started_event(self): self.exec = Exec() self.exec.setCommand("sleep 100") self.exec.execute() def joblet_pre_cancel_event(self): self.exec.signal("SIGABRT")
public void joblet_cancelled_event()
joblet_failed_event
is fired when Joblet execution has
failed either by code, runtime errors or by the self.fail()
function.
The Job writer can optionally implement this function to handle special
postprocessing such as cleanup of a running process.
Example to send a signal to a running process before the Joblet is ended:
class MyJoblet(Joblet): def joblet_started_event(self): self.exec = Exec() self.exec.setCommand("sleep 100") self.exec.execute() def joblet_failed_event(self): self.exec.signal("SIGABRT")
public void sendEvent(java.lang.String name, org.python.core.PyDictionary params)
Example to send an event with the parameters dictionary containing two elements:
self.sendEvent("custom_event", { "arg1":1,"arg2":"foo" } )
name
- Name of eventparams
- Dictionary of event parameterspublic void sendEvent(java.lang.String jobID, java.lang.String name, org.python.core.PyDictionary params)
jobID
- ID of job to send event toname
- Name of eventparams
- Dictionary of event parameterspublic void sendClientEvent(java.lang.String name, org.python.core.PyDictionary params)
name
- Name of eventparams
- Dictionary of event parameterspublic void terminate()
joblet.autoterminate
is True
.
public JobletParameterSpace getParameterSpace()
public void cancel()
public void cancel(java.lang.String reason)
reason
- string to store in job logpublic void fail()
public void fail(java.lang.String reason)
reason
- string to store in job logpublic void retry()
public void retry(java.lang.String reason)
reason
- string to store in job logpublic boolean isValidUser(java.lang.String username)
username
- Name of user to test
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |