|
@@ -33,8 +33,8 @@ import java.util.HashMap;
|
|
|
import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
-import java.util.Random;
|
|
|
import java.util.Set;
|
|
|
+import java.util.concurrent.ThreadLocalRandom;
|
|
|
|
|
|
import org.apache.commons.logging.impl.Log4JLogger;
|
|
|
import org.apache.hadoop.conf.Configuration;
|
|
@@ -73,7 +73,6 @@ public class TestReplicationPolicy {
|
|
|
((Log4JLogger)BlockPlacementPolicy.LOG).getLogger().setLevel(Level.ALL);
|
|
|
}
|
|
|
|
|
|
- private final Random random = DFSUtil.getRandom();
|
|
|
private static final int BLOCK_SIZE = 1024;
|
|
|
private static final int NUM_OF_DATANODES = 6;
|
|
|
private static NetworkTopology cluster;
|
|
@@ -848,14 +847,16 @@ public class TestReplicationPolicy {
|
|
|
.getNamesystem().getBlockManager().neededReplications;
|
|
|
for (int i = 0; i < 100; i++) {
|
|
|
// Adding the blocks directly to normal priority
|
|
|
- neededReplications.add(new Block(random.nextLong()), 2, 0, 3);
|
|
|
+ neededReplications.add(new Block(
|
|
|
+ ThreadLocalRandom.current().nextLong()), 2, 0, 3);
|
|
|
}
|
|
|
// Lets wait for the replication interval, to start process normal
|
|
|
// priority blocks
|
|
|
Thread.sleep(DFS_NAMENODE_REPLICATION_INTERVAL);
|
|
|
|
|
|
// Adding the block directly to high priority list
|
|
|
- neededReplications.add(new Block(random.nextLong()), 1, 0, 3);
|
|
|
+ neededReplications.add(new Block(
|
|
|
+ ThreadLocalRandom.current().nextLong()), 1, 0, 3);
|
|
|
|
|
|
// Lets wait for the replication interval
|
|
|
Thread.sleep(DFS_NAMENODE_REPLICATION_INTERVAL);
|
|
@@ -878,19 +879,24 @@ public class TestReplicationPolicy {
|
|
|
|
|
|
for (int i = 0; i < 5; i++) {
|
|
|
// Adding QUEUE_HIGHEST_PRIORITY block
|
|
|
- underReplicatedBlocks.add(new Block(random.nextLong()), 1, 0, 3);
|
|
|
+ underReplicatedBlocks.add(new Block(ThreadLocalRandom.current().
|
|
|
+ nextLong()), 1, 0, 3);
|
|
|
|
|
|
// Adding QUEUE_VERY_UNDER_REPLICATED block
|
|
|
- underReplicatedBlocks.add(new Block(random.nextLong()), 2, 0, 7);
|
|
|
+ underReplicatedBlocks.add(new Block(ThreadLocalRandom.current().
|
|
|
+ nextLong()), 2, 0, 7);
|
|
|
|
|
|
// Adding QUEUE_REPLICAS_BADLY_DISTRIBUTED block
|
|
|
- underReplicatedBlocks.add(new Block(random.nextLong()), 6, 0, 6);
|
|
|
+ underReplicatedBlocks.add(new Block(ThreadLocalRandom.current().
|
|
|
+ nextLong()), 6, 0, 6);
|
|
|
|
|
|
// Adding QUEUE_UNDER_REPLICATED block
|
|
|
- underReplicatedBlocks.add(new Block(random.nextLong()), 5, 0, 6);
|
|
|
+ underReplicatedBlocks.add(new Block(ThreadLocalRandom.current().
|
|
|
+ nextLong()), 5, 0, 6);
|
|
|
|
|
|
// Adding QUEUE_WITH_CORRUPT_BLOCKS block
|
|
|
- underReplicatedBlocks.add(new Block(random.nextLong()), 0, 0, 3);
|
|
|
+ underReplicatedBlocks.add(new Block(ThreadLocalRandom.current().
|
|
|
+ nextLong()), 0, 0, 3);
|
|
|
}
|
|
|
|
|
|
// Choose 6 blocks from UnderReplicatedBlocks. Then it should pick 5 blocks
|
|
@@ -906,7 +912,8 @@ public class TestReplicationPolicy {
|
|
|
assertTheChosenBlocks(chosenBlocks, 0, 4, 5, 1, 0);
|
|
|
|
|
|
// Adding QUEUE_HIGHEST_PRIORITY
|
|
|
- underReplicatedBlocks.add(new Block(random.nextLong()), 1, 0, 3);
|
|
|
+ underReplicatedBlocks.add(new Block(
|
|
|
+ ThreadLocalRandom.current().nextLong()), 1, 0, 3);
|
|
|
|
|
|
// Choose 10 blocks from UnderReplicatedBlocks. Then it should pick 1 block from
|
|
|
// QUEUE_HIGHEST_PRIORITY, 4 blocks from QUEUE_REPLICAS_BADLY_DISTRIBUTED
|