@Override public void register(final PipelineExecutorTrace trace) { checkNotNull("trace", trace); recordsMap.put(trace.getTaskId(), trace); }
@Override public void register(final PipelineExecutorTrace trace) { checkNotNull("trace", trace); recordsMap.put(trace.getTaskId(), trace); }
@Override public void register(final PipelineExecutorTrace trace) { checkNotNull("trace", trace); final Path path = buildTracePath(trace.getTaskId()); try { registryHelper.storeEntry(path, trace); } catch (Exception e) { //uncommon error logger.error("Unexpected error was produced during trace marshalling/storing, trace: " + trace, e); throw new RuntimeException("Unexpected error was produced during trace marshalling/storing, trace: " + trace, e); } super.register(trace); }
@Before public void setUp() { trace = mock(PipelineExecutorTrace.class); when(trace.getTaskId()).thenReturn(PIPELINE_EXECUTION_ID); pipelineExecutorRegistry = new InMemoryPipelineExecutorRegistry(); }
@Before public void setUp() { trace = mock(PipelineExecutorTrace.class); when(trace.getTaskId()).thenReturn(PIPELINE_EXECUTION_ID); pipelineExecutorRegistry = new InMemoryPipelineExecutorRegistry(); }
@Test public void testGetExecutorTraces() { List<PipelineExecutorTrace> traces = new ArrayList<>(); for (int i = 0; i < TRACES_COUNT; i++) { PipelineExecutorTrace trace = mock(PipelineExecutorTrace.class); when(trace.getTaskId()).thenReturn(PIPELINE_EXECUTION_ID + Integer.toString(i)); traces.add(trace); } traces.forEach(trace -> pipelineExecutorRegistry.register(trace)); Collection<PipelineExecutorTrace> result = pipelineExecutorRegistry.getExecutorTraces(); assertEquals(traces.size(), result.size()); for (PipelineExecutorTrace trace : traces) { assertTrue(result.contains(trace)); } }
@Test public void testGetExecutorTraces() { List<PipelineExecutorTrace> traces = new ArrayList<>(); for (int i = 0; i < TRACES_COUNT; i++) { PipelineExecutorTrace trace = mock(PipelineExecutorTrace.class); when(trace.getTaskId()).thenReturn(PIPELINE_EXECUTION_ID + Integer.toString(i)); traces.add(trace); } traces.forEach(trace -> pipelineExecutorRegistry.register(trace)); Collection<PipelineExecutorTrace> result = pipelineExecutorRegistry.getExecutorTraces(); assertEquals(traces.size(), result.size()); for (PipelineExecutorTrace trace : traces) { assertTrue(result.contains(trace)); } }
@Override public void destroyRuntime(String runtimeId, boolean forced) throws BusinessException { final Runtime runtimeById = runtimeRegistry.getRuntimeById(runtimeId); if (runtimeById == null) { throw new BusinessException("No runtime was found for runtimeId: " + runtimeId); } final PipelineExecutorTrace pipelineTrace = pipelineExecutorRegistry.getExecutorTrace(runtimeById); try { runtimeFactory.destroyRuntime(runtimeById); } catch (Exception e) { if (forced) { LOG.warn("Runtime destroy raised the following error for runtime: " + runtimeId + " but forced destroy will still remove the runtime from registry.", e); runtimeRegistry.deregisterRuntime(runtimeById); } else { throw e; } } if (pipelineTrace != null) { pipelineExecutorRegistry.deregister(pipelineTrace.getTaskId()); } }
times(5)).register(pipelineExecutorTraceCaptor.capture()); Map<String, PipelineExecutorTask> registeredTasks = new HashMap<>(); pipelineExecutorTraceCaptor.getAllValues().forEach(capture -> registeredTasks.put(capture.getTaskId(), capture.getTask())); tasks.forEach(task -> assertHasSameInfo(task,
@Test public void testInit() throws Exception { traces = new ArrayList<>(); for (int i = 0; i < TRACES_COUNT; i++) { PipelineExecutorTrace trace = mock(PipelineExecutorTrace.class); when(trace.getTaskId()).thenReturn(PIPELINE_EXECUTION_ID + Integer.toString(i)); traces.add(trace); } when(registryHelper.readEntries(registryRoot, VFSRegistryHelper.BySuffixFilter.newFilter(TRACE_SUFFIX))).thenReturn(traces); ((VFSPipelineExecutorRegistry) pipelineExecutorRegistry).init(); verify(registryHelper, times(2)).ensureDirectory(PIPELINE_EXECUTOR_REGISTRY_PATH); verify(registryHelper, times(2)).readEntries(registryRoot, VFSRegistryHelper.BySuffixFilter.newFilter(TRACE_SUFFIX)); for (Object trace : traces) { PipelineExecutorTrace result = pipelineExecutorRegistry.getExecutorTrace(((PipelineExecutorTrace) trace).getTaskId()); assertNotNull(result); assertEquals(trace, result); } }
@Test public void testInit() throws Exception { traces = new ArrayList<>(); for (int i = 0; i < TRACES_COUNT; i++) { PipelineExecutorTrace trace = mock(PipelineExecutorTrace.class); when(trace.getTaskId()).thenReturn(PIPELINE_EXECUTION_ID + Integer.toString(i)); traces.add(trace); } when(registryHelper.readEntries(registryRoot, VFSRegistryHelper.BySuffixFilter.newFilter(TRACE_SUFFIX))).thenReturn(traces); ((VFSPipelineExecutorRegistry) pipelineExecutorRegistry).init(); verify(registryHelper, times(2)).ensureDirectory(PIPELINE_EXECUTOR_REGISTRY_PATH); verify(registryHelper, times(2)).readEntries(registryRoot, VFSRegistryHelper.BySuffixFilter.newFilter(TRACE_SUFFIX)); for (Object trace : traces) { PipelineExecutorTrace result = pipelineExecutorRegistry.getExecutorTrace(((PipelineExecutorTrace) trace).getTaskId()); assertNotNull(result); assertEquals(trace, result); } }
times(5)).register(pipelineExecutorTraceCaptor.capture()); Map<String, PipelineExecutorTask> registeredTasks = new HashMap<>(); pipelineExecutorTraceCaptor.getAllValues().forEach(capture -> registeredTasks.put(capture.getTaskId(), capture.getTask())); tasks.forEach(task -> assertHasSameInfo(task,
@Test public void testExecuteSync() { when(taskManagerHelper.generateTaskId()).thenReturn(TASK_ID); taskManager.init(); //prepare the input parameters. prepareExecution(); String result = taskManager.execute(taskDef, PipelineExecutorTaskManager.ExecutionMode.SYNCHRONOUS); assertEquals(TASK_ID, result); //verify the task to execute was properly initialized. verify(taskManagerHelper, times(1)).createTask(taskDef); //verify the pipeline was properly executed. verify(pipelineExecutor, times(1)).execute(eq(taskDef.getInput()), eq(pipeline), any(Consumer.class), eq(taskManager.localListener)); //verify the pipeline executor registry was properly updated. verify(pipelineExecutorRegistry, times(1)).register(pipelineExecutorTraceCaptor.capture()); assertEquals(PIPELINE_ID, pipelineExecutorTraceCaptor.getValue().getPipelineId()); assertEquals(TASK_ID, pipelineExecutorTraceCaptor.getValue().getTaskId()); }
@Override public boolean test(PipelineExecutorTrace pipelineExecutorTrace) { if (pipelineExecutionId != null) { return pipelineExecutionId.equals(pipelineExecutorTrace.getTaskId()); } if (runtimeId != null) { return (pipelineExecutorTrace.getTask().getOutput() instanceof RuntimeId) && runtimeId.equals(((RuntimeId) pipelineExecutorTrace.getTask().getOutput()).getId()); } if (runtimeName != null) { return (pipelineExecutorTrace.getTask().getOutput() instanceof RuntimeId) && runtimeName.equals(((RuntimeId) pipelineExecutorTrace.getTask().getOutput()).getName()); } if (providerId != null) { if (pipelineExecutorTrace.getTask().getTaskDef().getProviderId() == null) { return false; } else if (!providerId.equals(pipelineExecutorTrace.getTask().getTaskDef().getProviderId().getId())) { return false; } } if (pipelineId != null) { if (!pipelineId.equals(pipelineExecutorTrace.getPipelineId())) { return false; } } return true; } }
@Test public void testExecuteSync() { when(taskManagerHelper.generateTaskId()).thenReturn(TASK_ID); taskManager.init(); //prepare the input parameters. prepareExecution(); String result = taskManager.execute(taskDef, PipelineExecutorTaskManager.ExecutionMode.SYNCHRONOUS); assertEquals(TASK_ID, result); //verify the task to execute was properly initialized. verify(taskManagerHelper, times(1)).createTask(taskDef); //verify the pipeline was properly executed. verify(pipelineExecutor, times(1)).execute(eq(taskDef.getInput()), eq(pipeline), any(Consumer.class), eq(taskManager.localListener)); //verify the pipeline executor registry was properly updated. verify(pipelineExecutorRegistry, times(1)).register(pipelineExecutorTraceCaptor.capture()); assertEquals(PIPELINE_ID, pipelineExecutorTraceCaptor.getValue().getPipelineId()); assertEquals(TASK_ID, pipelineExecutorTraceCaptor.getValue().getTaskId()); }
pipelineExecutorTraceCaptor.getValue().getPipelineId()); assertEquals(TASK_ID, pipelineExecutorTraceCaptor.getValue().getTaskId()); assertHasSameInfo(internalTaskEntry.getTask(), pipelineExecutorTraceCaptor.getValue().getTask());
pipelineExecutorTraceCaptor.getValue().getPipelineId()); assertEquals(TASK_ID, pipelineExecutorTraceCaptor.getValue().getTaskId()); assertHasSameInfo(internalTaskEntry.getTask(), pipelineExecutorTraceCaptor.getValue().getTask());
@Test public void testDeregister() { pipelineExecutorRegistry.register(trace); PipelineExecutorTrace result = pipelineExecutorRegistry.getExecutorTrace(PIPELINE_EXECUTION_ID); assertEquals(trace, result); pipelineExecutorRegistry.deregister(trace.getTaskId()); result = pipelineExecutorRegistry.getExecutorTrace(PIPELINE_EXECUTION_ID); assertNull(result); }
@Test public void testDeregister() { pipelineExecutorRegistry.register(trace); PipelineExecutorTrace result = pipelineExecutorRegistry.getExecutorTrace(PIPELINE_EXECUTION_ID); assertEquals(trace, result); pipelineExecutorRegistry.deregister(trace.getTaskId()); result = pipelineExecutorRegistry.getExecutorTrace(PIPELINE_EXECUTION_ID); assertNull(result); }
item.setPipelineExecutionId(pipelineExecutorTrace.getTaskId()); item.setPipelineStatus(pipelineExecutorTrace.getTask().getPipelineStatus().name()); if (pipelineExecutorTrace.getTask().getPipelineError() != null) {