de.esprit.netsuite.server.cpu

## Class AgentExecutorTask

- java.lang.Object
- - de.esprit.common.util.DumpableObject
  - - de.esprit.appsuite.launch.AbstractApplicationObject<C>
    - - de.esprit.appsuite.task.AbstractAsyncExecutable<C>
      - - de.esprit.appsuite.task.AbstractAsyncTask<S>
        - - de.esprit.netsuite.rtask.AbstractServerTask<S>
          - - de.esprit.netsuite.rtask.AbstractRemoteTask<ServerContext>
            - - de.esprit.netsuite.server.cpu.AgentExecutorTask

- All Implemented Interfaces:
    ApplicationObject<ServerContext>, AsyncExecutable<ServerContext>, AsyncTask<ServerContext>, CancellableTask, LocalCancellableTask, TaskMonitorSupport, TaskIdHolder, SimpleLogSupport, Dumpable, Executable, RemoteCancellableTask, RemoteTask<ServerContext>, ServerObject<ServerContext>, java.lang.Runnable

      public final class AgentExecutorTask
      extends AbstractRemoteTask<ServerContext>

  This task performs the async execution of an agent on the server. Note that it is being controlled by a `AgentWatchDogTask` in order to detect an execution timeout. The latter task is responsible for finalization of the agent.
  Author:
    Rainer Buesch

- - ### Field Summary

    - ### Fields inherited from class de.esprit.appsuite.task.AbstractAsyncExecutable

      `childTaskRef, isTestMode, monitorController, resultRef, stateFlag`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AgentExecutorTask(ServerContext serverCtx, AsyncAgent<ClientContext,ServerContext> agent)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `cancel(SessionId killerSessId)` Cancels the running task and stores the `SessionId` of the killer.
    `protected RemoteTaskId` | `createTaskId()` Overridden to 'abuse' the AgentId as TaskId.
    `protected TaskMonitor` | `createTaskMonitor()` Has got a special Monitor that only reports the main task events.
    `protected void` | `doOnCancel()` This method is called after having detected cancellation.
    `protected void` | `doOnFailure(java.lang.Exception error)` Is called when the task failed.
    `boolean` | `equals(java.lang.Object obj)`
    `void` | `executeAsync()` Must be overridden to perform the async part.
    `AsyncAgent` | `getAgent()`
    `AgentId` | `getAgentId()`
    `int` | `hashCode()`
    `ToString` | `toString(ToString s)` This method allows subclasses to add values to the existing ToString of the superclass.

    - ### Methods inherited from class de.esprit.netsuite.rtask.AbstractRemoteTask

      `addMonitor, createRunStateFlag, getKillerSessionId, getOwnerSessionId, getRunStateFlag, getSessionId, getTaskId, setSessionId, submit, submit`

    - ### Methods inherited from class de.esprit.netsuite.rtask.AbstractServerTask

      `executeSubTask, getServerContext`

    - ### Methods inherited from class de.esprit.appsuite.task.AbstractAsyncTask

      `awaitFinished, awaitFinished, awaitStarted, cancel, deregisterTask, doOnFinish, doOnStart, doOnSuccess, executeChildTask, executeChildTask, getCurrentFuture, getMaxChildTasks, getPriority, getProcessingDuration, getStartTime, getStopWatch, handleFinish, handleStart, handleSuccess, isRegisterForCancel, isRunning, notifyProceeded, registerTask, releaseStart, run, setCurrentFuture, setMaxChildTasks, setPriority, setRegisterForCancel, setReleaseTimeout, submitInternal, wasSucceeded`

    - ### Methods inherited from class de.esprit.appsuite.task.AbstractAsyncExecutable

      `checkCancelled, checkForErrorAndRethrow, clearMonitors, execute, executeSubTask, getError, getMaxProgressSteps, getMonitorCount, getMonitors, getName, getProgressStepCount, getResult, getType, handleCancellation, handleFailure, hasError, hasMonitor, isCancellable, registerTaskStateChange, removeMonitor, resetProgress, setCancellable, setLogLevel, setMaxProgressSteps, setMonitor, setName, setName, setResult, setRunStateFlag, setTaskId, setType, shouldFireMonitor, sleepChecked, wasCancelled`

    - ### Methods inherited from class de.esprit.appsuite.launch.AbstractApplicationObject

      `getApplicationContext, getLogChannel, isLogDebug, isLogVerbose, logDebug, logDump, logError, logError, logFatal, logInfo, logVerbose, logWarning, setLogChannel`

    - ### Methods inherited from class de.esprit.common.util.DumpableObject

      `configureDumpHeadlineLength, configureDumpMaxElementsPrinted, copyDumpStringValues, copyToStringValues, createDumpHeader, toDumpString, toDumpString, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface de.esprit.appsuite.task.AsyncTask

      `awaitFinished, awaitFinished, awaitStarted, executeChildTask, executeChildTask, getError, getProcessingDuration, hasError, isRegisterForCancel, isRunning, releaseStart, setName, setReleaseTimeout`

    - ### Methods inherited from interface de.esprit.appsuite.task.AsyncExecutable

      `checkCancelled, checkForErrorAndRethrow, executeSubTask, getName, getResult, getType, handleCancellation, handleFailure, isCancellable, notifyProceeded, setCancellable, setName, setResult, setRunStateFlag, sleepChecked`

    - ### Methods inherited from interface de.esprit.appsuite.launch.ApplicationObject

      `getApplicationContext`

    - ### Methods inherited from interface de.esprit.common.type.Executable

      `execute`

    - ### Methods inherited from interface de.esprit.appsuite.task.monitor.TaskMonitorSupport

      `clearMonitors, getMonitorCount, getMonitors, hasMonitor, removeMonitor`

    - ### Methods inherited from interface de.esprit.common.log.SimpleLogSupport

      `getLogChannel, isLogDebug, isLogVerbose, logDebug, logDump, logError, logError, logFatal, logInfo, logVerbose, logWarning, setLogChannel`

    - ### Methods inherited from interface java.lang.Runnable

      `run`

    - ### Methods inherited from interface de.esprit.appsuite.task.LocalCancellableTask

      `cancel`

    - ### Methods inherited from interface de.esprit.appsuite.task.CancellableTask

      `wasCancelled`

    - ### Methods inherited from interface de.esprit.common.type.Dumpable

      `toDumpString, toDumpString, toString`

    - ### Methods inherited from interface de.esprit.netsuite.server.ServerObject

      `getServerContext`

- - ### Constructor Detail

    - #### AgentExecutorTask

          public AgentExecutorTask(ServerContext serverCtx,
                           AsyncAgent<ClientContext,ServerContext> agent)

  - ### Method Detail

    - #### createTaskMonitor

          protected final TaskMonitor createTaskMonitor()

      Has got a special Monitor that only reports the main task events. No support for child tasks!
      Overrides:
        `createTaskMonitor` in class `AbstractRemoteTask<ServerContext>`

    - #### createTaskId

          protected final RemoteTaskId createTaskId()

      Overridden to 'abuse' the AgentId as TaskId. It is unique on the server because it contains the SessionId of the client as part of the id.
      Overrides:
        `createTaskId` in class `AbstractRemoteTask<ServerContext>`

    - #### getAgent

          public final AsyncAgent getAgent()

    - #### getAgentId

          public final AgentId getAgentId()

    - #### executeAsync

          public final void executeAsync()
                                  throws java.lang.Exception

      Description copied from class: `AbstractAsyncTask`
      Must be overridden to perform the async part. From within this method you may directly call `AbstractAsyncTask.notifyProceeded(Object, int, int, String)` in order to notify about task progress. Note: the running task should periodically call `AbstractAsyncExecutable.checkCancelled()` in order to detect cancellation.
      Specified by:
        `executeAsync` in interface `AsyncExecutable<ServerContext>`
      Specified by:
        `executeAsync` in class `AbstractAsyncTask<ServerContext>`
      Throws:
        `java.lang.Exception`
      See Also:
        `for synchronous execution`

    - #### doOnCancel

          protected final void doOnCancel()

      Description copied from class: `AbstractAsyncExecutable`
      This method is called after having detected cancellation. May be overridden to perform any cleanup. Note that any Exceptions thrown are caught and just logged but do NOT affect the task.
      Overrides:
        `doOnCancel` in class `AbstractAsyncExecutable<ServerContext>`

    - #### doOnFailure

          protected final void doOnFailure(java.lang.Exception error)

      Description copied from class: `AbstractAsyncExecutable`
      Is called when the task failed. Maybe overridden to perform any cleanup on error. Note that any Exceptions thrown are caught and just logged but do NOT affect the task.
      Overrides:
        `doOnFailure` in class `AbstractAsyncExecutable<ServerContext>`

    - #### cancel

          public final void cancel(SessionId killerSessId)

      Description copied from interface: `RemoteCancellableTask`
      Cancels the running task and stores the `SessionId` of the killer. Note that this call puts the task in a CANCEL_REQUESTED state. The task itself needs to detect this and perform any action needed for canceling itself - after all it puts itself in the cancelled state and terminates. The method `CancellableTask.wasCancelled()` returns true once a cancel was requested.
      Specified by:
        `cancel` in interface `RemoteCancellableTask`
      Overrides:
        `cancel` in class `AbstractRemoteTask<ServerContext>`

    - #### equals

          public final boolean equals(java.lang.Object obj)

      Overrides:
        `equals` in class `java.lang.Object`

    - #### hashCode

          public final int hashCode()

      Overrides:
        `hashCode` in class `java.lang.Object`

    - #### toString

          public ToString toString(ToString s)

      Description copied from interface: `Dumpable`
      This method allows subclasses to add values to the existing ToString of the superclass. Usually subclasses only need to override this method.
      Specified by:
        `toString` in interface `Dumpable`
      Overrides:
        `toString` in class `AbstractAsyncTask<ServerContext>`

Copyright © 2014 EsprIT-Systems. All Rights Reserved.