/** * after an auto-reconnect we may need to recreate a cache server and start it */ public void createAndStartCacheServers(List<CacheServerCreation> cacheServerCreation, InternalCache cache) { List<CacheServer> servers = cache.getCacheServers(); // if there used to be a cache server but now there isn't one we need // to recreate it. if (servers.isEmpty() && cacheServerCreation != null) { for (CacheServerCreation bridge : cacheServerCreation) { CacheServerImpl impl = (CacheServerImpl) cache.addCacheServer(); impl.configureFrom(bridge); } } servers = cache.getCacheServers(); for (CacheServer server : servers) { try { if (!server.isRunning()) { server.start(); } } catch (IOException ex) { throw new GemFireIOException( String.format("While starting cache server %s", server), ex); } } }
@Test public void userCanCreateMultipleCacheServersDeclaratively() { CacheCreation cacheCreation = new CacheCreation(); CacheServerCreation br1 = new CacheServerCreation(cacheCreation, false); br1.setPort(40406); CacheServerCreation br2 = new CacheServerCreation(cacheCreation, false); br1.setPort(40407); cacheCreation.getCacheServers().add(br1); cacheCreation.getCacheServers().add(br2); CacheServerImpl mockServer = mock(CacheServerImpl.class); when(this.cache.addCacheServer()).thenReturn(mockServer); cacheCreation.startCacheServers(cacheCreation.getCacheServers(), this.cache, ServerLauncherParameters.INSTANCE.withDisableDefaultServer(false)); verify(this.cache, times(2)).addCacheServer(); verify(mockServer).configureFrom(br1); verify(mockServer).configureFrom(br2); }
impl.configureFrom(declaredCacheServer);
CacheServerImpl bridge = (CacheServerImpl) cacheServer; if (System.identityHashCode(bridge) == config.getId()) { bridge.configureFrom(config); bridge.start(); m.bridgeInfo = new RemoteBridgeServer(bridge);