private synchronized void storeTaskEntry(final TaskEntry entry) { currentTasks.put(entry.task.getId(), entry); }
private synchronized void storeTaskEntry(final TaskEntry entry) { currentTasks.put(entry.task.getId(), entry); }
entrySet.addAll(currentTasks.values()); entrySet.forEach(entry -> { currentTasks.remove(entry.getTask().getId()); if (entry.isAsync()) { final PipelineExecutorTaskImpl task = entry.getTask(); updateExecutorRegistry(task); } catch (Exception e) { logger.error("It was not possible to update task: " + task.getId() + " during " + " PipelineExecutorTaskManager finalization. " + e.getMessage(), e);
entrySet.addAll(currentTasks.values()); entrySet.forEach(entry -> { currentTasks.remove(entry.getTask().getId()); if (entry.isAsync()) { final PipelineExecutorTaskImpl task = entry.getTask(); updateExecutorRegistry(task); } catch (Exception e) { logger.error("It was not possible to update task: " + task.getId() + " during " + " PipelineExecutorTaskManager finalization. " + e.getMessage(), e);
/** * Executes the task definition in asynchronous mode. * @param taskDef task definition for executing. * @return the taskId assigned to the running task. * @see PipelineExecutorTaskDef */ private synchronized String executeAsync(final PipelineExecutorTaskDef taskDef) { final PipelineExecutorTaskImpl task = taskManagerHelper.createTask(taskDef); storeTaskEntry(TaskEntry.newAsyncEntry(task)); startAsyncTask(task); updateExecutorRegistry(task); return task.getId(); }
/** * Executes the task definition in asynchronous mode. * @param taskDef task definition for executing. * @return the taskId assigned to the running task. * @see PipelineExecutorTaskDef */ private synchronized String executeAsync(final PipelineExecutorTaskDef taskDef) { final PipelineExecutorTaskImpl task = taskManagerHelper.createTask(taskDef); storeTaskEntry(TaskEntry.newAsyncEntry(task)); startAsyncTask(task); updateExecutorRegistry(task); return task.getId(); }
private void testStopTaskInNonStopeableState(PipelineExecutorTask.Status notStopeableStatus) throws PipelineExecutorException { PipelineExecutorTaskImpl task = mock(PipelineExecutorTaskImpl.class); when(task.getId()).thenReturn(TASK_ID); when(task.getPipelineStatus()).thenReturn(notStopeableStatus); PipelineExecutorTaskManagerImpl.TaskEntry taskEntry = mock(PipelineExecutorTaskManagerImpl.TaskEntry.class); when(taskEntry.isAsync()).thenReturn(true); when(taskEntry.getTask()).thenReturn(task); taskManager.currentTasks.put(TASK_ID, taskEntry); taskManager.init(); expectedException.expectMessage(new StartsWith("A PipelineExecutorTask in status: " + notStopeableStatus.name() + " can not be stopped. Stop operation is available for the following status set:")); taskManager.stop(TASK_ID); }
private void testStopTaskInNonStopeableState(PipelineExecutorTask.Status notStopeableStatus) throws PipelineExecutorException { PipelineExecutorTaskImpl task = mock(PipelineExecutorTaskImpl.class); when(task.getId()).thenReturn(TASK_ID); when(task.getPipelineStatus()).thenReturn(notStopeableStatus); PipelineExecutorTaskManagerImpl.TaskEntry taskEntry = mock(PipelineExecutorTaskManagerImpl.TaskEntry.class); when(taskEntry.isAsync()).thenReturn(true); when(taskEntry.getTask()).thenReturn(task); taskManager.currentTasks.put(TASK_ID, taskEntry); taskManager.init(); expectedException.expectMessage(new StartsWith("A PipelineExecutorTask in status: " + notStopeableStatus.name() + " can not be stopped. Stop operation is available for the following status set:")); taskManager.stop(TASK_ID); }
/** * Executes a task definition in synchronous mode. * @param taskDef task definition for executing. * @return the taskId assigned to the executed task. */ private String executeSync(final PipelineExecutorTaskDef taskDef) { final PipelineExecutorTaskImpl task = taskManagerHelper.createTask(taskDef); storeTaskEntry(TaskEntry.newSyncEntry(task)); final Pipeline pipeline = pipelineRegistry.getPipelineByName(taskDef.getPipeline()); pipelineExecutor.execute(taskDef.getInput(), pipeline, output -> processPipelineOutput(task, output), localListener); removeTaskEntry(task.getId()); updateExecutorRegistry(task); return task.getId(); }
/** * Executes a task definition in synchronous mode. * @param taskDef task definition for executing. * @return the taskId assigned to the executed task. */ private String executeSync(final PipelineExecutorTaskDef taskDef) { final PipelineExecutorTaskImpl task = taskManagerHelper.createTask(taskDef); storeTaskEntry(TaskEntry.newSyncEntry(task)); final Pipeline pipeline = pipelineRegistry.getPipelineByName(taskDef.getPipeline()); pipelineExecutor.execute(taskDef.getInput(), pipeline, output -> processPipelineOutput(task, output), localListener); removeTaskEntry(task.getId()); updateExecutorRegistry(task); return task.getId(); }
private void verifyInternalTask(PipelineExecutorTaskManagerImpl.TaskEntry taskEntry, boolean isAsync) { //verify that the generated internal task has the expect settings assertNotNull(taskEntry); assertEquals(TASK_ID, taskEntry.getTask().getId()); assertEquals(taskDef, taskEntry.getTask().getTaskDef()); assertEquals(isAsync, taskEntry.isAsync()); } }
private void verifyInternalTask(PipelineExecutorTaskManagerImpl.TaskEntry taskEntry, boolean isAsync) { //verify that the generated internal task has the expect settings assertNotNull(taskEntry); assertEquals(TASK_ID, taskEntry.getTask().getId()); assertEquals(taskDef, taskEntry.getTask().getTaskDef()); assertEquals(isAsync, taskEntry.isAsync()); } }