You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by kt...@apache.org on 2018/02/05 22:08:52 UTC
[accumulo] branch 1.8 updated: ACCUMULO-4797 improved namespace
config performance (#375)
This is an automated email from the ASF dual-hosted git repository.
kturner pushed a commit to branch 1.8
in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/1.8 by this push:
new 3c55eed ACCUMULO-4797 improved namespace config performance (#375)
3c55eed is described below
commit 3c55eed2198afc90d6c1230783fcdd64e4c7e47d
Author: Keith Turner <ke...@deenlo.com>
AuthorDate: Mon Feb 5 17:08:50 2018 -0500
ACCUMULO-4797 improved namespace config performance (#375)
---
.../apache/accumulo/core/client/impl/Tables.java | 5 ++-
.../server/conf/NamespaceConfiguration.java | 4 +-
.../server/conf/ServerConfigurationFactory.java | 10 ++++-
.../server/conf/TableParentConfiguration.java | 45 ----------------------
.../server/conf/NamespaceConfigurationTest.java | 8 ++--
5 files changed, 19 insertions(+), 53 deletions(-)
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 a93347c..423d81f 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 @@ public class Tables {
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 51783f6..3898f8c 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 @@ public class NamespaceConfiguration extends ObservableConfiguration {
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 class NamespaceConfiguration extends ObservableConfiguration {
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 @@ public class NamespaceConfiguration extends ObservableConfiguration {
}
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 f79f707..666c5eb 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.HashMap;
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 class ServerConfigurationFactory extends ServerConfiguration {
// 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 70649be..0000000
--- 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 071e9c0..1030546 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 class NamespaceConfigurationTest {
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);
--
To stop receiving notification emails like this one, please contact
kturner@apache.org.