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, 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

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()
           
Job(org.pentaho.di.core.logging.LogWriter lw, Repository rep, JobMeta ti)
           
Job(org.pentaho.di.core.logging.LogWriter lw, StepLoader steploader, Repository rep, JobMeta ti)
           
Job(org.pentaho.di.core.logging.LogWriter lw, 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 addJobListener(JobListener jobListener)
          Add a job listener to the job
 void addParameterDefinition(String key, String defValue, String description)
           
 boolean beginProcessing()
           
 void clearParameters()
           
 void copyParametersFrom(org.pentaho.di.core.parameters.NamedParams params)
           
 void copyVariablesFrom(org.pentaho.di.core.variables.VariableSpace space)
           
static Job createJobWithNewClassLoader()
           
 boolean endProcessing(String status, org.pentaho.di.core.Result res)
           
 String environmentSubstitute(String aString)
           
 String[] environmentSubstitute(String[] aString)
           
 void eraseParameters()
           
 org.pentaho.di.core.Result execute()
          Execute a job without previous results.
 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.
 long getBatchId()
           
 boolean getBooleanValueOfVariable(String variableName, boolean defaultValue)
           
 Date getCurrentDate()
           
 Date getDepDate()
           
 Date getEndDate()
           
 int getErrors()
          Get the number of errors that happened in the job.
 List<JobListener> getJobListeners()
           
 JobMeta getJobMeta()
           
 String getJobname()
           
 JobTracker getJobTracker()
           
 org.pentaho.di.core.logging.LogWriter getLog()
           
 Date getLogDate()
           
 String getParameterDefault(String key)
           
 String getParameterDescription(String key)
           
 String getParameterValue(String key)
           
 Job getParentJob()
           
 org.pentaho.di.core.variables.VariableSpace getParentVariableSpace()
           
 long getPassedBatchId()
           
 Repository getRep()
           
 org.pentaho.di.core.Result getResult()
           
 SocketRepository getSocketRepository()
           
 List<org.pentaho.di.core.RowMetaAndData> getSourceRows()
           
 Date getStartDate()
           
 String getStatus()
           
 Thread getThread()
           
 String getVariable(String variableName)
           
 String getVariable(String variableName, String defaultValue)
           
 void init(org.pentaho.di.core.logging.LogWriter lw, String name, String file, String[] args)
           
 void initializeVariablesFrom(org.pentaho.di.core.variables.VariableSpace parent)
           
 void injectVariables(Map<String,String> prop)
           
 boolean isActive()
           
 boolean isFinished()
           
 boolean isInitialized()
           
 boolean isStopped()
           
 String[] listParameters()
           
 String[] listVariables()
           
 void open(org.pentaho.di.core.logging.LogWriter lw, Repository rep, JobMeta ti)
           
 void open(org.pentaho.di.core.logging.LogWriter lw, StepLoader steploader, Repository rep, JobMeta ti)
           
 void open(Repository rep, String fname, String jobname, String dirname, org.pentaho.di.core.gui.OverwritePrompter prompter)
           
 void resetErrors()
          Set the number of occured errors to 0.
 void run()
           
static void sendToSlaveServer(JobMeta jobMeta, JobExecutionConfiguration executionConfiguration, Repository repository)
           
 void setBatchId(long batchId)
           
 void setFinished(boolean finished)
           
 void setInternalKettleVariables(org.pentaho.di.core.variables.VariableSpace var)
           
 void setJobListeners(List<JobListener> jobListeners)
           
 void setJobTracker(JobTracker jobTracker)
           
 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 setStopped(boolean stopped)
           
 void setVariable(String variableName, String variableValue)
           
 void shareVariablesWith(org.pentaho.di.core.variables.VariableSpace space)
           
 void stopAll()
           
 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, toString, 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(org.pentaho.di.core.logging.LogWriter lw,
           String name,
           String file,
           String[] args)

Job

public Job(org.pentaho.di.core.logging.LogWriter lw,
           StepLoader steploader,
           Repository rep,
           JobMeta ti)

Job

public Job(org.pentaho.di.core.logging.LogWriter lw,
           Repository rep,
           JobMeta ti)

Job

public Job()
Method Detail

init

public void init(org.pentaho.di.core.logging.LogWriter lw,
                 String name,
                 String file,
                 String[] args)

open

public void open(org.pentaho.di.core.logging.LogWriter lw,
                 Repository rep,
                 JobMeta ti)

open

public void open(org.pentaho.di.core.logging.LogWriter lw,
                 StepLoader steploader,
                 Repository rep,
                 JobMeta ti)

open

public void open(Repository rep,
                 String fname,
                 String jobname,
                 String dirname,
                 org.pentaho.di.core.gui.OverwritePrompter prompter)
          throws org.pentaho.di.core.exception.KettleException
Throws:
org.pentaho.di.core.exception.KettleException

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()
                                   throws org.pentaho.di.core.exception.KettleException
Execute a job without previous results. This is a job entry point (not recursive)
Fire the job listeners at the end.

Returns:
the result of the execution
Throws:
org.pentaho.di.core.exception.KettleException

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

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.KettleJobException
Throws:
org.pentaho.di.core.exception.KettleJobException

endProcessing

public boolean endProcessing(String status,
                             org.pentaho.di.core.Result res)
                      throws org.pentaho.di.core.exception.KettleJobException
Throws:
org.pentaho.di.core.exception.KettleJobException

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.

getLog

public org.pentaho.di.core.logging.LogWriter getLog()
Returns:
Returns the log.

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 void sendToSlaveServer(JobMeta jobMeta,
                                     JobExecutionConfiguration executionConfiguration,
                                     Repository repository)
                              throws org.pentaho.di.core.exception.KettleException
Throws:
org.pentaho.di.core.exception.KettleException

getJobListeners

public List<JobListener> getJobListeners()
Returns:
the jobListeners

setJobListeners

public void setJobListeners(List<JobListener> jobListeners)
Parameters:
jobListeners - the jobListeners to set

addJobListener

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

Parameters:
jobListener - the job listener to add

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()