org.ourgrid.mygrid.scheduler.jobmanager
Class JobEntry

java.lang.Object
  extended by org.ourgrid.mygrid.scheduler.jobmanager.JobEntry
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
FakeScheduler.FakeJob

public class JobEntry
extends java.lang.Object
implements java.io.Serializable

The Job is an abstraction representing a set of tasks that the user requested to be executed.

See Also:
Serialized Form

Field Summary
protected  java.util.List<TaskEntry> tasks
          All job's tasks.
 
Constructor Summary
JobEntry(int jobId, JobSpec jobSpec, int maxReplicas, int maxFails)
          This method constructs a new e constructor.
 
Method Summary
protected  TaskEntry createTaskEntry(TaskSpec taskSpec, int nextTaskId, int id, int maxTaskFails, int maxTaskReplicas)
           
protected  java.util.List<TaskEntry> createTasks(java.util.List<TaskSpec> taskSpecs)
          Creates the job's tasks according the specification.
 java.util.List<TaskEntry> getAvailableTasks()
          Returns the Job's available Tasks.
 int getId()
          Returns the job identification.
 JobSpec getJobSpec()
           
 java.lang.String getLabel()
          Returns the job label.
protected  ReplicaEntry getNewReplica(TaskEntry task)
          Creates and returns a new Replica.
 java.lang.String getRequirements()
          Returns the job requirements expression.
 ExecutionStatus getStatus()
          Returns the Job state according its Tasks' states.
 TaskEntry getTaskById(int taskId)
          Returns a Task by its identification.
 java.util.List<TaskEntry> getTasks()
          Returns the Job'sTasks.
protected  void replicaAborted(ReplicaExecutorResult result)
          Sets the replica contained in the ReplicaExecutorResult to the aborted state.
protected  void replicaCancelled(ReplicaExecutorResult result)
          Sets the replica contained in the ReplicaExecutorResult to the canceled state.
protected  void replicaFailed(ReplicaExecutorResult result)
          Sets the replica contained in the ReplicaExecutorResult to the failed state.
protected  void replicaFinished(ReplicaExecutorResult result)
          Sets the replica contained in the ReplicaExecutorResult to the finished state.
protected  void setCancelled()
          Sets the job as canceled.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tasks

protected java.util.List<TaskEntry> tasks
All job's tasks.

Constructor Detail

JobEntry

public JobEntry(int jobId,
                JobSpec jobSpec,
                int maxReplicas,
                int maxFails)
This method constructs a new e constructor.

Parameters:
jobId - The Job identification.
jobSpec - The job specification.
Method Detail

createTasks

protected java.util.List<TaskEntry> createTasks(java.util.List<TaskSpec> taskSpecs)
Creates the job's tasks according the specification.

Parameters:
taskSpecs - A list containing TasksSpecs.
Returns:
A list of Tasks.

createTaskEntry

protected TaskEntry createTaskEntry(TaskSpec taskSpec,
                                    int nextTaskId,
                                    int id,
                                    int maxTaskFails,
                                    int maxTaskReplicas)

getId

public int getId()
Returns the job identification.

Returns:
The job identification.

replicaFinished

protected void replicaFinished(ReplicaExecutorResult result)
Sets the replica contained in the ReplicaExecutorResult to the finished state.

Parameters:
result - The ReplicaExecutorResult.

replicaFailed

protected void replicaFailed(ReplicaExecutorResult result)
Sets the replica contained in the ReplicaExecutorResult to the failed state.

Parameters:
result - The ReplicaExecutorResult.

replicaAborted

protected void replicaAborted(ReplicaExecutorResult result)
Sets the replica contained in the ReplicaExecutorResult to the aborted state.

Parameters:
result - The ReplicaExecutorResult.

replicaCancelled

protected void replicaCancelled(ReplicaExecutorResult result)
Sets the replica contained in the ReplicaExecutorResult to the canceled state.

Parameters:
result - The ReplicaExecutorResult.

setCancelled

protected void setCancelled()
Sets the job as canceled.


getTaskById

public TaskEntry getTaskById(int taskId)
Returns a Task by its identification.

Parameters:
taskId - The Task's identification.
Returns:
A Task with the specified identification

getStatus

public ExecutionStatus getStatus()
Returns the Job state according its Tasks' states.

Returns:
The Job state.

getTasks

public java.util.List<TaskEntry> getTasks()
Returns the Job'sTasks.

Returns:
A List containing all the Tasks.

getNewReplica

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

Returns:
A new Replica in case that a replication is possible to be made, null otherwise.

getAvailableTasks

public java.util.List<TaskEntry> getAvailableTasks()
Returns the Job's available Tasks. If a task can be replicated, it is included in this list.

Returns:
A List containing all available Task s.

getJobSpec

public JobSpec getJobSpec()

getRequirements

public java.lang.String getRequirements()
Returns the job requirements expression.

Returns:
The job requirements expression.

getLabel

public java.lang.String getLabel()
Returns the job label.

Returns:
The label