Package de.hybris.platform.task.impl
Class DefaultTaskService
java.lang.Object
de.hybris.platform.task.impl.DefaultTaskService
- All Implemented Interfaces:
TaskService
- Direct Known Subclasses:
DefaultTaskServiceBaseTest.TestTaskService,TriggerTaskRunnerRetriesHandlingTest.TestTaskService
Default implementation of the
TaskService interface.-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final intstatic final intstatic final intstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from interface de.hybris.platform.task.TaskService
BEAN_ID -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanprotected voidprotected voidcheckTaskConditions(TaskModel toBeScheduled, TaskConditionModel cond) voiddestroy()Shut down this componentgetExecutionStrategy(TaskRunner<? extends TaskModel> runner) protected TaskRunnerprotected TaskRunnerprotected TaskDAOMap<Class<? extends TaskRunner>,TaskExecutionStrategy> protected TaskEngineParametersprotected Tenantvoidinit()Starts up this componentprotected booleanprotected booleanisAllowedToStart(int clusterId) protected booleanRead configuration setting for task engine from the configuration.booleanprotected voidmarkTaskFailed(Task task) protected voidpoll()protected voidprocess(TasksProvider.VersionPK versionPK) protected voidprotected voidprocessInTenant(TasksProvider.VersionPK versionPK) protected voidprocessTask(Task task, TasksProvider.VersionPK versionPK) protected intprotected intprotected intprotected intprotected <T> voidrefreshCurrentSessionWithRetry(Supplier<Void> failingMethodSupplier) voidSchedules repoll of taskprotected voidscheduleRetry(Task task, Date nextExecution, int turn) protected booleanDeprecated, for removal: This API element is subject to removal in a future version.protected booleanscheduleRetryIfAllowed(Task task, RetryLaterException e, RuntimeConfigHolder runtimeConfigHolder) voidscheduleTask(TaskModel task) Schedule a task.voidsetEventService(EventService eventService) voidsetMetricRegistry(com.codahale.metrics.MetricRegistry metricRegistry) voidsetModelService(ModelService modelService) voidsetScheduleAndTriggerStrategy(ScheduleAndTriggerStrategy scheduleAndTriggerStrategy) voidsetStrandedTasksLogic(StrandedTasksLogic strandedTasksLogic) voidsetTaskDao(TaskDAO dao) voidsetTaskEngineRetryTemplate(org.springframework.retry.support.RetryTemplate taskEngineRetryTemplate) voidsetTaskExecutionStrategies(Collection<? extends TaskExecutionStrategy> taskExecutionStrategies) voidsetTasksProvider(TasksProvider tasksProvider) booleantriggerEvent(TaskEvent event) Trigger event on task module.voidtriggerEvent(String uniqueId) Trigger an event on task module.voidtriggerEvent(String uniqueId, Date expirationDate) Trigger an event on task module.voidtriggerRepoll(Integer nodeId, String nodeGroupId) Triggers re-poll at the specified cluster node.protected voidtriggerRepollAfterSchedule(Date scheduledDate, Integer nodeId, String nodeGroupId) protected voidwaitAndRunExclusiveAction(String info, Runnable action)
-
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
-
PROCESSING_TIME_METRIC
-
PROCESSING_HITS_METRIC
-
PROCESSING_MISSES_METRIC
-
TASKS_QUEUE_SIZE_METRIC
-
CONDITIONS_QUEUE_SIZE_METRIC
-
POOLING_QUEUE_SIZE_METRIC
-
-
Constructor Details
-
DefaultTaskService
public DefaultTaskService()
-
-
Method Details
-
setModelService
-
setStrandedTasksLogic
-
setEventService
-
setScheduleAndTriggerStrategy
-
setMetricRegistry
public void setMetricRegistry(com.codahale.metrics.MetricRegistry metricRegistry) -
setTasksProvider
-
setTaskEngineRetryTemplate
public void setTaskEngineRetryTemplate(org.springframework.retry.support.RetryTemplate taskEngineRetryTemplate) -
getEngine
- Specified by:
getEnginein interfaceTaskService- Returns:
- the task engine.
-
isRunning
public boolean isRunning() -
triggerRepoll
Triggers re-poll at the specified cluster node.- Parameters:
nodeId- the cluster node id
-
triggerEvent
Description copied from interface:TaskServiceTrigger an event on task module.- Specified by:
triggerEventin interfaceTaskService- Parameters:
uniqueId- unique id of event
-
triggerEvent
Description copied from interface:TaskServiceTrigger an event on task module.- Specified by:
triggerEventin interfaceTaskService- Parameters:
uniqueId- unique id of eventexpirationDate- expiration date - when reached the task condition created after event send and before
-
triggerEvent
Description copied from interface:TaskServiceTrigger event on task module.- Specified by:
triggerEventin interfaceTaskService- Parameters:
event- event to be triggered- Returns:
trueif operation succeeded orfalseif event has been already triggered
-
scheduleTask
Description copied from interface:TaskServiceSchedule a task.- Specified by:
scheduleTaskin interfaceTaskService- Parameters:
task- task to schedule.
-
triggerRepollAfterSchedule
-
checkTask
-
checkTaskConditions
-
repoll
Schedules repoll of task- Parameters:
nodeId- target task engine nodeIdnodeGroupId- 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 bothTaskConstants.Params.TASK_PROCESSING_ENABLEDandTaskConstants.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
-
init
public void init()Starts up this component -
getTaskDao
-
setTaskDao
-
readPollingIntervalFromConfig
protected int readPollingIntervalFromConfig() -
readMaxWorkersFromConfig
protected int readMaxWorkersFromConfig() -
readWorkersIdleFromConfig
protected int readWorkersIdleFromConfig() -
readExcludedNodesFromConfig
-
readShutdownWaitFromConfig
protected int readShutdownWaitFromConfig() -
destroy
public void destroy()Shut down this component -
waitAndRunExclusiveAction
-
poll
protected void poll() -
getTaskProviderParameters
-
processInTenant
-
process
-
processCondition
-
processTask
-
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.since 2211 - usescheduleRetryIfAllowed(Task,RetryLaterException,RuntimeConfigHolder) -
scheduleRetryIfAllowed
protected boolean scheduleRetryIfAllowed(Task task, RetryLaterException e, RuntimeConfigHolder runtimeConfigHolder) -
scheduleRetry
-
markTaskFailed
-
getRunner
-
getRunner
- Throws:
IllegalStateException
-
getTenant
-
getExecutionStrategy
- Parameters:
runner-- Returns:
- task execution strategy assigned to task runner
-
getTaskExecutionStrategies
-
setTaskExecutionStrategies
@Autowired public void setTaskExecutionStrategies(Collection<? extends TaskExecutionStrategy> taskExecutionStrategies)
-
scheduleRetryIfAllowed(Task,RetryLaterException,RuntimeConfigHolder)