org.ourgrid.mygrid.scheduler.jobmanager
Class EBJobManager

java.lang.Object
  extended by org.ourgrid.mygrid.scheduler.jobmanager.AbstractJobManager
      extended by org.ourgrid.mygrid.scheduler.jobmanager.EBJobManager
All Implemented Interfaces:
JobManager
Direct Known Subclasses:
FakeJobManager

public class EBJobManager
extends AbstractJobManager

Class responsible for managing the jobs. It maintains a list of all jobs submitted by the user and controls all operations made in these jobs.


Field Summary
protected  java.util.Map<java.lang.Integer,JobEntry> jobs
           
 
Constructor Summary
EBJobManager()
          The constructor.
 
Method Summary
 void addJobInterested(JobInterested jobInterested)
          Adds a new JobInterested.
protected  void addNewJob(int jobId, JobEntry newJob)
           
 void cleanFinishedJobs()
          Clean the list of terminated jobs
 java.util.Collection<JobEntry> clonedJobList()
          Returns a clone of the Job list.
protected  JobEntry createJobEntry(int jobId, JobSpec jobSpec, int maxReplicas, int maxFails)
           
 JobEntry getJobById(int jobId)
          Returns a Job with the specified identification.
 ExecutionStatus getJobState(int jobId)
          Returns the state of the given Job.
 int getMaxFails()
          Gets the number of task replicas allowed to be running at the same time.
 int getMaxReplicas()
          Gets the number of task replicas allowed to be running at the same time.
 java.util.Collection<JobEntry> jobList()
          Returns the Job list.
protected  void realAddJob(int jobId, JobSpec jobSpec)
           
protected  ReplicaEntry realCreateNewReplica(TaskEntry task)
          Creates and returns a new Replica.
protected  void realRemoveJob(int jobId)
           
protected  void realReplicaAborted(ReplicaExecutorResult result)
          Sets the Replica state to aborted.
protected  void realReplicaCanceled(ReplicaExecutorResult result)
          Sets the Replica state to canceled.
protected  void realReplicaFailed(ReplicaExecutorResult result)
          Sets the Replica state to failed.
protected  void realReplicaFinished(ReplicaExecutorResult result)
          Sets the Replica state to finished.
protected  void realReplicaRunning(ReplicaEntry replica, GumID gumID)
           
protected  void realSetCanceled(int jobId)
           
protected  void realShutdown()
           
protected  void setJobList(java.util.Map<java.lang.Integer,JobEntry> newJobList)
           
 void setMaxFails(java.lang.String maxFails)
          Sets the number of failed task replicas until consider the Task itself as failed.
 void setMaxReplicas(java.lang.String maxReplicas)
          Sets the number of task replicas allowed to be running at the same time.
 
Methods inherited from class org.ourgrid.mygrid.scheduler.jobmanager.AbstractJobManager
addJob, addNewListener, createNewReplica, removeJob, removeListener, replicaAborted, replicaCanceled, replicaFailed, replicaFinished, replicaRunning, setCanceled, shutdown
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

jobs

protected java.util.Map<java.lang.Integer,JobEntry> jobs
Constructor Detail

EBJobManager

public EBJobManager()
The constructor.

Method Detail

clonedJobList

public java.util.Collection<JobEntry> clonedJobList()
Returns a clone of the Job list. All objects within this list are clones.

Returns:
A clone of the Job list.

jobList

public java.util.Collection<JobEntry> jobList()
Returns the Job list.

Returns:
The Job list.

addJobInterested

public void addJobInterested(JobInterested jobInterested)
Adds a new JobInterested.

Parameters:
jobInterested - The JobInterested.

realReplicaFinished

protected void realReplicaFinished(ReplicaExecutorResult result)
Sets the Replica state to finished. It also notifies JobInteresteds case it is necessary.

Specified by:
realReplicaFinished in class AbstractJobManager
Parameters:
result - The ReplicaExecutorResult.

realReplicaFailed

protected void realReplicaFailed(ReplicaExecutorResult result)
Sets the Replica state to failed. It also notifies JobInteresteds case it is necessary.

Specified by:
realReplicaFailed in class AbstractJobManager
Parameters:
result - The ReplicaExecutorResult.

realReplicaAborted

protected void realReplicaAborted(ReplicaExecutorResult result)
Sets the Replica state to aborted. It also notifies JobInteresteds case it is necessary.

Specified by:
realReplicaAborted in class AbstractJobManager
Parameters:
result - The ReplicaExecutorResult.

realReplicaCanceled

protected void realReplicaCanceled(ReplicaExecutorResult result)
Sets the Replica state to canceled. It also notifies JobInteresteds case it is necessary.

Specified by:
realReplicaCanceled in class AbstractJobManager
Parameters:
result - The ReplicaExecutorResult.

realReplicaRunning

protected void realReplicaRunning(ReplicaEntry replica,
                                  GumID gumID)
Specified by:
realReplicaRunning in class AbstractJobManager

realCreateNewReplica

protected ReplicaEntry realCreateNewReplica(TaskEntry task)
Creates and returns a new Replica.

Specified by:
realCreateNewReplica in class AbstractJobManager
Returns:
A new Replica in case that a replication is possible to be made, null otherwise.

getJobState

public ExecutionStatus getJobState(int jobId)
Returns the state of the given Job.

Parameters:
jobId - The Job identification
Returns:
The Job state

getJobById

public JobEntry getJobById(int jobId)
Returns a Job with the specified identification.

Parameters:
jobId - The job identification.
Returns:
The specified Job case it exists, null otherwise.

setMaxReplicas

public void setMaxReplicas(java.lang.String maxReplicas)
                    throws ConfigException
Sets the number of task replicas allowed to be running at the same time.

Parameters:
maxReplicas - The number of max replicas
Throws:
ConfigException

getMaxReplicas

public int getMaxReplicas()
Gets the number of task replicas allowed to be running at the same time.

Returns:
The number of max replicas

setMaxFails

public void setMaxFails(java.lang.String maxFails)
                 throws ConfigException
Sets the number of failed task replicas until consider the Task itself as failed.

Parameters:
maxFails - The number of max fails
Throws:
ConfigException

getMaxFails

public int getMaxFails()
Gets the number of task replicas allowed to be running at the same time.

Returns:
The number of max fails

realSetCanceled

protected void realSetCanceled(int jobId)
                        throws JobNotFoundException,
                               JobCouldNotBeCancelledException
Specified by:
realSetCanceled in class AbstractJobManager
Throws:
JobNotFoundException
JobCouldNotBeCancelledException

cleanFinishedJobs

public void cleanFinishedJobs()
Description copied from interface: JobManager
Clean the list of terminated jobs


realRemoveJob

protected void realRemoveJob(int jobId)
                      throws JobCannotBeRemovedException
Specified by:
realRemoveJob in class AbstractJobManager
Throws:
JobCannotBeRemovedException

realAddJob

protected void realAddJob(int jobId,
                          JobSpec jobSpec)
Specified by:
realAddJob in class AbstractJobManager

createJobEntry

protected JobEntry createJobEntry(int jobId,
                                  JobSpec jobSpec,
                                  int maxReplicas,
                                  int maxFails)

addNewJob

protected void addNewJob(int jobId,
                         JobEntry newJob)

setJobList

protected void setJobList(java.util.Map<java.lang.Integer,JobEntry> newJobList)

realShutdown

protected void realShutdown()
Specified by:
realShutdown in class AbstractJobManager