Return-Path: X-Original-To: apmail-accumulo-commits-archive@www.apache.org Delivered-To: apmail-accumulo-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DA2F310870 for ; Fri, 21 Mar 2014 02:13:31 +0000 (UTC) Received: (qmail 46420 invoked by uid 500); 21 Mar 2014 02:13:13 -0000 Delivered-To: apmail-accumulo-commits-archive@accumulo.apache.org Received: (qmail 46203 invoked by uid 500); 21 Mar 2014 02:13:09 -0000 Mailing-List: contact commits-help@accumulo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@accumulo.apache.org Delivered-To: mailing list commits@accumulo.apache.org Received: (qmail 45982 invoked by uid 99); 21 Mar 2014 02:13:06 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 Mar 2014 02:13:06 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 2CB979874D5; Fri, 21 Mar 2014 02:13:05 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: elserj@apache.org To: commits@accumulo.apache.org Date: Fri, 21 Mar 2014 02:13:26 -0000 Message-Id: <5892d6bf4c814b898e0995449ec97f1b@git.apache.org> In-Reply-To: <495c33a4a6a14a648b5884938895ce2f@git.apache.org> References: <495c33a4a6a14a648b5884938895ce2f@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [23/25] git commit: ACCUMULO-2515 ACCUMULO-2489 Apply same fixes from TableConfiguration to NamespaceConfiguration ACCUMULO-2515 ACCUMULO-2489 Apply same fixes from TableConfiguration to NamespaceConfiguration Also switch over TableConfigurationUpdateIT to use SimpleMacIT instead of doing it itself. Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/cb2f4b58 Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/cb2f4b58 Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/cb2f4b58 Branch: refs/heads/master Commit: cb2f4b58041a4176d907e77a0853e2c3316df4ec Parents: c25a41f Author: Josh Elser Authored: Thu Mar 20 21:14:35 2014 -0400 Committer: Josh Elser Committed: Thu Mar 20 21:14:35 2014 -0400 ---------------------------------------------------------------------- .../server/conf/NamespaceConfiguration.java | 24 ++++++++++---- .../test/TableConfigurationUpdateIT.java | 34 ++++---------------- 2 files changed, 24 insertions(+), 34 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/cb2f4b58/server/base/src/main/java/org/apache/accumulo/server/conf/NamespaceConfiguration.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/conf/NamespaceConfiguration.java b/server/base/src/main/java/org/apache/accumulo/server/conf/NamespaceConfiguration.java index d08d45f..99532ca 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/conf/NamespaceConfiguration.java +++ b/server/base/src/main/java/org/apache/accumulo/server/conf/NamespaceConfiguration.java @@ -38,13 +38,18 @@ public class NamespaceConfiguration extends AccumuloConfiguration { private static final Logger log = Logger.getLogger(NamespaceConfiguration.class); private final AccumuloConfiguration parent; - private static ZooCache propCache = null; + private static volatile ZooCache propCache = null; + private static final Object lock = new Object(); protected String namespaceId = null; protected Instance inst = null; private Set observers; public NamespaceConfiguration(String namespaceId, AccumuloConfiguration parent) { - inst = HdfsZooInstance.getInstance(); + this(namespaceId, HdfsZooInstance.getInstance(), parent); + } + + public NamespaceConfiguration(String namespaceId, Instance inst, AccumuloConfiguration parent) { + this.inst = inst; this.parent = parent; this.namespaceId = namespaceId; this.observers = Collections.synchronizedSet(new HashSet()); @@ -75,10 +80,17 @@ public class NamespaceConfiguration extends AccumuloConfiguration { return value; } - private synchronized static ZooCache getPropCache() { - Instance inst = HdfsZooInstance.getInstance(); - if (propCache == null) - propCache = new ZooCache(inst.getZooKeepers(), inst.getZooKeepersSessionTimeOut(), new NamespaceConfWatcher(inst)); + private void initializePropCache() { + synchronized (lock) { + if (propCache == null) + propCache = new ZooCache(inst.getZooKeepers(), inst.getZooKeepersSessionTimeOut(), new NamespaceConfWatcher(inst)); + } + } + + private ZooCache getPropCache() { + if (null == propCache) { + initializePropCache(); + } return propCache; } http://git-wip-us.apache.org/repos/asf/accumulo/blob/cb2f4b58/test/src/test/java/org/apache/accumulo/test/TableConfigurationUpdateIT.java ---------------------------------------------------------------------- diff --git a/test/src/test/java/org/apache/accumulo/test/TableConfigurationUpdateIT.java b/test/src/test/java/org/apache/accumulo/test/TableConfigurationUpdateIT.java index c3e3342..5e2b2c9 100644 --- a/test/src/test/java/org/apache/accumulo/test/TableConfigurationUpdateIT.java +++ b/test/src/test/java/org/apache/accumulo/test/TableConfigurationUpdateIT.java @@ -27,50 +27,28 @@ import java.util.concurrent.TimeUnit; import org.apache.accumulo.core.client.Connector; import org.apache.accumulo.core.client.Instance; -import org.apache.accumulo.core.client.ZooKeeperInstance; -import org.apache.accumulo.core.client.security.tokens.PasswordToken; +import org.apache.accumulo.core.client.impl.Namespaces; import org.apache.accumulo.core.conf.AccumuloConfiguration; import org.apache.accumulo.core.conf.Property; -import org.apache.accumulo.minicluster.MiniAccumuloCluster; import org.apache.accumulo.server.conf.NamespaceConfiguration; import org.apache.accumulo.server.conf.TableConfiguration; -import org.apache.accumulo.server.conf.TableParentConfiguration; +import org.apache.accumulo.test.functional.SimpleMacIT; import org.apache.log4j.Logger; -import org.junit.After; import org.junit.Assert; -import org.junit.Before; import org.junit.Test; -import org.junit.rules.TemporaryFolder; -public class TableConfigurationUpdateIT { +public class TableConfigurationUpdateIT extends SimpleMacIT { private static final Logger log = Logger.getLogger(TableConfigurationUpdateIT.class); - public static TemporaryFolder folder = new TemporaryFolder(); - private MiniAccumuloCluster accumulo; - private String secret = "secret"; - - @Before - public void setUp() throws Exception { - folder.create(); - accumulo = new MiniAccumuloCluster(folder.getRoot(), secret); - accumulo.start(); - } - - @After - public void tearDown() throws Exception { - accumulo.stop(); - folder.delete(); - } - @Test public void test() throws Exception { - Instance inst = new ZooKeeperInstance(accumulo.getInstanceName(), accumulo.getZooKeepers()); - Connector conn = inst.getConnector("root", new PasswordToken(secret)); + Connector conn = getConnector(); + Instance inst = conn.getInstance(); String table = "foo"; conn.tableOperations().create(table); - final NamespaceConfiguration defaultConf = new TableParentConfiguration(conn.tableOperations().tableIdMap().get(table), AccumuloConfiguration.getDefaultConfiguration()); + final NamespaceConfiguration defaultConf = new NamespaceConfiguration(Namespaces.DEFAULT_NAMESPACE_ID, inst, AccumuloConfiguration.getDefaultConfiguration()); // Cache invalidates 25% of the time int randomMax = 4;