org.pentaho.di.job
Class Job

java.lang.Object
  extended by java.lang.Thread
      extended by org.pentaho.di.job.Job
All Implemented Interfaces:
Runnable, HasLogChannelInterface, org.pentaho.di.core.logging.LoggingObjectInterface, org.pentaho.di.core.parameters.NamedParams, org.pentaho.di.core.variables.VariableSpace

public class Job
extends Thread
implements org.pentaho.di.core.variables.VariableSpace, org.pentaho.di.core.parameters.NamedParams, HasLogChannelInterface, org.pentaho.di.core.logging.LoggingObjectInterface

This class executes a JobInfo object.

Since:
07-apr-2003
Author:
Matt Casters

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
static String CONFIGURATION_IN_EXPORT_FILENAME
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
Job()
          Empty constructor, for Class.newInstance()
Job(Repository repository, JobMeta jobMeta)
           
Job(Repository repository, JobMeta jobMeta, org.pentaho.di.core.logging.LoggingObjectInterface parentLogging)
           
Job(String name, String file, String[] args)
           
 
Method Summary
 void activateParameters()
           
 void addErrors(int nrToAdd)
          Add a number of errors to the total number of erros that occured during execution.
 void addJobEntryListener(JobEntryListener jobEntryListener)
           
 void addJobListener(JobListener jobListener)
          Add a job listener to the job
 void addParameterDefinition(String key, String defValue, String description)
           
 boolean beginProcessing()
          Handle logging at start
 void clearParameters()
           
 void copyParametersFrom(org.pentaho.di.core.parameters.NamedParams params)
           
 void copyVariablesFrom(org.pentaho.di.core.variables.VariableSpace space)
           
static Job createJobWithNewClassLoader()
           
 String environmentSubstitute(String aString)
           
 String[] environmentSubstitute(String[] aString)
           
 void eraseParameters()
           
 org.pentaho.di.core.Result execute(int nr, org.pentaho.di.core.Result result)
          Execute a job with previous results passed in.

Execute called by JobEntryJob: don't clear the jobEntryResults.
 void fireJobListeners()
          Sets the finished flag. Then launch all the job listeners and call the jobFinished method for each.
 Map<JobEntryCopy,JobEntryJob> getActiveJobEntryJobs()
           
 Map<JobEntryCopy,JobEntryTrans> getActiveJobEntryTransformations()
           
 long getBatchId()
           
 boolean getBooleanValueOfVariable(String variableName, boolean defaultValue)
           
 String getContainerObjectId()
           
 Date getCurrentDate()
           
 Date getDepDate()
           
 Date getEndDate()
           
 int getErrors()
          Get the number of errors that happened in the job.
 String getFilename()
           
 List<JobEntryListener> getJobEntryListeners()
           
 List<JobEntryResult> getJobEntryResults()
           
 List<JobListener> getJobListeners()
           
 JobMeta getJobMeta()
           
 String getJobname()
           
 JobTracker getJobTracker()
           
 org.pentaho.di.core.logging.LogChannelInterface getLogChannel()
           
 String getLogChannelId()
           
 Date getLogDate()
           
 List<org.pentaho.di.core.logging.LoggingHierarchy> getLoggingHierarchy()
           
 org.pentaho.di.core.logging.LogLevel getLogLevel()
           
 String getObjectCopy()
           
 org.pentaho.di.repository.ObjectId getObjectId()
           
 String getObjectName()
           
 org.pentaho.di.repository.ObjectRevision getObjectRevision()
           
 org.pentaho.di.core.logging.LoggingObjectType getObjectType()
           
 String getParameterDefault(String key)
           
 String getParameterDescription(String key)
           
 String getParameterValue(String key)
           
 org.pentaho.di.core.logging.LoggingObjectInterface getParent()
           
 Job getParentJob()
           
 org.pentaho.di.core.logging.LoggingObjectInterface getParentLoggingObject()
           
 org.pentaho.di.core.variables.VariableSpace getParentVariableSpace()
           
 long getPassedBatchId()
           
 Date getRegistrationDate()
          Stub
 Repository getRep()
           
 org.pentaho.di.repository.RepositoryDirectoryInterface getRepositoryDirectory()
           
 org.pentaho.di.core.Result getResult()
           
 SocketRepository getSocketRepository()
           
 List<org.pentaho.di.core.RowMetaAndData> getSourceRows()
           
 Date getStartDate()
           
 JobEntryCopy getStartJobEntryCopy()
           
 String getStatus()
           
 Thread getThread()
           
 String getVariable(String variableName)
           
 String getVariable(String variableName, String defaultValue)
           
 void init()
           
 void initializeVariablesFrom(org.pentaho.di.core.variables.VariableSpace parent)
           
 void injectVariables(Map<String,String> prop)
           
 boolean isActive()
           
 boolean isFinished()
           
 boolean isInitialized()
           
 boolean isInteractive()
           
 boolean isStopped()
           
 String[] listParameters()
           
 String[] listVariables()
           
 void removeJobEntryListener(JobEntryListener jobEntryListener)
          Remove a job entry listener from the job
 void removeJobListener(JobListener jobListener)
          Remove a job listener from the job
 void resetErrors()
          Set the number of occured errors to 0.
 void run()
           
static String sendToSlaveServer(JobMeta jobMeta, JobExecutionConfiguration executionConfiguration, Repository repository)
           
 void setBatchId(long batchId)
           
 void setContainerObjectId(String containerObjectId)
           
 void setFinished(boolean finished)
           
 void setInteractive(boolean interactive)
           
 void setInternalKettleVariables(org.pentaho.di.core.variables.VariableSpace var)
           
 void setJobTracker(JobTracker jobTracker)
           
 void setLogLevel(org.pentaho.di.core.logging.LogLevel logLevel)
           
 void setParameterValue(String key, String value)
           
 void setParentJob(Job parentJob)
           
 void setParentVariableSpace(org.pentaho.di.core.variables.VariableSpace parent)
           
 void setPassedBatchId(long jobBatchId)
           
 void setRepository(Repository rep)
           
 void setResult(org.pentaho.di.core.Result result)
           
 void setSocketRepository(SocketRepository socketRepository)
           
 void setSourceRows(List<org.pentaho.di.core.RowMetaAndData> sourceRows)
           
 void setStartJobEntryCopy(JobEntryCopy startJobEntryCopy)
           
 void setStopped(boolean stopped)
           
 void setVariable(String variableName, String variableValue)
           
 void shareVariablesWith(org.pentaho.di.core.variables.VariableSpace space)
           
 void stopAll()
           
 String toString()
           
 void waitUntilFinished()
          Wait until this job has finished.
 void waitUntilFinished(long maxMiliseconds)
          Wait until this job has finished.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, yield
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CONFIGURATION_IN_EXPORT_FILENAME

public static final String CONFIGURATION_IN_EXPORT_FILENAME
See Also:
Constant Field Values
Constructor Detail

Job

public Job(String name,
           String file,
           String[] args)

Job

public Job(Repository repository,
           JobMeta jobMeta)

Job

public Job(Repository repository,
           JobMeta jobMeta,
           org.pentaho.di.core.logging.LoggingObjectInterface parentLogging)

Job

public Job()
Empty constructor, for Class.newInstance()

Method Detail

init

public void init()

toString

public String toString()
Overrides:
toString in class Thread

createJobWithNewClassLoader

public static final Job createJobWithNewClassLoader()
                                             throws org.pentaho.di.core.exception.KettleException
Throws:
org.pentaho.di.core.exception.KettleException

getJobname

public String getJobname()

setRepository

public void setRepository(Repository rep)

run

public void run()
Specified by:
run in interface Runnable
Overrides:
run in class Thread

execute

public org.pentaho.di.core.Result execute(int nr,
                                          org.pentaho.di.core.Result result)
                                   throws org.pentaho.di.core.exception.KettleException
Execute a job with previous results passed in.

Execute called by JobEntryJob: don't clear the jobEntryResults.

Parameters:
nr - The job entry number
result - the result of the previous execution
Returns:
Result of the job execution
Throws:
org.pentaho.di.core.exception.KettleJobException
org.pentaho.di.core.exception.KettleException

fireJobListeners

public void fireJobListeners()
                      throws org.pentaho.di.core.exception.KettleException
Sets the finished flag. Then launch all the job listeners and call the jobFinished method for each.

Throws:
org.pentaho.di.core.exception.KettleException
See Also:
JobListener.jobFinished(Job)

waitUntilFinished

public void waitUntilFinished()
Wait until this job has finished.


waitUntilFinished

public void waitUntilFinished(long maxMiliseconds)
Wait until this job has finished.

Parameters:
maxMiliseconds - the maximum number of ms to wait

getErrors

public int getErrors()
Get the number of errors that happened in the job.

Returns:
nr of error that have occurred during execution. During execution of a job the number can change.

resetErrors

public void resetErrors()
Set the number of occured errors to 0.


addErrors

public void addErrors(int nrToAdd)
Add a number of errors to the total number of erros that occured during execution.

Parameters:
nrToAdd - nr of errors to add.

beginProcessing

public boolean beginProcessing()
                        throws org.pentaho.di.core.exception.KettleException
Handle logging at start

Returns:
true if it went OK.
Throws:
org.pentaho.di.core.exception.KettleException

isActive

public boolean isActive()

stopAll

public void stopAll()

setStopped

public void setStopped(boolean stopped)

isStopped

public boolean isStopped()
Returns:
Returns the stopped status of this Job...

getStartDate

public Date getStartDate()
Returns:
Returns the startDate.

getEndDate

public Date getEndDate()
Returns:
Returns the endDate.

getCurrentDate

public Date getCurrentDate()
Returns:
Returns the currentDate.

getDepDate

public Date getDepDate()
Returns:
Returns the depDate.

getLogDate

public Date getLogDate()
Returns:
Returns the logDate.

getJobMeta

public JobMeta getJobMeta()
Returns:
Returns the jobinfo.

getRep

public Repository getRep()
Returns:
Returns the rep.

getThread

public Thread getThread()

getJobTracker

public JobTracker getJobTracker()
Returns:
Returns the jobTracker.

setJobTracker

public void setJobTracker(JobTracker jobTracker)
Parameters:
jobTracker - The jobTracker to set.

setSourceRows

public void setSourceRows(List<org.pentaho.di.core.RowMetaAndData> sourceRows)

getSourceRows

public List<org.pentaho.di.core.RowMetaAndData> getSourceRows()

getParentJob

public Job getParentJob()
Returns:
Returns the parentJob.

setParentJob

public void setParentJob(Job parentJob)
Parameters:
parentJob - The parentJob to set.

getResult

public org.pentaho.di.core.Result getResult()

setResult

public void setResult(org.pentaho.di.core.Result result)

isInitialized

public boolean isInitialized()
Returns:
Returns the initialized.

getBatchId

public long getBatchId()
Returns:
Returns the batchId.

setBatchId

public void setBatchId(long batchId)
Parameters:
batchId - The batchId to set.

getPassedBatchId

public long getPassedBatchId()
Returns:
the jobBatchId

setPassedBatchId

public void setPassedBatchId(long jobBatchId)
Parameters:
jobBatchId - the jobBatchId to set

setInternalKettleVariables

public void setInternalKettleVariables(org.pentaho.di.core.variables.VariableSpace var)

copyVariablesFrom

public void copyVariablesFrom(org.pentaho.di.core.variables.VariableSpace space)
Specified by:
copyVariablesFrom in interface org.pentaho.di.core.variables.VariableSpace

environmentSubstitute

public String environmentSubstitute(String aString)
Specified by:
environmentSubstitute in interface org.pentaho.di.core.variables.VariableSpace

environmentSubstitute

public String[] environmentSubstitute(String[] aString)
Specified by:
environmentSubstitute in interface org.pentaho.di.core.variables.VariableSpace

getParentVariableSpace

public org.pentaho.di.core.variables.VariableSpace getParentVariableSpace()
Specified by:
getParentVariableSpace in interface org.pentaho.di.core.variables.VariableSpace

setParentVariableSpace

public void setParentVariableSpace(org.pentaho.di.core.variables.VariableSpace parent)
Specified by:
setParentVariableSpace in interface org.pentaho.di.core.variables.VariableSpace

getVariable

public String getVariable(String variableName,
                          String defaultValue)
Specified by:
getVariable in interface org.pentaho.di.core.variables.VariableSpace

getVariable

public String getVariable(String variableName)
Specified by:
getVariable in interface org.pentaho.di.core.variables.VariableSpace

getBooleanValueOfVariable

public boolean getBooleanValueOfVariable(String variableName,
                                         boolean defaultValue)
Specified by:
getBooleanValueOfVariable in interface org.pentaho.di.core.variables.VariableSpace

initializeVariablesFrom

public void initializeVariablesFrom(org.pentaho.di.core.variables.VariableSpace parent)
Specified by:
initializeVariablesFrom in interface org.pentaho.di.core.variables.VariableSpace

listVariables

public String[] listVariables()
Specified by:
listVariables in interface org.pentaho.di.core.variables.VariableSpace

setVariable

public void setVariable(String variableName,
                        String variableValue)
Specified by:
setVariable in interface org.pentaho.di.core.variables.VariableSpace

shareVariablesWith

public void shareVariablesWith(org.pentaho.di.core.variables.VariableSpace space)
Specified by:
shareVariablesWith in interface org.pentaho.di.core.variables.VariableSpace

injectVariables

public void injectVariables(Map<String,String> prop)
Specified by:
injectVariables in interface org.pentaho.di.core.variables.VariableSpace

getStatus

public String getStatus()

sendToSlaveServer

public static String sendToSlaveServer(JobMeta jobMeta,
                                       JobExecutionConfiguration executionConfiguration,
                                       Repository repository)
                                throws org.pentaho.di.core.exception.KettleException
Throws:
org.pentaho.di.core.exception.KettleException

addJobListener

public void addJobListener(JobListener jobListener)
Add a job listener to the job

Parameters:
jobListener - the job listener to add

addJobEntryListener

public void addJobEntryListener(JobEntryListener jobEntryListener)

removeJobListener

public void removeJobListener(JobListener jobListener)
Remove a job listener from the job

Parameters:
jobListener - the job listener to remove

removeJobEntryListener

public void removeJobEntryListener(JobEntryListener jobEntryListener)
Remove a job entry listener from the job

Parameters:
jobListener - the job entry listener to remove

getJobEntryListeners

public List<JobEntryListener> getJobEntryListeners()

getJobListeners

public List<JobListener> getJobListeners()

isFinished

public boolean isFinished()
Returns:
the finished

setFinished

public void setFinished(boolean finished)
Parameters:
finished - the finished to set

addParameterDefinition

public void addParameterDefinition(String key,
                                   String defValue,
                                   String description)
                            throws org.pentaho.di.core.parameters.DuplicateParamException
Specified by:
addParameterDefinition in interface org.pentaho.di.core.parameters.NamedParams
Throws:
org.pentaho.di.core.parameters.DuplicateParamException

getParameterDescription

public String getParameterDescription(String key)
                               throws org.pentaho.di.core.parameters.UnknownParamException
Specified by:
getParameterDescription in interface org.pentaho.di.core.parameters.NamedParams
Throws:
org.pentaho.di.core.parameters.UnknownParamException

getParameterDefault

public String getParameterDefault(String key)
                           throws org.pentaho.di.core.parameters.UnknownParamException
Specified by:
getParameterDefault in interface org.pentaho.di.core.parameters.NamedParams
Throws:
org.pentaho.di.core.parameters.UnknownParamException

getParameterValue

public String getParameterValue(String key)
                         throws org.pentaho.di.core.parameters.UnknownParamException
Specified by:
getParameterValue in interface org.pentaho.di.core.parameters.NamedParams
Throws:
org.pentaho.di.core.parameters.UnknownParamException

listParameters

public String[] listParameters()
Specified by:
listParameters in interface org.pentaho.di.core.parameters.NamedParams

setParameterValue

public void setParameterValue(String key,
                              String value)
                       throws org.pentaho.di.core.parameters.UnknownParamException
Specified by:
setParameterValue in interface org.pentaho.di.core.parameters.NamedParams
Throws:
org.pentaho.di.core.parameters.UnknownParamException

eraseParameters

public void eraseParameters()
Specified by:
eraseParameters in interface org.pentaho.di.core.parameters.NamedParams

clearParameters

public void clearParameters()
Specified by:
clearParameters in interface org.pentaho.di.core.parameters.NamedParams

activateParameters

public void activateParameters()
Specified by:
activateParameters in interface org.pentaho.di.core.parameters.NamedParams

copyParametersFrom

public void copyParametersFrom(org.pentaho.di.core.parameters.NamedParams params)
Specified by:
copyParametersFrom in interface org.pentaho.di.core.parameters.NamedParams

setSocketRepository

public void setSocketRepository(SocketRepository socketRepository)

getSocketRepository

public SocketRepository getSocketRepository()

getLogChannel

public org.pentaho.di.core.logging.LogChannelInterface getLogChannel()
Specified by:
getLogChannel in interface HasLogChannelInterface

getObjectName

public String getObjectName()
Specified by:
getObjectName in interface org.pentaho.di.core.logging.LoggingObjectInterface

getObjectCopy

public String getObjectCopy()
Specified by:
getObjectCopy in interface org.pentaho.di.core.logging.LoggingObjectInterface

getFilename

public String getFilename()
Specified by:
getFilename in interface org.pentaho.di.core.logging.LoggingObjectInterface

getLogChannelId

public String getLogChannelId()
Specified by:
getLogChannelId in interface org.pentaho.di.core.logging.LoggingObjectInterface

getObjectId

public org.pentaho.di.repository.ObjectId getObjectId()
Specified by:
getObjectId in interface org.pentaho.di.core.logging.LoggingObjectInterface

getObjectRevision

public org.pentaho.di.repository.ObjectRevision getObjectRevision()
Specified by:
getObjectRevision in interface org.pentaho.di.core.logging.LoggingObjectInterface

getObjectType

public org.pentaho.di.core.logging.LoggingObjectType getObjectType()
Specified by:
getObjectType in interface org.pentaho.di.core.logging.LoggingObjectInterface

getParent

public org.pentaho.di.core.logging.LoggingObjectInterface getParent()
Specified by:
getParent in interface org.pentaho.di.core.logging.LoggingObjectInterface

getRepositoryDirectory

public org.pentaho.di.repository.RepositoryDirectoryInterface getRepositoryDirectory()
Specified by:
getRepositoryDirectory in interface org.pentaho.di.core.logging.LoggingObjectInterface

getLogLevel

public org.pentaho.di.core.logging.LogLevel getLogLevel()
Specified by:
getLogLevel in interface org.pentaho.di.core.logging.LoggingObjectInterface

setLogLevel

public void setLogLevel(org.pentaho.di.core.logging.LogLevel logLevel)

getLoggingHierarchy

public List<org.pentaho.di.core.logging.LoggingHierarchy> getLoggingHierarchy()

isInteractive

public boolean isInteractive()
Returns:
the interactive

setInteractive

public void setInteractive(boolean interactive)
Parameters:
interactive - the interactive to set

getActiveJobEntryTransformations

public Map<JobEntryCopy,JobEntryTrans> getActiveJobEntryTransformations()
Returns:
the activeJobEntryTransformations

getActiveJobEntryJobs

public Map<JobEntryCopy,JobEntryJob> getActiveJobEntryJobs()
Returns:
the activeJobEntryJobs

getJobEntryResults

public List<JobEntryResult> getJobEntryResults()
Returns:
A flat list of results in THIS job, in the order of execution of job entries

getContainerObjectId

public String getContainerObjectId()
Specified by:
getContainerObjectId in interface org.pentaho.di.core.logging.LoggingObjectInterface
Returns:
the carteObjectId

setContainerObjectId

public void setContainerObjectId(String containerObjectId)
Parameters:
containerObjectId - the execution container object id to set

getParentLoggingObject

public org.pentaho.di.core.logging.LoggingObjectInterface getParentLoggingObject()

getRegistrationDate

public Date getRegistrationDate()
Stub

Specified by:
getRegistrationDate in interface org.pentaho.di.core.logging.LoggingObjectInterface

getStartJobEntryCopy

public JobEntryCopy getStartJobEntryCopy()
Returns:
the startJobEntryCopy

setStartJobEntryCopy

public void setStartJobEntryCopy(JobEntryCopy startJobEntryCopy)
Parameters:
startJobEntryCopy - the startJobEntryCopy to set