Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 69632200B9B for ; Wed, 12 Oct 2016 18:41:37 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 67B22160AD4; Wed, 12 Oct 2016 16:41:37 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 600ED160ACA for ; Wed, 12 Oct 2016 18:41:36 +0200 (CEST) Received: (qmail 50682 invoked by uid 500); 12 Oct 2016 16:41:35 -0000 Mailing-List: contact commits-help@geode.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@geode.incubator.apache.org Delivered-To: mailing list commits@geode.incubator.apache.org Received: (qmail 50673 invoked by uid 99); 12 Oct 2016 16:41:35 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Oct 2016 16:41:35 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id DBFAEC1A08 for ; Wed, 12 Oct 2016 16:41:34 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -6.219 X-Spam-Level: X-Spam-Status: No, score=-6.219 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-2.999] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id gL-jbqbjB13V for ; Wed, 12 Oct 2016 16:41:32 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with SMTP id 631E35F22E for ; Wed, 12 Oct 2016 16:41:32 +0000 (UTC) Received: (qmail 50645 invoked by uid 99); 12 Oct 2016 16:41:31 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Oct 2016 16:41:31 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 784B1E0209; Wed, 12 Oct 2016 16:41:31 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jinmeiliao@apache.org To: commits@geode.incubator.apache.org Message-Id: <8126e59fbf2c4d61b460f154a03c4290@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: incubator-geode git commit: GEODE-1986: correctly set the flag indicating if cluster configuration service is running or not on a locator. Date: Wed, 12 Oct 2016 16:41:31 +0000 (UTC) archived-at: Wed, 12 Oct 2016 16:41:37 -0000 Repository: incubator-geode Updated Branches: refs/heads/develop f079f3709 -> 584337b32 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/develop Commit: 584337b323b3713ec95dbb8934862dc83a65757f Parents: f079f37 Author: Jinmei Liao Authored: Tue Oct 11 14:01:33 2016 -0700 Committer: Jinmei Liao 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> 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 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(); + } +}