accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ctubb...@apache.org
Subject [2/4] accumulo git commit: ACCUMULO-4304 Replace Guava use w/built-ins
Date Fri, 06 May 2016 04:00:57 GMT
http://git-wip-us.apache.org/repos/asf/accumulo/blob/84f70731/shell/src/main/java/org/apache/accumulo/shell/ShellUtil.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/ShellUtil.java b/shell/src/main/java/org/apache/accumulo/shell/ShellUtil.java
index aa74556..871dc79 100644
--- a/shell/src/main/java/org/apache/accumulo/shell/ShellUtil.java
+++ b/shell/src/main/java/org/apache/accumulo/shell/ShellUtil.java
@@ -21,17 +21,17 @@ import static java.nio.charset.StandardCharsets.UTF_8;
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.util.ArrayList;
+import java.util.Base64;
 import java.util.List;
 import java.util.Scanner;
 
-import org.apache.accumulo.core.util.Base64;
 import org.apache.hadoop.io.Text;
 
 public class ShellUtil {
 
   /**
    * Scans the given file line-by-line (ignoring empty lines) and returns a list containing
those lines. If decode is set to true, every line is decoded using
-   * {@link Base64#decodeBase64(byte[])} from the UTF-8 bytes of that line before inserting
in the list.
+   * {@link Base64} from the UTF-8 bytes of that line before inserting in the list.
    *
    * @param filename
    *          Path to the file that needs to be scanned
@@ -49,7 +49,7 @@ public class ShellUtil {
       while (file.hasNextLine()) {
         line = file.nextLine();
         if (!line.isEmpty()) {
-          result.add(decode ? new Text(Base64.decodeBase64(line.getBytes(UTF_8))) : new Text(line));
+          result.add(decode ? new Text(Base64.getDecoder().decode(line.getBytes(UTF_8)))
: new Text(line));
         }
       }
     } finally {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/84f70731/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 e5d6c59..ee39c7c 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
@@ -16,10 +16,12 @@
  */
 package org.apache.accumulo.shell.commands;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
+
 import java.io.IOException;
 import java.lang.reflect.Type;
-import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
+import java.util.Base64;
 import java.util.Collections;
 import java.util.EnumSet;
 import java.util.Formatter;
@@ -33,7 +35,6 @@ 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.util.Base64;
 import org.apache.accumulo.core.zookeeper.ZooUtil;
 import org.apache.accumulo.fate.AdminUtil;
 import org.apache.accumulo.fate.ReadOnlyRepo;
@@ -84,8 +85,8 @@ public class FateCommand extends Command {
     public String asBase64;
 
     ByteArrayContainer(byte[] ba) {
-      asUtf8 = new String(ba, StandardCharsets.UTF_8);
-      asBase64 = Base64.encodeBase64URLSafeString(ba);
+      asUtf8 = new String(ba, UTF_8);
+      asBase64 = new String(Base64.getUrlEncoder().encode(ba), UTF_8);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/accumulo/blob/84f70731/shell/src/main/java/org/apache/accumulo/shell/commands/GetSplitsCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/GetSplitsCommand.java
b/shell/src/main/java/org/apache/accumulo/shell/commands/GetSplitsCommand.java
index 17b7db4..4997242 100644
--- a/shell/src/main/java/org/apache/accumulo/shell/commands/GetSplitsCommand.java
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/GetSplitsCommand.java
@@ -16,9 +16,12 @@
  */
 package org.apache.accumulo.shell.commands;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
+
 import java.io.IOException;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
+import java.util.Base64;
 import java.util.Iterator;
 import java.util.Map.Entry;
 
@@ -34,7 +37,6 @@ import org.apache.accumulo.core.metadata.MetadataTable;
 import org.apache.accumulo.core.metadata.RootTable;
 import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection;
 import org.apache.accumulo.core.security.Authorizations;
-import org.apache.accumulo.core.util.Base64;
 import org.apache.accumulo.core.util.TextUtil;
 import org.apache.accumulo.core.util.format.DefaultFormatter;
 import org.apache.accumulo.shell.Shell;
@@ -103,7 +105,8 @@ public class GetSplitsCommand extends Command {
       return null;
     }
     final int length = text.getLength();
-    return encode ? Base64.encodeBase64String(TextUtil.getBytes(text)) : DefaultFormatter.appendText(new
StringBuilder(), text, length).toString();
+    return encode ? new String(Base64.getEncoder().encode(TextUtil.getBytes(text)), UTF_8)
: DefaultFormatter.appendText(new StringBuilder(), text, length)
+        .toString();
   }
 
   private static String obscuredTabletName(final KeyExtent extent) {
@@ -116,7 +119,7 @@ public class GetSplitsCommand extends Command {
     if (extent.getEndRow() != null && extent.getEndRow().getLength() > 0) {
       digester.update(extent.getEndRow().getBytes(), 0, extent.getEndRow().getLength());
     }
-    return Base64.encodeBase64String(digester.digest());
+    return new String(Base64.getEncoder().encode(digester.digest()), UTF_8);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/accumulo/blob/84f70731/shell/src/main/java/org/apache/accumulo/shell/commands/HiddenCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/HiddenCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/HiddenCommand.java
index 14d6c2c..d278913 100644
--- a/shell/src/main/java/org/apache/accumulo/shell/commands/HiddenCommand.java
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/HiddenCommand.java
@@ -19,9 +19,9 @@ package org.apache.accumulo.shell.commands;
 import static java.nio.charset.StandardCharsets.UTF_8;
 
 import java.security.SecureRandom;
+import java.util.Base64;
 import java.util.Random;
 
-import org.apache.accumulo.core.util.Base64;
 import org.apache.accumulo.shell.Shell;
 import org.apache.accumulo.shell.Shell.Command;
 import org.apache.accumulo.shell.ShellCommandException;
@@ -42,9 +42,10 @@ public class HiddenCommand extends Command {
       shellState.getReader().beep();
       shellState.getReader().println();
       shellState.getReader().println(
-          new String(Base64.decodeBase64(("ICAgICAgIC4tLS4KICAgICAgLyAvXCBcCiAgICAgKCAvLS1cICkKICAgICAuPl8gIF88LgogICAgLyB8ICd8ICcgXAog"
-              + "ICAvICB8Xy58Xy4gIFwKICAvIC98ICAgICAgfFwgXAogfCB8IHwgfFwvfCB8IHwgfAogfF98IHwgfCAgfCB8IHxffAogICAgIC8gIF9fICBcCiAgICAvICAv"
-              + "ICBcICBcCiAgIC8gIC8gICAgXCAgXF8KIHwvICAvICAgICAgXCB8IHwKIHxfXy8gICAgICAgIFx8X3wK").getBytes(UTF_8)),
UTF_8));
+          new String(Base64.getDecoder().decode(
+              ("ICAgICAgIC4tLS4KICAgICAgLyAvXCBcCiAgICAgKCAvLS1cICkKICAgICAuPl8gIF88LgogICAgLyB8ICd8ICcgXAog"
+                  + "ICAvICB8Xy58Xy4gIFwKICAvIC98ICAgICAgfFwgXAogfCB8IHwgfFwvfCB8IHwgfAogfF98IHwgfCAgfCB8IHxffAogICAgIC8gIF9fICBcCiAgICAvICAv"
+                  + "ICBcICBcCiAgIC8gIC8gICAgXCAgXF8KIHwvICAvICAgICAgXCB8IHwKIHxfXy8gICAgICAgIFx8X3wK").getBytes(UTF_8)),
UTF_8));
     } else {
       throw new ShellCommandException(ErrorCode.UNRECOGNIZED_COMMAND, getName());
     }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/84f70731/shell/src/main/java/org/apache/accumulo/shell/commands/HistoryCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/HistoryCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/HistoryCommand.java
index 785b49e..2caf69a 100644
--- a/shell/src/main/java/org/apache/accumulo/shell/commands/HistoryCommand.java
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/HistoryCommand.java
@@ -19,17 +19,16 @@ package org.apache.accumulo.shell.commands;
 import java.io.IOException;
 import java.util.Iterator;
 
-import jline.console.history.History.Entry;
-
 import org.apache.accumulo.shell.Shell;
 import org.apache.accumulo.shell.Shell.Command;
 import org.apache.commons.cli.CommandLine;
 import org.apache.commons.cli.Option;
 import org.apache.commons.cli.Options;
 
-import com.google.common.base.Function;
 import com.google.common.collect.Iterators;
 
+import jline.console.history.History.Entry;
+
 public class HistoryCommand extends Command {
   private Option clearHist;
   private Option disablePaginationOpt;
@@ -40,13 +39,7 @@ public class HistoryCommand extends Command {
       shellState.getReader().getHistory().clear();
     } else {
       Iterator<Entry> source = shellState.getReader().getHistory().entries();
-      Iterator<String> historyIterator = Iterators.transform(source, new Function<Entry,String>()
{
-        @Override
-        public String apply(Entry input) {
-          return String.format("%d: %s", input.index() + 1, input.value());
-        }
-      });
-
+      Iterator<String> historyIterator = Iterators.transform(source, input -> String.format("%d:
%s", input.index() + 1, input.value()));
       shellState.printLines(historyIterator, !cl.hasOption(disablePaginationOpt.getOpt()));
     }
 

http://git-wip-us.apache.org/repos/asf/accumulo/blob/84f70731/shell/src/main/java/org/apache/accumulo/shell/commands/NamespacesCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/NamespacesCommand.java
b/shell/src/main/java/org/apache/accumulo/shell/commands/NamespacesCommand.java
index d88d6f1..825153c 100644
--- a/shell/src/main/java/org/apache/accumulo/shell/commands/NamespacesCommand.java
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/NamespacesCommand.java
@@ -19,7 +19,6 @@ package org.apache.accumulo.shell.commands;
 import java.io.IOException;
 import java.util.Iterator;
 import java.util.Map;
-import java.util.Map.Entry;
 import java.util.TreeMap;
 
 import org.apache.accumulo.core.client.AccumuloException;
@@ -31,7 +30,6 @@ import org.apache.commons.cli.CommandLine;
 import org.apache.commons.cli.Option;
 import org.apache.commons.cli.Options;
 
-import com.google.common.base.Function;
 import com.google.common.collect.Iterators;
 
 public class NamespacesCommand extends Command {
@@ -43,18 +41,15 @@ public class NamespacesCommand extends Command {
   public int execute(final String fullCommand, final CommandLine cl, final Shell shellState)
throws AccumuloException, AccumuloSecurityException, IOException {
     Map<String,String> namespaces = new TreeMap<String,String>(shellState.getConnector().namespaceOperations().namespaceIdMap());
 
-    Iterator<String> it = Iterators.transform(namespaces.entrySet().iterator(), new
Function<Entry<String,String>,String>() {
-      @Override
-      public String apply(Map.Entry<String,String> entry) {
-        String name = entry.getKey();
-        if (Namespaces.DEFAULT_NAMESPACE.equals(name))
-          name = DEFAULT_NAMESPACE_DISPLAY_NAME;
-        String id = entry.getValue();
-        if (cl.hasOption(namespaceIdOption.getOpt()))
-          return String.format(TablesCommand.NAME_AND_ID_FORMAT, name, id);
-        else
-          return name;
-      }
+    Iterator<String> it = Iterators.transform(namespaces.entrySet().iterator(), entry
-> {
+      String name = entry.getKey();
+      if (Namespaces.DEFAULT_NAMESPACE.equals(name))
+        name = DEFAULT_NAMESPACE_DISPLAY_NAME;
+      String id = entry.getValue();
+      if (cl.hasOption(namespaceIdOption.getOpt()))
+        return String.format(TablesCommand.NAME_AND_ID_FORMAT, name, id);
+      else
+        return name;
     });
 
     shellState.printLines(it, !cl.hasOption(disablePaginationOpt.getOpt()));

http://git-wip-us.apache.org/repos/asf/accumulo/blob/84f70731/shell/src/main/java/org/apache/accumulo/shell/commands/TablesCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/TablesCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/TablesCommand.java
index a70cc13..8bf96e7 100644
--- a/shell/src/main/java/org/apache/accumulo/shell/commands/TablesCommand.java
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/TablesCommand.java
@@ -19,7 +19,6 @@ package org.apache.accumulo.shell.commands;
 import java.io.IOException;
 import java.util.Iterator;
 import java.util.Map;
-import java.util.Map.Entry;
 import java.util.TreeMap;
 
 import org.apache.accumulo.core.client.AccumuloException;
@@ -33,8 +32,6 @@ import org.apache.commons.cli.Option;
 import org.apache.commons.cli.Options;
 import org.apache.commons.collections.MapUtils;
 
-import com.google.common.base.Function;
-import com.google.common.base.Predicate;
 import com.google.common.collect.Iterators;
 import com.google.common.collect.Maps;
 
@@ -54,28 +51,20 @@ public class TablesCommand extends Command {
     Map<String,String> tables = shellState.getConnector().tableOperations().tableIdMap();
 
     // filter only specified namespace
-    tables = Maps.filterKeys(tables, new Predicate<String>() {
-      @Override
-      public boolean apply(String tableName) {
-        return namespace == null || Tables.qualify(tableName).getFirst().equals(namespace);
-      }
-    });
+    tables = Maps.filterKeys(tables, tableName -> namespace == null || Tables.qualify(tableName).getFirst().equals(namespace));
 
     final boolean sortByTableId = cl.hasOption(sortByTableIdOption.getOpt());
     tables = new TreeMap<String,String>((sortByTableId ? MapUtils.invertMap(tables)
: tables));
 
-    Iterator<String> it = Iterators.transform(tables.entrySet().iterator(), new Function<Entry<String,String>,String>()
{
-      @Override
-      public String apply(Map.Entry<String,String> entry) {
-        String tableName = String.valueOf(sortByTableId ? entry.getValue() : entry.getKey());
-        String tableId = String.valueOf(sortByTableId ? entry.getKey() : entry.getValue());
-        if (namespace != null)
-          tableName = Tables.qualify(tableName).getSecond();
-        if (cl.hasOption(tableIdOption.getOpt()))
-          return String.format(NAME_AND_ID_FORMAT, tableName, tableId);
-        else
-          return tableName;
-      }
+    Iterator<String> it = Iterators.transform(tables.entrySet().iterator(), entry ->
{
+      String tableName = String.valueOf(sortByTableId ? entry.getValue() : entry.getKey());
+      String tableId = String.valueOf(sortByTableId ? entry.getKey() : entry.getValue());
+      if (namespace != null)
+        tableName = Tables.qualify(tableName).getSecond();
+      if (cl.hasOption(tableIdOption.getOpt()))
+        return String.format(NAME_AND_ID_FORMAT, tableName, tableId);
+      else
+        return tableName;
     });
 
     shellState.printLines(it, !cl.hasOption(disablePaginationOpt.getOpt()));

http://git-wip-us.apache.org/repos/asf/accumulo/blob/84f70731/shell/src/test/java/org/apache/accumulo/shell/ShellUtilTest.java
----------------------------------------------------------------------
diff --git a/shell/src/test/java/org/apache/accumulo/shell/ShellUtilTest.java b/shell/src/test/java/org/apache/accumulo/shell/ShellUtilTest.java
index 9b3be51..d72477c 100644
--- a/shell/src/test/java/org/apache/accumulo/shell/ShellUtilTest.java
+++ b/shell/src/test/java/org/apache/accumulo/shell/ShellUtilTest.java
@@ -22,9 +22,9 @@ import static org.junit.Assert.assertEquals;
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
+import java.util.Base64;
 import java.util.List;
 
-import org.apache.accumulo.core.util.Base64;
 import org.apache.commons.io.FileUtils;
 import org.apache.hadoop.io.Text;
 import org.junit.Rule;
@@ -40,6 +40,7 @@ public class ShellUtilTest {
 
   // String with 3 lines, with one empty line
   private static final String FILEDATA = "line1\n\nline2";
+  private static final String B64_FILEDATA = "bGluZTE=\n\nbGluZTI=";
 
   @Test
   public void testWithoutDecode() throws IOException {
@@ -52,9 +53,11 @@ public class ShellUtilTest {
   @Test
   public void testWithDecode() throws IOException {
     File testFile = new File(folder.getRoot(), "testFileWithDecode.txt");
-    FileUtils.writeStringToFile(testFile, FILEDATA);
+    FileUtils.writeStringToFile(testFile, B64_FILEDATA);
     List<Text> output = ShellUtil.scanFile(testFile.getAbsolutePath(), true);
-    assertEquals(ImmutableList.of(new Text(Base64.decodeBase64("line1".getBytes(UTF_8))),
new Text(Base64.decodeBase64("line2".getBytes(UTF_8)))), output);
+    assertEquals(
+        ImmutableList.of(new Text(Base64.getDecoder().decode("bGluZTE=".getBytes(UTF_8))),
new Text(Base64.getDecoder().decode("bGluZTI=".getBytes(UTF_8)))),
+        output);
   }
 
   @Test(expected = FileNotFoundException.class)

http://git-wip-us.apache.org/repos/asf/accumulo/blob/84f70731/test/src/main/java/org/apache/accumulo/test/functional/MapReduceIT.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/MapReduceIT.java b/test/src/main/java/org/apache/accumulo/test/functional/MapReduceIT.java
index 8c4666c..3797e5b 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/MapReduceIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/MapReduceIT.java
@@ -21,6 +21,7 @@ import static org.junit.Assert.assertEquals;
 import java.io.IOException;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
+import java.util.Base64;
 import java.util.Collections;
 import java.util.Map.Entry;
 
@@ -37,7 +38,6 @@ import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.data.Mutation;
 import org.apache.accumulo.core.data.Value;
 import org.apache.accumulo.core.security.Authorizations;
-import org.apache.accumulo.core.util.Base64;
 import org.apache.accumulo.examples.simple.mapreduce.RowHash;
 import org.apache.accumulo.minicluster.impl.MiniAccumuloClusterImpl;
 import org.apache.hadoop.io.Text;
@@ -83,7 +83,7 @@ public class MapReduceIT extends ConfigurableMacBase {
     int i = 0;
     for (Entry<Key,Value> entry : s) {
       MessageDigest md = MessageDigest.getInstance("MD5");
-      byte[] check = Base64.encodeBase64(md.digest(("row" + i).getBytes()));
+      byte[] check = Base64.getEncoder().encode(md.digest(("row" + i).getBytes()));
       assertEquals(entry.getValue().toString(), new String(check));
       i++;
     }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/84f70731/test/src/main/java/org/apache/accumulo/test/functional/TabletStateChangeIteratorIT.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/TabletStateChangeIteratorIT.java
b/test/src/main/java/org/apache/accumulo/test/functional/TabletStateChangeIteratorIT.java
index b56b4a5..a86d114 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/TabletStateChangeIteratorIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/TabletStateChangeIteratorIT.java
@@ -60,7 +60,6 @@ import org.apache.accumulo.server.zookeeper.ZooLock;
 import org.apache.hadoop.io.Text;
 import org.junit.Test;
 
-import com.google.common.base.Predicate;
 import com.google.common.collect.Sets;
 
 /**
@@ -215,12 +214,7 @@ public class TabletStateChangeIteratorIT extends SharedMiniClusterBase
{
     @Override
     public Set<String> onlineTables() {
       HashSet<String> onlineTables = new HashSet<String>(getConnector().tableOperations().tableIdMap().values());
-      return Sets.filter(onlineTables, new Predicate<String>() {
-        @Override
-        public boolean apply(String tableId) {
-          return Tables.getTableState(getConnector().getInstance(), tableId) == TableState.ONLINE;
-        }
-      });
+      return Sets.filter(onlineTables, tableId -> Tables.getTableState(getConnector().getInstance(),
tableId) == TableState.ONLINE);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/accumulo/blob/84f70731/test/src/main/java/org/apache/accumulo/test/randomwalk/shard/BulkInsert.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/shard/BulkInsert.java
b/test/src/main/java/org/apache/accumulo/test/randomwalk/shard/BulkInsert.java
index 5f696d0..c95a7d6 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/shard/BulkInsert.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/shard/BulkInsert.java
@@ -16,11 +16,13 @@
  */
 package org.apache.accumulo.test.randomwalk.shard;
 
+import static com.google.common.util.concurrent.Uninterruptibles.sleepUninterruptibly;
 import static java.nio.charset.StandardCharsets.UTF_8;
 
 import java.io.BufferedOutputStream;
 import java.io.IOException;
 import java.io.PrintStream;
+import java.util.Base64;
 import java.util.Collection;
 import java.util.List;
 import java.util.Properties;
@@ -34,7 +36,6 @@ import org.apache.accumulo.core.data.ColumnUpdate;
 import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.data.Mutation;
 import org.apache.accumulo.core.data.Value;
-import org.apache.accumulo.core.util.Base64;
 import org.apache.accumulo.core.util.CachedConfiguration;
 import org.apache.accumulo.core.util.TextUtil;
 import org.apache.accumulo.test.randomwalk.Environment;
@@ -48,8 +49,6 @@ import org.apache.hadoop.io.SequenceFile;
 import org.apache.hadoop.io.Text;
 import org.apache.hadoop.util.ToolRunner;
 
-import static com.google.common.util.concurrent.Uninterruptibles.sleepUninterruptibly;
-
 public class BulkInsert extends Test {
 
   class SeqfileBatchWriter implements BatchWriter {
@@ -174,7 +173,7 @@ public class BulkInsert extends Test {
 
     Collection<Text> splits = conn.tableOperations().listSplits(tableName, maxSplits);
     for (Text split : splits)
-      out.println(Base64.encodeBase64String(TextUtil.getBytes(split)));
+      out.println(new String(Base64.getEncoder().encode(TextUtil.getBytes(split)), UTF_8));
 
     out.close();
 

http://git-wip-us.apache.org/repos/asf/accumulo/blob/84f70731/test/src/main/java/org/apache/accumulo/test/replication/ReplicationIT.java
----------------------------------------------------------------------
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 467a69b..f02f7b6 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
@@ -100,7 +100,6 @@ import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Function;
 import com.google.common.base.Joiner;
 import com.google.common.collect.HashMultimap;
 import com.google.common.collect.Iterables;
@@ -240,12 +239,6 @@ public class ReplicationIT extends ConfigurableMacBase {
     boolean foundLocalityGroupDef2 = false;
     boolean foundFormatter = false;
     Joiner j = Joiner.on(",");
-    Function<Text,String> textToString = new Function<Text,String>() {
-      @Override
-      public String apply(Text text) {
-        return text.toString();
-      }
-    };
     for (Entry<String,String> p : tops.getProperties(ReplicationTable.NAME)) {
       String key = p.getKey();
       String val = p.getValue();
@@ -259,10 +252,10 @@ public class ReplicationIT extends ConfigurableMacBase {
       } else if (key.startsWith(Property.TABLE_LOCALITY_GROUP_PREFIX.getKey())) {
         // look for locality group column family definitions
         if (key.equals(Property.TABLE_LOCALITY_GROUP_PREFIX.getKey() + ReplicationTable.STATUS_LG_NAME)
-            && val.equals(j.join(Iterables.transform(ReplicationTable.STATUS_LG_COLFAMS,
textToString)))) {
+            && val.equals(j.join(Iterables.transform(ReplicationTable.STATUS_LG_COLFAMS,
text -> text.toString())))) {
           foundLocalityGroupDef1 = true;
         } else if (key.equals(Property.TABLE_LOCALITY_GROUP_PREFIX.getKey() + ReplicationTable.WORK_LG_NAME)
-            && val.equals(j.join(Iterables.transform(ReplicationTable.WORK_LG_COLFAMS,
textToString)))) {
+            && val.equals(j.join(Iterables.transform(ReplicationTable.WORK_LG_COLFAMS,
text -> text.toString())))) {
           foundLocalityGroupDef2 = true;
         }
       }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/84f70731/test/src/main/java/org/apache/accumulo/test/util/CertUtils.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/util/CertUtils.java b/test/src/main/java/org/apache/accumulo/test/util/CertUtils.java
index 2345ea7..464bc48 100644
--- a/test/src/main/java/org/apache/accumulo/test/util/CertUtils.java
+++ b/test/src/main/java/org/apache/accumulo/test/util/CertUtils.java
@@ -41,6 +41,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.TreeMap;
+import java.util.function.Predicate;
 
 import org.apache.accumulo.core.cli.Help;
 import org.apache.accumulo.core.client.AccumuloSecurityException;
@@ -70,7 +71,6 @@ import org.slf4j.LoggerFactory;
 
 import com.beust.jcommander.JCommander;
 import com.beust.jcommander.Parameter;
-import com.google.common.base.Predicate;
 
 public class CertUtils {
   private static final Logger log = LoggerFactory.getLogger(CertUtils.class);
@@ -154,7 +154,7 @@ public class CertUtils {
           @Override
           public void getProperties(Map<String,String> props, Predicate<String>
filter) {
             for (Entry<String,String> entry : this)
-              if (filter.apply(entry.getKey()))
+              if (filter.test(entry.getKey()))
                 props.put(entry.getKey(), entry.getValue());
           }
         };

http://git-wip-us.apache.org/repos/asf/accumulo/blob/84f70731/test/src/main/java/org/apache/accumulo/test/util/SerializationUtil.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/util/SerializationUtil.java b/test/src/main/java/org/apache/accumulo/test/util/SerializationUtil.java
index b683139..ced5940 100644
--- a/test/src/main/java/org/apache/accumulo/test/util/SerializationUtil.java
+++ b/test/src/main/java/org/apache/accumulo/test/util/SerializationUtil.java
@@ -16,10 +16,7 @@
  */
 package org.apache.accumulo.test.util;
 
-import org.apache.commons.codec.binary.Base64;
-import org.apache.hadoop.io.Writable;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import static java.nio.charset.StandardCharsets.UTF_8;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
@@ -31,8 +28,13 @@ import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.io.OutputStream;
 import java.io.Serializable;
+import java.util.Base64;
 import java.util.Objects;
 
+import org.apache.hadoop.io.Writable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 /**
  * Partially based from {@link org.apache.commons.lang3.SerializationUtils}.
  *
@@ -70,21 +72,21 @@ public class SerializationUtil {
 
   public static String serializeWritableBase64(Writable writable) {
     byte[] b = serializeWritable(writable);
-    return org.apache.accumulo.core.util.Base64.encodeBase64String(b);
+    return new String(Base64.getEncoder().encode(b), UTF_8);
   }
 
   public static void deserializeWritableBase64(Writable writable, String str) {
-    byte[] b = Base64.decodeBase64(str);
+    byte[] b = Base64.getDecoder().decode(str.getBytes(UTF_8));
     deserializeWritable(writable, b);
   }
 
   public static String serializeBase64(Serializable obj) {
     byte[] b = serialize(obj);
-    return org.apache.accumulo.core.util.Base64.encodeBase64String(b);
+    return new String(Base64.getEncoder().encode(b), UTF_8);
   }
 
   public static Object deserializeBase64(String str) {
-    byte[] b = Base64.decodeBase64(str);
+    byte[] b = Base64.getDecoder().decode(str.getBytes(UTF_8));
     return deserialize(b);
   }
 

http://git-wip-us.apache.org/repos/asf/accumulo/blob/84f70731/test/src/test/java/org/apache/accumulo/test/TraceRepoDeserializationTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/TraceRepoDeserializationTest.java
b/test/src/test/java/org/apache/accumulo/test/TraceRepoDeserializationTest.java
index 413a6c9..71c50ea 100644
--- a/test/src/test/java/org/apache/accumulo/test/TraceRepoDeserializationTest.java
+++ b/test/src/test/java/org/apache/accumulo/test/TraceRepoDeserializationTest.java
@@ -16,13 +16,14 @@
  */
 package org.apache.accumulo.test;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.junit.Assert.fail;
 
 import java.io.ByteArrayInputStream;
 import java.io.InvalidClassException;
 import java.io.ObjectInputStream;
+import java.util.Base64;
 
-import org.apache.accumulo.core.util.Base64;
 import org.junit.Test;
 
 public class TraceRepoDeserializationTest {
@@ -39,7 +40,7 @@ public class TraceRepoDeserializationTest {
 
   @Test(expected = InvalidClassException.class)
   public void test() throws Exception {
-    byte bytes[] = Base64.decodeBase64(oldValue);
+    byte bytes[] = Base64.getDecoder().decode(oldValue.getBytes(UTF_8));
     ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
     ObjectInputStream ois = new ObjectInputStream(bais);
     ois.readObject();

http://git-wip-us.apache.org/repos/asf/accumulo/blob/84f70731/test/src/test/java/org/apache/accumulo/test/iterator/AgeOffFilterTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/iterator/AgeOffFilterTest.java b/test/src/test/java/org/apache/accumulo/test/iterator/AgeOffFilterTest.java
index e78d8a9..9d7d821 100644
--- a/test/src/test/java/org/apache/accumulo/test/iterator/AgeOffFilterTest.java
+++ b/test/src/test/java/org/apache/accumulo/test/iterator/AgeOffFilterTest.java
@@ -16,8 +16,6 @@
  */
 package org.apache.accumulo.test.iterator;
 
-import static org.junit.Assert.assertNotNull;
-
 import java.util.List;
 import java.util.Map.Entry;
 import java.util.TreeMap;
@@ -34,7 +32,6 @@ import org.apache.accumulo.iteratortest.junit4.BaseJUnit4IteratorTest;
 import org.apache.accumulo.iteratortest.testcases.IteratorTestCase;
 import org.junit.runners.Parameterized.Parameters;
 
-import com.google.common.base.Predicate;
 import com.google.common.collect.Iterables;
 
 /**
@@ -103,15 +100,7 @@ public class AgeOffFilterTest extends BaseJUnit4IteratorTest {
   private static TreeMap<Key,Value> createOutputData() {
     TreeMap<Key,Value> data = new TreeMap<>();
 
-    Iterable<Entry<Key,Value>> filtered = Iterables.filter(data.entrySet(), new
Predicate<Entry<Key,Value>>() {
-
-      @Override
-      public boolean apply(Entry<Key,Value> input) {
-        assertNotNull(input);
-        return NOW - input.getKey().getTimestamp() > TTL;
-      }
-
-    });
+    Iterable<Entry<Key,Value>> filtered = Iterables.filter(data.entrySet(), input
-> NOW - input.getKey().getTimestamp() > TTL);
 
     for (Entry<Key,Value> entry : filtered) {
       data.put(entry.getKey(), entry.getValue());

http://git-wip-us.apache.org/repos/asf/accumulo/blob/84f70731/test/src/test/java/org/apache/accumulo/test/iterator/CfCqSliceFilterTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/iterator/CfCqSliceFilterTest.java
b/test/src/test/java/org/apache/accumulo/test/iterator/CfCqSliceFilterTest.java
index fc0f672..0e4c517 100644
--- a/test/src/test/java/org/apache/accumulo/test/iterator/CfCqSliceFilterTest.java
+++ b/test/src/test/java/org/apache/accumulo/test/iterator/CfCqSliceFilterTest.java
@@ -16,8 +16,6 @@
  */
 package org.apache.accumulo.test.iterator;
 
-import static org.junit.Assert.assertNotNull;
-
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map.Entry;
@@ -35,7 +33,6 @@ import org.apache.accumulo.iteratortest.junit4.BaseJUnit4IteratorTest;
 import org.apache.accumulo.iteratortest.testcases.IteratorTestCase;
 import org.junit.runners.Parameterized.Parameters;
 
-import com.google.common.base.Predicate;
 import com.google.common.collect.Iterables;
 
 /**
@@ -92,16 +89,10 @@ public class CfCqSliceFilterTest extends BaseJUnit4IteratorTest {
   private static TreeMap<Key,Value> createOutputData() {
     TreeMap<Key,Value> data = new TreeMap<>();
 
-    Iterable<Entry<Key,Value>> filtered = Iterables.filter(INPUT_DATA.entrySet(),
new Predicate<Entry<Key,Value>>() {
-
-      @Override
-      public boolean apply(Entry<Key,Value> entry) {
-        assertNotNull(entry);
-        String cf = entry.getKey().getColumnFamily().toString();
-        String cq = entry.getKey().getColumnQualifier().toString();
-        return MIN_CF.compareTo(cf) <= 0 && MAX_CF.compareTo(cf) >= 0 &&
MIN_CQ.compareTo(cq) <= 0 && MAX_CQ.compareTo(cq) >= 0;
-      }
-
+    Iterable<Entry<Key,Value>> filtered = Iterables.filter(INPUT_DATA.entrySet(),
entry -> {
+      String cf = entry.getKey().getColumnFamily().toString();
+      String cq = entry.getKey().getColumnQualifier().toString();
+      return MIN_CF.compareTo(cf) <= 0 && MAX_CF.compareTo(cf) >= 0 &&
MIN_CQ.compareTo(cq) <= 0 && MAX_CQ.compareTo(cq) >= 0;
     });
 
     for (Entry<Key,Value> entry : filtered) {


Mime
View raw message