Class AbstractJobUnit
- All Implemented Interfaces:
IJobUnit
IJobUnits.
getWorkLength()returns 0getPriority()returns 0activate()does nothing
- Author:
- Stepan Roh, Polarion Software
-
Field Summary
Fields inherited from interface com.polarion.platform.jobs.IJobUnit
UNKNOWN_WORK_LENGTH -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidactivate()Activate job.Return factory used for creation of this job unit.getJob()AssociatedIJob.System job parameter: logger.getName()Job name.intReturn requested priority (is taken as an advise forIJob.getPriority().getScope()Job parameter: job scope.Returns associated working directory.intReturn number of ticksIJobUnit.run(IProgressMonitor)is expected to take.run(IProgressMonitor progress) Run job.voidSet associatedIJob.voidSystem job parameter: logger.voidJob parameter: job scope.voidsetWorkDir(File workDir) System job parameter: working directory.
-
Constructor Details
-
AbstractJobUnit
Constructor.- Parameters:
name- job namecreator- job unit creator- Throws:
IllegalArgumentException- if name isnullIllegalArgumentException- if creator isnull
-
-
Method Details
-
getCreator
Description copied from interface:IJobUnitReturn factory used for creation of this job unit.Job unit can not exist without factory.
- Specified by:
getCreatorin interfaceIJobUnit- Returns:
- factory (not
null)
-
getName
Description copied from interface:IJobUnitJob name. -
getJob
Description copied from interface:IJobUnitAssociatedIJob.Will be
nulluntilIJobManager.spawnJob(IJobUnit, IJob)is called. -
setJob
Description copied from interface:IJobUnitSet associatedIJob. -
activate
Description copied from interface:IJobUnitActivate job.Implementation should:
- call getJob().addResource() for any resources it wants to lock
- compute work length for getWorkLength()
- spawn jobs which it depends on
No resources which need manual destruction should be allocated.
Throwing exception from this method will stop the scheduling process and no jobs will be run.
- Specified by:
activatein interfaceIJobUnit- Throws:
GenericJobException- if error occurs
-
getWorkLength
public int getWorkLength()Description copied from interface:IJobUnitReturn number of ticksIJobUnit.run(IProgressMonitor)is expected to take.Allows for precise computation of progress bar.
- Specified by:
getWorkLengthin interfaceIJobUnit- Returns:
- number of ticks (greater or equal to zero or
IJobUnit.UNKNOWN_WORK_LENGTH)
-
getPriority
public int getPriority()Description copied from interface:IJobUnitReturn requested priority (is taken as an advise forIJob.getPriority().Return zero for "normal" priority.
- Specified by:
getPriorityin interfaceIJobUnit- Returns:
- requested priority
-
setWorkDir
Description copied from interface:IJobUnitSystem job parameter: working directory.May be shared with other jobs with same root job. Working directory of one root job must be different from working directories of other root jobs.
Set automatically for root job by job manager, must be set manually for jobs with parent.
- Specified by:
setWorkDirin interfaceIJobUnit- Parameters:
workDir- working directory
-
getWorkDir
Returns associated working directory.- Returns:
- work dir or
null
-
setLogger
Description copied from interface:IJobUnitSystem job parameter: logger.Set automatically for all jobs by job manager.
Logger will contain at least all logged events from child jobs when produced (but may contain more).
It is advised to output logged messages to some file in workdir besides other targets.
-
getLogger
Description copied from interface:IJobUnitSystem job parameter: logger. -
setScope
Description copied from interface:IJobUnitJob parameter: job scope.Value of
null(or if it is missing) means both "global scope" and "I don't care" (depends on invoked job). -
getScope
Description copied from interface:IJobUnitJob parameter: job scope. -
run
Description copied from interface:IJobUnitRun job.Method must not return before the job completes its execution even if it handles some work in separate threads.
Children spawned during
IJobUnit.activate()(if this job was given as their parent) will all finish prior to execution of this method.Supplied progress monitor should be prepared for
IJobUnit.getWorkLength()ticks. It will ignoretotalWorkparameter supplied toIProgressMonitor.beginTask(String, int).Returned status may (or may not) be multi-status (or otherwise reflect status) of getJob().getChildren().
If progress monitor is cancelled,
IJobStatus.JobStatusType.STATUS_TYPE_CANCELLEDmust be returned as early as possible.Although job manager will catch any exception thrown from this method and interpret it as
IJobStatus.JobStatusType.STATUS_TYPE_FAILEDit is recommended to wrap any exception (other than those listed here) as returned status.- Specified by:
runin interfaceIJobUnit- Parameters:
progress- progress monitor to use- Returns:
IJobStatus(not null)
-