@@ -2334,49 +2334,43 @@ public void delayDeleteReplica() {
23342334 public void testReplicationWorkConstructionWhenMostSrcUnavailable () {
23352335 LOG .info ("Starting testReplicationWorkConstructionWhenMostSrcUnavailable. " );
23362336 NetworkTopology clusterMap = bm .getDatanodeManager ().getNetworkTopology ();
2337- LOG .info ("Before adding Nodes, Cluster map is {}, numOfLeaves {}" , clusterMap .toString (), clusterMap .getNumOfLeaves () );
23382337 addNodes (nodes );
2339- LOG .info ("After adding Nodes, Cluster map is {}, numOfLeaves {}" , clusterMap .toString (), clusterMap .getNumOfLeaves () );
2340- for (int i = 881 ; i <=890 ;i ++){
2338+ int blk_index = 0 ;
2339+ // We bind block_0 ~ block_9 on nodes[0]
2340+ for (; blk_index < 10 ;blk_index ++){
23412341 //Block block = new Block(i);
23422342 //BlockInfo blockInfo = new BlockInfoContiguous(block, (short) 4);
23432343 //blockInfo.setBlockCollectionId(mockINodeId);
23442344 // We set it curReplicas to 1 to make its priority as QUEUE_WITH_CORRUPT_BLOCKS
23452345
23462346 // These low redundancy blocks are all located on nodes[0]
2347- addBlockOnNodes (i , getNodes (0 ));
2347+ addBlockOnNodes (blk_index , getNodes (0 ));
23482348 assertTrue ("Should add successfully to neededReconstruction" ,
2349- bm .neededReconstruction .add (bm .getStoredBlock (new Block (i )),
2349+ bm .neededReconstruction .add (bm .getStoredBlock (new Block (blk_index )),
23502350 1 ,
23512351 0 ,
23522352 0 ,
23532353 3 ));
23542354 }
2355- int id = 891 ;
2356- addBlockOnNodes (id , getNodes (0 ,1 ));
2355+ // We bind block_10 on node[0] and node[1]
2356+ addBlockOnNodes (blk_index , getNodes (0 ,1 ));
23572357 // The priority should be QUEUE_LOW_REDUNDANCY
23582358 assertTrue ("Should add successfully to neededReconstruction" ,
2359- bm .neededReconstruction .add (bm .getStoredBlock (new Block (id )),
2359+ bm .neededReconstruction .add (bm .getStoredBlock (new Block (blk_index )),
23602360 1 ,
23612361 0 ,
23622362 0 ,
23632363 3 ));
23642364
2365- // simulate the 2 nodes reach maxReplicationStreams
2365+ // simulate node[0] to reach maxReplicationStreams, so node[1] is able to work as source node for blk_10 Reconstruction
23662366 for (int i = 0 ; i < bm .getReplicationStreamsHardLimit (); i ++){
23672367 nodes .get (0 ).incrementPendingReplicationWithoutTargets ();
23682368 }
23692369
2370- for (int i = 0 ; i < nodes .size (); i ++){
2371- LOG .info ("pendingReplicationWithoutTargets for node " + nodes .get (i ) + " is " + nodes .get (i ).getNumberOfBlocksToBeReplicated ());
2372- }
2373-
2374- LOG .info ("low redundancy block is " + bm .neededReconstruction .getLowRedundancyBlocks ());
23752370 assertEquals ("There should exist 11 low-redundancy blocks" , 11 , bm .neededReconstruction .getLowRedundancyBlocks ());
23762371
2377- for (DatanodeStorageInfo storage : bm .getStorages (new Block (id ))) {
2378- LOG .info ("Storage for block is " + storage + ", block " + bm .getStoredBlock (new Block (id )));
2379- }
2372+ // We schedule reconstruction. the blk_0 ~ blk_9 cannot be scheduled because their source node reached ReplicationStreamsHardLimit,
2373+ // but computeBlockReconstructionWork() will move fast forward to schedule blk_10 inside this tick, instead of scheduling it in the next-next tick
23802374 int scheduledReconstruction = bm .computeBlockReconstructionWork (4 );
23812375 assertEquals ("The actual scheduled BlockReconstructionWork should include the blockAbleToReconstruct" , 1 , scheduledReconstruction );
23822376 }
0 commit comments