private void defineTopologyCacheConfig(EmbeddedCacheManager cacheManager) { InternalCacheRegistry internalCacheRegistry = cacheManager.getGlobalComponentRegistry().getComponent(InternalCacheRegistry.class); internalCacheRegistry.registerInternalCache(configuration.topologyCacheName(), createTopologyCacheConfig(cacheManager.getCacheManagerConfiguration().transport().distributedSyncTimeout()).build(), EnumSet.of(InternalCacheRegistry.Flag.EXCLUSIVE)); }
public void testServerUnregisterTopologyCacheOnStop() { for (HotRodServer server : hotRodServers) { String topologyCacheName = server.getConfiguration().topologyCacheName(); assertTrue(getInternalCacheNames(server).contains(topologyCacheName)); killServer(server); assertFalse(getInternalCacheNames(server).contains(topologyCacheName)); } }
public void testPutOnPrivateCache(Method m) { TestErrorResponse resp = (TestErrorResponse) hotRodClient .execute(0xA0, (byte) 0x01, hotRodServer.getConfiguration().topologyCacheName(), k(m), 0, 0, v(m), 0, (byte) 1, 0); assertTrue(resp.msg.contains("Remote requests are not allowed to private caches.")); assertEquals("Status should have been 'ParseError' but instead was: " + resp.status, ParseError, resp.status); hotRodClient.assertPut(m); }
private void addSelfToTopologyView(EmbeddedCacheManager cacheManager) { addressCache = cacheManager.getCache(configuration.topologyCacheName()); clusterAddress = cacheManager.getAddress(); address = new ServerAddress(configuration.publicHost(), configuration.publicPort()); distributedExecutorService = new DefaultExecutorService(addressCache); viewChangeListener = new CrashedMemberDetectorListener(addressCache, this); cacheManager.addListener(viewChangeListener); topologyChangeListener = new ReAddMyAddressListener(addressCache, clusterAddress, address); addressCache.addListener(topologyChangeListener); // Map cluster address to server endpoint address log.debugf("Map %s cluster address with %s server endpoint in address cache", clusterAddress, address); // Guaranteed delivery required since if data is lost, there won't be // any further cache calls, so negative acknowledgment can cause issues. addressCache.getAdvancedCache().withFlags(Flag.SKIP_CACHE_LOAD, Flag.GUARANTEED_DELIVERY) .put(clusterAddress, address); }
@Override public void stop() { if (removeCacheListener != null) { SecurityActions.removeListener(cacheManager, removeCacheListener); } if (viewChangeListener != null) { SecurityActions.removeListener(cacheManager, viewChangeListener); } if (topologyChangeListener != null) { SecurityActions.removeListener(addressCache, topologyChangeListener); } if (Configurations.isClustered(cacheManager.getCacheManagerConfiguration())) { InternalCacheRegistry internalCacheRegistry = cacheManager.getGlobalComponentRegistry().getComponent(InternalCacheRegistry.class); if (internalCacheRegistry != null) internalCacheRegistry.unregisterInternalCache(configuration.topologyCacheName()); } if (distributedExecutorService != null) { distributedExecutorService.shutdownNow(); } if (clientListenerRegistry != null) clientListenerRegistry.stop(); if (clientCounterNotificationManager != null) clientCounterNotificationManager.stop(); super.stop(); }
private void withClusteredServer(HotRodServerConfigurationBuilder builder, BiConsumer<Configuration, Long> consumer) { Stoppable.useCacheManager(TestCacheManagerFactory.createClusteredCacheManager(hotRodCacheConfiguration()), cm -> Stoppable.useServer(startHotRodServer(cm, serverPort(), builder), server -> { Configuration cfg = cm.getCacheConfiguration(server.getConfiguration().topologyCacheName()); consumer.accept(cfg, cm.getCacheManagerConfiguration().transport().distributedSyncTimeout()); })); }