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

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

commit b25f679af1ac2546b9a2c5d35006954a026bc7a7
Author: Mike Miller <mmil...@apache.org>
AuthorDate: Thu Sep 14 11:48:00 2017 -0400

    ACCUMULO-4702 Removed Beta Guava dependencies
---
 .../core/file/rfile/VisMetricsGatherer.java        | 20 ++++++++++-------
 .../java/org/apache/accumulo/fate/ZooStore.java    |  2 +-
 .../apache/accumulo/fate/util/UtilWaitThread.java  | 26 ++++++++++++++++++++++
 .../accumulo/minicluster/MiniAccumuloRunner.java   |  7 +++---
 .../main/java/org/apache/accumulo/proxy/Proxy.java |  4 ++--
 5 files changed, 45 insertions(+), 14 deletions(-)

diff --git 
a/core/src/main/java/org/apache/accumulo/core/file/rfile/VisMetricsGatherer.java
 
b/core/src/main/java/org/apache/accumulo/core/file/rfile/VisMetricsGatherer.java
index 8c8c949..b648335 100644
--- 
a/core/src/main/java/org/apache/accumulo/core/file/rfile/VisMetricsGatherer.java
+++ 
b/core/src/main/java/org/apache/accumulo/core/file/rfile/VisMetricsGatherer.java
@@ -19,6 +19,8 @@ package org.apache.accumulo.core.file.rfile;
 import static java.nio.charset.StandardCharsets.UTF_8;
 
 import java.io.PrintStream;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Map;
@@ -30,9 +32,6 @@ import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.data.Value;
 import org.apache.hadoop.io.Text;
 
-import com.google.common.hash.HashCode;
-import com.google.common.hash.HashFunction;
-import com.google.common.hash.Hashing;
 import com.google.common.util.concurrent.AtomicLongMap;
 
 /**
@@ -127,11 +126,16 @@ public class VisMetricsGatherer implements 
MetricsGatherer<Map<String,ArrayList<
       out.printf("%-27s", metricWord);
       out.println("Number of keys" + "\t   " + "Percent of keys" + "\t" + 
"Number of blocks" + "\t" + "Percent of blocks");
       for (Entry<String,Long> entry : metric.get(lGName).asMap().entrySet()) {
-        HashFunction hf = Hashing.md5();
-        HashCode hc = hf.newHasher().putString(entry.getKey(), UTF_8).hash();
-        if (hash)
-          out.printf("%-20s", hc.toString().substring(0, 8));
-        else
+        if (hash) {
+          String md5String = "";
+          try {
+            byte[] md5Bytes = 
MessageDigest.getInstance("MD5").digest(entry.getKey().getBytes(UTF_8));
+            md5String = new String(md5Bytes, UTF_8);
+          } catch (NoSuchAlgorithmException e) {
+            out.println("Failed to convert key to MD5 hash: " + 
e.getMessage());
+          }
+          out.printf("%-20s", md5String.substring(0, 8));
+        } else
           out.printf("%-20s", entry.getKey());
         out.print("\t\t" + entry.getValue() + "\t\t\t");
         out.printf("%.2f", ((double) entry.getValue() / numEntries.get(i)) * 
100);
diff --git a/fate/src/main/java/org/apache/accumulo/fate/ZooStore.java 
b/fate/src/main/java/org/apache/accumulo/fate/ZooStore.java
index ac18e83..68f1efd 100644
--- a/fate/src/main/java/org/apache/accumulo/fate/ZooStore.java
+++ b/fate/src/main/java/org/apache/accumulo/fate/ZooStore.java
@@ -16,8 +16,8 @@
  */
 package org.apache.accumulo.fate;
 
-import static 
com.google.common.util.concurrent.Uninterruptibles.sleepUninterruptibly;
 import static java.nio.charset.StandardCharsets.UTF_8;
+import static 
org.apache.accumulo.fate.util.UtilWaitThread.sleepUninterruptibly;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
diff --git 
a/fate/src/main/java/org/apache/accumulo/fate/util/UtilWaitThread.java 
b/fate/src/main/java/org/apache/accumulo/fate/util/UtilWaitThread.java
index de31fb0..f8c18b0 100644
--- a/fate/src/main/java/org/apache/accumulo/fate/util/UtilWaitThread.java
+++ b/fate/src/main/java/org/apache/accumulo/fate/util/UtilWaitThread.java
@@ -16,6 +16,10 @@
  */
 package org.apache.accumulo.fate.util;
 
+import static java.util.concurrent.TimeUnit.NANOSECONDS;
+
+import java.util.concurrent.TimeUnit;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -29,4 +33,26 @@ public class UtilWaitThread {
       log.error("{}", e.getMessage(), e);
     }
   }
+
+  public static void sleepUninterruptibly(long sleepFor, TimeUnit unit) {
+    boolean interrupted = false;
+    try {
+      long remainingNanos = unit.toNanos(sleepFor);
+      long end = System.nanoTime() + remainingNanos;
+      while (true) {
+        try {
+          // TimeUnit.sleep() treats negative timeouts just like zero.
+          NANOSECONDS.sleep(remainingNanos);
+          return;
+        } catch (InterruptedException e) {
+          interrupted = true;
+          remainingNanos = end - System.nanoTime();
+        }
+      }
+    } finally {
+      if (interrupted) {
+        Thread.currentThread().interrupt();
+      }
+    }
+  }
 }
diff --git 
a/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloRunner.java
 
b/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloRunner.java
index e88248c..71b4f10 100644
--- 
a/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloRunner.java
+++ 
b/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloRunner.java
@@ -21,6 +21,7 @@ import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.ServerSocket;
+import java.nio.file.Files;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
@@ -35,7 +36,6 @@ import org.slf4j.LoggerFactory;
 
 import com.beust.jcommander.IStringConverter;
 import com.beust.jcommander.Parameter;
-import com.google.common.io.Files;
 
 /**
  * A runner for starting up a {@link MiniAccumuloCluster} from the command 
line using an optional configuration properties file. An example property file 
looks
@@ -152,8 +152,9 @@ public class MiniAccumuloRunner {
 
     if (opts.prop.containsKey(DIRECTORY_PROP))
       miniDir = new File(opts.prop.getProperty(DIRECTORY_PROP));
-    else
-      miniDir = Files.createTempDir();
+    else {
+      miniDir = Files.createTempDirectory(System.currentTimeMillis() + "", 
null).toFile();
+    }
 
     String rootPass = opts.prop.containsKey(ROOT_PASSWORD_PROP) ? 
opts.prop.getProperty(ROOT_PASSWORD_PROP) : "secret";
 
diff --git a/proxy/src/main/java/org/apache/accumulo/proxy/Proxy.java 
b/proxy/src/main/java/org/apache/accumulo/proxy/Proxy.java
index e385f47..fb1f06c 100644
--- a/proxy/src/main/java/org/apache/accumulo/proxy/Proxy.java
+++ b/proxy/src/main/java/org/apache/accumulo/proxy/Proxy.java
@@ -20,6 +20,7 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.nio.file.Files;
 import java.util.Properties;
 
 import org.apache.accumulo.core.cli.Help;
@@ -53,7 +54,6 @@ import org.slf4j.LoggerFactory;
 import com.beust.jcommander.IStringConverter;
 import com.beust.jcommander.Parameter;
 import com.google.auto.service.AutoService;
-import com.google.common.io.Files;
 
 @AutoService(KeywordExecutable.class)
 public class Proxy implements KeywordExecutable {
@@ -139,7 +139,7 @@ public class Proxy implements KeywordExecutable {
 
     if (useMini) {
       log.info("Creating mini cluster");
-      final File folder = Files.createTempDir();
+      final File folder = Files.createTempDirectory(System.currentTimeMillis() 
+ "", null).toFile();
       final MiniAccumuloCluster accumulo = new MiniAccumuloCluster(folder, 
"secret");
       accumulo.start();
       opts.prop.setProperty("instance", 
accumulo.getConfig().getInstanceName());

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

Reply via email to