Lightweight Bartering Grid

lbg.peer.core.xms
Class ExecutionManager

java.lang.Object
  extended by lbg.peer.core.xms.ExecutionManager

public class ExecutionManager
extends java.lang.Object

Author:
Cyril Briquet

Constructor Summary
ExecutionManager(Peer managed_peer, long consumption_timeout)
           
 
Method Summary
 void cancelLocalTaskOnLocalResource(Task t, byte[] logs)
          The managed Peer instructs itself to cancel a Local Task running locally.
 void cancelLocalTaskOnSupplyingResource(java.lang.String supplier_id, Task t)
          Notifies Consumer Peer of the cancellation of target Task on the Supplier Peer.
 void cancelLocalTaskOnSupplyingResource(Task t)
          Notifies Consumer Peer of the cancellation of target Task on the Supplier Peer.
 void cancelSupplyingTaskOnLocalResource(Task t)
          Asks this (Supplier) Peer to cancel target Supplying Task.
 RequestStatus completeLocalTaskOnLocalResource(Task t)
           
 RequestStatus completeLocalTaskOnSupplyingResource(Task t)
           
 RequestStatus completeSupplyingTaskOnLocalResource(Task t)
           
 int countRunningConsumptionTasks()
           
 int countRunningLocalTasks()
           
 int countRunningSupplyingTasks()
           
 double estimateMeanLocalTaskRuntime()
           
 double estimateMeanSelfRuntime()
           
 double estimateMeanSupplierRuntime()
           
 double estimateMeanSupplyingTaskRuntime()
           
 long getCancelledConsumptionTasksCount()
           
 long getCancelledConsumptionTasksTotalRuntime()
           
 long getCancelledLocalTasksCount()
           
 long getCancelledLocalTasksTotalRuntime()
           
 long getCancelledSupplyingTasksCount()
           
 long getCancelledSupplyingTasksTotalRuntime()
           
 long getCompletedConsumptionTasksCount()
           
 long getCompletedConsumptionTasksTotalRuntime()
           
 long getCompletedLocalTasksCount()
           
 long getCompletedLocalTasksTotalRuntime()
           
 long getCompletedSupplyingTasksCount()
           
 long getCompletedSupplyingTasksTotalRuntime()
           
 double getLocalToTotalTasksRatio()
           
 Task getMostRecentlyRunningAndUngracedSupplyingTask()
          Returns the most recently running Supplying Task that has not been graced (useful for PSufferage Resource selection to preempt a running Supplying Task).
 long getRunConsumptionTasksCount()
           
 long getRunLocalTasksCount()
           
 long getRunSupplyingTasksCount()
           
 long getStartTime(Task t, RequestType rt)
          Returns the start time of target Task's execution.
 double getSupplyingToTotalTasksRatio()
           
 RequestType identifyRunningTaskType(Task t)
          Identity running Task type.
 boolean isSupplyingTaskGraced(Task t)
          Identifies if target Supplying Task has been graced
 Task[] listRunningConsumptionTasks()
          Lists running Consumption Tasks, in decreasing order of execution time (longest-running first).
 Task[] listRunningLocalTasks()
          Lists running Local Tasks, in decreasing order of execution time (longest-running first).
 Task[] listRunningSupplyingTasks()
          Lists running Supplying Tasks, in decreasing order of execution time (longest-running first).
 void preemptLocalTaskOnLocalResource(Task t, byte[] logs)
          The managed Peer instructs itself to preempt a Local Task running locally.
 void preemptSupplyingTaskOnLocalResource(Task t, byte[] logs)
          The managed Peer instructs itself to preempt a Supplying Task running locally.
 boolean processTimedOutConsumptionTasks()
          Cancels timed-out Consumption Tasks.
 boolean processTimedOutLocalTasks()
          Cancels timed-out Local Tasks.
 boolean processTimedOutSupplyingTasks()
          Cancels timed-out Supplying Tasks.
 boolean runLocalTaskOnLocalResource(Task t, ResourceHandle rh)
          Runs target Task on target Resource.
 boolean runLocalTaskOnSupplyingResource(Task t, ExternalPeerHandle peer_handle)
          Returns the target Task on target Supplier Peer.
 boolean runSupplyingTaskOnLocalResource(Task t, ResourceHandle rh)
          Runs target Task on target Resource.
 java.lang.String toString()
           
 boolean updateSupplyingTaskTimeOutAction(Task t, boolean do_cancel, long time_out)
          Updates the time-out and action tag associated with the target Supplying Task.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ExecutionManager

public ExecutionManager(Peer managed_peer,
                        long consumption_timeout)
                 throws GridException
Throws:
GridException
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getRunLocalTasksCount

public long getRunLocalTasksCount()

getRunSupplyingTasksCount

public long getRunSupplyingTasksCount()

getRunConsumptionTasksCount

public long getRunConsumptionTasksCount()

getCancelledLocalTasksTotalRuntime

public long getCancelledLocalTasksTotalRuntime()

getCancelledLocalTasksCount

public long getCancelledLocalTasksCount()

getCancelledSupplyingTasksTotalRuntime

public long getCancelledSupplyingTasksTotalRuntime()

getCancelledSupplyingTasksCount

public long getCancelledSupplyingTasksCount()

getCancelledConsumptionTasksTotalRuntime

public long getCancelledConsumptionTasksTotalRuntime()

getCancelledConsumptionTasksCount

public long getCancelledConsumptionTasksCount()

getCompletedLocalTasksTotalRuntime

public long getCompletedLocalTasksTotalRuntime()

getCompletedLocalTasksCount

public long getCompletedLocalTasksCount()

getCompletedSupplyingTasksTotalRuntime

public long getCompletedSupplyingTasksTotalRuntime()

getCompletedSupplyingTasksCount

public long getCompletedSupplyingTasksCount()

getCompletedConsumptionTasksTotalRuntime

public long getCompletedConsumptionTasksTotalRuntime()

getCompletedConsumptionTasksCount

public long getCompletedConsumptionTasksCount()

estimateMeanLocalTaskRuntime

public double estimateMeanLocalTaskRuntime()

estimateMeanSupplyingTaskRuntime

public double estimateMeanSupplyingTaskRuntime()

getLocalToTotalTasksRatio

public double getLocalToTotalTasksRatio()

getSupplyingToTotalTasksRatio

public double getSupplyingToTotalTasksRatio()

estimateMeanSelfRuntime

public double estimateMeanSelfRuntime()

estimateMeanSupplierRuntime

public double estimateMeanSupplierRuntime()

runLocalTaskOnLocalResource

public boolean runLocalTaskOnLocalResource(Task t,
                                           ResourceHandle rh)
                                    throws GridException
Runs target Task on target Resource.

Parameters:
rh - target Resource
t - target Task
Returns:
true if the target Resource can run the target Task, or false if the target Resource cannot run the target Task (e.g. typically because the WorkingSet is too large for the Resource, which would be caused by uncareful scheduling)
Throws:
GridException

runSupplyingTaskOnLocalResource

public boolean runSupplyingTaskOnLocalResource(Task t,
                                               ResourceHandle rh)
                                        throws GridException
Runs target Task on target Resource.

Parameters:
rh - target Resource
t - target Task
Returns:
true if the target Resource can run the target Task, or false if the target Resource cannot run the target Task (e.g. typically because the WorkingSet is too large for the Resource, which would be caused by uncareful scheduling)
Throws:
GridException

runLocalTaskOnSupplyingResource

public boolean runLocalTaskOnSupplyingResource(Task t,
                                               ExternalPeerHandle peer_handle)
                                        throws GridException
Returns the target Task on target Supplier Peer.

Parameters:
t - target Task
peer_handle - target Supplier Peer
Returns:
true if target Supplier Peer has accepted to run target Task
Throws:
GridException - if a parameter is illegal

getStartTime

public long getStartTime(Task t,
                         RequestType rt)
                  throws GridException
Returns the start time of target Task's execution.

Parameters:
t - target Task
Returns:
start time
Throws:
GridException - if a parameter is illegal

updateSupplyingTaskTimeOutAction

public boolean updateSupplyingTaskTimeOutAction(Task t,
                                                boolean do_cancel,
                                                long time_out)
                                         throws GridException
Updates the time-out and action tag associated with the target Supplying Task.

Parameters:
t - target Task
do_cancel - time-out action tag
time_out - time-out
Returns:
true if the time-out and action tag have been updated, or false if they were not updated (i.e. the action tag has already been updated)
Throws:
GridException - if a parameter is illegal

isSupplyingTaskGraced

public boolean isSupplyingTaskGraced(Task t)
                              throws GridException
Identifies if target Supplying Task has been graced

Parameters:
t - target Task
Returns:
true if target Supplying Task has been graced
Throws:
GridException - if a parameter is illegal

getMostRecentlyRunningAndUngracedSupplyingTask

public Task getMostRecentlyRunningAndUngracedSupplyingTask()
                                                    throws GridException
Returns the most recently running Supplying Task that has not been graced (useful for PSufferage Resource selection to preempt a running Supplying Task).

Returns:
most recently running Supplying Task that has not been graced, or null if there is no running Supplying Task ungraced
Throws:
GridException

identifyRunningTaskType

public RequestType identifyRunningTaskType(Task t)
                                    throws GridException
Identity running Task type.

Parameters:
t - target Task
Returns:
running Task type
Throws:
GridException - if a parameter is illegal

completeLocalTaskOnLocalResource

public RequestStatus completeLocalTaskOnLocalResource(Task t)
                                               throws GridException
Throws:
GridException

completeSupplyingTaskOnLocalResource

public RequestStatus completeSupplyingTaskOnLocalResource(Task t)
                                                   throws GridException
Throws:
GridException

completeLocalTaskOnSupplyingResource

public RequestStatus completeLocalTaskOnSupplyingResource(Task t)
                                                   throws GridException
Throws:
GridException

cancelLocalTaskOnLocalResource

public void cancelLocalTaskOnLocalResource(Task t,
                                           byte[] logs)
                                    throws GridException
The managed Peer instructs itself to cancel a Local Task running locally.

Throws:
GridException

preemptLocalTaskOnLocalResource

public void preemptLocalTaskOnLocalResource(Task t,
                                            byte[] logs)
                                     throws GridException
The managed Peer instructs itself to preempt a Local Task running locally.

Note: Task preemption is non-terminating cancellation of a Task.

Throws:
GridException

preemptSupplyingTaskOnLocalResource

public void preemptSupplyingTaskOnLocalResource(Task t,
                                                byte[] logs)
                                         throws GridException
The managed Peer instructs itself to preempt a Supplying Task running locally.

Note: Task preemption is non-terminating cancellation of a Task.

Note: as opposed to the pair of cancelXTaskOnXResource() methods, there is no symmetry for preemptSupplyingTaskOnLocalResource(), because there is no interest to announce delays in Supplying Task execution through preemptLocalTaskOnSupplyingResource().

Throws:
GridException

cancelSupplyingTaskOnLocalResource

public void cancelSupplyingTaskOnLocalResource(Task t)
                                        throws GridException
Asks this (Supplier) Peer to cancel target Supplying Task.

Note: cancelSupplyingTaskOnLocalResource() would be called by this Peer, or by another Peer (through the ExternalPeerHandle).

Note: Task cancellation is terminating cancellation of a Task.

Throws:
GridException

cancelLocalTaskOnSupplyingResource

public void cancelLocalTaskOnSupplyingResource(Task t)
                                        throws GridException
Notifies Consumer Peer of the cancellation of target Task on the Supplier Peer.

Note: cancelLocalTaskOnSupplyingResource() would be called by this Peer, or by another Peer (through the ExternalPeerHandle).

Note: Task cancellation is terminating cancellation of a Task.

Throws:
GridException

cancelLocalTaskOnSupplyingResource

public void cancelLocalTaskOnSupplyingResource(java.lang.String supplier_id,
                                               Task t)
                                        throws GridException
Notifies Consumer Peer of the cancellation of target Task on the Supplier Peer.

Note: cancelLocalTaskOnSupplyingResource() would be called by this Peer, or by another Peer (through the ExternalPeerHandle).

Note: Task cancellation is terminating cancellation of a Task.

Throws:
GridException

processTimedOutConsumptionTasks

public boolean processTimedOutConsumptionTasks()
                                        throws GridException
Cancels timed-out Consumption Tasks.

Returns:
true if at least one Consumption Task has been cancelled
Throws:
GridException

processTimedOutLocalTasks

public boolean processTimedOutLocalTasks()
                                  throws GridException
Cancels timed-out Local Tasks.

Returns:
true if at least one Local Task has been cancelled
Throws:
GridException

processTimedOutSupplyingTasks

public boolean processTimedOutSupplyingTasks()
                                      throws GridException
Cancels timed-out Supplying Tasks.

Returns:
true if at least one Supplying Task has been cancelled
Throws:
GridException

countRunningLocalTasks

public int countRunningLocalTasks()
                           throws GridException
Throws:
GridException

countRunningSupplyingTasks

public int countRunningSupplyingTasks()
                               throws GridException
Throws:
GridException

countRunningConsumptionTasks

public int countRunningConsumptionTasks()
                                 throws GridException
Throws:
GridException

listRunningLocalTasks

public Task[] listRunningLocalTasks()
Lists running Local Tasks, in decreasing order of execution time (longest-running first).

Returns:
running Local Tasks, in decreasing order of execution time

listRunningSupplyingTasks

public Task[] listRunningSupplyingTasks()
Lists running Supplying Tasks, in decreasing order of execution time (longest-running first).

Returns:
running Supplying Tasks, in decreasing order of execution time

listRunningConsumptionTasks

public Task[] listRunningConsumptionTasks()
Lists running Consumption Tasks, in decreasing order of execution time (longest-running first).

Returns:
running Consumption Tasks, in decreasing order of execution time

Lightweight Bartering Grid

Copyright (c) 2005-2008, Cyril Briquet, parts Xavier Dalem.