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.
  1. Create new class, which extends eu.geclipse.core.jobs.GridJobStatus
  2. 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...
  3. If you have longer description of current status, pass to it member: GridJobStatus#reason
  4. 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:
  5. 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: