@Override public void destroy(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("Destroy operation is not available for taskId: " + taskId + " running in SYNCHRONOUS mode"); } destroyFutureTask(taskId); removeTaskEntry(taskId); pipelineExecutorRegistry.deregister(taskId); }
@Override public void destroy(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("Destroy operation is not available for taskId: " + taskId + " running in SYNCHRONOUS mode"); } destroyFutureTask(taskId); removeTaskEntry(taskId); pipelineExecutorRegistry.deregister(taskId); }
private PipelineExecutorException mockError(String error) { //mock an exception and set a reduced stacktrace for testing purposes. Throwable throwable = new Throwable(error); StackTraceElement[] stackTrace = {new StackTraceElement(PipelineExecutorException.class.getName(), "methodName", "fileName", 0)}; throwable.setStackTrace(stackTrace); PipelineExecutorException result = new PipelineExecutorException(error, throwable); result.setStackTrace(stackTrace); return result; }
@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 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 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 onPipelineError(final OnErrorPipelineExecutionEvent oepee, final TaskEntry taskEntry) { taskEntry.getTask().setPipelineStatus(PipelineExecutorTask.Status.ERROR); taskEntry.getTask().setPipelineError(new PipelineExecutorException(oepee.getError().getMessage(), oepee.getError())); if (taskEntry.isAsync()) { updateExecutorRegistry(taskEntry.getTask()); } }
private void testOnPipelineErrorExecutionEvent(boolean async) { when(taskEntry.isAsync()).thenReturn(async); OnErrorPipelineExecutionEvent event = new OnErrorPipelineExecutionEvent(TASK_ID, pipeline, stage, error); taskManager.localListener.onPipelineError(event); verify(task, times(1)).setPipelineStatus(PipelineExecutorTask.Status.ERROR); verify(task, times(1)).setPipelineError(pipelineExecutorExceptionCaptor.capture()); assertEqualsException(new PipelineExecutorException(ERROR_MESSAGE, error), pipelineExecutorExceptionCaptor.getValue()); verifyExecutorRegistryUpdated(async); verifyExternalListenersNotified(event); }
private void testOnStageErrorExecutionEvent(boolean async) { when(taskEntry.isAsync()).thenReturn(async); OnErrorStageExecutionEvent event = new OnErrorStageExecutionEvent(TASK_ID, pipeline, stage, error); taskManager.localListener.onStageError(event); verify(task, times(1)).setPipelineStatus(PipelineExecutorTask.Status.ERROR); verify(task, times(1)).setStageStatus(stage.getName(), PipelineExecutorTask.Status.ERROR); verify(task, times(1)).setStageError(eq(stage.getName()), pipelineExecutorExceptionCaptor.capture()); assertEqualsException(new PipelineExecutorException(ERROR_MESSAGE, error), pipelineExecutorExceptionCaptor.getValue()); verifyExecutorRegistryUpdated(async); verifyExternalListenersNotified(event); }
private void onStageError(final OnErrorStageExecutionEvent oesee, final TaskEntry taskEntry) { taskEntry.getTask().setPipelineStatus(PipelineExecutorTask.Status.ERROR); taskEntry.getTask().setStageStatus(oesee.getStage().getName(), PipelineExecutorTask.Status.ERROR); taskEntry.getTask().setStageError(oesee.getStage().getName(), new PipelineExecutorException(oesee.getError().getMessage(), oesee.getError())); if (taskEntry.isAsync()) { updateExecutorRegistry(taskEntry.getTask()); } }