|
|||||||||
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.Job
public class Job
The Job class is a representation of a running job instance.
This class defines functions for interacting with the server
including handling notification of job state transitions, child job submission,
managing Joblets and for receiving and sending events from resources and from
clients. A Job writer defines a subclass of the Job class and uses the methods
available on the Job class for scheduling Joblets and event processing.
When a job is started, the Job subclass is instantiated.
There can only be one Job
subclass per JDL file.
The Job
subclass name is not required to match the JDL filename.
The filename is the defined job name. However, the JDL filename must match
the .job
file containing a JDL file. Packaging a JDL file inside of a
.job
file is necessary for also including the matching .policy
and
.sched
files.
Example of a job that schedules a single Joblet to run on one resource:
class Simple(Job): def job_started_event(self): self.schedule(SimpleJoblet) class SimpleJoblet(Joblet): def joblet_started_event(self): print "Hello from Joblet"For the above example, the class
Simple
is instantiated on the server
when a job is started either by client tools or by the Job Scheduler.
When a job transitions to the started state, the method job_started_event
is invoked. Here the job_started_event
invokes the base class
method schedule()
to create a single instance of SimpleJoblet
and
schedule the SimpleJoblet
to be run on a resource. When an appropriate
resource is allocated, the SimpleJoblet
class is instantiated and run on the resource.
Each Job has a set of events that are invoked at the state transitions
of a Job. On the starting state of a Job, the job_started_event
is always
invoked.
Following is a list of Job events that are invoked upon Job state transitions:
job_started_event job_completed_event job_cancelled_event job_failed_event job_paused_event job_resumed_event
List of Job events invoked upon child Job state transitions:
child_job_started_event child_job_completed_event child_job_cancelled_event child_job_failed_event
List of provisioner events invoked upon provisioner state transitions:
provisioner_completed_event provisioner_cancelled_event provisioner_failed_event
List of Joblet events invoked upon joblet state transitions:
joblet_started_event joblet_completed_event joblet_failed_event joblet_cancelled_event joblet_retry_event* Of the above list, only the
job_started_event
is required. The rest are optional.
A Job writer can also handle and invoke custom events within a Job. Events can come from clients, other Jobs and from Joblets.
Example of defining an event handler named mycustom_event
in a Job:
class Simple(Job): def job_started_event(self): ... def mycustom_event(self,params): dir = params["directory_to_list"] self.schedule(MyJoblet,{ "dir" : dir } )For the above example, the event
mycustom_event
retrieves an element from the params
dictionary
that is supplied to every custom event. The dictionary is optionally filled by the caller
of the event.
Example of invoking the custom event named 'mycustom_event' from the zos
client command line tool:
zos event mycustom_event directory_to_list="/tmp"In the above, a message is sent from the client tool to the job running on the server.
Example of invoking the same custom event from a Joblet:
class SimpleJoblet(Joblet): def joblet_started_event(self): ... self.sendEvent("mycustom_event", { ... } )In the above, a message is sent from the Joblet running on a resource to the job running on the server.
Fact values are retrieved using the GridObjectInfo
functions that the Job
class inherits.
Example of retrieving the value of the job instance fact state.string
from the
jobinstance
namespace:
class Simple(Job): def job_started_event(self): jobstate = self.getFact("jobinstance.state.string") print "job state=%s" % (jobstate)Defined Job Instance Facts:
jobinstance.id The job instance unique identifier jobinstance.priority The numeric represenation of the current priority of this job instance (1=lowest, 9=higest). Default value is the user's default priority jobinstance.priority.string The string representation of the current priority of this job instance jobinstance.instancename The optional human readable name for this job instance jobinstance.memo A brief memo set by this job instance that can be seen in user/administrator portals jobinstance.starttime The formated start date and time for this job instance jobinstance.joblet.pspace The number of 'rows' in a fully expanded p-space definition. Will be equals to the number of joblets only if 'jobinstance.joblet.size' is 1 jobinstance.joblet.size The number of p-space rows encapsulated in each joblet. May be explicitly set of derived as a result of specifing joblet count jobinstance.joblets.count The number of joblets under management of this job instance jobinstance.joblets.waiting Number of joblets that are waiting for available resources jobinstance.joblets.running Number of joblets that are actively running on resources jobinstance.joblets.failed Number of joblets that ended in a failed state jobinstance.joblets.cancelled Number of joblets that ended in a cancelled state jobinstance.joblets.complete Number of joblets that completed successfully jobinstance.restarted Whether this job instance was been restarted due to server restart jobinstance.resources The resources currently in use by this job jobinstance.resources.count Number of resources currently in use by this job jobinstance.cost The cost of this job ($) jobinstance.cost.burnrate The computed moving average burn rate of the job ($/hr) jobinstance.startat The date/time that this job was requested to start at jobinstance.time.submitted The time this job instance was submitted jobinstance.time.started The time this job instance was actually started or an estimating if queued jobinstance.time.elapsed The elapsed wall time this job instance has been running or ran (in seconds) jobinstance.time.queued The elapsed wall time this job instance has been a queued (in second)s jobinstance.time.elapsed.string The elapsed wall time this job instance has been in a running jobinstance.time.completed The time this job instance completed or an estimation if still active jobinstance.matchingresources The number of currently active resources that match the 'resource' contraints jobinstance.state The numeric state of this job instance jobinstance.state.string String representation of the current state of this job instance jobinstance.problemresources The names of resources that are excluded from this job instance due to reaching the 'job.maxnodefailures' limit jobinstance.problemresources.count The number of resources that are excluded from this job instance due to reaching the 'job.maxnodefailures' limit jobinstance.errors The error messages recorded for a failed job jobinstance.terminationtype The cause of the termination for a cancelled or failed job. jobinstance.originid The job identifier of the root job of this hierarchy or this job if a top level job jobinstance.parentid The job identifier of the parent job of this hierarchy or empty if this is a top level job with no parent jobinstance.childids String array of child job ids. Empty array if no child jobs were launched jobinstance.provision.count The total number of resources that have been automaticaly provisioned (or are in progress) for this job jobinstance.provision.pending The total number of automatically provisioned resources that are pending online status jobinstance.provision.problemresources The names of automatically provisioned resources that encountered provisioning errors and have been excluded jobinstance.provision.avoidresources The names of automatically provisioned resources that are currently being avoided (not yet excluded) because of prior provisioning errors jobinstance.provision.problemresources.count The number of automatically provisioned resources that encountered provisioning errors and have been excluded
Field Summary | |
---|---|
static int |
CANCELLED_STATE
Cancelled end state. |
static int |
CANCELLING_STATE
Cancelling. |
static int |
COMPLETED_STATE
Completed end state. |
static int |
COMPLETING_STATE
Completing. |
static int |
FAILED_STATE
Failed end state. |
static int |
FAILING_STATE
Failing. |
static int |
PAUSED_STATE
Paused. |
static int |
QUEUED_STATE
Queued. |
static int |
RUNNING_STATE
Running. |
static int |
STARTING_STATE
Starting. |
static int |
SUBMITTED_STATE
Submitted. |
static java.lang.String |
TERMINATION_TYPE_ADMIN
Indicate Job was cancelled by admin. |
static java.lang.String |
TERMINATION_TYPE_JOB
Indicate Job was cancelled by a Job function. |
static java.lang.String |
TERMINATION_TYPE_TIMEOUT
Indicate Job was cancelled due to exceeding the job timeout value. |
static java.lang.String |
TERMINATION_TYPE_USER
Indicate Job was cancelled by client user. |
Method Summary | |
---|---|
void |
cancel()
Cancel this job instance. |
void |
cancel(java.lang.String reason)
Cancel this job instance with a reason. |
void |
cancelAllJoblets()
Cancel all joblets for this job instance. |
void |
cancelAllTimers()
Cancel all timers for this job instance. |
void |
changePriority(java.lang.String priority)
Change priority of this job. |
void |
child_job_cancelled_event(Job job)
child_job_cancelled_event is fired when a child job has transitioned to the cancelled state. |
void |
child_job_completed_event(Job job)
child_job_completed_event is fired when a child job has transitioned to the completed state. |
void |
child_job_failed_event(Job job)
child_job_failed_event is fired when a child job has transitioned to the failed state. |
void |
child_job_started_event(Job job)
child_job_started_event is fired when a child job has transitioned to the running state. |
void |
fail()
Fail this job instance. |
void |
fail(java.lang.String reason)
Fail this job instance with a reason. |
org.python.core.PyList |
getChildJobs()
Retrieve a list of child jobs submitted by this job. |
Joblet |
getJoblet(int jobletNumber)
Retrieve a scheduled Joblet. |
java.lang.Object |
getMatchingResources()
Retrieve a List of matching resources for this Job instance. |
java.lang.Object |
getMatchingResources(ScheduleSpec scheduleSpec)
Retrieve a List of matching resources for this Job instance using the supplied ScheduleSpec . |
void |
job_cancelled_event()
job_cancelled_event is fired when a job is transitioning to the cancelled state. |
void |
job_completed_event()
job_completed_event is fired when the job is transitioning to the completed state. |
void |
job_failed_event()
job_failed_event is fired when the job is transitioning to the failed state. |
void |
job_paused_event()
Fired when a job is paused by user or administrator. |
void |
job_resumed_event()
Fired when a previously paused job is resumed. |
void |
job_started_event()
job_started_event is the first event to be called when a job is started. |
void |
joblet_cancelled_event(int jobletNumber,
java.lang.String resourceId,
java.lang.String reason)
joblet_cancelled_event is fired when the Joblet has had execution cancelled. |
void |
joblet_completed_event(int jobletNumber,
java.lang.String resourceId)
joblet_completed_event is fired when the Joblet has completed execution on a resource. |
void |
joblet_failed_event(int jobletNumber,
java.lang.String resourceId,
java.lang.String errorMsg)
joblet_failed_event is fired when the Joblet has failed execution on a resource. |
void |
joblet_retry_event(int jobletNumber,
java.lang.String resourceId,
java.lang.String errorMsg)
joblet_retry_event is fired when the Joblet is transitioning back to a waiting state after a failed execution on a resource. |
void |
joblet_started_event(int jobletNumber,
java.lang.String resourceId)
joblet_started_event is fired when the Joblet has started execution on a resource. |
void |
pause()
Pause this job instance. |
void |
provisioner_cancelled_event(org.python.core.PyDictionary params)
provisioner_cancelled_event is fired when the provision operation submitted by this job has been cancelled. |
void |
provisioner_completed_event(org.python.core.PyDictionary params)
provisioner_completed_event is fired when the provision operation submitted by this job has completed. |
void |
provisioner_failed_event(org.python.core.PyDictionary params)
provisioner_failed_event is fired when the provision operation submitted by this job has failed. |
void |
resume()
Resume this job instance if it is currently paused. |
org.python.core.PyObject |
runJob(RunJobSpec runJobSpec)
Run a new child or stand-alone job using attributes defined in the supplied RunJobSpec . |
org.python.core.PyObject |
runJob(java.lang.String job)
Run a new child job. |
org.python.core.PyObject |
runJob(java.lang.String job,
org.python.core.PyDictionary params)
Run a new child job with supplied job arguments. |
org.python.core.PyObject |
runJob(java.lang.String job,
org.python.core.PyDictionary params,
Constraint constraint)
Run a new child job using supplied resource Constraint. |
org.python.core.PyObject |
runJob(java.lang.String job,
org.python.core.PyDictionary params,
java.lang.String policy)
Run a new child job using supplied policy text. |
void |
schedule(org.python.core.PyClass jobletClass)
Schedule a single joblet. |
void |
schedule(org.python.core.PyClass jobletClass,
int jobletCount)
Schedule one or more joblets. |
void |
schedule(org.python.core.PyClass jobletClass,
ParameterSpace parameterSpace,
org.python.core.PyDictionary params)
Schedule a set of joblets using the passed ParameterSpace as the basis for joblet assignment. |
void |
schedule(org.python.core.PyClass jobletClass,
ParameterSpace parameterSpace,
org.python.core.PyDictionary params,
int jobletCount)
Schedule a set of joblets using the passed ParameterSpace as the basis for joblet assignment. |
void |
schedule(org.python.core.PyClass jobletClass,
ParameterSpace parameterSpace,
org.python.core.PyDictionary params,
int jobletCount,
org.python.core.PyMethod allocate)
Schedule a set of joblets using the passed ParameterSpace as the basis for joblet assignment. |
void |
schedule(org.python.core.PyClass jobletClass,
org.python.core.PyDictionary params)
Schedule a single joblet with additional joblet facts. |
void |
schedule(org.python.core.PyClass jobletClass,
org.python.core.PyDictionary params,
int jobletCount)
Schedule one or more joblets with additional joblet facts. |
void |
schedule(ScheduleSpec spec)
Schedule a set of joblets using the passed ScheduleSpec . |
void |
scheduleSweep(org.python.core.PyClass jobletClass)
Schedule as many joblets as there are matching resources using the job's resource constraints. |
void |
scheduleSweep(org.python.core.PyClass jobletClass,
org.python.core.PyDictionary params)
Schedule as many joblets as there are matching resources using the job's resource constraints. |
void |
scheduleSweep(ScheduleSpec spec)
Schedule as many joblets as there are matching resources after applying any constraint from the ScheduleSpec to
constrain the available joblets. |
void |
sendClientEvent(java.lang.String name,
org.python.core.PyDictionary params)
Send an event to the client. |
void |
sendEvent(java.lang.String name,
org.python.core.PyDictionary params)
Send an event to the parent job. |
void |
sendEvent(java.lang.String destJobID,
java.lang.String name,
org.python.core.PyDictionary params)
Send an event to another job. |
void |
sendJobletEvent(int jobletNumber,
java.lang.String name,
org.python.core.PyDictionary params)
Send an event from server to Joblet execution on a resource. |
void |
subscribeToEvent(java.lang.String event,
org.python.core.PyMethod method)
Subscribe to be notified of a Platespin Orchestrate Event |
void |
terminate()
Terminate this job instance. |
void |
unsubscribeFromEvent(java.lang.String event,
org.python.core.PyMethod method)
Unsubscribe from Platespin Orchestrate Event notifications |
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 SUBMITTED_STATE
public static final int QUEUED_STATE
public static final int STARTING_STATE
public static final int RUNNING_STATE
public static final int PAUSED_STATE
public static final int COMPLETING_STATE
public static final int CANCELLING_STATE
public static final int FAILING_STATE
public static final int COMPLETED_STATE
public static final int CANCELLED_STATE
public static final int FAILED_STATE
public static final java.lang.String TERMINATION_TYPE_USER
jobinstance.terminationtype
fact
public static final java.lang.String TERMINATION_TYPE_ADMIN
jobinstance.terminationtype
fact
public static final java.lang.String TERMINATION_TYPE_JOB
jobinstance.terminationtype
fact
public static final java.lang.String TERMINATION_TYPE_TIMEOUT
jobinstance.terminationtype
fact
Method Detail |
---|
public void scheduleSweep(org.python.core.PyClass jobletClass)
Note that joblets created with scheduleSweep()
will take
precedence over regularly scheduled joblets and will prevent regular
joblets from running until all preassigned ones are complete. For this
reason it is not normally recommended to mix schedule()
and scheduleSweep
in the same job.
jobletClass
- Reference to Joblet class to execute on nodepublic void scheduleSweep(org.python.core.PyClass jobletClass, org.python.core.PyDictionary params)
Note that joblets created with scheduleSweep()
will take
precedence over regularly scheduled joblets and will prevent regular
joblets from running until all preassigned ones are complete. For this
reason it is not normally recommended to mix schedule()
and scheduleSweep
in the same job.
jobletClass
- Reference to Joblet class to execute on nodeparams
- dictionary of facts to store in jobletpublic void scheduleSweep(ScheduleSpec spec)
ScheduleSpec
to
constrain the available joblets.
Each created joblet will be preassigned to run only on the specified
resource.
Note that joblets created with scheduleSweep()
will take
precedence over regularly scheduled joblets and will prevent regular
joblets from running until all preassigned ones are complete. For this
reason it is not normally recommended to mix schedule()
and scheduleSweep
in the same job.
spec
- ScheduleSpec
to use for scheduling jobletspublic void schedule(org.python.core.PyClass jobletClass)
jobletClass
- Reference to Joblet class to execute on nodepublic void schedule(org.python.core.PyClass jobletClass, int jobletCount)
jobletClass
- Reference to Joblet class to execute on nodejobletCount
- Number of joblets to createpublic void schedule(org.python.core.PyClass jobletClass, org.python.core.PyDictionary params)
jobletClass
- Reference to Joblet class to execute on nodeparams
- dictionary of facts to store in jobletpublic void schedule(org.python.core.PyClass jobletClass, org.python.core.PyDictionary params, int jobletCount)
jobletClass
- Reference to Joblet class to execute on nodeparams
- dictionary of facts to store in jobletjobletCount
- Number of joblets to createpublic void schedule(org.python.core.PyClass jobletClass, ParameterSpace parameterSpace, org.python.core.PyDictionary params)
jobletClass
- Reference to Joblet class to execute on nodeparameterSpace
- ParameterSpace object instanceparams
- dictionary of facts to store in jobletpublic void schedule(org.python.core.PyClass jobletClass, ParameterSpace parameterSpace, org.python.core.PyDictionary params, int jobletCount)
jobletClass
- Reference to Joblet class to execute on nodeparameterSpace
- ParameterSpace object instanceparams
- dictionary of facts to store in jobletjobletCount
- Maximum number of joblets to break up ParameterSpace
A count of 1 means to only create 1 joblet. This
may override ParameterSpace defined joblet breakup.public void schedule(org.python.core.PyClass jobletClass, ParameterSpace parameterSpace, org.python.core.PyDictionary params, int jobletCount, org.python.core.PyMethod allocate)
jobletClass
- Reference to Joblet class to execute on nodeparameterSpace
- ParameterSpace object instanceparams
- dictionary of facts to store in jobletjobletCount
- Maximum number of joblets to break up ParameterSpaceallocate
- Reference to function to execute for choosing nodes (optional)public void schedule(ScheduleSpec spec)
ScheduleSpec
.
spec
- ScheduleSpec
instance defining Joblets to schedulepublic org.python.core.PyObject runJob(java.lang.String job)
job
- Name of job to run
JdlException
- if child job is not deployedpublic org.python.core.PyObject runJob(java.lang.String job, org.python.core.PyDictionary params)
Example to run the sample job with two arguments:
self.runJob('quickie',{"numJoblets":2,"sleeptime":5})
job
- Name of job to runparams
- Dictionary of job arguments
JdlException
- if child job is not deployed or job arguments are not of the correct typepublic org.python.core.PyObject runJob(java.lang.String job, org.python.core.PyDictionary params, java.lang.String policy)
job
- Name of job to runparams
- Dictionary of job argumentspolicy
- Policy text
JdlException
- if child job is not deployed or job arguments are not of the correct typepublic org.python.core.PyObject runJob(java.lang.String job, org.python.core.PyDictionary params, Constraint constraint)
Example to run the "osInfo" job as a child job with a supplied constraint that matches on a specific OS family:
eq = EqConstraint() eq.setFact("resource.os.family") eq.setValue("windows") self.runJob("osInfo",{},eq)The supplied constraint is AND'd to the job's existing constraints.
job
- Name of job to runparams
- Dictionary of job argumentsconstraint
- Constraint object
JdlException
- if child job is not deployed or job arguments are not of the correct typepublic org.python.core.PyObject runJob(RunJobSpec runJobSpec)
RunJobSpec
.
runJobSpec
- RunJobSpec instance with attributes for starting child job
JdlException
- if child job is not deployed or job arguments are not of the correct typepublic void sendEvent(java.lang.String name, org.python.core.PyDictionary params)
name
- Name of eventparams
- Dictionary of parameters to send to destinationpublic void sendEvent(java.lang.String destJobID, java.lang.String name, org.python.core.PyDictionary params)
This is typically used to communicate to a child job.
destJobID
- Job Instance ID of job to send event toname
- Name of eventparams
- Dictionary of parameters to send to destinationpublic void sendClientEvent(java.lang.String name, org.python.core.PyDictionary params)
This allows communication from the Job running on the server to a client that is listening to Job events using the Client Toolkit.
Example to send an event to a client with a payload consisting of integer and a string:
self.sendClientEvent("client_event",{ "param1": 1024, "param2":"hello world" })
name
- Name of eventparams
- Dictionary of parameters to send to destination.public void sendJobletEvent(int jobletNumber, java.lang.String name, org.python.core.PyDictionary params)
Joblet must be running on a resource or this event is ignored. Typically used to communicate state changes to a long running Joblet.
jobletNumber
- Number of joblet to send event to. Joblet
must be contracted on node.name
- name of eventparams
- dictionary of parameters to send to destination
org.python.core.PyException
- if joblet does not exist or is not contractedpublic void cancel()
public void cancel(java.lang.String reason)
reason
- message to put in job logpublic void fail()
public void fail(java.lang.String reason)
reason
- Reason message to put in job logpublic void pause()
public void resume()
public void terminate()
Typically used when the fact job.autoterminate
has been
set to False
.
public org.python.core.PyList getChildJobs()
public void cancelAllJoblets()
Any joblets that are running or waiting are cancelled. If the job is set to autoterminate, then the job will terminate normally.
public void cancelAllTimers()
Any running Timer
instances are cancelled.
A running Timer
will keep the job instance in a
Running state.
public void changePriority(java.lang.String priority)
priority
- String priority namepublic void job_started_event()
public void job_cancelled_event()
public void job_paused_event()
public void job_completed_event()
public void job_failed_event()
public void job_resumed_event()
public void child_job_started_event(Job job)
job
- Child Job instance that is runningpublic void child_job_completed_event(Job job)
job
- Child Job instance that has completedpublic void child_job_failed_event(Job job)
job
- Child Job instance that has failedpublic void child_job_cancelled_event(Job job)
job
- Child Job instance that has cancelledpublic void joblet_started_event(int jobletNumber, java.lang.String resourceId)
jobletNumber
- Joblet number that has started (0 based)resourceId
- Id of resource where joblet was started on.public void joblet_cancelled_event(int jobletNumber, java.lang.String resourceId, java.lang.String reason)
jobletNumber
- Joblet number that has been cancelled (0 based)resourceId
- ID of resource where joblet was cancelled. Can be None if was not runningreason
- Reason message for the joblet error. Maybe emptypublic void joblet_completed_event(int jobletNumber, java.lang.String resourceId)
jobletNumber
- Joblet number that has completed (0 based)resourceId
- ID of resource where joblet ran to completionpublic void joblet_failed_event(int jobletNumber, java.lang.String resourceId, java.lang.String errorMsg)
jobletNumber
- Joblet number that has failedresourceId
- ID of resource where joblet ranerrorMsg
- Error message for the joblet errorpublic void joblet_retry_event(int jobletNumber, java.lang.String resourceId, java.lang.String errorMsg)
jobletNumber
- Joblet number that is to be retriedresourceId
- ID of resource where joblet ranerrorMsg
- Error message for the joblet errorpublic Joblet getJoblet(int jobletNumber)
GridObjectInfo
methods. Retrieve the state
facts to determine the state of the Joblet.
jobletNumber
- Number of joblet
java.lang.Exception
- if Joblet number refers to a Joblet that has not yet been createdpublic void provisioner_completed_event(org.python.core.PyDictionary params)
A Job writer can optionally implement this event to handle any job response to provision completion.
Example of a handler for the completion of suspending a resource
def provisioner_completed_event(params): if params["action"] == "Suspend": print "Successfully suspended resource '%s'" % (params["resource"])
params
argument is a Dictionary containing various attributes including "action" and "provisionjob" keys.
Valid "action" strings include:
"Provision" "Clone" "Move" "Shutdown" "Restart" "Destroy" "Suspend" "Pause" "Resume" "Personalize" "Save Config" "Apply Config" "Create Template" "Migrate" "Checkpoint" "Restore" "Install Agent" "Make Standalone" "Check Status" "Delete" "Cancel Action" "Build" Additional Params include "resource" key. "Discover All" No additional Params keys. "Discover VmHost" Additional Params include "host" key. "Discover Repository" Additional Params include "repository" key.The "provisionjob" key contains the Job Id of the provisioning adapter job that was run.
params
- Dictionary containing "action", "provisionjob" and other action specific keyspublic void provisioner_failed_event(org.python.core.PyDictionary params)
A Job writer can optionally implement this event to handle any job response to provision failure.
An optional "error" key may be passed as a param indicating
the failure. More information may also be available by looking up the
provisioning job.
params
- Dictionary containing "action", "resource", "provisionjob" and other action specific keys.public void provisioner_cancelled_event(org.python.core.PyDictionary params)
A Job writer can optionally implement this event to handle any job response to provision cancellation.
params
- Dictionary containing "action", "resource", "provisionjob" and other action specific keyspublic void subscribeToEvent(java.lang.String event, org.python.core.PyMethod method)
Example of a job subscribing to an event:
class EventDaemon(Job): def job_started_event(self): self.setFact("job.autoterminate",False) self.subscribeToEvent("vmhost",self.eventHandler) def eventHandler(self,context): print "Context:" keys = context.keys() keys.sort() for k in keys: v = context[k] print " key(%s) type(%s) value(%s)" % (k,type(v),str(v))In the above example, the job subscribes to an event named "vmhost". The Job method
eventHandler()
will be invoked upon the
event notification. This job will continue running until the job is canceled
or an error occurs.
event
- Event Name to subscribe tomethod
- Method in this Job subclasspublic void unsubscribeFromEvent(java.lang.String event, org.python.core.PyMethod method)
Example of unsubscribing from same event example used in subscribeToEvent()
:
self.unsubscribeFromEvent("vmhost",self.eventHandler)
event
- Event Name to unsubscribe frommethod
- Method in this Job subclass that was used in subscribing.public java.lang.Object getMatchingResources()
schedule()
.
So only online resources that match this job instance's constraints will
be returned.
Constraint
search for Grid Objects,
use the getMatrix().getGridObjects()
methods.
public java.lang.Object getMatchingResources(ScheduleSpec scheduleSpec)
ScheduleSpec
.
schedule()
if it were called with the
same ScheduleSpec
instance. So only resources that match this job instance's
constraints and any specified in the supplied ScheduleSpec
will be returned.
Constraint
search for Grid Objects,
use the getMatrix().getGridObjects()
methods.
scheduleSpec
- ScheduleSpec
instance defining optional additional constraint
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |