accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ctubb...@apache.org
Subject [accumulo] branch master updated: Additional cleanup related to #528
Date Wed, 13 Jun 2018 23:11:32 GMT
This is an automated email from the ASF dual-hosted git repository.

ctubbsii 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 d2da4e1  Additional cleanup related to #528
d2da4e1 is described below

commit d2da4e1c7b41036642ff8d5bb42f480a093f5b9c
Author: Christopher Tubbs <ctubbsii@apache.org>
AuthorDate: Wed Jun 13 18:40:14 2018 -0400

    Additional cleanup related to #528
    
    * Remove unneeded ConfiguratorBase method
    * Remove unused variables
    * Fix some warnings
    * Simplify writing properties to a file in TokenFileIT
---
 .../core/client/mapred/AbstractInputFormat.java    |  2 +-
 .../core/client/mapred/AccumuloOutputFormat.java   |  2 +-
 .../core/client/mapreduce/AbstractInputFormat.java |  2 +-
 .../client/mapreduce/AccumuloOutputFormat.java     |  2 +-
 .../mapreduce/lib/impl/ConfiguratorBase.java       | 29 +---------------------
 .../accumulo/core/client/impl/ClientContext.java   |  2 +-
 .../core/client/impl/ConditionalWriterImpl.java    |  2 --
 .../impl/TabletServerBatchReaderIterator.java      |  2 +-
 .../accumulo/server/AccumuloServerContext.java     |  2 +-
 .../java/org/apache/accumulo/master/Master.java    |  2 +-
 .../tserver/replication/ReplicationWorker.java     |  3 ---
 .../apache/accumulo/test/mapred/TokenFileIT.java   | 12 +++------
 .../accumulo/test/mapreduce/TokenFileIT.java       | 10 +++-----
 .../accumulo/test/replication/ReplicationIT.java   |  3 ---
 14 files changed, 16 insertions(+), 59 deletions(-)

diff --git a/client/mapreduce/src/main/java/org/apache/accumulo/core/client/mapred/AbstractInputFormat.java
b/client/mapreduce/src/main/java/org/apache/accumulo/core/client/mapred/AbstractInputFormat.java
index 56a59a7..31d57a4 100644
--- a/client/mapreduce/src/main/java/org/apache/accumulo/core/client/mapred/AbstractInputFormat.java
+++ b/client/mapreduce/src/main/java/org/apache/accumulo/core/client/mapred/AbstractInputFormat.java
@@ -225,7 +225,7 @@ public abstract class AbstractInputFormat<K,V> implements InputFormat<K,V>
{
   @Deprecated
   public static void setConnectorInfo(JobConf job, String principal, String tokenFile)
       throws AccumuloSecurityException {
-    InputConfigurator.setConnectorInfo(CLASS, job, principal, tokenFile);
+    setClientPropertiesFile(job, tokenFile);
   }
 
   /**
diff --git a/client/mapreduce/src/main/java/org/apache/accumulo/core/client/mapred/AccumuloOutputFormat.java
b/client/mapreduce/src/main/java/org/apache/accumulo/core/client/mapred/AccumuloOutputFormat.java
index 4f5c7f2..30710ec 100644
--- a/client/mapreduce/src/main/java/org/apache/accumulo/core/client/mapred/AccumuloOutputFormat.java
+++ b/client/mapreduce/src/main/java/org/apache/accumulo/core/client/mapred/AccumuloOutputFormat.java
@@ -178,7 +178,7 @@ public class AccumuloOutputFormat implements OutputFormat<Text,Mutation>
{
   @Deprecated
   public static void setConnectorInfo(JobConf job, String principal, String tokenFile)
       throws AccumuloSecurityException {
-    OutputConfigurator.setConnectorInfo(CLASS, job, principal, tokenFile);
+    setClientPropertiesFile(job, tokenFile);
   }
 
   /**
diff --git a/client/mapreduce/src/main/java/org/apache/accumulo/core/client/mapreduce/AbstractInputFormat.java
b/client/mapreduce/src/main/java/org/apache/accumulo/core/client/mapreduce/AbstractInputFormat.java
index 6d7ef48..42e8637 100644
--- a/client/mapreduce/src/main/java/org/apache/accumulo/core/client/mapreduce/AbstractInputFormat.java
+++ b/client/mapreduce/src/main/java/org/apache/accumulo/core/client/mapreduce/AbstractInputFormat.java
@@ -227,7 +227,7 @@ public abstract class AbstractInputFormat<K,V> extends InputFormat<K,V>
{
   @Deprecated
   public static void setConnectorInfo(Job job, String principal, String tokenFile)
       throws AccumuloSecurityException {
-    InputConfigurator.setConnectorInfo(CLASS, job.getConfiguration(), principal, tokenFile);
+    setClientPropertiesFile(job, tokenFile);
   }
 
   /**
diff --git a/client/mapreduce/src/main/java/org/apache/accumulo/core/client/mapreduce/AccumuloOutputFormat.java
b/client/mapreduce/src/main/java/org/apache/accumulo/core/client/mapreduce/AccumuloOutputFormat.java
index 9777509..eaa67c8 100644
--- a/client/mapreduce/src/main/java/org/apache/accumulo/core/client/mapreduce/AccumuloOutputFormat.java
+++ b/client/mapreduce/src/main/java/org/apache/accumulo/core/client/mapreduce/AccumuloOutputFormat.java
@@ -178,7 +178,7 @@ public class AccumuloOutputFormat extends OutputFormat<Text,Mutation>
{
   @Deprecated
   public static void setConnectorInfo(Job job, String principal, String tokenFile)
       throws AccumuloSecurityException {
-    OutputConfigurator.setConnectorInfo(CLASS, job.getConfiguration(), principal, tokenFile);
+    setClientPropertiesFile(job, tokenFile);
   }
 
   /**
diff --git a/client/mapreduce/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/impl/ConfiguratorBase.java
b/client/mapreduce/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/impl/ConfiguratorBase.java
index 1ffa291..0df6469 100644
--- a/client/mapreduce/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/impl/ConfiguratorBase.java
+++ b/client/mapreduce/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/impl/ConfiguratorBase.java
@@ -250,33 +250,6 @@ public class ConfiguratorBase {
   }
 
   /**
-   * Sets the connector information needed to communicate with Accumulo in this job.
-   *
-   * <p>
-   * Pulls a token file into the Distributed Cache that contains the authentication token
in an
-   * attempt to be more secure than storing the password in the Configuration. Token file
created
-   * with "bin/accumulo create-token".
-   *
-   * @param implementingClass
-   *          the class whose name will be used as a prefix for the property configuration
key
-   * @param conf
-   *          the Hadoop configuration object to configure
-   * @param principal
-   *          a valid Accumulo user name
-   * @param tokenFile
-   *          the path to the token file in DFS
-   * @since 1.6.0
-   */
-  public static void setConnectorInfo(Class<?> implementingClass, Configuration conf,
-      String principal, String tokenFile) throws AccumuloSecurityException {
-    if (isConnectorInfoSet(implementingClass, conf))
-      throw new IllegalStateException("Connector info for " + implementingClass.getSimpleName()
-          + " can only be set once per job");
-    checkArgument(tokenFile != null, "tokenFile is null");
-    setClientPropertiesFile(implementingClass, conf, tokenFile);
-  }
-
-  /**
    * Determines if the connector info has already been set for this instance.
    *
    * @param implementingClass
@@ -393,7 +366,7 @@ public class ConfiguratorBase {
    * @return A ClientConfiguration
    * @since 1.7.0
    */
-  @SuppressWarnings("deprecation")
+  @Deprecated
   public static org.apache.accumulo.core.client.ClientConfiguration getClientConfiguration(
       Class<?> implementingClass, Configuration conf) {
     return ClientConfConverter.toClientConf(getClientInfo(implementingClass, conf).getProperties());
diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/ClientContext.java b/core/src/main/java/org/apache/accumulo/core/client/impl/ClientContext.java
index b5d407a..99d5b72 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/ClientContext.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/ClientContext.java
@@ -50,7 +50,7 @@ import com.google.common.base.Suppliers;
 public class ClientContext {
 
   private ClientInfo info;
-  protected Instance inst;
+  private Instance inst;
   private Credentials creds;
   private BatchWriterConfig batchWriterConfig;
   private AccumuloConfiguration serverConf;
diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/ConditionalWriterImpl.java
b/core/src/main/java/org/apache/accumulo/core/client/impl/ConditionalWriterImpl.java
index 847331c..0401e07 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/ConditionalWriterImpl.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/ConditionalWriterImpl.java
@@ -46,7 +46,6 @@ import org.apache.accumulo.core.client.AccumuloSecurityException;
 import org.apache.accumulo.core.client.ConditionalWriter;
 import org.apache.accumulo.core.client.ConditionalWriterConfig;
 import org.apache.accumulo.core.client.Durability;
-import org.apache.accumulo.core.client.Instance;
 import org.apache.accumulo.core.client.TableDeletedException;
 import org.apache.accumulo.core.client.TableNotFoundException;
 import org.apache.accumulo.core.client.TableOfflineException;
@@ -691,7 +690,6 @@ class ConditionalWriterImpl implements ConditionalWriter {
 
     long startTime = System.currentTimeMillis();
 
-    Instance instance = context.getInstance();
     LockID lid = new LockID(ZooUtil.getRoot(context.getInstanceID()) + Constants.ZTSERVERS,
         sessionId.lockId);
 
diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchReaderIterator.java
b/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchReaderIterator.java
index db47f60..fcb07be 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchReaderIterator.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchReaderIterator.java
@@ -252,7 +252,7 @@ public class TabletServerBatchReaderIterator implements Iterator<Entry<Key,Value
           if (!Tables.exists(context, tableId))
             throw new TableDeletedException(tableId.canonicalID());
           else if (Tables.getTableState(instance, tableId) == TableState.OFFLINE)
-            throw new TableOfflineException(instance, tableId.canonicalID());
+            throw new TableOfflineException(Tables.getTableOfflineMsg(context, tableId));
 
         lastFailureSize = failures.size();
 
diff --git a/server/base/src/main/java/org/apache/accumulo/server/AccumuloServerContext.java
b/server/base/src/main/java/org/apache/accumulo/server/AccumuloServerContext.java
index feb8231..1640cbd 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/AccumuloServerContext.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/AccumuloServerContext.java
@@ -172,7 +172,7 @@ public class AccumuloServerContext extends ClientContext {
   public Connector getConnector() throws AccumuloException, AccumuloSecurityException {
     // avoid making more connectors than necessary
     if (conn == null) {
-      if (inst instanceof ZooKeeperInstance || inst instanceof HdfsZooInstance) {
+      if (getInstance() instanceof ZooKeeperInstance || getInstance() instanceof HdfsZooInstance)
{
         // reuse existing context
         conn = new ConnectorImpl(this);
       } else {
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 e88b574..1ac98f8 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
@@ -1765,7 +1765,7 @@ public class Master extends AccumuloServerContext
 
   public void markDeadServerLogsAsClosed(Map<TServerInstance,List<Path>> logsForDeadServers)
       throws WalMarkerException {
-    WalStateManager mgr = new WalStateManager(this.inst, ZooReaderWriter.getInstance());
+    WalStateManager mgr = new WalStateManager(getInstance(), ZooReaderWriter.getInstance());
     for (Entry<TServerInstance,List<Path>> server : logsForDeadServers.entrySet())
{
       for (Path path : server.getValue()) {
         mgr.closeWal(server.getKey(), path);
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/replication/ReplicationWorker.java
b/server/tserver/src/main/java/org/apache/accumulo/tserver/replication/ReplicationWorker.java
index 3b9c196..27ce654 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/replication/ReplicationWorker.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/replication/ReplicationWorker.java
@@ -18,7 +18,6 @@ package org.apache.accumulo.tserver.replication;
 
 import java.util.concurrent.ThreadPoolExecutor;
 
-import org.apache.accumulo.core.client.Instance;
 import org.apache.accumulo.core.client.impl.ClientContext;
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
 import org.apache.accumulo.core.conf.DefaultConfiguration;
@@ -38,14 +37,12 @@ public class ReplicationWorker implements Runnable {
   private static final Logger log = LoggerFactory.getLogger(ReplicationWorker.class);
 
   private ClientContext context;
-  private Instance inst;
   private AccumuloConfiguration conf;
   private VolumeManager fs;
   private ThreadPoolExecutor executor;
 
   public ReplicationWorker(ClientContext clientCtx, VolumeManager fs) {
     this.context = clientCtx;
-    this.inst = clientCtx.getInstance();
     this.fs = fs;
     this.conf = clientCtx.getConfiguration();
   }
diff --git a/test/src/main/java/org/apache/accumulo/test/mapred/TokenFileIT.java b/test/src/main/java/org/apache/accumulo/test/mapred/TokenFileIT.java
index 26877f8..699283e 100644
--- a/test/src/main/java/org/apache/accumulo/test/mapred/TokenFileIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/mapred/TokenFileIT.java
@@ -26,7 +26,6 @@ import java.io.IOException;
 import java.io.PrintStream;
 import java.util.Iterator;
 import java.util.Map.Entry;
-import java.util.Properties;
 
 import org.apache.accumulo.core.client.BatchWriter;
 import org.apache.accumulo.core.client.BatchWriterConfig;
@@ -91,6 +90,7 @@ public class TokenFileIT extends AccumuloClusterHarness {
 
     }
 
+    @SuppressWarnings("deprecation")
     @Override
     public int run(String[] args) throws Exception {
 
@@ -119,7 +119,7 @@ public class TokenFileIT extends AccumuloClusterHarness {
       job.setOutputKeyClass(Text.class);
       job.setOutputValueClass(Mutation.class);
 
-      AccumuloOutputFormat.setClientInfo(job, getCluster().getClientInfo());
+      AccumuloOutputFormat.setConnectorInfo(job, user, tokenFile);
       AccumuloOutputFormat.setCreateTables(job, false);
       AccumuloOutputFormat.setDefaultTableName(job, table2);
 
@@ -159,13 +159,9 @@ public class TokenFileIT extends AccumuloClusterHarness {
     bw.close();
 
     File tf = folder.newFile("client.properties");
-    PrintStream out = new PrintStream(tf);
-    Properties props = getClientInfo().getProperties();
-    for (Object keyObj : props.keySet()) {
-      String key = (String) keyObj;
-      out.println(key + " = " + props.getProperty(key));
+    try (PrintStream out = new PrintStream(tf)) {
+      getClientInfo().getProperties().store(out, "Credentials for " + getClass().getName());
     }
-    out.close();
 
     MRTokenFileTester.main(new String[] {tf.getAbsolutePath(), table1, table2});
     assertNull(e1);
diff --git a/test/src/main/java/org/apache/accumulo/test/mapreduce/TokenFileIT.java b/test/src/main/java/org/apache/accumulo/test/mapreduce/TokenFileIT.java
index a4ffcd4..43a93b2 100644
--- a/test/src/main/java/org/apache/accumulo/test/mapreduce/TokenFileIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/mapreduce/TokenFileIT.java
@@ -26,7 +26,6 @@ import java.io.IOException;
 import java.io.PrintStream;
 import java.util.Iterator;
 import java.util.Map.Entry;
-import java.util.Properties;
 
 import org.apache.accumulo.core.client.BatchWriter;
 import org.apache.accumulo.core.client.BatchWriterConfig;
@@ -81,6 +80,7 @@ public class TokenFileIT extends AccumuloClusterHarness {
       }
     }
 
+    @SuppressWarnings("deprecation")
     @Override
     public int run(String[] args) throws Exception {
 
@@ -152,13 +152,9 @@ public class TokenFileIT extends AccumuloClusterHarness {
     bw.close();
 
     File tf = folder.newFile("client.properties");
-    PrintStream out = new PrintStream(tf);
-    Properties props = getClientInfo().getProperties();
-    for (Object keyObj : props.keySet()) {
-      String key = (String) keyObj;
-      out.println(key + " = " + props.getProperty(key));
+    try (PrintStream out = new PrintStream(tf)) {
+      getClientInfo().getProperties().store(out, "Credentials for " + getClass().getName());
     }
-    out.close();
 
     MRTokenFileTester.main(new String[] {tf.getAbsolutePath(), table1, table2});
     assertNull(e1);
diff --git a/test/src/main/java/org/apache/accumulo/test/replication/ReplicationIT.java b/test/src/main/java/org/apache/accumulo/test/replication/ReplicationIT.java
index 8f36541..6f01a5f 100644
--- a/test/src/main/java/org/apache/accumulo/test/replication/ReplicationIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/replication/ReplicationIT.java
@@ -47,7 +47,6 @@ import org.apache.accumulo.core.client.IteratorSetting.Column;
 import org.apache.accumulo.core.client.Scanner;
 import org.apache.accumulo.core.client.TableNotFoundException;
 import org.apache.accumulo.core.client.TableOfflineException;
-import org.apache.accumulo.core.client.ZooKeeperInstance;
 import org.apache.accumulo.core.client.admin.TableOperations;
 import org.apache.accumulo.core.client.impl.Table;
 import org.apache.accumulo.core.conf.ClientProperty;
@@ -156,7 +155,6 @@ public class ReplicationIT extends ConfigurableMacBase {
       }
       // Map of logs to tableId
       Multimap<String,Table.ID> logs = HashMultimap.create();
-      Instance i = conn.getInstance();
       ZooReaderWriter zk = new ZooReaderWriter(conn.info().getZooKeepers(),
           conn.info().getZooKeepersSessionTimeOut(), "");
       WalStateManager wals = new WalStateManager(conn.getInstance(), zk);
@@ -197,7 +195,6 @@ public class ReplicationIT extends ConfigurableMacBase {
 
   private void waitForGCLock(Connector conn) throws InterruptedException {
     // Check if the GC process has the lock before wasting our retry attempts
-    ZooKeeperInstance zki = (ZooKeeperInstance) conn.getInstance();
     ZooCacheFactory zcf = new ZooCacheFactory();
     ZooCache zcache = zcf.getZooCache(conn.info().getZooKeepers(),
         conn.info().getZooKeepersSessionTimeOut());

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

Mime
View raw message