Repository: incubator-geode Updated Branches: refs/heads/feature/GEODE-578 cfccc654f -> 02b6d6c74
incorporating Darrel's feedback Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/02b6d6c7 Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/02b6d6c7 Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/02b6d6c7 Branch: refs/heads/feature/GEODE-578 Commit: 02b6d6c74a91d2a445abb52e33e19c11d198e763 Parents: cfccc65 Author: Swapnil Bawaskar <sbawas...@pivotal.io> Authored: Wed Nov 25 11:24:39 2015 -0800 Committer: Swapnil Bawaskar <sbawas...@pivotal.io> Committed: Wed Nov 25 11:24:39 2015 -0800 ---------------------------------------------------------------------- .../internal/cache/xmlcache/CacheCreation.java | 22 ++++++++++++-------- .../cache/xmlcache/CacheCreationJUnitTest.java | 18 +++++++--------- 2 files changed, 20 insertions(+), 20 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/02b6d6c7/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheCreation.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheCreation.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheCreation.java index 4572ade..ed67ca4 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheCreation.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheCreation.java @@ -559,7 +559,7 @@ public class CacheCreation implements InternalCache { Integer serverPort = CacheServerLauncher.getServerPort(); String serverBindAdd = CacheServerLauncher.getServerBindAddress(); Boolean disableDefaultServer = CacheServerLauncher.disableDefaultServer.get(); - startBridgeServers(this.getCacheServers(), cache, serverPort, serverBindAdd, disableDefaultServer); + startCacheServers(this.getCacheServers(), cache, serverPort, serverBindAdd, disableDefaultServer); cache.setBackupFiles(this.backups); cache.addDeclarableProperties(this.declarablePropertiesMap); runInitializer(); @@ -578,16 +578,20 @@ public class CacheCreation implements InternalCache { } } - protected void startBridgeServers(List declarativeCacheServer, Cache cache, Integer serverPort, String serverBindAdd, Boolean disableDefaultServer) { + /** + * starts declarative cache servers if a server is not running on the port already. + * Also adds a default server to the param declarativeCacheServers if a serverPort is specified. + */ + protected void startCacheServers(List declarativeCacheServers, Cache cache, Integer serverPort, String serverBindAdd, Boolean disableDefaultServer) { - if (declarativeCacheServer.size() > 1 + if (declarativeCacheServers.size() > 1 && (serverPort != null || serverBindAdd != null)) { throw new RuntimeException( LocalizedStrings.CacheServerLauncher_SERVER_PORT_MORE_THAN_ONE_CACHE_SERVER .toLocalizedString()); } - if (declarativeCacheServer.isEmpty() + if (declarativeCacheServers.isEmpty() && (serverPort != null || serverBindAdd != null) && (disableDefaultServer == null || !disableDefaultServer)) { boolean existingCacheServer = false; @@ -602,18 +606,18 @@ public class CacheCreation implements InternalCache { } if (!existingCacheServer) { - declarativeCacheServer.add(new CacheServerCreation((GemFireCacheImpl)cache, false)); + declarativeCacheServers.add(new CacheServerCreation((GemFireCacheImpl)cache, false)); } } - for (Iterator iter = declarativeCacheServer.iterator(); iter.hasNext();) { - CacheServerCreation bridge = (CacheServerCreation)iter.next(); + for (Iterator iter = declarativeCacheServers.iterator(); iter.hasNext();) { + CacheServerCreation declaredCacheServer = (CacheServerCreation)iter.next(); boolean startServer = true; List<CacheServer> cacheServers = cache.getCacheServers(); if (cacheServers != null) { for (CacheServer cacheServer : cacheServers) { - if (bridge.getPort() == cacheServer.getPort()) { + if (declaredCacheServer.getPort() == cacheServer.getPort()) { startServer = false; } } @@ -624,7 +628,7 @@ public class CacheCreation implements InternalCache { } CacheServerImpl impl = (CacheServerImpl)cache.addCacheServer(); - impl.configureFrom(bridge); + impl.configureFrom(declaredCacheServer); if (serverPort != null && serverPort != CacheServer.DEFAULT_PORT) { impl.setPort(serverPort); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/02b6d6c7/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheCreationJUnitTest.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheCreationJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheCreationJUnitTest.java index 764d214..d697286 100644 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheCreationJUnitTest.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheCreationJUnitTest.java @@ -1,16 +1,12 @@ package com.gemstone.gemfire.internal.cache.xmlcache; -import com.gemstone.gemfire.cache.Region; import com.gemstone.gemfire.cache.server.CacheServer; import com.gemstone.gemfire.internal.cache.CacheServerImpl; import com.gemstone.gemfire.internal.cache.GemFireCacheImpl; -import com.gemstone.gemfire.internal.i18n.LocalizedStrings; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @@ -66,7 +62,7 @@ public class CacheCreationJUnitTest { List<CacheServer> cacheServers = new ArrayList<>(); when(cache.getCacheServers()).thenReturn(cacheServers); - cacheCreation.startBridgeServers(cacheCreation.getCacheServers(), cache, configuredServerPort, configuredServerBindAddress, disableDefaultCacheServer); + cacheCreation.startCacheServers(cacheCreation.getCacheServers(), cache, configuredServerPort, configuredServerBindAddress, disableDefaultCacheServer); verify(cache, never()).addCacheServer(); } @@ -85,7 +81,7 @@ public class CacheCreationJUnitTest { List<CacheServer> cacheServers = new ArrayList<>(); when(cache.getCacheServers()).thenReturn(cacheServers); - cacheCreation.startBridgeServers(cacheCreation.getCacheServers(), cache, configuredServerPort, configuredServerBindAddress, disableDefaultCacheServer); + cacheCreation.startCacheServers(cacheCreation.getCacheServers(), cache, configuredServerPort, configuredServerBindAddress, disableDefaultCacheServer); verify(cache, never()).addCacheServer(); } @@ -104,7 +100,7 @@ public class CacheCreationJUnitTest { List<CacheServer> cacheServers = new ArrayList<>(); when(cache.getCacheServers()).thenReturn(cacheServers); - cacheCreation.startBridgeServers(cacheCreation.getCacheServers(), cache, configuredServerPort, configuredServerBindAddress, disableDefaultCacheServer); + cacheCreation.startCacheServers(cacheCreation.getCacheServers(), cache, configuredServerPort, configuredServerBindAddress, disableDefaultCacheServer); verify(cache, times(1)).addCacheServer(); verify(mockServer).setPort(9999); @@ -124,7 +120,7 @@ public class CacheCreationJUnitTest { CacheServerImpl mockServer = mock(CacheServerImpl.class); when(cache.addCacheServer()).thenReturn(mockServer); - cacheCreation.startBridgeServers(cacheCreation.getCacheServers(), cache, configuredServerPort, configuredServerBindAddress, disableDefaultCacheServer); + cacheCreation.startCacheServers(cacheCreation.getCacheServers(), cache, configuredServerPort, configuredServerBindAddress, disableDefaultCacheServer); verify(cache, times(1)).addCacheServer(); verify(mockServer).setPort(configuredServerPort); @@ -150,7 +146,7 @@ public class CacheCreationJUnitTest { when(cache.getCacheServers()).thenReturn(cacheServers); - cacheCreation.startBridgeServers(cacheCreation.getCacheServers(), cache, configuredServerPort, configuredServerBindAddress, disableDefaultCacheServer); + cacheCreation.startCacheServers(cacheCreation.getCacheServers(), cache, configuredServerPort, configuredServerBindAddress, disableDefaultCacheServer); verify(cache, never()).addCacheServer(); @@ -173,7 +169,7 @@ public class CacheCreationJUnitTest { CacheServerImpl mockServer = mock(CacheServerImpl.class); when(cache.addCacheServer()).thenReturn(mockServer); - cacheCreation.startBridgeServers(cacheCreation.getCacheServers(), cache, configuredServerPort, configuredServerBindAddress, disableDefaultCacheServer); + cacheCreation.startCacheServers(cacheCreation.getCacheServers(), cache, configuredServerPort, configuredServerBindAddress, disableDefaultCacheServer); verify(cache, times(2)).addCacheServer(); verify(mockServer).configureFrom(br1); @@ -190,6 +186,6 @@ public class CacheCreationJUnitTest { cacheCreation.getCacheServers().add(new CacheServerCreation(cacheCreation, false)); cacheCreation.getCacheServers().add(new CacheServerCreation(cacheCreation, false)); - cacheCreation.startBridgeServers(cacheCreation.getCacheServers(), cache, configuredServerPort, configuredServerBindAddress, disableDefaultCacheServer); + cacheCreation.startCacheServers(cacheCreation.getCacheServers(), cache, configuredServerPort, configuredServerBindAddress, disableDefaultCacheServer); } }