You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by sa...@apache.org on 2018/03/29 22:52:56 UTC
[geode] branch develop updated: GEODE-4913: gfsh start server cmd is not recognizing local properties… (#1687)
This is an automated email from the ASF dual-hosted git repository.
sai_boorlagadda pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/develop by this push:
new 2a6db7c GEODE-4913: gfsh start server cmd is not recognizing local properties… (#1687)
2a6db7c is described below
commit 2a6db7c6661d3e43bd99921175437162a523f222
Author: Sai Boorlagadda <sa...@gmail.com>
AuthorDate: Thu Mar 29 15:52:52 2018 -0700
GEODE-4913: gfsh start server cmd is not recognizing local properties… (#1687)
… and cache.xml, instead using default
* Reverted having a default cluster xml, having a default xml
in the cluster config caused a default cache server to be
launched, which caused the sighted issue.
* Instead cluster config is initialized only when needed.
---
.../cli/CreateConnectionCommandDUnitTest.java | 2 +-
.../InternalClusterConfigurationService.java | 18 +++--
.../configuration/domain/Configuration.java | 8 --
.../cache/StartServerWithXmlDUnitTest.java | 88 ++++++++++++++++++++++
.../CreateAsyncEventQueueCommandDUnitTest.java | 3 +-
.../CreateDefinedIndexesCommandDUnitTest.java | 5 +-
.../internal/cache/CacheServerWithZeroPort.xml | 24 ++++++
7 files changed, 128 insertions(+), 20 deletions(-)
diff --git a/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/cli/CreateConnectionCommandDUnitTest.java b/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/cli/CreateConnectionCommandDUnitTest.java
index 1019394..5f06fa5 100644
--- a/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/cli/CreateConnectionCommandDUnitTest.java
+++ b/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/cli/CreateConnectionCommandDUnitTest.java
@@ -103,7 +103,7 @@ public class CreateConnectionCommandDUnitTest {
locator.invoke(() -> {
String xml = InternalLocator.getLocator().getSharedConfiguration().getConfiguration("cluster")
.getCacheXmlContent();
- assertThat(xml).doesNotContain("jdbc:connector-service");
+ assertThat(xml).isNull();
});
}
}
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalClusterConfigurationService.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalClusterConfigurationService.java
index ff18923..7c6a194 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalClusterConfigurationService.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalClusterConfigurationService.java
@@ -239,10 +239,7 @@ public class InternalClusterConfigurationService implements ClusterConfiguration
}
String xmlContent = configuration.getCacheXmlContent();
if (xmlContent == null || xmlContent.isEmpty()) {
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- CacheXmlGenerator.generateDefault(pw);
- xmlContent = sw.toString();
+ xmlContent = generateInitialXmlContent();
}
try {
final Document doc = XmlUtils.createAndUpgradeDocumentFromXml(xmlContent);
@@ -866,13 +863,24 @@ public class InternalClusterConfigurationService implements ClusterConfiguration
return unmarshaller;
}
+ private String generateInitialXmlContent() {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ CacheXmlGenerator.generateDefault(pw);
+ return sw.toString();
+ }
+
@Override
public CacheConfig getCacheConfig(String group,
Class<? extends CacheElement>... additionalBindClass) {
if (group == null) {
group = CLUSTER_CONFIG;
}
- return unMarshall(getConfiguration(group).getCacheXmlContent(), additionalBindClass);
+ String xmlContent = getConfiguration(group).getCacheXmlContent();
+ if (xmlContent == null || xmlContent.isEmpty()) {
+ xmlContent = generateInitialXmlContent();
+ }
+ return unMarshall(xmlContent, additionalBindClass);
}
@Override
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/configuration/domain/Configuration.java b/geode-core/src/main/java/org/apache/geode/management/internal/configuration/domain/Configuration.java
index 132b8a3..b9059b7 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/configuration/domain/Configuration.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/configuration/domain/Configuration.java
@@ -73,14 +73,6 @@ public class Configuration implements DataSerializable {
this.propertiesFileName = configName + ".properties";
this.gemfireProperties = new Properties();
this.jarNames = new HashSet<String>();
- this.cacheXmlContent = generateInitialXmlContent();
- }
-
- private String generateInitialXmlContent() {
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- CacheXmlGenerator.generateDefault(pw);
- return sw.toString();
}
public String getCacheXmlContent() {
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/StartServerWithXmlDUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/StartServerWithXmlDUnitTest.java
new file mode 100644
index 0000000..b034cfb
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/StartServerWithXmlDUnitTest.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package org.apache.geode.internal.cache;
+
+import static org.apache.geode.distributed.ConfigurationProperties.CACHE_XML_FILE;
+import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Properties;
+import java.util.stream.Collectors;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.CacheFactory;
+import org.apache.geode.cache.server.CacheServer;
+import org.apache.geode.distributed.ServerLauncher;
+import org.apache.geode.distributed.ServerLauncherIntegrationTest;
+import org.apache.geode.distributed.internal.DistributionConfig;
+import org.apache.geode.distributed.internal.InternalDistributedSystem;
+import org.apache.geode.internal.cache.CacheServerLauncher;
+import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.internal.cache.InternalCache;
+import org.apache.geode.test.dunit.VM;
+import org.apache.geode.test.dunit.rules.ClusterStartupRule;
+import org.apache.geode.test.dunit.rules.MemberVM;
+import org.apache.geode.test.junit.categories.DistributedTest;
+import org.apache.geode.test.junit.rules.GfshCommandRule;
+import org.apache.geode.test.junit.rules.LocatorStarterRule;
+import org.apache.geode.test.junit.rules.Server;
+import org.apache.geode.test.junit.rules.ServerStarterRule;
+import org.apache.geode.util.test.TestUtil;
+
+@Category(DistributedTest.class)
+public class StartServerWithXmlDUnitTest {
+
+ private VM server;
+ private MemberVM locator;
+
+ @Rule
+ public ClusterStartupRule cluster = new ClusterStartupRule();
+
+ @Before
+ public void before() throws Exception {
+ locator = cluster.startLocatorVM(0);
+
+ Properties props = new Properties();
+ String locators = "localhost[" + locator.getPort() + "]";
+ props.setProperty(LOCATORS, locators);
+ String cacheXmlPath = TestUtil.getResourcePath(getClass(), "CacheServerWithZeroPort.xml");
+ props.setProperty(CACHE_XML_FILE, cacheXmlPath);
+
+ server = cluster.getVM(1);
+
+ server.invoke(() -> {
+ CacheServerLauncher.setServerBindAddress("localhost");
+ CacheServerLauncher.setDisableDefaultServer(false);
+ CacheFactory cf = new CacheFactory(props);
+ Cache cache = cf.create();
+ });
+ }
+
+ @Test
+ public void startServerWithXMLNotToStartDefaultCacheServer() {
+ // Verify that when there is a declarative cache server then we dont launch default server
+ server.invoke(() -> {
+ assertThat(GemFireCacheImpl.getInstance().getCacheServers().size()).isEqualTo(1);
+ });
+ }
+}
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateAsyncEventQueueCommandDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateAsyncEventQueueCommandDUnitTest.java
index 8afc799..aec2627 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateAsyncEventQueueCommandDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateAsyncEventQueueCommandDUnitTest.java
@@ -113,8 +113,7 @@ public class CreateAsyncEventQueueCommandDUnitTest {
locator.invoke(() -> {
InternalClusterConfigurationService service =
ClusterStartupRule.getLocator().getSharedConfiguration();
- assertThat(service.getConfiguration("cluster").getCacheXmlContent())
- .doesNotContain("async-event-queue");
+ assertThat(service.getConfiguration("cluster").getCacheXmlContent()).isNull();
});
gfsh.executeAndAssertThat(VALID_COMMAND + " --id=queue").statusIsSuccess()
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateDefinedIndexesCommandDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateDefinedIndexesCommandDUnitTest.java
index b0925e9..5149478 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateDefinedIndexesCommandDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateDefinedIndexesCommandDUnitTest.java
@@ -206,10 +206,7 @@ public class CreateDefinedIndexesCommandDUnitTest {
((InternalLocator) Locator.getLocator()).getSharedConfiguration();
assertThat(sharedConfig.getConfiguration("group1").getCacheXmlContent()).contains(index2Name,
index1Name);
- assertThat(sharedConfig.getConfiguration("cluster").getCacheXmlContent())
- .doesNotContain(index2Name);
- assertThat(sharedConfig.getConfiguration("cluster").getCacheXmlContent())
- .doesNotContain(index1Name);
+ assertThat(sharedConfig.getConfiguration("cluster").getCacheXmlContent()).isNullOrEmpty();
});
}
}
diff --git a/geode-core/src/test/resources/org/apache/geode/internal/cache/CacheServerWithZeroPort.xml b/geode-core/src/test/resources/org/apache/geode/internal/cache/CacheServerWithZeroPort.xml
new file mode 100755
index 0000000..01d6633
--- /dev/null
+++ b/geode-core/src/test/resources/org/apache/geode/internal/cache/CacheServerWithZeroPort.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<cache
+ xmlns="http://geode.apache.org/schema/cache"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://geode.apache.org/schema/cache http://geode.apache.org/schema/cache/cache-1.0.xsd"
+ version="1.0">
+ <cache-server port="0"/>
+</cache>
--
To stop receiving notification emails like this one, please contact
sai_boorlagadda@apache.org.