org.ourgrid.mygrid.scheduler
Class FakeSchedulingHeuristic

java.lang.Object
  extended by org.ourgrid.mygrid.scheduler.FakeSchedulingHeuristic
All Implemented Interfaces:
EBSchedulingHeuristic

public class FakeSchedulingHeuristic
extends java.lang.Object


Field Summary
protected  GridManager gridManager
           
protected  JobManager jobManager
           
 
Constructor Summary
FakeSchedulingHeuristic(JobManager jobManager, GridManager ebGridManager, EBReplicaExecutorFacade ebReplicaExecutorFacade)
           
 
Method Summary
 void addJob(int jobId, JobSpec jobSpec)
          Adds a new Job.
 void cancelJob(int jobId)
          Cancels the given job and put an Event indicating that in the responseQueue.
 void executeReplica(ReplicaEntry replica, GumClient gumClient)
          It clones the replica and sends it to be executed by the ReplicaExecutor.
 GridManager getEBGridManager()
          Returns the EBGridManager.
 JobManager getEBJobManager()
          Returns the EBJobManager.
 ReplicaEntry getLatestScheduledReplica()
           
 int getNumberOfNeededGums(JobSpec jobSpec)
          Returns the number of needed Gums according the Job specification.
protected  java.lang.String getRequirementsOfJob(int jobId)
          Returns a String representing the given job requirements.
protected  java.util.List<TaskEntry> getTasksToScheduleQueue()
          Gets the list of tasks to schedule.
 void newPeersHaveBeenSet()
          Notifies the heuristic that new GridMachineProviders have been set.
 void replicaAborted(ReplicaExecutorResult result)
          Notifies that a task replica has been aborted.
 void replicaCanceled(ReplicaExecutorResult result)
          Notifies that a task replica has canceled.
 void replicaFailed(ReplicaExecutorResult result)
          Notifies that a task replica has failed.
 void replicaFinished(ReplicaExecutorResult result)
          Notifies that a task replica has finished.
 boolean schedule()
          Schedules a task replica to a machine.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

jobManager

protected JobManager jobManager

gridManager

protected GridManager gridManager
Constructor Detail

FakeSchedulingHeuristic

public FakeSchedulingHeuristic(JobManager jobManager,
                               GridManager ebGridManager,
                               EBReplicaExecutorFacade ebReplicaExecutorFacade)
Method Detail

schedule

public boolean schedule()
Description copied from interface: EBSchedulingHeuristic
Schedules a task replica to a machine. Important: only one task replica should be scheduled in call to this method..

Specified by:
schedule in interface EBSchedulingHeuristic
See Also:
EBSchedulingHeuristic.schedule()

getLatestScheduledReplica

public ReplicaEntry getLatestScheduledReplica()

getEBGridManager

public final GridManager getEBGridManager()
Description copied from interface: EBSchedulingHeuristic
Returns the EBGridManager.

Specified by:
getEBGridManager in interface EBSchedulingHeuristic
Returns:
The EBGridManager.
See Also:
EBSchedulingHeuristic.getEBGridManager()

getEBJobManager

public final JobManager getEBJobManager()
Description copied from interface: EBSchedulingHeuristic
Returns the EBJobManager.

Specified by:
getEBJobManager in interface EBSchedulingHeuristic
Returns:
The EBJobManager.
See Also:
EBSchedulingHeuristic.getEBJobManager()

addJob

public void addJob(int jobId,
                   JobSpec jobSpec)
Description copied from interface: EBSchedulingHeuristic
Adds a new Job.

Specified by:
addJob in interface EBSchedulingHeuristic
Parameters:
jobId - The job identification.
jobSpec - The new Job specification.
See Also:
EBSchedulingHeuristic.addJob(int,org.ourgrid.common.spec.JobSpec)

newPeersHaveBeenSet

public void newPeersHaveBeenSet()
Description copied from interface: EBSchedulingHeuristic
Notifies the heuristic that new GridMachineProviders have been set. GridMachines should be requested to the GridMachineProviders.

Specified by:
newPeersHaveBeenSet in interface EBSchedulingHeuristic
See Also:
EBSchedulingHeuristic.newPeersHaveBeenSet()

getNumberOfNeededGums

public int getNumberOfNeededGums(JobSpec jobSpec)
Returns the number of needed Gums according the Job specification.

Parameters:
jobSpec - The Job specification.
Returns:
The number of Gums needed.

executeReplica

public void executeReplica(ReplicaEntry replica,
                           GumClient gumClient)
It clones the replica and sends it to be executed by the ReplicaExecutor. It also sets the replica state to 'Running' and sets the GridMachine as allocated.

Parameters:
replica - The replica to be executed.
gumClient - The GridMachine to execute the replica

replicaFinished

public void replicaFinished(ReplicaExecutorResult result)
Description copied from interface: EBSchedulingHeuristic
Notifies that a task replica has finished.

Specified by:
replicaFinished in interface EBSchedulingHeuristic
Parameters:
result - The ReplicaExecutorResult that contains all information about the replica execution.
See Also:
EBSchedulingHeuristic.replicaFinished(ReplicaExecutorResult)

replicaAborted

public void replicaAborted(ReplicaExecutorResult result)
Description copied from interface: EBSchedulingHeuristic
Notifies that a task replica has been aborted.

Specified by:
replicaAborted in interface EBSchedulingHeuristic
Parameters:
result - The ReplicaExecutorResult that contains all information about the replica execution.
See Also:
EBSchedulingHeuristic.replicaAborted(ReplicaExecutorResult)

replicaCanceled

public void replicaCanceled(ReplicaExecutorResult result)
Description copied from interface: EBSchedulingHeuristic
Notifies that a task replica has canceled.

Specified by:
replicaCanceled in interface EBSchedulingHeuristic
Parameters:
result - The ReplicaExecutorResult that contains all information about the replica execution.
See Also:
EBSchedulingHeuristic.replicaCanceled(ReplicaExecutorResult)

replicaFailed

public void replicaFailed(ReplicaExecutorResult result)
Description copied from interface: EBSchedulingHeuristic
Notifies that a task replica has failed.

Specified by:
replicaFailed in interface EBSchedulingHeuristic
Parameters:
result - The ReplicaExecutorResult that contains all information about the replica execution.
See Also:
By analyzing the cause of a task failure, it is possible to know whether the failure has been provoked by an error in the application or by a machine failure. In the first case, the grid machine has its status set to READY, so it may be used again. In the latter case, the gum entry is removed from the broker's Grid Manager.

cancelJob

public void cancelJob(int jobId)
               throws JobNotFoundException,
                      JobCouldNotBeCancelledException
Description copied from interface: EBSchedulingHeuristic
Cancels the given job and put an Event indicating that in the responseQueue.

Specified by:
cancelJob in interface EBSchedulingHeuristic
Parameters:
jobId - The job identification
Throws:
JobNotFoundException - if asked to cancel an invalid job.
JobCouldNotBeCancelledException
See Also:
EBSchedulingHeuristic.cancelJob(int)

getTasksToScheduleQueue

protected java.util.List<TaskEntry> getTasksToScheduleQueue()
Gets the list of tasks to schedule.

Returns:
The list of tasks to schedule

getRequirementsOfJob

protected java.lang.String getRequirementsOfJob(int jobId)
Returns a String representing the given job requirements.

Parameters:
jobId - The identification of the job to get the requirements
Returns:
The job requirements.