accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ktur...@apache.org
Subject [accumulo] 02/03: ACCUMULO-4779 fixed classpath context config performance issue (#358)
Date Wed, 17 Jan 2018 17:35:30 GMT
This is an automated email from the ASF dual-hosted git repository.

kturner pushed a commit to branch 1.7
in repository https://gitbox.apache.org/repos/asf/accumulo.git

commit 8c27bdf0e0168f854e9bb6effad25e6b6b0cb853
Author: Keith Turner <kturner@apache.org>
AuthorDate: Wed Jan 10 16:23:27 2018 -0500

    ACCUMULO-4779 fixed classpath context config performance issue (#358)
---
 .../java/org/apache/accumulo/master/Master.java    |  8 ++---
 .../org/apache/accumulo/tserver/TabletServer.java  |  8 ++---
 .../main/java/org/apache/accumulo/shell/Shell.java | 18 +++++------
 .../start/classloader/vfs/ContextManager.java      | 36 ++++++++--------------
 4 files changed, 29 insertions(+), 41 deletions(-)

diff --git a/server/master/src/main/java/org/apache/accumulo/master/Master.java b/server/master/src/main/java/org/apache/accumulo/master/Master.java
index 6a43e93..984fb60 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/Master.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/Master.java
@@ -589,12 +589,12 @@ public class Master extends AccumuloServerContext implements LiveTServerSet.List
     this.tabletBalancer.init(serverConfig);
 
     try {
-      AccumuloVFSClassLoader.getContextManager().setContextConfig(new ContextManager.DefaultContextsConfig(new
Iterable<Entry<String,String>>() {
+      AccumuloVFSClassLoader.getContextManager().setContextConfig(new ContextManager.DefaultContextsConfig()
{
         @Override
-        public Iterator<Entry<String,String>> iterator() {
-          return getConfiguration().iterator();
+        public String getProperty(String key) {
+          return getConfiguration().get(key);
         }
-      }));
+      });
     } catch (IOException e) {
       throw new RuntimeException(e);
     }
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
index 9ac56ae..305b030 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
@@ -2811,12 +2811,12 @@ public class TabletServer extends AccumuloServerContext implements
Runnable {
 
     clientAddress = HostAndPort.fromParts(hostname, 0);
     try {
-      AccumuloVFSClassLoader.getContextManager().setContextConfig(new ContextManager.DefaultContextsConfig(new
Iterable<Entry<String,String>>() {
+      AccumuloVFSClassLoader.getContextManager().setContextConfig(new ContextManager.DefaultContextsConfig()
{
         @Override
-        public Iterator<Entry<String,String>> iterator() {
-          return getConfiguration().iterator();
+        public String getProperty(String key) {
+          return getConfiguration().get(key);
         }
-      }));
+      });
     } catch (IOException e) {
       throw new RuntimeException(e);
     }
diff --git a/shell/src/main/java/org/apache/accumulo/shell/Shell.java b/shell/src/main/java/org/apache/accumulo/shell/Shell.java
index 36c843e..b5e5afb 100644
--- a/shell/src/main/java/org/apache/accumulo/shell/Shell.java
+++ b/shell/src/main/java/org/apache/accumulo/shell/Shell.java
@@ -545,18 +545,16 @@ public class Shell extends ShellOptions implements KeywordExecutable
{
       shellState.getConnector().instanceOperations().getSystemConfiguration().get(Property.VFS_CONTEXT_CLASSPATH_PROPERTY.getKey()
+ classpath);
 
       try {
-        AccumuloVFSClassLoader.getContextManager().setContextConfig(new ContextManager.DefaultContextsConfig(new
Iterable<Map.Entry<String,String>>() {
+
+        final Map<String,String> systemConfig = shellState.getConnector().instanceOperations().getSystemConfiguration();
+
+        AccumuloVFSClassLoader.getContextManager().setContextConfig(new ContextManager.DefaultContextsConfig()
{
           @Override
-          public Iterator<Entry<String,String>> iterator() {
-            try {
-              return shellState.getConnector().instanceOperations().getSystemConfiguration().entrySet().iterator();
-            } catch (AccumuloException e) {
-              throw new RuntimeException(e);
-            } catch (AccumuloSecurityException e) {
-              throw new RuntimeException(e);
-            }
+          public String getProperty(String key) {
+            return systemConfig.get(key);
           }
-        }));
+
+        });
       } catch (IllegalStateException ise) {}
 
       classloader = AccumuloVFSClassLoader.getContextManager().getClassLoader(classpath);
diff --git a/start/src/main/java/org/apache/accumulo/start/classloader/vfs/ContextManager.java
b/start/src/main/java/org/apache/accumulo/start/classloader/vfs/ContextManager.java
index 7145b4a..a3d51fc 100644
--- a/start/src/main/java/org/apache/accumulo/start/classloader/vfs/ContextManager.java
+++ b/start/src/main/java/org/apache/accumulo/start/classloader/vfs/ContextManager.java
@@ -18,9 +18,7 @@ package org.apache.accumulo.start.classloader.vfs;
 
 import java.io.IOException;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Map;
-import java.util.Map.Entry;
 import java.util.Set;
 
 import org.apache.commons.vfs2.FileSystemException;
@@ -99,38 +97,30 @@ public class ContextManager {
     ContextConfig getContextConfig(String context);
   }
 
-  public static class DefaultContextsConfig implements ContextsConfig {
+  public static abstract class DefaultContextsConfig implements ContextsConfig {
 
-    private Iterable<Entry<String,String>> config;
-
-    public DefaultContextsConfig(Iterable<Entry<String,String>> config) {
-      this.config = config;
-    }
+    public abstract String getProperty(String key);
 
     @Override
     public ContextConfig getContextConfig(String context) {
 
       String key = AccumuloVFSClassLoader.VFS_CONTEXT_CLASSPATH_PROPERTY + context;
 
-      String uris = null;
-      boolean preDelegate = true;
+      String uris = getProperty(key);
 
-      Iterator<Entry<String,String>> iter = config.iterator();
-      while (iter.hasNext()) {
-        Entry<String,String> entry = iter.next();
-        if (entry.getKey().equals(key)) {
-          uris = entry.getValue();
-        }
-
-        if (entry.getKey().equals(key + ".delegation") && entry.getValue().trim().equalsIgnoreCase("post"))
{
-          preDelegate = false;
-        }
+      if (uris == null) {
+        return null;
       }
 
-      if (uris != null)
-        return new ContextConfig(uris, preDelegate);
+      String delegate = getProperty(key + ".delegation");
+
+      boolean preDelegate = true;
+
+      if (delegate != null && delegate.trim().equalsIgnoreCase("post")) {
+        preDelegate = false;
+      }
 
-      return null;
+      return new ContextConfig(uris, preDelegate);
     }
   }
 

-- 
To stop receiving notification emails like this one, please contact
"commits@accumulo.apache.org" <commits@accumulo.apache.org>.

Mime
View raw message