From commits-return-21449-archive-asf-public=cust-asf.ponee.io@accumulo.apache.org Mon Feb 5 23:08:54 2018 Return-Path: X-Original-To: archive-asf-public@eu.ponee.io Delivered-To: archive-asf-public@eu.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by mx-eu-01.ponee.io (Postfix) with ESMTP id E1E4B180647 for ; Mon, 5 Feb 2018 23:08:54 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id D1AF4160C3B; Mon, 5 Feb 2018 22:08:54 +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 007CF160C4B for ; Mon, 5 Feb 2018 23:08:53 +0100 (CET) Received: (qmail 67964 invoked by uid 500); 5 Feb 2018 22:08:53 -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 67955 invoked by uid 99); 5 Feb 2018 22:08:53 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Feb 2018 22:08:53 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 3500F811C7; Mon, 5 Feb 2018 22:08:52 +0000 (UTC) Date: Mon, 05 Feb 2018 22:08:52 +0000 To: "commits@accumulo.apache.org" Subject: [accumulo] branch 1.8 updated: ACCUMULO-4797 improved namespace config performance (#375) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <151786853211.25934.9005176543694911950@gitbox.apache.org> From: kturner@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: accumulo X-Git-Refname: refs/heads/1.8 X-Git-Reftype: branch X-Git-Oldrev: 3ca3d65962e5229a44d67ef46233467d53a7016c X-Git-Newrev: 3c55eed2198afc90d6c1230783fcdd64e4c7e47d X-Git-Rev: 3c55eed2198afc90d6c1230783fcdd64e4c7e47d X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated 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 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() { @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.