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 23D1A200D33 for ; Wed, 4 Oct 2017 03:49:47 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 2253D1609DE; Wed, 4 Oct 2017 01:49:47 +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 6D8F4160BDB for ; Wed, 4 Oct 2017 03:49:46 +0200 (CEST) Received: (qmail 49806 invoked by uid 500); 4 Oct 2017 01:49:45 -0000 Mailing-List: contact commits-help@helix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@helix.apache.org Delivered-To: mailing list commits@helix.apache.org Received: (qmail 49665 invoked by uid 99); 4 Oct 2017 01:49:45 -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, 04 Oct 2017 01:49:45 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id ED579F56AE; Wed, 4 Oct 2017 01:49:42 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jxue@apache.org To: commits@helix.apache.org Date: Wed, 04 Oct 2017 01:49:44 -0000 Message-Id: In-Reply-To: <69c1d8a4214044698d5f845da106d27b@git.apache.org> References: <69c1d8a4214044698d5f845da106d27b@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [3/7] helix git commit: Prevent ClusterControllerManager from starting multiple times archived-at: Wed, 04 Oct 2017 01:49:47 -0000 Prevent ClusterControllerManager from starting multiple times ClusterControllerManager is a runnable wrapper for a Helix Controller that could run on a separate thread for testing purpose. Since HelixManager.connect() should not be called more than once, this Controller should not be started more than once, either. Project: http://git-wip-us.apache.org/repos/asf/helix/repo Commit: http://git-wip-us.apache.org/repos/asf/helix/commit/94f39618 Tree: http://git-wip-us.apache.org/repos/asf/helix/tree/94f39618 Diff: http://git-wip-us.apache.org/repos/asf/helix/diff/94f39618 Branch: refs/heads/master Commit: 94f3961842263d04eef89019a1955e4c49e3305c Parents: d5a2395 Author: Weihan Kong Authored: Wed Feb 8 23:38:49 2017 -0800 Committer: Junkai Xue Committed: Tue Oct 3 15:07:52 2017 -0700 ---------------------------------------------------------------------- .../integration/manager/ClusterControllerManager.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/helix/blob/94f39618/helix-core/src/test/java/org/apache/helix/integration/manager/ClusterControllerManager.java ---------------------------------------------------------------------- diff --git a/helix-core/src/test/java/org/apache/helix/integration/manager/ClusterControllerManager.java b/helix-core/src/test/java/org/apache/helix/integration/manager/ClusterControllerManager.java index 9e10771..92ed52b 100644 --- a/helix-core/src/test/java/org/apache/helix/integration/manager/ClusterControllerManager.java +++ b/helix-core/src/test/java/org/apache/helix/integration/manager/ClusterControllerManager.java @@ -36,6 +36,8 @@ public class ClusterControllerManager extends ZKHelixManager implements Runnable private final CountDownLatch _stopCountDown = new CountDownLatch(1); private final CountDownLatch _waitStopFinishCountDown = new CountDownLatch(1); + private boolean _started = false; + public ClusterControllerManager(String zkAddr, String clusterName) { this(zkAddr, clusterName, "controller"); } @@ -48,13 +50,20 @@ public class ClusterControllerManager extends ZKHelixManager implements Runnable _stopCountDown.countDown(); try { _waitStopFinishCountDown.await(); + _started = false; } catch (InterruptedException e) { LOG.error("Interrupted waiting for finish", e); } } + // This should not be called more than once because HelixManager.connect() should not be called more than once. public void syncStart() { - // TODO: prevent start multiple times + if (_started) { + throw new RuntimeException("Helix Controller already started. Do not call syncStart() more than once."); + } else { + _started = true; + } + new Thread(this).start(); try { _startCountDown.await();