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); }
public void setTaskInStoppedStatus(final PipelineExecutorTaskImpl task) { task.setPipelineStatus(PipelineExecutorTask.Status.STOPPED); task.getTaskDef().getStages() .stream() .filter(stage -> PipelineExecutorTask.Status.RUNNING.equals(task.getStageStatus(stage)) || PipelineExecutorTask.Status.SCHEDULED.equals(task.getStageStatus(stage))) .forEach(stage -> task.setStageStatus(stage, PipelineExecutorTask.Status.STOPPED)); task.clearErrors(); task.setOutput(null); } }
assertEquals(pipelineExecutionId, itemList.getItems().get(0).getPipelineExecutionId()); assertEquals(PipelineExecutorTask.Status.STOPPED.name(), itemList.getItems().get(0).getPipelineStatus());
item.setPipelineStatus(pipelineExecutorTrace.getTask().getPipelineStatus().name()); if (pipelineExecutorTrace.getTask().getPipelineError() != null) { item.setPipelineError(pipelineExecutorTrace.getTask().getPipelineError().toString()); stageStatus = pipelineExecutorTrace.getTask().getStageStatus(stage).name();
@Override public void delete(final String taskId) throws PipelineExecutorException { final TaskEntry entry = getTaskEntry(taskId); if (entry != null) { throw new PipelineExecutorException("An active PipelineExecutorTask was found for taskId: " + taskId + " delete operation is only available for the following status set: " + deleteEnabledStatus); } final PipelineExecutorTrace trace = pipelineExecutorRegistry.getExecutorTrace(taskId); if (trace == null) { throw new PipelineExecutorException("No PipelineExecutorTask was found for taskId: " + taskId); } else { if (!deleteEnabledStatus.contains(trace.getTask().getPipelineStatus())) { throw new PipelineExecutorException("A PipelineExecutorTask in status: " + trace.getTask().getPipelineStatus().name() + " can not" + " be deleted. Delete operation is available for the following status set: " + deleteEnabledStatus); } else { pipelineExecutorRegistry.deregister(taskId); } } }
@Override public void stop(final String taskId) throws PipelineExecutorException { final TaskEntry entry = getTaskEntry(taskId); if (entry == null) { throw new PipelineExecutorException("No PipelineExecutorTask was found for taskId: " + taskId); } if (!entry.isAsync()) { throw new PipelineExecutorException("Stop operation is not available for taskId: " + taskId + " running in SYNCHRONOUS mode"); } final PipelineExecutorTask.Status currentStatus = entry.getTask().getPipelineStatus(); if (!stopEnabledStatus.contains(currentStatus)) { throw new PipelineExecutorException("A PipelineExecutorTask in status: " + currentStatus.name() + " can not" + " be stopped. Stop operation is available for the following status set: " + stopEnabledStatus); } destroyFutureTask(taskId); removeTaskEntry(taskId); taskManagerHelper.setTaskInStoppedStatus(entry.getTask()); updateExecutorRegistry(entry.getTask()); }
@Override public void delete(final String taskId) throws PipelineExecutorException { final TaskEntry entry = getTaskEntry(taskId); if (entry != null) { throw new PipelineExecutorException("An active PipelineExecutorTask was found for taskId: " + taskId + " delete operation is only available for the following status set: " + deleteEnabledStatus); } final PipelineExecutorTrace trace = pipelineExecutorRegistry.getExecutorTrace(taskId); if (trace == null) { throw new PipelineExecutorException("No PipelineExecutorTask was found for taskId: " + taskId); } else { if (!deleteEnabledStatus.contains(trace.getTask().getPipelineStatus())) { throw new PipelineExecutorException("A PipelineExecutorTask in status: " + trace.getTask().getPipelineStatus().name() + " can not" + " be deleted. Delete operation is available for the following status set: " + deleteEnabledStatus); } else { pipelineExecutorRegistry.deregister(taskId); } } }
@Override public void stop(final String taskId) throws PipelineExecutorException { final TaskEntry entry = getTaskEntry(taskId); if (entry == null) { throw new PipelineExecutorException("No PipelineExecutorTask was found for taskId: " + taskId); } if (!entry.isAsync()) { throw new PipelineExecutorException("Stop operation is not available for taskId: " + taskId + " running in SYNCHRONOUS mode"); } final PipelineExecutorTask.Status currentStatus = entry.getTask().getPipelineStatus(); if (!stopEnabledStatus.contains(currentStatus)) { throw new PipelineExecutorException("A PipelineExecutorTask in status: " + currentStatus.name() + " can not" + " be stopped. Stop operation is available for the following status set: " + stopEnabledStatus); } destroyFutureTask(taskId); removeTaskEntry(taskId); taskManagerHelper.setTaskInStoppedStatus(entry.getTask()); updateExecutorRegistry(entry.getTask()); }
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); }
public void setTaskInStoppedStatus(final PipelineExecutorTaskImpl task) { task.setPipelineStatus(PipelineExecutorTask.Status.STOPPED); task.getTaskDef().getStages() .stream() .filter(stage -> PipelineExecutorTask.Status.RUNNING.equals(task.getStageStatus(stage)) || PipelineExecutorTask.Status.SCHEDULED.equals(task.getStageStatus(stage))) .forEach(stage -> task.setStageStatus(stage, PipelineExecutorTask.Status.STOPPED)); task.clearErrors(); task.setOutput(null); } }