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 <els...@apache.org>
Authored: Thu Mar 20 21:14:35 2014 -0400
Committer: Josh Elser <els...@apache.org>
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<ConfigurationObserver> 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<ConfigurationObserver>());
@@ -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;

Reply via email to