hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From inigo...@apache.org
Subject [hadoop] branch trunk updated: HDFS-9596. Remove Shuffle Method From DFSUtil. Contributed by BELUGA BEHR.
Date Mon, 18 Feb 2019 23:30:49 GMT
This is an automated email from the ASF dual-hosted git repository.

inigoiri pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 1de25d1  HDFS-9596. Remove Shuffle Method From DFSUtil. Contributed by BELUGA BEHR.
1de25d1 is described below

commit 1de25d134f64d815f9b43606fa426ece5ddbc430
Author: Inigo Goiri <inigoiri@apache.org>
AuthorDate: Mon Feb 18 15:30:38 2019 -0800

    HDFS-9596. Remove Shuffle Method From DFSUtil. Contributed by BELUGA BEHR.
---
 .../src/main/java/org/apache/hadoop/hdfs/DFSUtil.java   | 17 -----------------
 .../apache/hadoop/hdfs/server/balancer/Dispatcher.java  |  6 ++++--
 .../TestBlockPlacementPolicyRackFaultTolerant.java      |  3 +--
 3 files changed, 5 insertions(+), 21 deletions(-)

diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSUtil.java
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSUtil.java
index 8627268..6a21dfc 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSUtil.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSUtil.java
@@ -56,7 +56,6 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.concurrent.ThreadLocalRandom;
 
 import org.apache.commons.cli.CommandLine;
 import org.apache.commons.cli.CommandLineParser;
@@ -116,22 +115,6 @@ public class DFSUtil {
     return SECURE_RANDOM.get();
   }
 
-  /** Shuffle the elements in the given array. */
-  public static <T> T[] shuffle(final T[] array) {
-    if (array != null && array.length > 0) {
-      for (int n = array.length; n > 1; ) {
-        final int randomIndex = ThreadLocalRandom.current().nextInt(n);
-        n--;
-        if (n != randomIndex) {
-          final T tmp = array[randomIndex];
-          array[randomIndex] = array[n];
-          array[n] = tmp;
-        }
-      }
-    }
-    return array;
-  }
-
   /**
    * Comparator for sorting DataNodeInfo[] based on
    * decommissioned and entering_maintenance states.
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/balancer/Dispatcher.java
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/balancer/Dispatcher.java
index 8a71417..cf3dc3b 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/balancer/Dispatcher.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/balancer/Dispatcher.java
@@ -29,7 +29,9 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.net.Socket;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.EnumMap;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -50,7 +52,6 @@ import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.StorageType;
 import org.apache.hadoop.hdfs.DFSConfigKeys;
-import org.apache.hadoop.hdfs.DFSUtil;
 import org.apache.hadoop.hdfs.DFSUtilClient;
 import org.apache.hadoop.hdfs.DistributedFileSystem;
 import org.apache.hadoop.hdfs.client.HdfsClientConfigKeys;
@@ -1120,7 +1121,8 @@ public class Dispatcher {
     final List<DatanodeStorageReport> trimmed = new ArrayList<DatanodeStorageReport>();

     // create network topology and classify utilization collections:
     // over-utilized, above-average, below-average and under-utilized.
-    for (DatanodeStorageReport r : DFSUtil.shuffle(reports)) {
+    Collections.shuffle(Arrays.asList(reports));
+    for (DatanodeStorageReport r : reports) {
       final DatanodeInfo datanode = r.getDatanodeInfo();
       if (shouldIgnore(datanode)) {
         continue;
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestBlockPlacementPolicyRackFaultTolerant.java
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestBlockPlacementPolicyRackFaultTolerant.java
index f1e59f5..9825f13 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestBlockPlacementPolicyRackFaultTolerant.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestBlockPlacementPolicyRackFaultTolerant.java
@@ -22,7 +22,6 @@ import org.apache.hadoop.fs.CreateFlag;
 import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.fs.permission.PermissionStatus;
 import org.apache.hadoop.hdfs.DFSConfigKeys;
-import org.apache.hadoop.hdfs.DFSUtil;
 import org.apache.hadoop.hdfs.HdfsConfiguration;
 import org.apache.hadoop.hdfs.MiniDFSCluster;
 import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
@@ -174,7 +173,7 @@ public class TestBlockPlacementPolicyRackFaultTolerant {
     for (int i = 0; i < length; i++) {
       pairs[i] = new Object[]{locs[i], storageIDs[i]};
     }
-    DFSUtil.shuffle(pairs);
+    Collections.shuffle(Arrays.asList(pairs));
     for (int i = 0; i < length; i++) {
       locs[i] = (DatanodeInfo) pairs[i][0];
       storageIDs[i] = (String) pairs[i][1];


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message