Class AbstractJobUnit
- All Implemented Interfaces:
IJobUnit
IJobUnit
s.
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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
activate()
Activate job.Return factory used for creation of this job unit.getJob()
AssociatedIJob
.System job parameter: logger.getName()
Job name.int
Return requested priority (is taken as an advise forIJob.getPriority()
.getScope()
Job parameter: job scope.Returns associated working directory.int
Return number of ticksIJobUnit.run(IProgressMonitor)
is expected to take.run
(IProgressMonitor progress) Run job.void
Set associatedIJob
.void
System job parameter: logger.void
Job parameter: job scope.void
setWorkDir
(File workDir) System job parameter: working directory.
-
Constructor Details
-
AbstractJobUnit
Constructor.- Parameters:
name
- job namecreator
- job unit creator- Throws:
IllegalArgumentException
- if name isnull
IllegalArgumentException
- if creator isnull
-
-
Method Details
-
getCreator
Description copied from interface:IJobUnit
Return factory used for creation of this job unit.Job unit can not exist without factory.
- Specified by:
getCreator
in interfaceIJobUnit
- Returns:
- factory (not
null
)
-
getName
Description copied from interface:IJobUnit
Job name. -
getJob
Description copied from interface:IJobUnit
AssociatedIJob
.Will be
null
untilIJobManager.spawnJob(IJobUnit, IJob)
is called. -
setJob
Description copied from interface:IJobUnit
Set associatedIJob
. -
activate
Description copied from interface:IJobUnit
Activate 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:
activate
in interfaceIJobUnit
- Throws:
GenericJobException
- if error occurs
-
getWorkLength
public int getWorkLength()Description copied from interface:IJobUnit
Return number of ticksIJobUnit.run(IProgressMonitor)
is expected to take.Allows for precise computation of progress bar.
- Specified by:
getWorkLength
in interfaceIJobUnit
- Returns:
- number of ticks (greater or equal to zero or
IJobUnit.UNKNOWN_WORK_LENGTH
)
-
getPriority
public int getPriority()Description copied from interface:IJobUnit
Return requested priority (is taken as an advise forIJob.getPriority()
.Return zero for "normal" priority.
- Specified by:
getPriority
in interfaceIJobUnit
- Returns:
- requested priority
-
setWorkDir
Description copied from interface:IJobUnit
System 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:
setWorkDir
in interfaceIJobUnit
- Parameters:
workDir
- working directory
-
getWorkDir
Returns associated working directory.- Returns:
- work dir or
null
-
setLogger
Description copied from interface:IJobUnit
System 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:IJobUnit
System job parameter: logger. -
setScope
Description copied from interface:IJobUnit
Job 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:IJobUnit
Job parameter: job scope. -
run
Description copied from interface:IJobUnit
Run 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 ignoretotalWork
parameter 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_CANCELLED
must 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_FAILED
it is recommended to wrap any exception (other than those listed here) as returned status.- Specified by:
run
in interfaceIJobUnit
- Parameters:
progress
- progress monitor to use- Returns:
IJobStatus
(not null)
-