|
@@ -831,6 +831,10 @@ public class TestReplicationPolicy {
|
|
|
assertEquals(targets.length, 2);
|
|
|
assertTrue(isOnSameRack(targets[0], dataNodes[2]));
|
|
|
}
|
|
|
+
|
|
|
+ private BlockInfo genBlockInfo(long id) {
|
|
|
+ return new BlockInfoContiguous(new Block(id), (short) 3);
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* Test for the high priority blocks are processed before the low priority
|
|
@@ -850,16 +854,17 @@ public class TestReplicationPolicy {
|
|
|
.getNamesystem().getBlockManager().neededReplications;
|
|
|
for (int i = 0; i < 100; i++) {
|
|
|
// Adding the blocks directly to normal priority
|
|
|
- neededReplications.add(new Block(ThreadLocalRandom.current()
|
|
|
- .nextLong()), 2, 0, 3);
|
|
|
+
|
|
|
+ neededReplications.add(genBlockInfo(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(ThreadLocalRandom.current().nextLong()),
|
|
|
- 1, 0, 3);
|
|
|
+ neededReplications.add(genBlockInfo(ThreadLocalRandom.current().
|
|
|
+ nextLong()), 1, 0, 3);
|
|
|
|
|
|
// Lets wait for the replication interval
|
|
|
Thread.sleep(DFS_NAMENODE_REPLICATION_INTERVAL);
|
|
@@ -882,30 +887,31 @@ public class TestReplicationPolicy {
|
|
|
|
|
|
for (int i = 0; i < 5; i++) {
|
|
|
// Adding QUEUE_HIGHEST_PRIORITY block
|
|
|
- underReplicatedBlocks.add(new Block(ThreadLocalRandom.current()
|
|
|
- .nextLong()), 1, 0, 3);
|
|
|
+ underReplicatedBlocks.add(genBlockInfo(ThreadLocalRandom.current().
|
|
|
+ nextLong()), 1, 0, 3);
|
|
|
|
|
|
// Adding QUEUE_VERY_UNDER_REPLICATED block
|
|
|
- underReplicatedBlocks.add(new Block(ThreadLocalRandom.current()
|
|
|
- .nextLong()), 2, 0, 7);
|
|
|
+ underReplicatedBlocks.add(genBlockInfo(ThreadLocalRandom.current().
|
|
|
+ nextLong()), 2, 0, 7);
|
|
|
|
|
|
// Adding QUEUE_REPLICAS_BADLY_DISTRIBUTED block
|
|
|
- underReplicatedBlocks.add(new Block(ThreadLocalRandom.current()
|
|
|
- .nextLong()), 6, 0, 6);
|
|
|
+ underReplicatedBlocks.add(genBlockInfo(ThreadLocalRandom.current().
|
|
|
+ nextLong()), 6, 0, 6);
|
|
|
|
|
|
// Adding QUEUE_UNDER_REPLICATED block
|
|
|
- underReplicatedBlocks.add(new Block(ThreadLocalRandom.current()
|
|
|
- .nextLong()), 5, 0, 6);
|
|
|
+ underReplicatedBlocks.add(genBlockInfo(ThreadLocalRandom.current().
|
|
|
+ nextLong()), 5, 0, 6);
|
|
|
|
|
|
// Adding QUEUE_WITH_CORRUPT_BLOCKS block
|
|
|
- underReplicatedBlocks.add(new Block(ThreadLocalRandom.current()
|
|
|
- .nextLong()), 0, 0, 3);
|
|
|
+ underReplicatedBlocks.add(genBlockInfo(ThreadLocalRandom.current().
|
|
|
+ nextLong()), 0, 0, 3);
|
|
|
}
|
|
|
|
|
|
// Choose 6 blocks from UnderReplicatedBlocks. Then it should pick 5 blocks
|
|
|
// from
|
|
|
// QUEUE_HIGHEST_PRIORITY and 1 block from QUEUE_VERY_UNDER_REPLICATED.
|
|
|
- List<List<Block>> chosenBlocks = underReplicatedBlocks.chooseUnderReplicatedBlocks(6);
|
|
|
+ List<List<BlockInfo>> chosenBlocks =
|
|
|
+ underReplicatedBlocks.chooseUnderReplicatedBlocks(6);
|
|
|
assertTheChosenBlocks(chosenBlocks, 5, 1, 0, 0, 0);
|
|
|
|
|
|
// Choose 10 blocks from UnderReplicatedBlocks. Then it should pick 4 blocks from
|
|
@@ -915,8 +921,8 @@ public class TestReplicationPolicy {
|
|
|
assertTheChosenBlocks(chosenBlocks, 0, 4, 5, 1, 0);
|
|
|
|
|
|
// Adding QUEUE_HIGHEST_PRIORITY
|
|
|
- underReplicatedBlocks.add(new Block(ThreadLocalRandom.current().nextLong()),
|
|
|
- 1, 0, 3);
|
|
|
+ underReplicatedBlocks.add(genBlockInfo(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
|
|
@@ -934,7 +940,7 @@ public class TestReplicationPolicy {
|
|
|
|
|
|
/** asserts the chosen blocks with expected priority blocks */
|
|
|
private void assertTheChosenBlocks(
|
|
|
- List<List<Block>> chosenBlocks, int firstPrioritySize,
|
|
|
+ List<List<BlockInfo>> chosenBlocks, int firstPrioritySize,
|
|
|
int secondPrioritySize, int thirdPrioritySize, int fourthPrioritySize,
|
|
|
int fifthPrioritySize) {
|
|
|
assertEquals(
|
|
@@ -1108,9 +1114,9 @@ public class TestReplicationPolicy {
|
|
|
public void testUpdateDoesNotCauseSkippedReplication() {
|
|
|
UnderReplicatedBlocks underReplicatedBlocks = new UnderReplicatedBlocks();
|
|
|
|
|
|
- Block block1 = new Block(ThreadLocalRandom.current().nextLong());
|
|
|
- Block block2 = new Block(ThreadLocalRandom.current().nextLong());
|
|
|
- Block block3 = new Block(ThreadLocalRandom.current().nextLong());
|
|
|
+ BlockInfo block1 = genBlockInfo(ThreadLocalRandom.current().nextLong());
|
|
|
+ BlockInfo block2 = genBlockInfo(ThreadLocalRandom.current().nextLong());
|
|
|
+ BlockInfo block3 = genBlockInfo(ThreadLocalRandom.current().nextLong());
|
|
|
|
|
|
// Adding QUEUE_VERY_UNDER_REPLICATED block
|
|
|
final int block1CurReplicas = 2;
|
|
@@ -1124,7 +1130,7 @@ public class TestReplicationPolicy {
|
|
|
// Adding QUEUE_UNDER_REPLICATED block
|
|
|
underReplicatedBlocks.add(block3, 2, 0, 6);
|
|
|
|
|
|
- List<List<Block>> chosenBlocks;
|
|
|
+ List<List<BlockInfo>> chosenBlocks;
|
|
|
|
|
|
// Choose 1 block from UnderReplicatedBlocks. Then it should pick 1 block
|
|
|
// from QUEUE_VERY_UNDER_REPLICATED.
|
|
@@ -1156,9 +1162,9 @@ public class TestReplicationPolicy {
|
|
|
when(mockNS.hasWriteLock()).thenReturn(true);
|
|
|
BlockManager bm = new BlockManager(mockNS, new HdfsConfiguration());
|
|
|
UnderReplicatedBlocks underReplicatedBlocks = bm.neededReplications;
|
|
|
-
|
|
|
- Block block1 = new Block(ThreadLocalRandom.current().nextLong());
|
|
|
- Block block2 = new Block(ThreadLocalRandom.current().nextLong());
|
|
|
+
|
|
|
+ BlockInfo block1 = genBlockInfo(ThreadLocalRandom.current().nextLong());
|
|
|
+ BlockInfo block2 = genBlockInfo(ThreadLocalRandom.current().nextLong());
|
|
|
|
|
|
// Adding QUEUE_UNDER_REPLICATED block
|
|
|
underReplicatedBlocks.add(block1, 0, 1, 1);
|
|
@@ -1166,7 +1172,7 @@ public class TestReplicationPolicy {
|
|
|
// Adding QUEUE_UNDER_REPLICATED block
|
|
|
underReplicatedBlocks.add(block2, 0, 1, 1);
|
|
|
|
|
|
- List<List<Block>> chosenBlocks;
|
|
|
+ List<List<BlockInfo>> chosenBlocks;
|
|
|
|
|
|
// Choose 1 block from UnderReplicatedBlocks. Then it should pick 1 block
|
|
|
// from QUEUE_VERY_UNDER_REPLICATED.
|
|
@@ -1203,8 +1209,13 @@ public class TestReplicationPolicy {
|
|
|
BlockManager bm = new BlockManager(mockNS, new HdfsConfiguration());
|
|
|
UnderReplicatedBlocks underReplicatedBlocks = bm.neededReplications;
|
|
|
|
|
|
+<<<<<<< HEAD
|
|
|
Block block1 = new Block(ThreadLocalRandom.current().nextLong());
|
|
|
Block block2 = new Block(ThreadLocalRandom.current().nextLong());
|
|
|
+=======
|
|
|
+ BlockInfo block1 = genBlockInfo(random.nextLong());
|
|
|
+ BlockInfo block2 = genBlockInfo(random.nextLong());
|
|
|
+>>>>>>> 3e6f458... HDFS-7912. Erasure Coding: track BlockInfo instead of Block in UnderReplicatedBlocks and PendingReplicationBlocks. Contributed by Jing Zhao.
|
|
|
|
|
|
// Adding QUEUE_UNDER_REPLICATED block
|
|
|
underReplicatedBlocks.add(block1, 0, 1, 1);
|
|
@@ -1212,7 +1223,7 @@ public class TestReplicationPolicy {
|
|
|
// Adding QUEUE_UNDER_REPLICATED block
|
|
|
underReplicatedBlocks.add(block2, 0, 1, 1);
|
|
|
|
|
|
- List<List<Block>> chosenBlocks;
|
|
|
+ List<List<BlockInfo>> chosenBlocks;
|
|
|
|
|
|
// Choose 1 block from UnderReplicatedBlocks. Then it should pick 1 block
|
|
|
// from QUEUE_VERY_UNDER_REPLICATED.
|
|
@@ -1266,8 +1277,13 @@ public class TestReplicationPolicy {
|
|
|
BlockManager bm = new BlockManager(mockNS, new HdfsConfiguration());
|
|
|
UnderReplicatedBlocks underReplicatedBlocks = bm.neededReplications;
|
|
|
|
|
|
+<<<<<<< HEAD
|
|
|
Block block1 = new Block(ThreadLocalRandom.current().nextLong());
|
|
|
Block block2 = new Block(ThreadLocalRandom.current().nextLong());
|
|
|
+=======
|
|
|
+ BlockInfo block1 = genBlockInfo(random.nextLong());
|
|
|
+ BlockInfo block2 = genBlockInfo(random.nextLong());
|
|
|
+>>>>>>> 3e6f458... HDFS-7912. Erasure Coding: track BlockInfo instead of Block in UnderReplicatedBlocks and PendingReplicationBlocks. Contributed by Jing Zhao.
|
|
|
|
|
|
// Adding QUEUE_UNDER_REPLICATED block
|
|
|
underReplicatedBlocks.add(block1, 0, 1, 1);
|
|
@@ -1275,14 +1291,14 @@ public class TestReplicationPolicy {
|
|
|
// Adding QUEUE_UNDER_REPLICATED block
|
|
|
underReplicatedBlocks.add(block2, 0, 1, 1);
|
|
|
|
|
|
- List<List<Block>> chosenBlocks;
|
|
|
+ List<List<BlockInfo>> chosenBlocks;
|
|
|
|
|
|
// Choose 1 block from UnderReplicatedBlocks. Then it should pick 1 block
|
|
|
// from QUEUE_VERY_UNDER_REPLICATED.
|
|
|
chosenBlocks = underReplicatedBlocks.chooseUnderReplicatedBlocks(1);
|
|
|
assertTheChosenBlocks(chosenBlocks, 1, 0, 0, 0, 0);
|
|
|
|
|
|
- bm.setReplication((short)0, (short)1, "", block1);
|
|
|
+ bm.setReplication((short)0, (short)1, "", (BlockInfoContiguous) block1);
|
|
|
|
|
|
// Choose 1 block from UnderReplicatedBlocks. Then it should pick 1 block
|
|
|
// from QUEUE_VERY_UNDER_REPLICATED.
|