Implementing Job Status Update
Overview
For submitted job user may update status to see if this job is watinging for something, running, finished etc.
Addtionionally in the background g-Eclipse updates periodicaly status of not finished jobs.
To implement updating of job status you have to implement method IGridJobService#getJobStatus() and return object implementing IGridJobStatus.
Implementing IGridJobStatus
The simplest way to implement IGridJobStatus is to use abstract class GridJobStatus, which contains basic functionality like serialization of common job status data.
- Create new class, which extends
eu.geclipse.core.jobs.GridJobStatus
- Create constructor for your class and pass 2 values to constructor of super class: status name, status type
- status name
- String describing shortly current job status in terms of your middleware. So if your middleware has status "FINISHED" instead of "DONE" (like g-eclipse has) just return "FINISHED", which is more familiar for your users.
- status type
- Integer value representing current state of job in term of g-Eclipse states like: IGridJobStatus#RUNNING, IGridJobStatus#DONE...
- If you have longer description of current status, pass to it member: GridJobStatus#reason
- All data passed to super class will be serialized in the workspace (status type, status name and reason).
If you want to serialize more data, override following methods:
String GridJobID#setData(String)
String GridJobID#getData(String)
Example:
public JobStatus( final MiddlewareJobStatus middlewareStatus ) {
super( middlewareStatus.getProcessState(), mapStatus( middlewareStatus ) );
this.reason = middlewareStatus.getAppSpecificStatus();
}
private static int mapStatus( final MiddlewareJobStatus middlewareStatus ) {
int status = IGridJobStatus.RUNNING;
if( !middlewareStatus.getInProgress() ) {
status = middlewareStatustatus.getExitStatus() == 0 ? IGridJobStatus.DONE : IGridJobStatus.ABORTED;
}
return status;
}
Implementing IGridJobService#getJobStatus()
This method should connect with the remote service and check current status of submitted job. Based on returned data new object IGridJobStatus should be created and returned.
Example:
public IGridJobStatus getJobStatus( final IGridJobID id,
final IVirtualOrganization vo,
final boolean fullStatus,
final IProgressMonitor progressMonitor )
throws ProblemException
{
authenticate();
MiddlewareJobStatus middlewareStatus = this.webservice.checkJob( id.getJobID(), fullStatus );
return new JobStatus( middlewareStatus );
}
If you can control how many data remote service will sent during checking job status, then check parameter fullStatus:
- If status is updated in the background, then only basic status information are requested and
fullStatus is false.
- If status is updated by the user's (she/he pressed update button or opened view "Job Details") then all available status data are requested and
fullStatus is true.