You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by mw...@apache.org on 2018/04/28 13:05:04 UTC

[accumulo] branch master updated: #408 - Removed more uses of deprecated ClientConfiguration (#450)

This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/master by this push:
     new ba5146c   #408 - Removed more uses of deprecated ClientConfiguration (#450)
ba5146c is described below

commit ba5146c71b1f54af5fd93c815d944088f2485515
Author: Mike Walch <mw...@apache.org>
AuthorDate: Sat Apr 28 09:04:59 2018 -0400

     #408 - Removed more uses of deprecated ClientConfiguration (#450)
    
    * Update checkstyle to ignore line length checks for lines
      with org.apache.accumulo in it
---
 .../core/client/impl/ClientConfConverter.java      | 106 ++++++++++++++-------
 .../core/client/impl/ConnectionInfoFactory.java    |   5 +-
 .../apache/accumulo/cluster/AccumuloCluster.java   |   6 +-
 .../standalone/StandaloneAccumuloCluster.java      |   4 +-
 .../accumulo/minicluster/MiniAccumuloCluster.java  |  14 ++-
 .../accumulo/minicluster/MiniAccumuloInstance.java |   7 +-
 .../minicluster/impl/MiniAccumuloClusterImpl.java  |  14 +--
 pom.xml                                            |   2 +-
 8 files changed, 104 insertions(+), 54 deletions(-)

diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/ClientConfConverter.java b/core/src/main/java/org/apache/accumulo/core/client/impl/ClientConfConverter.java
index 16cb286..7bdddf0 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/ClientConfConverter.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/ClientConfConverter.java
@@ -16,8 +16,6 @@
  */
 package org.apache.accumulo.core.client.impl;
 
-import static org.apache.accumulo.core.client.ClientConfiguration.ClientProperty.KERBEROS_SERVER_PRIMARY;
-
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -26,7 +24,6 @@ import java.util.Map;
 import java.util.Properties;
 import java.util.function.Predicate;
 
-import org.apache.accumulo.core.client.ClientConfiguration;
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
 import org.apache.accumulo.core.conf.ClientProperty;
 import org.apache.accumulo.core.conf.CredentialProviderFactoryShim;
@@ -37,48 +34,66 @@ import org.apache.hadoop.security.authentication.util.KerberosName;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-@SuppressWarnings("deprecation")
 public class ClientConfConverter {
 
   private static final Logger log = LoggerFactory.getLogger(ClientConfConverter.class);
   private static Map<String,String> confProps = new HashMap<>();
   private static Map<String,String> propsConf = new HashMap<>();
 
-  static {
+  @SuppressWarnings("deprecation")
+  private static void init() {
     propsConf.put(ClientProperty.INSTANCE_ZOOKEEPERS.getKey(),
-        ClientConfiguration.ClientProperty.INSTANCE_ZK_HOST.getKey());
+        org.apache.accumulo.core.client.ClientConfiguration.ClientProperty.INSTANCE_ZK_HOST
+            .getKey());
     propsConf.put(ClientProperty.INSTANCE_ZOOKEEPERS_TIMEOUT_SEC.getKey(),
-        ClientConfiguration.ClientProperty.INSTANCE_ZK_TIMEOUT.getKey());
+        org.apache.accumulo.core.client.ClientConfiguration.ClientProperty.INSTANCE_ZK_TIMEOUT
+            .getKey());
     propsConf.put(ClientProperty.SSL_ENABLED.getKey(),
-        ClientConfiguration.ClientProperty.INSTANCE_RPC_SSL_ENABLED.getKey());
+        org.apache.accumulo.core.client.ClientConfiguration.ClientProperty.INSTANCE_RPC_SSL_ENABLED
+            .getKey());
     propsConf.put(ClientProperty.SSL_KEYSTORE_PATH.getKey(),
-        ClientConfiguration.ClientProperty.RPC_SSL_KEYSTORE_PATH.getKey());
+        org.apache.accumulo.core.client.ClientConfiguration.ClientProperty.RPC_SSL_KEYSTORE_PATH
+            .getKey());
     propsConf.put(ClientProperty.SSL_KEYSTORE_TYPE.getKey(),
-        ClientConfiguration.ClientProperty.RPC_SSL_KEYSTORE_TYPE.getKey());
+        org.apache.accumulo.core.client.ClientConfiguration.ClientProperty.RPC_SSL_KEYSTORE_TYPE
+            .getKey());
     propsConf.put(ClientProperty.SSL_KEYSTORE_PASSWORD.getKey(),
-        ClientConfiguration.ClientProperty.RPC_SSL_KEYSTORE_PASSWORD.getKey());
+        org.apache.accumulo.core.client.ClientConfiguration.ClientProperty.RPC_SSL_KEYSTORE_PASSWORD
+            .getKey());
     propsConf.put(ClientProperty.SSL_TRUSTSTORE_PATH.getKey(),
-        ClientConfiguration.ClientProperty.RPC_SSL_TRUSTSTORE_PATH.getKey());
+        org.apache.accumulo.core.client.ClientConfiguration.ClientProperty.RPC_SSL_TRUSTSTORE_PATH
+            .getKey());
     propsConf.put(ClientProperty.SSL_TRUSTSTORE_TYPE.getKey(),
-        ClientConfiguration.ClientProperty.RPC_SSL_TRUSTSTORE_TYPE.getKey());
+        org.apache.accumulo.core.client.ClientConfiguration.ClientProperty.RPC_SSL_TRUSTSTORE_TYPE
+            .getKey());
     propsConf.put(ClientProperty.SSL_TRUSTSTORE_PASSWORD.getKey(),
-        ClientConfiguration.ClientProperty.RPC_SSL_TRUSTSTORE_PASSWORD.getKey());
+        org.apache.accumulo.core.client.ClientConfiguration.ClientProperty.RPC_SSL_TRUSTSTORE_PASSWORD
+            .getKey());
     propsConf.put(ClientProperty.SSL_USE_JSSE.getKey(),
-        ClientConfiguration.ClientProperty.RPC_USE_JSSE.getKey());
+        org.apache.accumulo.core.client.ClientConfiguration.ClientProperty.RPC_USE_JSSE.getKey());
     propsConf.put(ClientProperty.SASL_ENABLED.getKey(),
-        ClientConfiguration.ClientProperty.INSTANCE_RPC_SASL_ENABLED.getKey());
+        org.apache.accumulo.core.client.ClientConfiguration.ClientProperty.INSTANCE_RPC_SASL_ENABLED
+            .getKey());
     propsConf.put(ClientProperty.SASL_QOP.getKey(),
-        ClientConfiguration.ClientProperty.RPC_SASL_QOP.getKey());
+        org.apache.accumulo.core.client.ClientConfiguration.ClientProperty.RPC_SASL_QOP.getKey());
     propsConf.put(ClientProperty.SASL_KERBEROS_SERVER_PRIMARY.getKey(),
-        KERBEROS_SERVER_PRIMARY.getKey());
+        org.apache.accumulo.core.client.ClientConfiguration.ClientProperty.KERBEROS_SERVER_PRIMARY
+            .getKey());
 
     for (Map.Entry<String,String> entry : propsConf.entrySet()) {
       confProps.put(entry.getValue(), entry.getKey());
     }
   }
 
-  public static ClientConfiguration toClientConf(Properties properties) {
-    ClientConfiguration config = ClientConfiguration.create();
+  static {
+    init();
+  }
+
+  @SuppressWarnings("deprecation")
+  public static org.apache.accumulo.core.client.ClientConfiguration toClientConf(
+      Properties properties) {
+    org.apache.accumulo.core.client.ClientConfiguration config = org.apache.accumulo.core.client.ClientConfiguration
+        .create();
     for (Object keyObj : properties.keySet()) {
       String propKey = (String) keyObj;
       String val = properties.getProperty(propKey);
@@ -89,13 +104,17 @@ public class ClientConfConverter {
         config.setProperty(confKey, val);
       }
       if (propKey.equals(ClientProperty.SSL_KEYSTORE_PATH.getKey())) {
-        config.setProperty(ClientConfiguration.ClientProperty.INSTANCE_RPC_SSL_CLIENT_AUTH, "true");
+        config.setProperty(
+            org.apache.accumulo.core.client.ClientConfiguration.ClientProperty.INSTANCE_RPC_SSL_CLIENT_AUTH,
+            "true");
       }
     }
     return config;
   }
 
-  public static Properties toProperties(ClientConfiguration clientConf) {
+  @SuppressWarnings("deprecation")
+  public static Properties toProperties(
+      org.apache.accumulo.core.client.ClientConfiguration clientConf) {
     Properties props = new Properties();
     Iterator<String> clientConfIter = clientConf.getKeys();
     while (clientConfIter.hasNext()) {
@@ -103,8 +122,9 @@ public class ClientConfConverter {
       String val = clientConf.getString(confKey);
       String propKey = confProps.get(confKey);
       if (propKey == null) {
-        if (!confKey
-            .equals(ClientConfiguration.ClientProperty.INSTANCE_RPC_SSL_CLIENT_AUTH.getKey())) {
+        if (!confKey.equals(
+            org.apache.accumulo.core.client.ClientConfiguration.ClientProperty.INSTANCE_RPC_SSL_CLIENT_AUTH
+                .getKey())) {
           props.setProperty(confKey, val);
         }
       } else {
@@ -127,10 +147,12 @@ public class ClientConfConverter {
    * internally.
    *
    * @param config
-   *          the original {@link ClientConfiguration}
+   *          the original {@link org.apache.accumulo.core.client.ClientConfiguration}
    * @return the client configuration presented in the form of an {@link AccumuloConfiguration}
    */
-  public static AccumuloConfiguration toAccumuloConf(final ClientConfiguration config) {
+  @SuppressWarnings("deprecation")
+  public static AccumuloConfiguration toAccumuloConf(
+      final org.apache.accumulo.core.client.ClientConfiguration config) {
 
     final AccumuloConfiguration defaults = DefaultConfiguration.getInstance();
 
@@ -166,10 +188,14 @@ public class ClientConfConverter {
         else {
           // Reconstitute the server kerberos property from the client config
           if (Property.GENERAL_KERBEROS_PRINCIPAL == property) {
-            if (config.containsKey(KERBEROS_SERVER_PRIMARY.getKey())) {
+            if (config.containsKey(
+                org.apache.accumulo.core.client.ClientConfiguration.ClientProperty.KERBEROS_SERVER_PRIMARY
+                    .getKey())) {
               // Avoid providing a realm since we don't know what it is...
-              return config.getString(KERBEROS_SERVER_PRIMARY.getKey()) + "/_HOST@"
-                  + SaslConnectionParams.getDefaultRealm();
+              return config.getString(
+                  org.apache.accumulo.core.client.ClientConfiguration.ClientProperty.KERBEROS_SERVER_PRIMARY
+                      .getKey())
+                  + "/_HOST@" + SaslConnectionParams.getDefaultRealm();
             }
           }
           return defaults.get(property);
@@ -190,8 +216,12 @@ public class ClientConfConverter {
         // Two client props that don't exist on the server config. Client doesn't need to know about
         // the Kerberos instance from the principle, but servers do
         // Automatically reconstruct the server property when converting a client config.
-        if (props.containsKey(KERBEROS_SERVER_PRIMARY.getKey())) {
-          final String serverPrimary = props.remove(KERBEROS_SERVER_PRIMARY.getKey());
+        if (props.containsKey(
+            org.apache.accumulo.core.client.ClientConfiguration.ClientProperty.KERBEROS_SERVER_PRIMARY
+                .getKey())) {
+          final String serverPrimary = props.remove(
+              org.apache.accumulo.core.client.ClientConfiguration.ClientProperty.KERBEROS_SERVER_PRIMARY
+                  .getKey());
           if (filter.test(Property.GENERAL_KERBEROS_PRINCIPAL.getKey())) {
             // Use the _HOST expansion. It should be unnecessary in "client land".
             props.put(Property.GENERAL_KERBEROS_PRINCIPAL.getKey(),
@@ -239,8 +269,11 @@ public class ClientConfConverter {
     };
   }
 
-  public static ClientConfiguration toClientConf(AccumuloConfiguration conf) {
-    ClientConfiguration clientConf = ClientConfiguration.create();
+  @SuppressWarnings("deprecation")
+  public static org.apache.accumulo.core.client.ClientConfiguration toClientConf(
+      AccumuloConfiguration conf) {
+    org.apache.accumulo.core.client.ClientConfiguration clientConf = org.apache.accumulo.core.client.ClientConfiguration
+        .create();
 
     // Servers will only have the full principal in their configuration -- parse the
     // primary and realm from it.
@@ -249,11 +282,14 @@ public class ClientConfConverter {
     final KerberosName krbName;
     if (serverPrincipal != null && !serverPrincipal.isEmpty()) {
       krbName = new KerberosName(serverPrincipal);
-      clientConf.setProperty(KERBEROS_SERVER_PRIMARY, krbName.getServiceName());
+      clientConf.setProperty(
+          org.apache.accumulo.core.client.ClientConfiguration.ClientProperty.KERBEROS_SERVER_PRIMARY,
+          krbName.getServiceName());
     }
 
     HashSet<String> clientKeys = new HashSet<>();
-    for (ClientConfiguration.ClientProperty prop : ClientConfiguration.ClientProperty.values()) {
+    for (org.apache.accumulo.core.client.ClientConfiguration.ClientProperty prop : org.apache.accumulo.core.client.ClientConfiguration.ClientProperty
+        .values()) {
       clientKeys.add(prop.getKey());
     }
 
diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/ConnectionInfoFactory.java b/core/src/main/java/org/apache/accumulo/core/client/impl/ConnectionInfoFactory.java
index 6420f2f..b7ec137 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/ConnectionInfoFactory.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/ConnectionInfoFactory.java
@@ -21,7 +21,6 @@ import java.util.concurrent.TimeUnit;
 import org.apache.accumulo.core.client.AccumuloException;
 import org.apache.accumulo.core.client.AccumuloSecurityException;
 import org.apache.accumulo.core.client.BatchWriterConfig;
-import org.apache.accumulo.core.client.ClientConfiguration;
 import org.apache.accumulo.core.client.ConnectionInfo;
 import org.apache.accumulo.core.client.Connector;
 import org.apache.accumulo.core.client.Durability;
@@ -80,7 +79,9 @@ public class ConnectionInfoFactory {
     return batchWriterConfig;
   }
 
-  public static ClientConfiguration getClientConfiguration(ConnectionInfo info) {
+  @SuppressWarnings("deprecation")
+  public static org.apache.accumulo.core.client.ClientConfiguration getClientConfiguration(
+      ConnectionInfo info) {
     return ClientConfConverter.toClientConf(info.getProperties());
   }
 }
diff --git a/minicluster/src/main/java/org/apache/accumulo/cluster/AccumuloCluster.java b/minicluster/src/main/java/org/apache/accumulo/cluster/AccumuloCluster.java
index 53ed0b4..a66d69b 100644
--- a/minicluster/src/main/java/org/apache/accumulo/cluster/AccumuloCluster.java
+++ b/minicluster/src/main/java/org/apache/accumulo/cluster/AccumuloCluster.java
@@ -20,7 +20,6 @@ import java.io.IOException;
 
 import org.apache.accumulo.core.client.AccumuloException;
 import org.apache.accumulo.core.client.AccumuloSecurityException;
-import org.apache.accumulo.core.client.ClientConfiguration;
 import org.apache.accumulo.core.client.ConnectionInfo;
 import org.apache.accumulo.core.client.Connector;
 import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
@@ -56,8 +55,11 @@ public interface AccumuloCluster {
 
   /**
    * Get the client configuration for the cluster
+   *
+   * @deprecated since 2.0.0, replaced by {{@link #getConnectionInfo()}}
    */
-  ClientConfiguration getClientConfig();
+  @Deprecated
+  org.apache.accumulo.core.client.ClientConfiguration getClientConfig();
 
   /**
    * @return Connection Info for cluster
diff --git a/minicluster/src/main/java/org/apache/accumulo/cluster/standalone/StandaloneAccumuloCluster.java b/minicluster/src/main/java/org/apache/accumulo/cluster/standalone/StandaloneAccumuloCluster.java
index 1f1d80b..67b9088 100644
--- a/minicluster/src/main/java/org/apache/accumulo/cluster/standalone/StandaloneAccumuloCluster.java
+++ b/minicluster/src/main/java/org/apache/accumulo/cluster/standalone/StandaloneAccumuloCluster.java
@@ -27,7 +27,6 @@ import org.apache.accumulo.cluster.AccumuloCluster;
 import org.apache.accumulo.cluster.ClusterUser;
 import org.apache.accumulo.core.client.AccumuloException;
 import org.apache.accumulo.core.client.AccumuloSecurityException;
-import org.apache.accumulo.core.client.ClientConfiguration;
 import org.apache.accumulo.core.client.ConnectionInfo;
 import org.apache.accumulo.core.client.Connector;
 import org.apache.accumulo.core.client.impl.ClientConfConverter;
@@ -134,7 +133,8 @@ public class StandaloneAccumuloCluster implements AccumuloCluster {
   }
 
   @Override
-  public ClientConfiguration getClientConfig() {
+  @Deprecated
+  public org.apache.accumulo.core.client.ClientConfiguration getClientConfig() {
     return ClientConfConverter.toClientConf(info.getProperties());
   }
 
diff --git a/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloCluster.java b/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloCluster.java
index 200a477..ba8879c 100644
--- a/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloCluster.java
+++ b/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloCluster.java
@@ -22,7 +22,7 @@ import java.util.Set;
 
 import org.apache.accumulo.core.client.AccumuloException;
 import org.apache.accumulo.core.client.AccumuloSecurityException;
-import org.apache.accumulo.core.client.ClientConfiguration;
+import org.apache.accumulo.core.client.ConnectionInfo;
 import org.apache.accumulo.core.client.Connector;
 import org.apache.accumulo.core.client.security.tokens.PasswordToken;
 import org.apache.accumulo.core.util.Pair;
@@ -122,10 +122,18 @@ public class MiniAccumuloCluster {
 
   /**
    * @since 1.6.0
-   * @deprecated since 2.0.0
+   * @deprecated since 2.0.0, replaced by {{@link #getConnectionInfo()}}
    */
   @Deprecated
-  public ClientConfiguration getClientConfig() {
+  public org.apache.accumulo.core.client.ClientConfiguration getClientConfig() {
     return impl.getClientConfig();
   }
+
+  /**
+   * @return Connection info for cluster
+   * @since 2.0.0
+   */
+  public ConnectionInfo getConnectionInfo() {
+    return impl.getConnectionInfo();
+  }
 }
diff --git a/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloInstance.java b/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloInstance.java
index 2bb9107..b76daf0 100644
--- a/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloInstance.java
+++ b/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloInstance.java
@@ -20,7 +20,6 @@ import java.io.File;
 import java.io.FileNotFoundException;
 import java.net.MalformedURLException;
 
-import org.apache.accumulo.core.client.ClientConfiguration;
 import org.apache.accumulo.core.client.Instance;
 import org.apache.accumulo.core.client.ZooKeeperInstance;
 import org.apache.accumulo.core.conf.Property;
@@ -36,9 +35,11 @@ public class MiniAccumuloInstance extends ZooKeeperInstance {
    * Construct an {@link Instance} entry point to Accumulo using a {@link MiniAccumuloCluster}
    * directory
    */
+  @SuppressWarnings("deprecation")
   public MiniAccumuloInstance(String instanceName, File directory) throws FileNotFoundException {
-    super(ClientConfiguration.fromFile(new File(new File(directory, "conf"), "client.conf"))
-        .withInstance(instanceName).withZkHosts(getZooKeepersFromDir(directory)));
+    super(org.apache.accumulo.core.client.ClientConfiguration
+        .fromFile(new File(new File(directory, "conf"), "client.conf")).withInstance(instanceName)
+        .withZkHosts(getZooKeepersFromDir(directory)));
   }
 
   // Keep this private to avoid bringing it into the public API
diff --git a/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/MiniAccumuloClusterImpl.java b/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/MiniAccumuloClusterImpl.java
index f294b65..b554270 100644
--- a/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/MiniAccumuloClusterImpl.java
+++ b/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/MiniAccumuloClusterImpl.java
@@ -56,7 +56,6 @@ import org.apache.accumulo.cluster.AccumuloCluster;
 import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.AccumuloException;
 import org.apache.accumulo.core.client.AccumuloSecurityException;
-import org.apache.accumulo.core.client.ClientConfiguration;
 import org.apache.accumulo.core.client.ConnectionInfo;
 import org.apache.accumulo.core.client.Connector;
 import org.apache.accumulo.core.client.Instance;
@@ -444,8 +443,10 @@ public class MiniAccumuloClusterImpl implements AccumuloCluster {
 
     File clientConfFile = config.getClientConfFile();
     // Write only the properties that correspond to ClientConfiguration properties
-    writeConfigProperties(clientConfFile, Maps.filterEntries(config.getSiteConfig(),
-        v -> ClientConfiguration.ClientProperty.getPropertyByKey(v.getKey()) != null));
+    writeConfigProperties(clientConfFile,
+        Maps.filterEntries(config.getSiteConfig(),
+            v -> org.apache.accumulo.core.client.ClientConfiguration.ClientProperty
+                .getPropertyByKey(v.getKey()) != null));
 
     Map<String,String> clientProps = config.getClientProps();
     clientProps.put(ClientProperty.INSTANCE_ZOOKEEPERS.getKey(), config.getZooKeepers());
@@ -774,10 +775,11 @@ public class MiniAccumuloClusterImpl implements AccumuloCluster {
     return instance.getConnector(user, token);
   }
 
+  @SuppressWarnings("deprecation")
   @Override
-  public ClientConfiguration getClientConfig() {
-    return ClientConfiguration.fromMap(config.getSiteConfig()).withInstance(this.getInstanceName())
-        .withZkHosts(this.getZooKeepers());
+  public org.apache.accumulo.core.client.ClientConfiguration getClientConfig() {
+    return org.apache.accumulo.core.client.ClientConfiguration.fromMap(config.getSiteConfig())
+        .withInstance(this.getInstanceName()).withZkHosts(this.getZooKeepers());
   }
 
   @Override
diff --git a/pom.xml b/pom.xml
index 3a93869..a76a375 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1243,7 +1243,7 @@
                 <module name="OuterTypeFilename" />
                 <module name="LineLength">
                   <property name="max" value="100" />
-                  <property name="ignorePattern" value="^[ ]*[*].*@(link|see) |Map.* = new .*Map|a href=|http://|https://|ftp://" />
+                  <property name="ignorePattern" value="^[ ]*[*].*@(link|see) |Map.* = new .*Map|org[.]apache[.]accumulo[.]|a href=|http://|https://|ftp://" />
                 </module>
                 <module name="AvoidStarImport" />
                 <module name="UnusedImports">

-- 
To stop receiving notification emails like this one, please contact
mwalch@apache.org.