Package com.carfey.ops.job
Class Context
- java.lang.Object
-
- com.carfey.ops.job.Context
-
public class Context extends java.lang.ObjectProvides parameterization and execution context to aSchedulableJob.Most jobs will use the
JobConfigobject returned by instances of this class to retrieve defined and/or custom parameter values.Beyond job configuration, this class provides access to information regarding the executing job, such as the name of the job, the scheduled time, etc.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JobConfiggetConfig()java.lang.StringgetInterruptUser()Set just beforeInterruptableJob.beforeInterrupt()orInterruptableContextJob.beforeInterrupt(Context)is called and before the thread is actually interrupted.longgetJobHistoryId()longgetJobId()java.lang.StringgetJobNickname()com.carfey.jdk.lang.DateTimegetPickupTime()java.lang.StringgetRunningHost()com.carfey.jdk.lang.DateTimegetScheduledTime()JobConfiggetSourceConfig()Returns job config from the job that chained to this job.java.lang.LonggetSourceJobHistoryId()java.util.Map<java.lang.String,java.util.List<java.lang.Object>>getSourceJobResults()Returns job results from the job that chained to this job.booleanisAdHoc()voidreplaceJobResult(java.lang.String name, java.lang.Object value)Replace a job result with new value.voidreplaceMultipleJobResults(java.lang.String name, java.util.Collection<?> values)Replace all existing job results with new values.protected <T> TrunAutonomous(java.util.concurrent.Callable<T> callable)voidsaveJobResult(java.lang.String name, java.lang.Object value)Save a job result, which will be viewable in the Obsidian web application, and is available to jobs chained from this one, as well as the REST and Embedded APIs.voidsaveMultipleJobResults(java.lang.String name, java.util.Collection<?> values)Save multiple job results, which will be viewable in the Obsidian web application, and are available to jobs chained from this one, as well as the REST and Embedded APIs.protected voidsetInterruptUser(java.lang.String interruptUser)java.lang.StringtoString()
-
-
-
Method Detail
-
getSourceJobHistoryId
public java.lang.Long getSourceJobHistoryId()
- Returns:
- The source JobHistoryId that triggered chaining to this job.
-
getConfig
public JobConfig getConfig()
- Returns:
- JobConfig containing all parameterization.
-
getJobHistoryId
public long getJobHistoryId()
- Returns:
- JobHistoryId
-
getScheduledTime
public com.carfey.jdk.lang.DateTime getScheduledTime()
- Returns:
- Scheduled runtime.
-
getPickupTime
public com.carfey.jdk.lang.DateTime getPickupTime()
- Returns:
- Pickup time
- Since:
- 4.9.0
-
getJobId
public long getJobId()
- Returns:
- JobId
-
getJobNickname
public java.lang.String getJobNickname()
- Returns:
- Job Nickname
-
isAdHoc
public boolean isAdHoc()
- Returns:
- whether this is an ad hoc execution
-
getRunningHost
public java.lang.String getRunningHost()
- Returns:
- host job is running on
- Since:
- 4.9.0
-
getInterruptUser
public java.lang.String getInterruptUser()
Set just beforeInterruptableJob.beforeInterrupt()orInterruptableContextJob.beforeInterrupt(Context)is called and before the thread is actually interrupted.- Returns:
- the user who interrupted the job, if applicable.
- Since:
- 3.2
-
setInterruptUser
protected void setInterruptUser(java.lang.String interruptUser)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getSourceConfig
public JobConfig getSourceConfig() throws com.carfey.jdk.db.Database.DBException, ParameterException
Returns job config from the job that chained to this job. This allows configuring the source job and inheriting the config in a target job of a chain.- Returns:
- map of source job config
- Throws:
ParameterException- when an error is encountered building the configurationcom.carfey.jdk.db.Database.DBException- any type of database error- Since:
- 3.8.0
-
getSourceJobResults
public java.util.Map<java.lang.String,java.util.List<java.lang.Object>> getSourceJobResults() throws ParameterException, com.carfey.jdk.db.Database.DBExceptionReturns job results from the job that chained to this job. This allows to using output from one job as input to another job.- Returns:
- map of all job results from the job that triggered chaining to this job.
- Throws:
ParameterException- when an error is encountered building the configurationcom.carfey.jdk.db.Database.DBException- any type of database error
-
saveJobResult
public void saveJobResult(java.lang.String name, java.lang.Object value) throws com.carfey.jdk.db.Database.DBExceptionSave a job result, which will be viewable in the Obsidian web application, and is available to jobs chained from this one, as well as the REST and Embedded APIs.- Parameters:
name- name of job resultvalue- value for job result (type is preserved)- Throws:
com.carfey.jdk.db.Database.DBException- any type of database error
-
replaceJobResult
public void replaceJobResult(java.lang.String name, java.lang.Object value) throws com.carfey.jdk.db.Database.DBExceptionReplace a job result with new value. Any job results that exist with the given name will be deleted, after whichsaveJobResult(String, Object)is invoked.- Parameters:
name- name of job result to replacevalue- value for job result (type is preserved)- Throws:
com.carfey.jdk.db.Database.DBException- any type of database error- Since:
- 3.6
-
replaceMultipleJobResults
public void replaceMultipleJobResults(java.lang.String name, java.util.Collection<?> values) throws com.carfey.jdk.db.Database.DBExceptionReplace all existing job results with new values. Any job results that exist with the given name will be deleted, after whichsaveMultipleJobResults(String, Collection)is invoked.- Parameters:
name- name of job result to replacevalues- values for job result (type is preserved)- Throws:
com.carfey.jdk.db.Database.DBException- any type of database error- Since:
- 3.6
-
runAutonomous
protected <T> T runAutonomous(java.util.concurrent.Callable<T> callable) throws com.carfey.jdk.db.Database.DBException- Throws:
com.carfey.jdk.db.Database.DBException
-
saveMultipleJobResults
public void saveMultipleJobResults(java.lang.String name, java.util.Collection<?> values) throws com.carfey.jdk.db.Database.DBExceptionSave multiple job results, which will be viewable in the Obsidian web application, and are available to jobs chained from this one, as well as the REST and Embedded APIs.- Parameters:
name- name of job resultvalues- zero or more values of the same type (type preserved)- Throws:
com.carfey.jdk.db.Database.DBException- any type of database error- Since:
- 2.2
-
-