private void initializeRegistry() { try { final List<Object> traces = registryHelper.readEntries(registryRoot, newFilter(TRACE_SUFFIX)); traces.forEach(trace -> super.register((PipelineExecutorTrace) trace)); } catch (Exception e) { logger.error("An error was produced during " + VFSPipelineExecutorRegistry.class.getName() + " initialization.", e); } }
@Test public void testInit() throws Exception { providers = new ArrayList<>(); providers.addAll(mockProviderListSPI(providerType, ELEMENTS_COUNT)); runtimes = new ArrayList<>(); runtimes.addAll(mockRuntimeList(providerId, "", ELEMENTS_COUNT)); when(registryHelper.readEntries(registryRoot, VFSRegistryHelper.BySuffixFilter.newFilter(PROVIDER_SUFFIX))).thenReturn(providers); when(registryHelper.readEntries(registryRoot, VFSRegistryHelper.BySuffixFilter.newFilter(RUNTIME_SUFFIX))).thenReturn(runtimes); ((VFSRuntimeRegistry) runtimeRegistry).init(); verify(registryHelper, times(2)).ensureDirectory(RUNTIME_REGISTRY_PATH); verify(registryHelper, times(2)).readEntries(registryRoot, VFSRegistryHelper.BySuffixFilter.newFilter(PROVIDER_SUFFIX)); verify(registryHelper, times(2)).readEntries(registryRoot, VFSRegistryHelper.BySuffixFilter.newFilter(RUNTIME_SUFFIX)); for (Object provider : providers) { verifyProviderIsRegistered((Provider) provider); } for (Object runtime : runtimes) { verifyRuntimeIsRegistered((Runtime) runtime); } }
@Test public void testInit() throws Exception { providers = new ArrayList<>(); providers.addAll(mockProviderListSPI(providerType, ELEMENTS_COUNT)); runtimes = new ArrayList<>(); runtimes.addAll(mockRuntimeList(providerId, "", ELEMENTS_COUNT)); when(registryHelper.readEntries(registryRoot, VFSRegistryHelper.BySuffixFilter.newFilter(PROVIDER_SUFFIX))).thenReturn(providers); when(registryHelper.readEntries(registryRoot, VFSRegistryHelper.BySuffixFilter.newFilter(RUNTIME_SUFFIX))).thenReturn(runtimes); ((VFSRuntimeRegistry) runtimeRegistry).init(); verify(registryHelper, times(2)).ensureDirectory(RUNTIME_REGISTRY_PATH); verify(registryHelper, times(2)).readEntries(registryRoot, VFSRegistryHelper.BySuffixFilter.newFilter(PROVIDER_SUFFIX)); verify(registryHelper, times(2)).readEntries(registryRoot, VFSRegistryHelper.BySuffixFilter.newFilter(RUNTIME_SUFFIX)); for (Object provider : providers) { verifyProviderIsRegistered((Provider) provider); } for (Object runtime : runtimes) { verifyRuntimeIsRegistered((Runtime) runtime); } }
@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); } }
public static BySuffixFilter newFilter(final String suffix) { return new BySuffixFilter(suffix); }
private void initializeRegistry() { try { final List<Object> providers = registryHelper.readEntries(registryRoot, newFilter(PROVIDER_SUFFIX)); providers.forEach(provider -> super.registerProvider((Provider) provider)); final List<Object> runtimes = registryHelper.readEntries(registryRoot, newFilter(RUNTIME_SUFFIX)); runtimes.forEach(runtime -> super.registerRuntime((Runtime) runtime)); } catch (Exception e) { logger.error("An error was produced during " + VFSRuntimeRegistry.class.getName() + " initialization.", e); } }