diff --git a/src/main/java/org/springframework/data/gemfire/CacheFactoryBean.java b/src/main/java/org/springframework/data/gemfire/CacheFactoryBean.java index c80ea232..d2909afe 100644 --- a/src/main/java/org/springframework/data/gemfire/CacheFactoryBean.java +++ b/src/main/java/org/springframework/data/gemfire/CacheFactoryBean.java @@ -97,7 +97,7 @@ public class CacheFactoryBean implements BeanClassLoaderAware, BeanFactoryAware, protected Boolean pdxIgnoreUnreadFields; protected Boolean pdxPersistent; protected Boolean pdxReadSerialized; - protected Boolean useSharedConfiguration; + protected Boolean useClusterConfiguration; protected Cache cache; @@ -695,8 +695,8 @@ public class CacheFactoryBean implements BeanClassLoaderAware, BeanFactoryAware, * * @param useSharedConfiguration a boolean value to set the use-shared-configuration GemFire distribution property. */ - public void setUseSharedConfiguration(Boolean useSharedConfiguration) { - this.useSharedConfiguration = useSharedConfiguration; + public void setUseClusterConfiguration(Boolean useSharedConfiguration) { + this.useClusterConfiguration = useSharedConfiguration; } /** @@ -895,8 +895,8 @@ public class CacheFactoryBean implements BeanClassLoaderAware, BeanFactoryAware, * * @return a boolean value indicating whether shared configuration use has been enabled or not. */ - public Boolean getUseSharedConfiguration() { - return this.useSharedConfiguration; + public Boolean getUseClusterConfiguration() { + return this.useClusterConfiguration; } /** @@ -911,8 +911,8 @@ public class CacheFactoryBean implements BeanClassLoaderAware, BeanFactoryAware, protected void postProcessPropertiesBeforeInitialization(Properties gemfireProperties) { gemfireProperties.setProperty("disable-auto-reconnect", String.valueOf( !Boolean.TRUE.equals(getEnableAutoReconnect()))); - gemfireProperties.setProperty("use-shared-configuration", String.valueOf( - Boolean.TRUE.equals(getUseSharedConfiguration()))); + gemfireProperties.setProperty("use-cluster-configuration", String.valueOf( + Boolean.TRUE.equals(getUseClusterConfiguration()))); } /* (non-Javadoc) diff --git a/src/main/java/org/springframework/data/gemfire/client/ClientCacheFactoryBean.java b/src/main/java/org/springframework/data/gemfire/client/ClientCacheFactoryBean.java index 159580d3..0ee55b72 100644 --- a/src/main/java/org/springframework/data/gemfire/client/ClientCacheFactoryBean.java +++ b/src/main/java/org/springframework/data/gemfire/client/ClientCacheFactoryBean.java @@ -263,12 +263,12 @@ public class ClientCacheFactoryBean extends CacheFactoryBean { } @Override - public final Boolean getUseSharedConfiguration() { + public final Boolean getUseClusterConfiguration() { return Boolean.FALSE; } @Override - public final void setUseSharedConfiguration(Boolean useSharedConfiguration) { + public final void setUseClusterConfiguration(Boolean useClusterConfiguration) { throw new UnsupportedOperationException("Shared, cluster configuration is not applicable to clients."); } diff --git a/src/main/java/org/springframework/data/gemfire/config/CacheParser.java b/src/main/java/org/springframework/data/gemfire/config/CacheParser.java index 9eb50507..87c82a02 100644 --- a/src/main/java/org/springframework/data/gemfire/config/CacheParser.java +++ b/src/main/java/org/springframework/data/gemfire/config/CacheParser.java @@ -72,7 +72,7 @@ class CacheParser extends AbstractSimpleBeanDefinitionParser { ParsingUtils.setPropertyValue(element, builder, "pdx-persistent"); parsePdxDiskStore(element, parserContext, builder); ParsingUtils.setPropertyValue(element, builder, "search-timeout"); - ParsingUtils.setPropertyValue(element, builder, "use-shared-configuration"); + ParsingUtils.setPropertyValue(element, builder, "use-cluster-configuration"); List txListeners = DomUtils.getChildElementsByTagName(element, "transaction-listener"); diff --git a/src/main/resources/org/springframework/data/gemfire/config/spring-gemfire-1.5.xsd b/src/main/resources/org/springframework/data/gemfire/config/spring-gemfire-1.5.xsd index 57f4f2a7..0984d689 100644 --- a/src/main/resources/org/springframework/data/gemfire/config/spring-gemfire-1.5.xsd +++ b/src/main/resources/org/springframework/data/gemfire/config/spring-gemfire-1.5.xsd @@ -328,7 +328,7 @@ You may want to change this based on your knowledge of the network load or other ]]> - + sharedConfigRegion; - - @Resource(name = "NativeLocalRegion") - private Region nativeLocalRegion; - - @Resource(name = "NativePartitionRegion") - private Region nativePartitionRegion; - - @Resource(name = "NativeReplicateRegion") - private Region nativeReplicateRegion; - - @Resource(name = "LocalRegion") - private Region localRegion; +public class CacheClusterConfigurationIntegrationTest { private static File locatorWorkingDirectory; @@ -82,7 +69,7 @@ public class CacheUsingSharedConfigurationIntegrationTest { @BeforeClass public static void testSuiteSetup() throws IOException { - String locatorName = "SharedConfigLocator"; + String locatorName = "ClusterConfigLocator"; locatorWorkingDirectory = new File(System.getProperty("user.dir"), locatorName.toLowerCase()); @@ -93,8 +80,8 @@ public class CacheUsingSharedConfigurationIntegrationTest { List arguments = new ArrayList(); arguments.add("-Dgemfire.name=" + locatorName); - arguments.add("-Dspring.gemfire.enable-shared-configuration=true"); - arguments.add("-Dspring.gemfire.load-shared-configuration=true"); + arguments.add("-Dspring.gemfire.enable-cluster-configuration=true"); + arguments.add("-Dspring.gemfire.load-cluster-configuration=true"); locatorProcess = ProcessExecutor.launch(locatorWorkingDirectory, LocatorProcess.class, arguments.toArray(new String[arguments.size()])); @@ -103,7 +90,7 @@ public class CacheUsingSharedConfigurationIntegrationTest { waitForLocatorStart(TimeUnit.SECONDS.toMillis(30)); - //System.out.println("Shared Configuration Locator should be running!"); + //System.out.println("Cluster Configuration Locator should be running!"); } private static void waitForLocatorStart(final long milliseconds) { @@ -140,20 +127,54 @@ public class CacheUsingSharedConfigurationIntegrationTest { return actualRegion; } + protected String getLocation(final String configLocation) { + String baseLocation = getClass().getPackage().getName().replace('.', File.separatorChar); + return baseLocation.concat(File.separator).concat(configLocation); + } + + protected Region getRegion(final ConfigurableApplicationContext applicationContext, final String regionBeanName) { + return applicationContext.getBean(regionBeanName, Region.class); + } + + protected ConfigurableApplicationContext newApplicationContext(final String... configLocations) { + ConfigurableApplicationContext applicationContext = new ClassPathXmlApplicationContext(configLocations); + applicationContext.registerShutdownHook(); + return applicationContext; + } + @Test - public void testConfiguration() { - assertRegionAttributes(assertRegion(sharedConfigRegion, "SharedConfigRegion"), + public void testClusterConfiguration() { + ConfigurableApplicationContext applicationContext = newApplicationContext( + getLocation("cacheUsingClusterConfigurationIntegrationTest.xml")); + + assertRegionAttributes(assertRegion(getRegion(applicationContext, "ClusterConfigRegion"), "ClusterConfigRegion"), DataPolicy.PARTITION, Scope.DISTRIBUTED_NO_ACK); - assertRegionAttributes(assertRegion(nativeLocalRegion, "NativeLocalRegion"), DataPolicy.NORMAL, Scope.LOCAL); + assertRegionAttributes(assertRegion(getRegion(applicationContext, "NativeLocalRegion"), "NativeLocalRegion"), + DataPolicy.NORMAL, Scope.LOCAL); - assertRegionAttributes(assertRegion(nativePartitionRegion, "NativePartitionRegion"), + assertRegionAttributes(assertRegion(getRegion(applicationContext, "NativePartitionRegion"), "NativePartitionRegion"), DataPolicy.PARTITION, Scope.DISTRIBUTED_NO_ACK); - assertRegionAttributes(assertRegion(nativeReplicateRegion, "NativeReplicateRegion"), + assertRegionAttributes(assertRegion(getRegion(applicationContext, "NativeReplicateRegion"), "NativeReplicateRegion"), DataPolicy.REPLICATE, Scope.DISTRIBUTED_ACK); - assertRegionAttributes(assertRegion(localRegion, "LocalRegion"), DataPolicy.NORMAL, Scope.LOCAL); + assertRegionAttributes(assertRegion(getRegion(applicationContext, "LocalRegion"), "LocalRegion"), + DataPolicy.NORMAL, Scope.LOCAL); + } + + @Test + public void testLocalOnlyConfiguration() { + try { + newApplicationContext(getLocation("cacheUsingLocalOnlyConfigurationIntegrationTest.xml")); + fail("Loading the 'cacheUsingLocalOnlyConfigurationIntegrationTest.xml' Spring ApplicationContext" + + " configuration file should have resulted in an Exception due to the Region lookup on" + + " 'ClusterConfigRegion' when GemFire Cluster Configuration is disabled!"); + } + catch (BeanCreationException expected) { + assertTrue(expected.getCause() instanceof BeanInitializationException); + assertTrue(expected.getCause().getMessage().contains("Cannot find Region [ClusterConfigRegion] in Cache")); + } } } diff --git a/src/test/java/org/springframework/data/gemfire/fork/LocatorProcess.java b/src/test/java/org/springframework/data/gemfire/fork/LocatorProcess.java index e1336d4c..a69f0f91 100644 --- a/src/test/java/org/springframework/data/gemfire/fork/LocatorProcess.java +++ b/src/test/java/org/springframework/data/gemfire/fork/LocatorProcess.java @@ -73,18 +73,18 @@ public class LocatorProcess { .setPort(Integer.getInteger("spring.gemfire.locator-port", DEFAULT_LOCATOR_PORT)) .setRedirectOutput(false) .set(DistributionConfig.ENABLE_SHARED_CONFIGURATION_NAME, String.valueOf(Boolean.getBoolean( - "spring.gemfire.enable-shared-configuration"))) + "spring.gemfire.enable-cluster-configuration"))) .set(DistributionConfig.HTTP_SERVICE_PORT_NAME, System.getProperty("spring.gemfire.http-service-port", DEFAULT_HTTP_SERVICE_PORT)) .set(DistributionConfig.JMX_MANAGER_NAME, String.valueOf(Boolean.TRUE)) .set(DistributionConfig.JMX_MANAGER_START_NAME, String.valueOf(Boolean.FALSE)) .set(DistributionConfig.LOAD_SHARED_CONFIG_FROM_DIR_NAME, String.valueOf(Boolean.getBoolean( - "spring.gemfire.load-shared-configuration"))) + "spring.gemfire.load-cluster-configuration"))) .set(DistributionConfig.LOG_LEVEL_NAME, System.getProperty("spring.gemfire.log-level", DEFAULT_LOG_LEVEL)) .build(); } - private static boolean isSharedConfigurationEnabled(final InternalLocator locator) { + private static boolean isClusterConfigurationEnabled(final InternalLocator locator) { return (locator != null && Boolean.valueOf(locator.getDistributedSystem().getProperties().getProperty( DistributionConfig.ENABLE_SHARED_CONFIGURATION_NAME))); } @@ -99,7 +99,7 @@ public class LocatorProcess { private void stopSharedConfigurationService() { InternalLocator locator = InternalLocator.getLocator(); - if (isSharedConfigurationEnabled(locator)) { + if (isClusterConfigurationEnabled(locator)) { SharedConfiguration sharedConfiguration = locator.getSharedConfiguration(); if (sharedConfiguration != null) { @@ -113,7 +113,7 @@ public class LocatorProcess { private static void waitForLocatorStart(final long milliseconds) { final InternalLocator locator = InternalLocator.getLocator(); - if (isSharedConfigurationEnabled(locator)) { + if (isClusterConfigurationEnabled(locator)) { ThreadUtils.timedWait(milliseconds, 500, new ThreadUtils.WaitCondition() { @Override public boolean waiting() { return !locator.isSharedConfigurationRunning(); diff --git a/src/test/resources/org/springframework/data/gemfire/cacheUsingSharedConfigurationIntegrationTest.xml b/src/test/resources/org/springframework/data/gemfire/cacheUsingClusterConfigurationIntegrationTest.xml similarity index 88% rename from src/test/resources/org/springframework/data/gemfire/cacheUsingSharedConfigurationIntegrationTest.xml rename to src/test/resources/org/springframework/data/gemfire/cacheUsingClusterConfigurationIntegrationTest.xml index eb9fcea8..96ffde25 100644 --- a/src/test/resources/org/springframework/data/gemfire/cacheUsingSharedConfigurationIntegrationTest.xml +++ b/src/test/resources/org/springframework/data/gemfire/cacheUsingClusterConfigurationIntegrationTest.xml @@ -17,9 +17,9 @@ + use-cluster-configuration="true" cache-xml-location="/sharedconfig-test-cache.xml" lazy-init="false"/> - + diff --git a/src/test/resources/org/springframework/data/gemfire/cacheUsingLocalOnlyConfigurationIntegrationTest.xml b/src/test/resources/org/springframework/data/gemfire/cacheUsingLocalOnlyConfigurationIntegrationTest.xml new file mode 100644 index 00000000..a0243fab --- /dev/null +++ b/src/test/resources/org/springframework/data/gemfire/cacheUsingLocalOnlyConfigurationIntegrationTest.xml @@ -0,0 +1,25 @@ + + + + + CacheNotUsingSharedConfigurationIntegrationTest + 0 + config + localhost[20668] + + + + + + + + diff --git a/src/test/resources/shared_config.zip b/src/test/resources/shared_config.zip index e81a520d..6537f261 100644 Binary files a/src/test/resources/shared_config.zip and b/src/test/resources/shared_config.zip differ