@Override public void deregisterProvider(final Provider provider) { checkNotNull("provider", provider); deregisterProvider(provider.getId()); }
@PostConstruct protected void init() { initializeRegistryRoot(); initializeRegistry(); }
@Before @Override public void setUp() { super.setUp(); when(registryHelper.ensureDirectory(RUNTIME_REGISTRY_PATH)).thenReturn(registryRoot); runtimeRegistry = spy(new VFSRuntimeRegistry(registryHelper)); ((VFSRuntimeRegistry) runtimeRegistry).init(); }
@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); } }
@Override public void deregisterProvider(final String providerId) { checkNotNull("providerId", providerId); final Path path = buildProviderPath(providerId); registryHelper.deleteBatch(path); super.deregisterProvider(providerId); }
@Override public void registerRuntime(final Runtime runtime) { checkNotNull("runtime", runtime); final Path path = buildRuntimePath(runtime.getId()); try { registryHelper.storeEntry(path, runtime); } catch (Exception e) { //uncommon error logger.error("Unexpected error was produced during runtime marshalling/storing, runtime: " + runtime, e); throw new RuntimeException("Unexpected error was produced during runtime marshalling/storing, runtime: " + runtime, e); } super.registerRuntime(runtime); }
@Before @Override public void setUp() { super.setUp(); when(registryHelper.ensureDirectory(RUNTIME_REGISTRY_PATH)).thenReturn(registryRoot); runtimeRegistry = spy(new VFSRuntimeRegistry(registryHelper)); ((VFSRuntimeRegistry) runtimeRegistry).init(); }
@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); } }
@Override public void registerProvider(final Provider provider) { checkNotNull("provider", provider); final Path path = buildProviderPath(provider.getId()); try { registryHelper.storeEntry(path, provider); } catch (Exception e) { //uncommon error logger.error("Unexpected error was produced during provider marshalling/storing, provider: " + provider, e); throw new RuntimeException("Unexpected error was produced during provider marshalling/storing, provider: " + provider, e); } super.registerProvider(provider); }
@Override public void deregisterRuntime(final RuntimeId runtimeId) { checkNotNull("runtimeId", runtimeId); final Path path = buildRuntimePath(runtimeId.getId()); registryHelper.deleteBatch(path); super.deregisterRuntime(runtimeId); }