Class DefaultTaskService

    • Field Detail

      • DEFAULT_POLLING_INTERVAL

        public static final int DEFAULT_POLLING_INTERVAL
        See Also:
        Constant Field Values
      • QUEUE_SIZE_METRIC

        public static final java.lang.String QUEUE_SIZE_METRIC
      • PROCESSING_TIME_METRIC

        public static final java.lang.String PROCESSING_TIME_METRIC
      • PROCESSING_HITS_METRIC

        public static final java.lang.String PROCESSING_HITS_METRIC
      • PROCESSING_MISSES_METRIC

        public static final java.lang.String PROCESSING_MISSES_METRIC
    • Constructor Detail

      • DefaultTaskService

        public DefaultTaskService()
    • Method Detail

      • setModelService

        public void setModelService​(ModelService modelService)
      • 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)
      • isRunning

        public boolean isRunning()
      • triggerRepoll

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

        public void triggerEvent​(java.lang.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​(java.lang.String uniqueId,
                                 java.util.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​(java.util.Date scheduledDate,
                                                  java.lang.Integer nodeId,
                                                  java.lang.String nodeGroupId)
      • checkTask

        protected void checkTask​(TaskModel toBeScheduled)
      • repoll

        public void repoll​(java.lang.Integer nodeId,
                           java.lang.String 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​(java.util.function.Supplier<java.lang.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 java.util.Set<java.lang.Integer> readExcludedNodesFromConfig()
      • readShutdownWaitFromConfig

        protected int readShutdownWaitFromConfig()
      • destroy

        public void destroy()
        Shut down this component
      • waitAndRunExclusiveAction

        protected void waitAndRunExclusiveAction​(java.lang.String info,
                                                 java.lang.Runnable action)
      • poll

        protected void poll()
      • processCondition

        protected void processCondition​(TaskCondition cond)
      • scheduleRetry

        protected void scheduleRetry​(Task task,
                                     java.util.Date nextExecution,
                                     int turn)
      • markTaskFailed

        protected void markTaskFailed​(Task task)
      • getRunner

        protected TaskRunner getRunner​(java.lang.String runnerBean)
                                throws java.lang.IllegalStateException
        Throws:
        java.lang.IllegalStateException
      • getTenant

        protected Tenant getTenant()
      • setTaskExecutionStrategies

        @Autowired
        public void setTaskExecutionStrategies​(java.util.Collection<? extends TaskExecutionStrategy> taskExecutionStrategies)