accumulo-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] keith-turner closed pull request #375: ACCUMULO-4797 improved namespace config performance
Date Thu, 01 Jan 1970 00:00:00 GMT
keith-turner closed pull request #375: ACCUMULO-4797 improved namespace config performance
URL: https://github.com/apache/accumulo/pull/375
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/Tables.java b/core/src/main/java/org/apache/accumulo/core/client/impl/Tables.java
index a93347c216..423d81f541 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/Tables.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/Tables.java
@@ -60,14 +60,15 @@ private static ZooCache getZooCache(final Instance instance) {
     if (sm != null) {
       sm.checkPermission(TABLES_PERMISSION);
     }
-    final String zks = instance.getZooKeepers();
-    final int timeOut = instance.getZooKeepersSessionTimeOut();
+
     final String uuid = instance.getInstanceID();
 
     try {
       return instanceToZooCache.get(uuid, new Callable<ZooCache>() {
         @Override
         public ZooCache call() {
+          final String zks = instance.getZooKeepers();
+          final int timeOut = instance.getZooKeepersSessionTimeOut();
           return new ZooCacheFactory().getZooCache(zks, timeOut, new Watcher() {
             @Override
             public void process(WatchedEvent watchedEvent) {
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 1ca083e30b..099f9e0527 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
@@ -45,6 +45,7 @@
   protected String namespaceId = null;
   protected Instance inst = null;
   private ZooCacheFactory zcf = new ZooCacheFactory();
+  private final String path;
 
   public NamespaceConfiguration(String namespaceId, AccumuloConfiguration parent) {
     this(namespaceId, HdfsZooInstance.getInstance(), parent);
@@ -54,6 +55,7 @@ public NamespaceConfiguration(String namespaceId, Instance inst, AccumuloConfigu
     this.inst = inst;
     this.parent = parent;
     this.namespaceId = namespaceId;
+    this.path = ZooUtil.getRoot(inst.getInstanceID()) + Constants.ZNAMESPACES + "/" + namespaceId
+ Constants.ZNAMESPACE_CONF;
   }
 
   /**
@@ -85,7 +87,7 @@ private synchronized ZooCachePropertyAccessor getPropCacheAccessor() {
   }
 
   private String getPath() {
-    return ZooUtil.getRoot(inst.getInstanceID()) + Constants.ZNAMESPACES + "/" + getNamespaceId()
+ Constants.ZNAMESPACE_CONF;
+    return path;
   }
 
   @Override
diff --git a/server/base/src/main/java/org/apache/accumulo/server/conf/ServerConfigurationFactory.java
b/server/base/src/main/java/org/apache/accumulo/server/conf/ServerConfigurationFactory.java
index f79f707c98..666c5eb1b9 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/conf/ServerConfigurationFactory.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/conf/ServerConfigurationFactory.java
@@ -21,6 +21,7 @@
 import java.util.Map;
 
 import org.apache.accumulo.core.client.Instance;
+import org.apache.accumulo.core.client.TableNotFoundException;
 import org.apache.accumulo.core.client.impl.Tables;
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
 import org.apache.accumulo.core.conf.ConfigSanityCheck;
@@ -189,8 +190,13 @@ public NamespaceConfiguration getNamespaceConfigurationForTable(String
tableId)
     // can't hold the lock during the construction and validation of the config,
     // which may result in creating multiple objects for the same id, but that's ok.
     if (conf == null) {
-      // changed - include instance in constructor call
-      conf = new TableParentConfiguration(tableId, instance, getConfiguration());
+      String namespaceId;
+      try {
+        namespaceId = Tables.getNamespaceId(instance, tableId);
+      } catch (TableNotFoundException e) {
+        throw new RuntimeException(e);
+      }
+      conf = new NamespaceConfiguration(namespaceId, instance, getConfiguration());
       ConfigSanityCheck.validate(conf);
       synchronized (tableParentConfigs) {
         tableParentConfigs.get(instanceID).put(tableId, conf);
diff --git a/server/base/src/main/java/org/apache/accumulo/server/conf/TableParentConfiguration.java
b/server/base/src/main/java/org/apache/accumulo/server/conf/TableParentConfiguration.java
deleted file mode 100644
index 70649be8af..0000000000
--- a/server/base/src/main/java/org/apache/accumulo/server/conf/TableParentConfiguration.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.accumulo.server.conf;
-
-import org.apache.accumulo.core.client.Instance;
-import org.apache.accumulo.core.client.TableNotFoundException;
-import org.apache.accumulo.core.client.impl.Tables;
-import org.apache.accumulo.core.conf.AccumuloConfiguration;
-
-/**
- * Used by TableConfiguration to dynamically get the NamespaceConfiguration if the namespace
changes
- */
-public class TableParentConfiguration extends NamespaceConfiguration {
-
-  private String tableId;
-
-  public TableParentConfiguration(String tableId, Instance inst, AccumuloConfiguration parent)
{
-    super(null, inst, parent);
-    this.tableId = tableId;
-    this.namespaceId = getNamespaceId();
-  }
-
-  @Override
-  protected String getNamespaceId() {
-    try {
-      return Tables.getNamespaceId(inst, tableId);
-    } catch (TableNotFoundException e) {
-      throw new RuntimeException(e);
-    }
-  }
-}
diff --git a/server/base/src/test/java/org/apache/accumulo/server/conf/NamespaceConfigurationTest.java
b/server/base/src/test/java/org/apache/accumulo/server/conf/NamespaceConfigurationTest.java
index 071e9c0402..1030546d59 100644
--- a/server/base/src/test/java/org/apache/accumulo/server/conf/NamespaceConfigurationTest.java
+++ b/server/base/src/test/java/org/apache/accumulo/server/conf/NamespaceConfigurationTest.java
@@ -65,15 +65,17 @@ public void setUp() {
     iid = UUID.randomUUID().toString();
     instance = createMock(Instance.class);
     parent = createMock(AccumuloConfiguration.class);
-    c = new NamespaceConfiguration(NSID, instance, parent);
-    zcf = createMock(ZooCacheFactory.class);
-    c.setZooCacheFactory(zcf);
 
     expect(instance.getInstanceID()).andReturn(iid);
     expectLastCall().anyTimes();
     expect(instance.getZooKeepers()).andReturn(ZOOKEEPERS);
     expect(instance.getZooKeepersSessionTimeOut()).andReturn(ZK_SESSION_TIMEOUT);
     replay(instance);
+
+    c = new NamespaceConfiguration(NSID, instance, parent);
+    zcf = createMock(ZooCacheFactory.class);
+    c.setZooCacheFactory(zcf);
+
     zc = createMock(ZooCache.class);
     expect(zcf.getZooCache(eq(ZOOKEEPERS), eq(ZK_SESSION_TIMEOUT), anyObject(NamespaceConfWatcher.class))).andReturn(zc);
     replay(zcf);


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message