accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ctubb...@apache.org
Subject [2/6] accumulo git commit: ACCUMULO-4640 Fix SiteConfiguration parent
Date Fri, 09 Jun 2017 03:22:17 GMT
ACCUMULO-4640 Fix SiteConfiguration parent

Removes the use of client configuration as the parent to
SiteConfiguration. Always use DefaultConfiguration as its parent.


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/4effd0e9
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/4effd0e9
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/4effd0e9

Branch: refs/heads/1.8
Commit: 4effd0e9a757b513e62a3c8dd9637922e2d9742e
Parents: 2ff2678
Author: Christopher Tubbs <ctubbsii@apache.org>
Authored: Thu Jun 8 20:44:31 2017 -0400
Committer: Christopher Tubbs <ctubbsii@apache.org>
Committed: Thu Jun 8 20:44:31 2017 -0400

----------------------------------------------------------------------
 .../accumulo/core/conf/SiteConfiguration.java   | 20 +++++---------------
 .../accumulo/core/file/rfile/PrintInfo.java     |  4 +---
 .../core/file/rfile/bcfile/PrintInfo.java       |  3 +--
 .../server/conf/ServerConfigurationFactory.java |  2 +-
 .../accumulo/tserver/log/LocalWALRecovery.java  |  2 +-
 .../java/org/apache/accumulo/shell/Shell.java   |  6 +++---
 .../apache/accumulo/shell/ShellOptionsJC.java   |  3 +--
 .../accumulo/shell/commands/FateCommand.java    |  3 +--
 .../apache/accumulo/test/util/CertUtils.java    |  4 ++--
 9 files changed, 16 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/4effd0e9/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java b/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java
index 07aaf9f..9f047e2 100644
--- a/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java
+++ b/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java
@@ -43,17 +43,13 @@ import com.google.common.base.Predicate;
 public class SiteConfiguration extends AccumuloConfiguration {
   private static final Logger log = LoggerFactory.getLogger(SiteConfiguration.class);
 
-  private AccumuloConfiguration parent = null;
+  private static final AccumuloConfiguration parent = DefaultConfiguration.getInstance();
   private static SiteConfiguration instance = null;
 
   private static Configuration xmlConfig;
   private final Map<String,String> staticConfigs;
 
-  /**
-   * Not for consumers. Call {@link SiteConfiguration#getInstance(AccumuloConfiguration)}
instead
-   */
-  SiteConfiguration(AccumuloConfiguration parent) {
-    this.parent = parent;
+  private SiteConfiguration() {
     /*
      * Make a read-only copy of static configs so we can avoid lock contention on the Hadoop
Configuration object
      */
@@ -75,25 +71,19 @@ public class SiteConfiguration extends AccumuloConfiguration {
   }
 
   /**
-   * Gets an instance of this class. A new instance is only created on the first call, and
so the parent configuration cannot be changed later.
+   * Gets an instance of this class. A new instance is only created on the first call.
    *
-   * @param parent
-   *          parent (default) configuration
    * @throws RuntimeException
    *           if the configuration is invalid
    */
-  synchronized public static SiteConfiguration getInstance(AccumuloConfiguration parent)
{
+  synchronized public static SiteConfiguration getInstance() {
     if (instance == null) {
-      instance = new SiteConfiguration(parent);
+      instance = new SiteConfiguration();
       ConfigSanityCheck.validate(instance);
     }
     return instance;
   }
 
-  synchronized public static SiteConfiguration getInstance() {
-    return getInstance(DefaultConfiguration.getInstance());
-  }
-
   synchronized private static Configuration getXmlConfig() {
     String configFile = System.getProperty("org.apache.accumulo.config.file", "accumulo-site.xml");
     if (xmlConfig == null) {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/4effd0e9/core/src/main/java/org/apache/accumulo/core/file/rfile/PrintInfo.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/file/rfile/PrintInfo.java b/core/src/main/java/org/apache/accumulo/core/file/rfile/PrintInfo.java
index 366e4a8..4af087f 100644
--- a/core/src/main/java/org/apache/accumulo/core/file/rfile/PrintInfo.java
+++ b/core/src/main/java/org/apache/accumulo/core/file/rfile/PrintInfo.java
@@ -21,7 +21,6 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.accumulo.core.cli.Help;
-import org.apache.accumulo.core.conf.DefaultConfiguration;
 import org.apache.accumulo.core.conf.SiteConfiguration;
 import org.apache.accumulo.core.data.ByteSequence;
 import org.apache.accumulo.core.data.Key;
@@ -102,8 +101,7 @@ public class PrintInfo implements KeywordExecutable {
       }
       System.out.println("Reading file: " + path.makeQualified(fs.getUri(), fs.getWorkingDirectory()).toString());
 
-      CachableBlockFile.Reader _rdr = new CachableBlockFile.Reader(fs, path, conf, null,
null,
-          SiteConfiguration.getInstance(DefaultConfiguration.getInstance()));
+      CachableBlockFile.Reader _rdr = new CachableBlockFile.Reader(fs, path, conf, null,
null, SiteConfiguration.getInstance());
       Reader iter = new RFile.Reader(_rdr);
       MetricsGatherer<Map<String,ArrayList<VisibilityMetric>>> vmg = new
VisMetricsGatherer();
 

http://git-wip-us.apache.org/repos/asf/accumulo/blob/4effd0e9/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/PrintInfo.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/PrintInfo.java
b/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/PrintInfo.java
index 7b2abe8..666d7e3 100644
--- a/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/PrintInfo.java
+++ b/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/PrintInfo.java
@@ -21,7 +21,6 @@ import java.io.PrintStream;
 import java.util.Map.Entry;
 import java.util.Set;
 
-import org.apache.accumulo.core.conf.DefaultConfiguration;
 import org.apache.accumulo.core.conf.SiteConfiguration;
 import org.apache.accumulo.core.file.rfile.bcfile.BCFile.MetaIndexEntry;
 import org.apache.hadoop.conf.Configuration;
@@ -34,7 +33,7 @@ public class PrintInfo {
     FSDataInputStream fsin = fs.open(path);
     BCFile.Reader bcfr = null;
     try {
-      bcfr = new BCFile.Reader(fsin, fs.getFileStatus(path).getLen(), conf, SiteConfiguration.getInstance(DefaultConfiguration.getInstance()));
+      bcfr = new BCFile.Reader(fsin, fs.getFileStatus(path).getLen(), conf, SiteConfiguration.getInstance());
 
       Set<Entry<String,MetaIndexEntry>> es = bcfr.metaIndex.index.entrySet();
 

http://git-wip-us.apache.org/repos/asf/accumulo/blob/4effd0e9/server/base/src/main/java/org/apache/accumulo/server/conf/ServerConfigurationFactory.java
----------------------------------------------------------------------
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 2995272..965db51 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
@@ -120,7 +120,7 @@ public class ServerConfigurationFactory extends ServerConfiguration {
   public synchronized SiteConfiguration getSiteConfiguration() {
     if (siteConfig == null) {
       checkPermissions();
-      siteConfig = SiteConfiguration.getInstance(getDefaultConfiguration());
+      siteConfig = SiteConfiguration.getInstance();
     }
     return siteConfig;
   }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/4effd0e9/server/tserver/src/main/java/org/apache/accumulo/tserver/log/LocalWALRecovery.java
----------------------------------------------------------------------
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/log/LocalWALRecovery.java
b/server/tserver/src/main/java/org/apache/accumulo/tserver/log/LocalWALRecovery.java
index 2667b53..f1b5be8 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/log/LocalWALRecovery.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/log/LocalWALRecovery.java
@@ -58,7 +58,7 @@ public class LocalWALRecovery implements Runnable {
   }
 
   public static void main(String[] args) throws IOException {
-    AccumuloConfiguration configuration = SiteConfiguration.getInstance(SiteConfiguration.getDefaultConfiguration());
+    AccumuloConfiguration configuration = SiteConfiguration.getInstance();
 
     LocalWALRecovery main = new LocalWALRecovery(configuration);
     main.parseArgs(args);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/4effd0e9/shell/src/main/java/org/apache/accumulo/shell/Shell.java
----------------------------------------------------------------------
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 ccb12a0..cdd177e 100644
--- a/shell/src/main/java/org/apache/accumulo/shell/Shell.java
+++ b/shell/src/main/java/org/apache/accumulo/shell/Shell.java
@@ -53,7 +53,6 @@ import org.apache.accumulo.core.client.IteratorSetting;
 import org.apache.accumulo.core.client.NamespaceNotFoundException;
 import org.apache.accumulo.core.client.TableNotFoundException;
 import org.apache.accumulo.core.client.ZooKeeperInstance;
-import org.apache.accumulo.core.client.impl.ClientContext;
 import org.apache.accumulo.core.client.impl.Tables;
 import org.apache.accumulo.core.client.mock.MockInstance;
 import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
@@ -480,7 +479,7 @@ public class Shell extends ShellOptions implements KeywordExecutable {
       return clientConfig.get(ClientProperty.INSTANCE_ZK_HOST);
     }
 
-    return SiteConfiguration.getInstance(ClientContext.convertClientConfig(clientConfig)).get(Property.INSTANCE_ZK_HOST);
+    return SiteConfiguration.getInstance().get(Property.INSTANCE_ZK_HOST);
   }
 
   /*
@@ -495,7 +494,7 @@ public class Shell extends ShellOptions implements KeywordExecutable {
 
     String keepers = getZooKeepers(keepersOption, clientConfig);
     if (instanceName == null) {
-      AccumuloConfiguration conf = SiteConfiguration.getInstance(ClientContext.convertClientConfig(clientConfig));
+      AccumuloConfiguration conf = SiteConfiguration.getInstance();
       Path instanceDir = new Path(VolumeConfiguration.getVolumeUris(conf)[0], "instance_id");
       instanceId = UUID.fromString(ZooUtil.getInstanceIDFromHdfs(instanceDir, conf));
     }
@@ -1000,6 +999,7 @@ public class Shell extends ShellOptions implements KeywordExecutable
{
   public interface PrintLine extends AutoCloseable {
     void print(String s);
 
+    @Override
     void close();
   }
 

http://git-wip-us.apache.org/repos/asf/accumulo/blob/4effd0e9/shell/src/main/java/org/apache/accumulo/shell/ShellOptionsJC.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/ShellOptionsJC.java b/shell/src/main/java/org/apache/accumulo/shell/ShellOptionsJC.java
index 7c27343..250084b 100644
--- a/shell/src/main/java/org/apache/accumulo/shell/ShellOptionsJC.java
+++ b/shell/src/main/java/org/apache/accumulo/shell/ShellOptionsJC.java
@@ -26,7 +26,6 @@ import java.util.TreeMap;
 
 import org.apache.accumulo.core.client.ClientConfiguration;
 import org.apache.accumulo.core.client.ClientConfiguration.ClientProperty;
-import org.apache.accumulo.core.client.impl.ClientContext;
 import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
 import org.apache.accumulo.core.client.security.tokens.KerberosToken;
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
@@ -328,7 +327,7 @@ public class ShellOptionsJC {
 
     // Automatically try to add in the proper ZK from accumulo-site for backwards compat.
     if (!clientConfig.containsKey(ClientProperty.INSTANCE_ZK_HOST.getKey())) {
-      AccumuloConfiguration siteConf = SiteConfiguration.getInstance(ClientContext.convertClientConfig(clientConfig));
+      AccumuloConfiguration siteConf = SiteConfiguration.getInstance();
       clientConfig.withZkHosts(siteConf.get(Property.INSTANCE_ZK_HOST));
     }
 

http://git-wip-us.apache.org/repos/asf/accumulo/blob/4effd0e9/shell/src/main/java/org/apache/accumulo/shell/commands/FateCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/FateCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/FateCommand.java
index d557830..94b83fc 100644
--- a/shell/src/main/java/org/apache/accumulo/shell/commands/FateCommand.java
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/FateCommand.java
@@ -26,7 +26,6 @@ import java.util.Set;
 import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.Instance;
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
-import org.apache.accumulo.core.conf.DefaultConfiguration;
 import org.apache.accumulo.core.conf.Property;
 import org.apache.accumulo.core.conf.SiteConfiguration;
 import org.apache.accumulo.core.zookeeper.ZooUtil;
@@ -143,7 +142,7 @@ public class FateCommand extends Command {
   protected synchronized IZooReaderWriter getZooReaderWriter(Instance instance, String secret)
{
 
     if (secret == null) {
-      AccumuloConfiguration conf = SiteConfiguration.getInstance(DefaultConfiguration.getInstance());
+      AccumuloConfiguration conf = SiteConfiguration.getInstance();
       secret = conf.get(Property.INSTANCE_SECRET);
     }
 

http://git-wip-us.apache.org/repos/asf/accumulo/blob/4effd0e9/test/src/test/java/org/apache/accumulo/test/util/CertUtils.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/util/CertUtils.java b/test/src/test/java/org/apache/accumulo/test/util/CertUtils.java
index 95042d2..a49e1cd 100644
--- a/test/src/test/java/org/apache/accumulo/test/util/CertUtils.java
+++ b/test/src/test/java/org/apache/accumulo/test/util/CertUtils.java
@@ -125,7 +125,7 @@ public class CertUtils {
 
     public AccumuloConfiguration getConfiguration() {
       if (siteFile == null) {
-        return SiteConfiguration.getInstance(DefaultConfiguration.getInstance());
+        return SiteConfiguration.getInstance();
       } else {
         return new AccumuloConfiguration() {
           Configuration xml = new Configuration();
@@ -195,7 +195,7 @@ public class CertUtils {
   }
 
   private static String getDefaultKeyPassword() {
-    return SiteConfiguration.getInstance(DefaultConfiguration.getInstance()).get(Property.INSTANCE_SECRET);
+    return SiteConfiguration.getInstance().get(Property.INSTANCE_SECRET);
   }
 
   private String issuerDirString;


Mime
View raw message