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 3E0A5200B6A for ; Mon, 22 Aug 2016 18:39:36 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 3CECE160A87; Mon, 22 Aug 2016 16:39:36 +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 5ACB5160ABD for ; Mon, 22 Aug 2016 18:39:35 +0200 (CEST) Received: (qmail 30050 invoked by uid 500); 22 Aug 2016 16:39:34 -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 30041 invoked by uid 99); 22 Aug 2016 16:39:34 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Aug 2016 16:39:34 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 24855C0439 for ; Mon, 22 Aug 2016 16:39:34 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -4.646 X-Spam-Level: X-Spam-Status: No, score=-4.646 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=-1.426] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id 127jd3PeIAzu for ; Mon, 22 Aug 2016 16:39:32 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id 15BE25FBDE for ; Mon, 22 Aug 2016 16:39:30 +0000 (UTC) Received: (qmail 29566 invoked by uid 99); 22 Aug 2016 16:39:30 -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; Mon, 22 Aug 2016 16:39:30 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 15BCAE69B5; Mon, 22 Aug 2016 16:39:30 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: abaker@apache.org To: commits@geode.incubator.apache.org Date: Mon, 22 Aug 2016 16:39:36 -0000 Message-Id: <715f7dd57c5042d7b529c55678318138@git.apache.org> In-Reply-To: <8b9a752aeaea46b4a978db43c4ab5ae0@git.apache.org> References: <8b9a752aeaea46b4a978db43c4ab5ae0@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [08/50] [abbrv] incubator-geode git commit: GEODE-1600: startLocatorAndDS takes 0 as port number parameter archived-at: Mon, 22 Aug 2016 16:39:36 -0000 GEODE-1600: startLocatorAndDS takes 0 as port number parameter * Use of getAvailableTCP port led to race conditions which led to locators being assigned ports in use. * Use of 0 now assignes a port number to the locator after the server is started. * Code modification to accept 0 as a valid port number until a real port number is assigned after the server is started. This closes #202 Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/8a28f523 Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/8a28f523 Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/8a28f523 Branch: refs/heads/master Commit: 8a28f52334ac08183d53b427fa9bb8feaab8f834 Parents: 5b28987 Author: nabarun Authored: Mon Jul 11 14:11:38 2016 -0700 Committer: nabarun Committed: Thu Jul 14 09:50:05 2016 -0700 ---------------------------------------------------------------------- .../internal/AbstractDistributionConfig.java | 5 ++- .../distributed/internal/InternalLocator.java | 8 +++++ .../test/dunit/standalone/DUnitLauncher.java | 36 +++++++++++++------- 3 files changed, 35 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8a28f523/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/AbstractDistributionConfig.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/AbstractDistributionConfig.java b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/AbstractDistributionConfig.java index 531e462..601818e 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/AbstractDistributionConfig.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/AbstractDistributionConfig.java @@ -322,7 +322,10 @@ public abstract class AbstractDistributionConfig int portVal = 0; try { portVal = Integer.parseInt(port); - if (portVal < 1 || portVal > 65535) { + if(0 == portVal){ + return ""; + } + else if (portVal < 1 || portVal > 65535) { throw new IllegalArgumentException(LocalizedStrings.AbstractDistributionConfig_INVALID_LOCATOR_0_THE_PORT_1_WAS_NOT_GREATER_THAN_ZERO_AND_LESS_THAN_65536.toLocalizedString(new Object[] {value, Integer.valueOf(portVal)})); } } catch (NumberFormatException ex) { http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8a28f523/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/InternalLocator.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/InternalLocator.java b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/InternalLocator.java index de191e8..1a343dc 100755 --- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/InternalLocator.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/InternalLocator.java @@ -603,6 +603,14 @@ public class InternalLocator extends Locator implements ConnectListener { this.handler, new DelayedPoolStatHelper(), group, this.toString()); } + //Reset the file names with the correct port number if startLocatorAndDS was called with port number 0 + public void resetInternalLocatorFileNamesWithCorrectPortNumber(int port){ + this.stateFile = new File("locator" + port + "view.dat"); + File productUseFile = new File("locator"+port+"views.log"); + this.productUseLog = new ProductUseLog(productUseFile); + } + + private void startTcpServer() throws IOException { logger.info(LocalizedMessage.create(LocalizedStrings.InternalLocator_STARTING_0, this)); server.start(); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8a28f523/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/DUnitLauncher.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/DUnitLauncher.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/DUnitLauncher.java index b53327d..3335158 100755 --- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/DUnitLauncher.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/DUnitLauncher.java @@ -141,8 +141,6 @@ public class DUnitLauncher { DUNIT_SUSPECT_FILE.delete(); DUNIT_SUSPECT_FILE.deleteOnExit(); - locatorPort = AvailablePortHelper.getRandomAvailableTCPPort(); - //create an RMI registry and add an object to share our tests config int namingPort = AvailablePortHelper.getRandomAvailableTCPPort(); Registry registry = LocateRegistry.createRegistry(namingPort); @@ -184,27 +182,35 @@ public class DUnitLauncher { processManager.killVMs(); } }); - + + //Create a VM for the locator processManager.launchVM(LOCATOR_VM_NUM); - + + //wait for the VM to start up + if(!processManager.waitForVMs(STARTUP_TIMEOUT)) { + throw new RuntimeException("VMs did not start up with 30 seconds"); + } + + locatorPort = startLocator(registry); + + init(master); + + //Launch an initial set of VMs for(int i=0; i < NUM_VMS; i++) { processManager.launchVM(i); } - + //wait for the VMS to start up if(!processManager.waitForVMs(STARTUP_TIMEOUT)) { throw new RuntimeException("VMs did not start up with 30 seconds"); } - + //populate the Host class with our stubs. The tests use this host class DUnitHost host = new DUnitHost(InetAddress.getLocalHost().getCanonicalHostName(), processManager); host.init(registry, NUM_VMS); - init(master); - - startLocator(registry); } public static Properties getDistributedSystemProperties() { @@ -241,7 +247,7 @@ public class DUnitLauncher { loggerConfig.addAppender(fileAppender, Level.INFO, null); } - private static void startLocator(Registry registry) throws IOException, NotBoundException { + private static int startLocator(Registry registry) throws IOException, NotBoundException { RemoteDUnitVMIF remote = (RemoteDUnitVMIF) registry.lookup("vm" + LOCATOR_VM_NUM); final File locatorLogFile = LOCATOR_LOG_TO_DISK ? new File("locator-" + locatorPort + ".log") : new File(""); @@ -262,12 +268,15 @@ public class DUnitLauncher { p.setProperty(DISABLE_AUTO_RECONNECT, "true"); try { - Locator.startLocatorAndDS(locatorPort, locatorLogFile, p); + Locator.startLocatorAndDS(0, locatorLogFile, p); + InternalLocator internalLocator = (InternalLocator) Locator.getLocator(); + locatorPort = internalLocator.getPort(); + internalLocator.resetInternalLocatorFileNamesWithCorrectPortNumber(locatorPort); } finally { System.getProperties().remove(GMSJoinLeave.BYPASS_DISCOVERY_PROPERTY); } - - return null; + + return locatorPort; } }, "call"); if(result.getException() != null) { @@ -275,6 +284,7 @@ public class DUnitLauncher { ex.printStackTrace(); throw ex; } + return (Integer) result.getResult(); } public static void init(MasterRemote master) {