public void init(WorkflowExecutor workflowExecutor) { ScheduledExecutorService deciderPool = Executors.newScheduledThreadPool(1); deciderPool.scheduleWithFixedDelay(() -> { try { boolean disable = config.disableSweep(); if (disable) { logger.info("Workflow sweep is disabled."); return; } List<String> workflowIds = queueDAO.pop(WorkflowExecutor.DECIDER_QUEUE, 2 * executorThreadPoolSize, 2000); int currentQueueSize = queueDAO.getSize(WorkflowExecutor.DECIDER_QUEUE); logger.debug("Sweeper's current deciderqueue size: {}.", currentQueueSize); int retrievedWorkflows = (workflowIds != null) ? workflowIds.size() : 0; logger.debug("Sweeper retrieved {} workflows from the decider queue.", retrievedWorkflows); sweep(workflowIds, workflowExecutor); } catch (Exception e) { Monitors.error(className, "sweep"); logger.error("Error when sweeping workflow", e); } }, 500, 500, TimeUnit.MILLISECONDS); }
workflowSweeper.sweep(Arrays.asList(wfid), workflowExecutor); es = workflowExecutionService.getExecutionStatus(wfid, true); assertNotNull(es);
public void init(WorkflowExecutor workflowExecutor) { ScheduledExecutorService deciderPool = Executors.newScheduledThreadPool(1); deciderPool.scheduleWithFixedDelay(() -> { try { boolean disable = config.disableSweep(); if (disable) { logger.info("Workflow sweep is disabled."); return; } List<String> workflowIds = queueDAO.pop(WorkflowExecutor.DECIDER_QUEUE, 2 * executorThreadPoolSize, 2000); int currentQueueSize = queueDAO.getSize(WorkflowExecutor.DECIDER_QUEUE); logger.debug("Sweeper's current deciderqueue size: {}.", currentQueueSize); int retrievedWorkflows = (workflowIds != null) ? workflowIds.size() : 0; logger.debug("Sweeper retrieved {} workflows from the decider queue.", retrievedWorkflows); sweep(workflowIds, workflowExecutor); } catch (Exception e) { Monitors.error(className, "sweep"); logger.error("Error when sweeping workflow", e); } }, 500, 500, TimeUnit.MILLISECONDS); }