Class DefaultTaskService

java.lang.Object
de.hybris.platform.task.impl.DefaultTaskService
All Implemented Interfaces:
TaskService
Direct Known Subclasses:
DefaultTaskServiceBaseTest.TestTaskService, TriggerTaskRunnerRetriesHandlingTest.TestTaskService

public class DefaultTaskService extends Object implements TaskService
Default implementation of the TaskService interface.
  • Field Details

    • DEFAULT_WORKER_MAX

      public static final int DEFAULT_WORKER_MAX
      See Also:
    • DEFAULT_POLLING_INTERVAL

      public static final int DEFAULT_POLLING_INTERVAL
      See Also:
    • DEFAULT_SHUTDOWN_WAIT

      public static final int DEFAULT_SHUTDOWN_WAIT
      See Also:
    • QUEUE_SIZE_METRIC

      public static final String QUEUE_SIZE_METRIC
    • PROCESSING_TIME_METRIC

      public static final String PROCESSING_TIME_METRIC
    • PROCESSING_HITS_METRIC

      public static final String PROCESSING_HITS_METRIC
    • PROCESSING_MISSES_METRIC

      public static final String PROCESSING_MISSES_METRIC
    • TASKS_QUEUE_SIZE_METRIC

      public static final String TASKS_QUEUE_SIZE_METRIC
    • CONDITIONS_QUEUE_SIZE_METRIC

      public static final String CONDITIONS_QUEUE_SIZE_METRIC
    • POOLING_QUEUE_SIZE_METRIC

      public static final String POOLING_QUEUE_SIZE_METRIC
  • Constructor Details

    • DefaultTaskService

      public DefaultTaskService()
  • Method Details

    • setModelService

      public void setModelService(ModelService modelService)
    • setStrandedTasksLogic

      public void setStrandedTasksLogic(StrandedTasksLogic strandedTasksLogic)
    • setEventService

      public void setEventService(EventService eventService)
    • setScheduleAndTriggerStrategy

      public void setScheduleAndTriggerStrategy(ScheduleAndTriggerStrategy scheduleAndTriggerStrategy)
    • setMetricRegistry

      public void setMetricRegistry(com.codahale.metrics.MetricRegistry metricRegistry)
    • setTasksProvider

      public void setTasksProvider(TasksProvider tasksProvider)
    • setTaskEngineRetryTemplate

      public void setTaskEngineRetryTemplate(org.springframework.retry.support.RetryTemplate taskEngineRetryTemplate)
    • getEngine

      public TaskEngine getEngine()
      Specified by:
      getEngine in interface TaskService
      Returns:
      the task engine.
    • isRunning

      public boolean isRunning()
    • triggerRepoll

      public void triggerRepoll(Integer nodeId, String nodeGroupId)
      Triggers re-poll at the specified cluster node.
      Parameters:
      nodeId - the cluster node id
    • triggerEvent

      public void triggerEvent(String uniqueId)
      Description copied from interface: TaskService
      Trigger an event on task module.
      Specified by:
      triggerEvent in interface TaskService
      Parameters:
      uniqueId - unique id of event
    • triggerEvent

      public void triggerEvent(String uniqueId, Date expirationDate)
      Description copied from interface: TaskService
      Trigger an event on task module.
      Specified by:
      triggerEvent in interface TaskService
      Parameters:
      uniqueId - unique id of event
      expirationDate - expiration date - when reached the task condition created after event send and before
    • triggerEvent

      public boolean triggerEvent(TaskEvent event)
      Description copied from interface: TaskService
      Trigger event on task module.
      Specified by:
      triggerEvent in interface TaskService
      Parameters:
      event - event to be triggered
      Returns:
      true if operation succeeded or false if event has been already triggered
    • scheduleTask

      public void scheduleTask(TaskModel task)
      Description copied from interface: TaskService
      Schedule a task.
      Specified by:
      scheduleTask in interface TaskService
      Parameters:
      task - task to schedule.
    • triggerRepollAfterSchedule

      protected void triggerRepollAfterSchedule(Date scheduledDate, Integer nodeId, String nodeGroupId)
    • checkTask

      protected void checkTask(TaskModel toBeScheduled)
    • checkTaskConditions

      protected void checkTaskConditions(TaskModel toBeScheduled, TaskConditionModel cond)
    • repoll

      public void repoll(Integer nodeId, String nodeGroupId)
      Schedules repoll of task
      Parameters:
      nodeId - target task engine nodeId
      nodeGroupId - target task engine nodeGroupId
    • isAllowedToStart

      protected boolean isAllowedToStart()
    • isAllowedToStart

      protected boolean isAllowedToStart(int clusterId)
    • isEnabledInConfig

      protected boolean isEnabledInConfig()
      Read configuration setting for task engine from the configuration. This method considers both TaskConstants.Params.TASK_PROCESSING_ENABLED and TaskConstants.Params.TASK_PROCESSING_ENABLED_LEGACY. The following applies:
      • If only the old parameter is set, it is used.
      • If only the new parameter is set, it is used.
      • If both the old and new parameters are set, the new parameter is used and a warning is written to the log.
    • checkSystemOK

      protected boolean checkSystemOK()
    • refreshCurrentSessionWithRetry

      protected <T> void refreshCurrentSessionWithRetry(Supplier<Void> failingMethodSupplier)
    • init

      public void init()
      Starts up this component
    • getTaskDao

      protected TaskDAO getTaskDao()
    • setTaskDao

      public void setTaskDao(TaskDAO dao)
    • readPollingIntervalFromConfig

      protected int readPollingIntervalFromConfig()
    • readMaxWorkersFromConfig

      protected int readMaxWorkersFromConfig()
    • readWorkersIdleFromConfig

      protected int readWorkersIdleFromConfig()
    • readExcludedNodesFromConfig

      protected Set<Integer> readExcludedNodesFromConfig()
    • readShutdownWaitFromConfig

      protected int readShutdownWaitFromConfig()
    • destroy

      public void destroy()
      Shut down this component
    • waitAndRunExclusiveAction

      protected void waitAndRunExclusiveAction(String info, Runnable action)
    • poll

      protected void poll()
    • getTaskProviderParameters

      protected TaskEngineParameters getTaskProviderParameters()
    • processInTenant

      protected void processInTenant(TasksProvider.VersionPK versionPK)
    • process

      protected void process(TasksProvider.VersionPK versionPK)
    • processCondition

      protected void processCondition(TaskCondition cond)
    • processTask

      protected void processTask(Task task, TasksProvider.VersionPK versionPK)
    • getStrandedTasksLogic

      public StrandedTasksLogic getStrandedTasksLogic()
    • scheduleRetryIfAllowed

      @Deprecated(since="2211", forRemoval=true) protected boolean scheduleRetryIfAllowed(Task task, RetryLaterException e)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • scheduleRetryIfAllowed

      protected boolean scheduleRetryIfAllowed(Task task, RetryLaterException e, RuntimeConfigHolder runtimeConfigHolder)
    • scheduleRetry

      protected void scheduleRetry(Task task, Date nextExecution, int turn)
    • markTaskFailed

      protected void markTaskFailed(Task task)
    • getRunner

      protected TaskRunner getRunner(Task task)
    • getRunner

      protected TaskRunner getRunner(String runnerBean) throws IllegalStateException
      Throws:
      IllegalStateException
    • getTenant

      protected Tenant getTenant()
    • getExecutionStrategy

      public TaskExecutionStrategy getExecutionStrategy(TaskRunner<? extends TaskModel> runner)
      Parameters:
      runner -
      Returns:
      task execution strategy assigned to task runner
    • getTaskExecutionStrategies

      public Map<Class<? extends TaskRunner>,TaskExecutionStrategy> getTaskExecutionStrategies()
    • setTaskExecutionStrategies

      @Autowired public void setTaskExecutionStrategies(Collection<? extends TaskExecutionStrategy> taskExecutionStrategies)