Class AbstractExecutionManager

java.lang.Object
org.jppf.execute.AbstractExecutionManager
All Implemented Interfaces:
ExecutionManager

public abstract class AbstractExecutionManager extends Object implements ExecutionManager
Instances of this class manage the execution of JPPF tasks by a node.
Author:
Laurent Cohen, Martin JANDA, Paul Woodward
  • Field Details

    • timeoutHandler

      protected final JPPFScheduleHandler timeoutHandler
      Timer managing the tasks timeout.
    • bundle

      protected TaskBundle bundle
      The bundle whose tasks are currently being executed.
    • taskList

      protected List<Task<?>> taskList
      The list of tasks to execute.
    • uuidList

      protected List<String> uuidList
      The uuid path of the current bundle.
    • taskWrapperList

      protected List<NodeTaskWrapper> taskWrapperList
      Holds the tasks submitted to the executor.
    • taskNotificationDispatcher

      protected final TaskExecutionDispatcher taskNotificationDispatcher
      Dispatches tasks notifications to registered listeners.
    • configChanged

      protected final AtomicBoolean configChanged
      Determines whether the number of threads or their priority has changed.
    • reconnectionNotification

      protected AtomicReference<JPPFReconnectionNotification> reconnectionNotification
      Set if the node must reconnect to the driver.
    • threadManager

      protected final ThreadManager threadManager
      The thread manager that is used for execution.
    • jobCancelled

      protected AtomicBoolean jobCancelled
      Determines whether the current job has been cancelled.
    • usedClassLoader

      protected ThreadManager.UsedClassLoader usedClassLoader
      The class loader used to load the tasks and the classes they need from the client.
    • dataProvider

      protected DataProvider dataProvider
      The data provider for the current job.
    • accumulatedElapsed

      protected final AtomicLong accumulatedElapsed
      The total accumulated elapsed time of the tasks in the current bundle.
  • Constructor Details

    • AbstractExecutionManager

      public AbstractExecutionManager(TypedProperties config, JPPFProperty<Integer> nbThreadsProperty)
      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

      public void execute(TaskBundle bundle, List<Task<?>> taskList) throws Exception
      Description copied from interface: ExecutionManager
      Execute the specified tasks of the specified tasks bundle.
      Specified by:
      execute in interface ExecutionManager
      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: ExecutionManager
      Cancel all executing or pending tasks.
      Specified by:
      cancelAllTasks in interface ExecutionManager
      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: ExecutionManager
      Shutdown this execution manager.
      Specified by:
      shutdown in interface ExecutionManager
    • setup

      protected abstract void setup(TaskBundle bundle, List<Task<?>> taskList)
      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

      protected void taskEnded(NodeTaskWrapper taskWrapper)
      Notification sent by a node task wrapper when a task is complete.
      Parameters:
      taskWrapper - the task that just ended.
    • getCurrentJobId

      public String getCurrentJobId()
      Description copied from interface: ExecutionManager
      Get the id of the job currently being executed.
      Specified by:
      getCurrentJobId in interface ExecutionManager
      Returns:
      the job id as a string, or null if no job is being executed.
    • getCurrentJobName

      public String getCurrentJobName()
      Get the job name.
      Returns:
      the name as a string.
    • getExecutor

      public ExecutorService getExecutor()
      Description copied from interface: ExecutionManager
      Get the executor used by this execution manager.
      Specified by:
      getExecutor in interface ExecutionManager
      Returns:
      an ExecutorService instance.
    • checkConfigChanged

      public boolean checkConfigChanged()
      Description copied from interface: ExecutionManager
      Determines whether the configuration has changed and resets the flag if it has.
      Specified by:
      checkConfigChanged in interface ExecutionManager
      Returns:
      true if the config was changed, false otherwise.
    • triggerConfigChanged

      public void triggerConfigChanged()
      Description copied from interface: ExecutionManager
      Trigger the configuration changed flag.
      Specified by:
      triggerConfigChanged in interface ExecutionManager
    • setThreadPoolSize

      public void setThreadPoolSize(int size)
      Description copied from interface: ExecutionManager
      Set the size of the node's thread pool.
      Specified by:
      setThreadPoolSize in interface ExecutionManager
      Parameters:
      size - the size as an int.
    • getThreadPoolSize

      public int getThreadPoolSize()
      Description copied from interface: ExecutionManager
      Get the size of the node's thread pool.
      Specified by:
      getThreadPoolSize in interface ExecutionManager
      Returns:
      the size as an int.
    • getThreadsPriority

      public int getThreadsPriority()
      Description copied from interface: ExecutionManager
      Get the priority assigned to the execution threads.
      Specified by:
      getThreadsPriority in interface ExecutionManager
      Returns:
      the priority as an int value.
    • updateThreadsPriority

      public void updateThreadsPriority(int newPriority)
      Description copied from interface: ExecutionManager
      Update the priority of all execution threads.
      Specified by:
      updateThreadsPriority in interface ExecutionManager
      Parameters:
      newPriority - the new priority to set.
    • getThreadManager

      public ThreadManager getThreadManager()
      Description copied from interface: ExecutionManager
      Get the thread manager for this node.
      Specified by:
      getThreadManager in interface ExecutionManager
      Returns:
      a ThreadManager instance.
    • isJobCancelled

      public boolean isJobCancelled()
      Description copied from interface: ExecutionManager
      Determine whether the current job has been cancelled, including before starting its execution.
      Specified by:
      isJobCancelled in interface ExecutionManager
      Returns:
      true if the job has been cancelled, false otherwise.
    • setJobCancelled

      public void setJobCancelled(boolean jobCancelled)
      Description copied from interface: ExecutionManager
      Specify whether the current job has been cancelled, including before starting its execution.
      Specified by:
      setJobCancelled in interface ExecutionManager
      Parameters:
      jobCancelled - true if the job has been cancelled, false otherwise.
    • getBundle

      public TaskBundle getBundle()
      Description copied from interface: ExecutionManager
      Get the bundle whose tasks are currently being executed.
      Specified by:
      getBundle in interface ExecutionManager
      Returns:
      a TaskBundle instance.
    • setBundle

      public void setBundle(TaskBundle bundle)
      Description copied from interface: ExecutionManager
      Set the bundle whose tasks are currently being executed.
      Specified by:
      setBundle in interface ExecutionManager
      Parameters:
      bundle - a TaskBundle instance.
    • getTaskNotificationDispatcher

      public TaskExecutionDispatcher getTaskNotificationDispatcher()
      Description copied from interface: ExecutionManager
      Get the object which dispatches tasks notifications to registered listeners.
      Specified by:
      getTaskNotificationDispatcher in interface ExecutionManager
      Returns:
      a TaskExecutionDispatcher instance.