Package org.jppf.execute
Class AbstractExecutionManager
java.lang.Object
org.jppf.execute.AbstractExecutionManager
- All Implemented Interfaces:
ExecutionManager
Instances of this class manage the execution of JPPF tasks by a node.
- Author:
- Laurent Cohen, Martin JANDA, Paul Woodward
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AtomicLongThe total accumulated elapsed time of the tasks in the current bundle.protected TaskBundleThe bundle whose tasks are currently being executed.protected final AtomicBooleanDetermines whether the number of threads or their priority has changed.protected DataProviderThe data provider for the current job.protected AtomicBooleanDetermines whether the current job has been cancelled.protected AtomicReference<JPPFReconnectionNotification>Set if the node must reconnect to the driver.The list of tasks to execute.protected final TaskExecutionDispatcherDispatches tasks notifications to registered listeners.protected List<NodeTaskWrapper>Holds the tasks submitted to the executor.protected final ThreadManagerThe thread manager that is used for execution.protected final JPPFScheduleHandlerTimer managing the tasks timeout.protected ThreadManager.UsedClassLoaderThe class loader used to load the tasks and the classes they need from the client.The uuid path of the current bundle. -
Constructor Summary
ConstructorsConstructorDescriptionAbstractExecutionManager(TypedProperties config, JPPFProperty<Integer> nbThreadsProperty) Initialize this execution manager with the specified node. -
Method Summary
Modifier and TypeMethodDescriptionvoidcancelAllTasks(boolean callOnCancel, boolean requeue) Cancel all executing or pending tasks.booleanDetermines whether the configuration has changed and resets the flag if it has.protected abstract voidcleanup()Cleanup method invoked when all tasks for the current bundle have completed.voidexecute(TaskBundle bundle, List<Task<?>> taskList) Execute the specified tasks of the specified tasks bundle.Get the bundle whose tasks are currently being executed.Get the id of the job currently being executed.Get the job name.Get the executor used by this execution manager.Get the object which dispatches tasks notifications to registered listeners.Get the thread manager for this node.intGet the size of the node's thread pool.intGet the priority assigned to the execution threads.booleanDetermine whether the current job has been cancelled, including before starting its execution.voidsetBundle(TaskBundle bundle) Set the bundle whose tasks are currently being executed.voidsetJobCancelled(boolean jobCancelled) Specify whether the current job has been cancelled, including before starting its execution.voidsetThreadPoolSize(int size) Set the size of the node's thread pool.protected abstract voidsetup(TaskBundle bundle, List<Task<?>> taskList) Prepare this execution manager for executing the tasks of a bundle.voidshutdown()Shutdown this execution manager.protected voidtaskEnded(NodeTaskWrapper taskWrapper) Notification sent by a node task wrapper when a task is complete.voidTrigger the configuration changed flag.voidupdateThreadsPriority(int newPriority) Update the priority of all execution threads.
-
Field Details
-
timeoutHandler
Timer managing the tasks timeout. -
bundle
The bundle whose tasks are currently being executed. -
taskList
The list of tasks to execute. -
uuidList
The uuid path of the current bundle. -
taskWrapperList
Holds the tasks submitted to the executor. -
taskNotificationDispatcher
Dispatches tasks notifications to registered listeners. -
configChanged
Determines whether the number of threads or their priority has changed. -
reconnectionNotification
Set if the node must reconnect to the driver. -
threadManager
The thread manager that is used for execution. -
jobCancelled
Determines whether the current job has been cancelled. -
usedClassLoader
The class loader used to load the tasks and the classes they need from the client. -
dataProvider
The data provider for the current job. -
accumulatedElapsed
The total accumulated elapsed time of the tasks in the current bundle.
-
-
Constructor Details
-
AbstractExecutionManager
Initialize this execution manager with the specified node.- Parameters:
config- the configuration to get the thread manager properties from.nbThreadsProperty- the name of the property which configures the number of threads.
-
-
Method Details
-
execute
Description copied from interface:ExecutionManagerExecute the specified tasks of the specified tasks bundle.- Specified by:
executein interfaceExecutionManager- Parameters:
bundle- the bundle to which the tasks are associated.taskList- the list of tasks to execute.- Throws:
Exception- if the execution failed.
-
cancelAllTasks
public void cancelAllTasks(boolean callOnCancel, boolean requeue) Description copied from interface:ExecutionManagerCancel all executing or pending tasks.- Specified by:
cancelAllTasksin interfaceExecutionManager- Parameters:
callOnCancel- determines whether the onCancel() callback method of each task should be invoked.requeue- true if the job should be requeued on the server side, false otherwise.
-
shutdown
public void shutdown()Description copied from interface:ExecutionManagerShutdown this execution manager.- Specified by:
shutdownin interfaceExecutionManager
-
setup
Prepare this execution manager for executing the tasks of a bundle.- Parameters:
bundle- the bundle whose tasks are to be executed.taskList- the list of tasks to execute.
-
cleanup
protected abstract void cleanup()Cleanup method invoked when all tasks for the current bundle have completed. -
taskEnded
Notification sent by a node task wrapper when a task is complete.- Parameters:
taskWrapper- the task that just ended.
-
getCurrentJobId
Description copied from interface:ExecutionManagerGet the id of the job currently being executed.- Specified by:
getCurrentJobIdin interfaceExecutionManager- Returns:
- the job id as a string, or null if no job is being executed.
-
getCurrentJobName
Get the job name.- Returns:
- the name as a string.
-
getExecutor
Description copied from interface:ExecutionManagerGet the executor used by this execution manager.- Specified by:
getExecutorin interfaceExecutionManager- Returns:
- an
ExecutorServiceinstance.
-
checkConfigChanged
public boolean checkConfigChanged()Description copied from interface:ExecutionManagerDetermines whether the configuration has changed and resets the flag if it has.- Specified by:
checkConfigChangedin interfaceExecutionManager- Returns:
- true if the config was changed, false otherwise.
-
triggerConfigChanged
public void triggerConfigChanged()Description copied from interface:ExecutionManagerTrigger the configuration changed flag.- Specified by:
triggerConfigChangedin interfaceExecutionManager
-
setThreadPoolSize
public void setThreadPoolSize(int size) Description copied from interface:ExecutionManagerSet the size of the node's thread pool.- Specified by:
setThreadPoolSizein interfaceExecutionManager- Parameters:
size- the size as an int.
-
getThreadPoolSize
public int getThreadPoolSize()Description copied from interface:ExecutionManagerGet the size of the node's thread pool.- Specified by:
getThreadPoolSizein interfaceExecutionManager- Returns:
- the size as an int.
-
getThreadsPriority
public int getThreadsPriority()Description copied from interface:ExecutionManagerGet the priority assigned to the execution threads.- Specified by:
getThreadsPriorityin interfaceExecutionManager- Returns:
- the priority as an int value.
-
updateThreadsPriority
public void updateThreadsPriority(int newPriority) Description copied from interface:ExecutionManagerUpdate the priority of all execution threads.- Specified by:
updateThreadsPriorityin interfaceExecutionManager- Parameters:
newPriority- the new priority to set.
-
getThreadManager
Description copied from interface:ExecutionManagerGet the thread manager for this node.- Specified by:
getThreadManagerin interfaceExecutionManager- Returns:
- a
ThreadManagerinstance.
-
isJobCancelled
public boolean isJobCancelled()Description copied from interface:ExecutionManagerDetermine whether the current job has been cancelled, including before starting its execution.- Specified by:
isJobCancelledin interfaceExecutionManager- Returns:
trueif the job has been cancelled,falseotherwise.
-
setJobCancelled
public void setJobCancelled(boolean jobCancelled) Description copied from interface:ExecutionManagerSpecify whether the current job has been cancelled, including before starting its execution.- Specified by:
setJobCancelledin interfaceExecutionManager- Parameters:
jobCancelled-trueif the job has been cancelled,falseotherwise.
-
getBundle
Description copied from interface:ExecutionManagerGet the bundle whose tasks are currently being executed.- Specified by:
getBundlein interfaceExecutionManager- Returns:
- a
TaskBundleinstance.
-
setBundle
Description copied from interface:ExecutionManagerSet the bundle whose tasks are currently being executed.- Specified by:
setBundlein interfaceExecutionManager- Parameters:
bundle- aTaskBundleinstance.
-
getTaskNotificationDispatcher
Description copied from interface:ExecutionManagerGet the object which dispatches tasks notifications to registered listeners.- Specified by:
getTaskNotificationDispatcherin interfaceExecutionManager- Returns:
- a
TaskExecutionDispatcherinstance.
-