You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2016/10/13 17:14:43 UTC
[06/20] incubator-geode git commit: GEODE-1986: correctly set the
flag indicating if cluster configuration service is running or not on a
locator.
GEODE-1986: correctly set the flag indicating if cluster configuration service is running or not on a locator.
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/584337b3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/584337b3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/584337b3
Branch: refs/heads/feature/GEODE-1466
Commit: 584337b323b3713ec95dbb8934862dc83a65757f
Parents: f079f37
Author: Jinmei Liao <ji...@pivotal.io>
Authored: Tue Oct 11 14:01:33 2016 -0700
Committer: Jinmei Liao <ji...@pivotal.io>
Committed: Wed Oct 12 09:40:26 2016 -0700
----------------------------------------------------------------------
.../internal/InternalDistributedSystem.java | 68 +++++++++++---------
.../geode/internal/cache/GemFireCacheImpl.java | 6 +-
...lusterConfigWithEmbededLocatorDUnitTest.java | 67 +++++++++++++++++++
3 files changed, 107 insertions(+), 34 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/584337b3/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
index 17303c1..848a86e 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
@@ -98,15 +98,13 @@ import org.apache.geode.internal.offheap.MemoryAllocator;
import org.apache.geode.internal.offheap.OffHeapStorage;
import org.apache.geode.internal.statistics.DummyStatisticsImpl;
import org.apache.geode.internal.statistics.GemFireStatSampler;
-import org.apache.geode.internal.statistics.platform.LinuxProcFsStatistics;
import org.apache.geode.internal.statistics.LocalStatisticsImpl;
-import org.apache.geode.internal.statistics.platform.OsStatisticsFactory;
import org.apache.geode.internal.statistics.StatisticsImpl;
import org.apache.geode.internal.statistics.StatisticsManager;
import org.apache.geode.internal.statistics.StatisticsTypeFactoryImpl;
+import org.apache.geode.internal.statistics.platform.LinuxProcFsStatistics;
+import org.apache.geode.internal.statistics.platform.OsStatisticsFactory;
import org.apache.geode.internal.tcp.ConnectionTable;
-import org.apache.geode.internal.util.concurrent.StoppableCondition;
-import org.apache.geode.internal.util.concurrent.StoppableReentrantLock;
import org.apache.geode.management.ManagementException;
import org.apache.geode.security.GemFireSecurityException;
@@ -733,39 +731,45 @@ public class InternalDistributedSystem extends DistributedSystem implements OsSt
*/
private void startInitLocator() throws InterruptedException {
String locatorString = this.originalConfig.getStartLocator();
- if (locatorString.length() > 0) {
- // when reconnecting we don't want to join with a colocated locator unless
- // there is a quorum of the old members available
- if (attemptingToReconnect && !this.isConnected) {
- if (this.quorumChecker != null) {
- logger.info("performing a quorum check to see if location services can be started early");
- if (!quorumChecker.checkForQuorum(3 * this.config.getMemberTimeout())) {
- logger.info("quorum check failed - not allowing location services to start early");
- return;
- }
- logger.info("Quorum check passed - allowing location services to start early");
+ if (locatorString.length()==0) {
+ return;
+ }
+
+ // when reconnecting we don't want to join with a colocated locator unless
+ // there is a quorum of the old members available
+ if (attemptingToReconnect && !this.isConnected) {
+ if (this.quorumChecker != null) {
+ logger.info("performing a quorum check to see if location services can be started early");
+ if (!quorumChecker.checkForQuorum(3 * this.config.getMemberTimeout())) {
+ logger.info("quorum check failed - not allowing location services to start early");
+ return;
}
+ logger.info("Quorum check passed - allowing location services to start early");
}
- DistributionLocatorId locId = new DistributionLocatorId(locatorString);
- try {
- this.startedLocator = InternalLocator.createLocator(locId.getPort(), null, null, this.logWriter, // LOG: this is after IDS has created LogWriterLoggers and Appenders
- this.securityLogWriter, // LOG: this is after IDS has created LogWriterLoggers and Appenders
- locId.getHost(), locId.getHostnameForClients(), this.originalConfig.toProperties(), false);
- if (locId.isPeerLocator()) {
- boolean startedPeerLocation = false;
- try {
- this.startedLocator.startPeerLocation(true);
- startedPeerLocation = true;
- } finally {
- if (!startedPeerLocation) {
- this.startedLocator.stop();
- }
+ }
+ DistributionLocatorId locId = new DistributionLocatorId(locatorString);
+ try {
+ this.startedLocator = InternalLocator.createLocator(locId.getPort(), null, null, this.logWriter, // LOG: this is after IDS has created LogWriterLoggers and Appenders
+ this.securityLogWriter, // LOG: this is after IDS has created LogWriterLoggers and Appenders
+ locId.getHost(), locId.getHostnameForClients(), this.originalConfig.toProperties(), false);
+
+ // if locator is started this way, cluster config is not enabled, set the flag correctly
+ this.startedLocator.getConfig().setEnableClusterConfiguration(false);
+
+ if (locId.isPeerLocator()) {
+ boolean startedPeerLocation = false;
+ try {
+ this.startedLocator.startPeerLocation(true);
+ startedPeerLocation = true;
+ } finally {
+ if (!startedPeerLocation) {
+ this.startedLocator.stop();
}
}
- } catch (IOException e) {
- throw new GemFireIOException(LocalizedStrings.
- InternalDistributedSystem_PROBLEM_STARTING_A_LOCATOR_SERVICE.toLocalizedString(), e);
}
+ } catch (IOException e) {
+ throw new GemFireIOException(LocalizedStrings.
+ InternalDistributedSystem_PROBLEM_STARTING_A_LOCATOR_SERVICE.toLocalizedString(), e);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/584337b3/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java b/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
index d166397..6c195e7 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
@@ -952,7 +952,6 @@ public class GemFireCacheImpl implements InternalCache, ClientCache, HasCachePer
* Request the shared configuration from the locator(s) which have the Cluster config service running
*/
public ConfigurationResponse requestSharedConfiguration() {
- //Request the shared configuration from the locator(s)
final DistributionConfig config = this.system.getConfig();
if (!(dm instanceof DistributionManager))
@@ -964,6 +963,9 @@ public class GemFireCacheImpl implements InternalCache, ClientCache, HasCachePer
|| Locator.getLocator() !=null )
return null;
+ // can't simply return null if server is not using shared configuration, since we need to find out
+ // if the locator is running in secure mode or not, if yes, then we need to throw an exception if server is not using cluster config
+
Map<InternalDistributedMember, Collection<String>> scl = this.getDistributionManager().getAllHostedLocatorsWithSharedConfiguration();
//If there are no locators with Shared configuration, that means the system has been started without shared configuration
@@ -973,7 +975,7 @@ public class GemFireCacheImpl implements InternalCache, ClientCache, HasCachePer
return null;
}
- String groupsString = config.getGroups();
+
ConfigurationResponse response = null;
List<String> locatorConnectionStrings = getSharedConfigLocatorConnectionStringList();
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/584337b3/geode-core/src/test/java/org/apache/geode/security/ClusterConfigWithEmbededLocatorDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/security/ClusterConfigWithEmbededLocatorDUnitTest.java b/geode-core/src/test/java/org/apache/geode/security/ClusterConfigWithEmbededLocatorDUnitTest.java
new file mode 100644
index 0000000..467caaa
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/security/ClusterConfigWithEmbededLocatorDUnitTest.java
@@ -0,0 +1,67 @@
+/*
+ * 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.security;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.cache.CacheFactory;
+import org.apache.geode.internal.AvailablePortHelper;
+import org.apache.geode.test.dunit.Host;
+import org.apache.geode.test.dunit.VM;
+import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase;
+import org.apache.geode.test.junit.categories.DistributedTest;
+import org.apache.geode.test.junit.categories.SecurityTest;
+
+@Category({ DistributedTest.class, SecurityTest.class })
+public class ClusterConfigWithEmbededLocatorDUnitTest extends JUnit4DistributedTestCase {
+ protected VM locator = null;
+
+ @Before
+ public void before() throws Exception {
+ final Host host = Host.getHost(0);
+ this.locator = host.getVM(0);
+ }
+
+ @Test
+ public void testEmbeddedLocator() throws Exception{
+ int locatorPort = AvailablePortHelper.getRandomAvailableTCPPort();
+
+ // locator started this way won't have cluster configuration running
+ locator.invoke(()->{
+ new CacheFactory()
+ .set("name", this.getName()+".server1")
+ .set("mcast-port", "0")
+ .set("log-level", "config")
+ .set("start-locator", "localhost["+locatorPort+"]")
+ .create();
+ });
+
+ // when this server joins the above locator, it won't request the cluster config from the locator
+ // since DM.getAllHostedLocatorsWithSharedConfiguration() will return an empty list. This would
+ // execute without error
+
+ new CacheFactory()
+ .set("name", this.getName()+".server2")
+ .set("mcast-port", "0")
+ .set("log-level", "config")
+ .set("locators", "localhost["+locatorPort+"]")
+ .create();
+ }
+}