This is an automated email from the ASF dual-hosted git repository.
siyao pushed a commit to branch HDDS-2665-ofs
in repository https://gitbox.apache.org/repos/asf/hadoop-ozone.git
The following commit(s) were added to refs/heads/HDDS-2665-ofs by this push:
new 8356a4a HDDS-3390. Adapt OFSPath to master branch changes (#847)
8356a4a is described below
commit 8356a4a382e0584ba39fc89ae082b124c6797789
Author: Siyao Meng <[email protected]>
AuthorDate: Wed Apr 22 13:29:10 2020 -0700
HDDS-3390. Adapt OFSPath to master branch changes (#847)
---
.../java/org/apache/hadoop/fs/ozone/OFSPath.java | 27 ++++++++++++++++++----
1 file changed, 23 insertions(+), 4 deletions(-)
diff --git
a/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/OFSPath.java
b/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/OFSPath.java
index f7d4ded..e970168 100644
--- a/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/OFSPath.java
+++ b/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/OFSPath.java
@@ -19,15 +19,19 @@ package org.apache.hadoop.fs.ozone;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
-import org.apache.commons.codec.digest.DigestUtils;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.http.ParseException;
-import org.apache.yetus.audience.InterfaceAudience;
-import org.apache.yetus.audience.InterfaceStability;
+import org.apache.hadoop.hdds.annotation.InterfaceAudience;
+import org.apache.hadoop.hdds.annotation.InterfaceStability;
+
+import java.math.BigInteger;
import java.net.URI;
import java.net.URISyntaxException;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
import java.util.StringTokenizer;
import static org.apache.hadoop.ozone.OzoneConsts.OZONE_URI_DELIMITER;
@@ -186,6 +190,21 @@ class OFSPath {
return this.getBucketName().isEmpty() && !this.getVolumeName().isEmpty();
}
+ private static String md5Hex(String input) {
+ try {
+ MessageDigest md = MessageDigest.getInstance("MD5");
+ byte[] digest = md.digest(input.getBytes(StandardCharsets.UTF_8));
+ BigInteger bigInt = new BigInteger(1, digest);
+ StringBuilder sb = new StringBuilder(bigInt.toString(16));
+ while (sb.length() < 32) {
+ sb.insert(0, "0");
+ }
+ return sb.toString();
+ } catch (NoSuchAlgorithmException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+
/**
* Get the bucket name of temp for given username.
* @param username Input user name String. Mustn't be null.
@@ -196,7 +215,7 @@ class OFSPath {
Preconditions.checkNotNull(username);
// TODO: Improve this to "slugify(username)-md5(username)" for better
// readability?
- return DigestUtils.md5Hex(username);
+ return md5Hex(username);
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]