HDFS-7366. BlockInfo should take replication as an short in the constructor. Contributed by Li Lu.
This commit is contained in:
parent
e96f0c6aae
commit
0f9d0d9d8f
|
@ -145,6 +145,9 @@ Release 2.7.0 - UNRELEASED
|
|||
HDFS-7324. haadmin command usage prints incorrect command name.
|
||||
(Brahma Reddy Battula via suresh)
|
||||
|
||||
HDFS-7366. BlockInfo should take replication as an short in the constructor.
|
||||
(Li Lu via wheat9)
|
||||
|
||||
Release 2.6.0 - UNRELEASED
|
||||
|
||||
INCOMPATIBLE CHANGES
|
||||
|
|
|
@ -59,12 +59,12 @@ public class BlockInfo extends Block implements LightWeightGSet.LinkedElement {
|
|||
* Construct an entry for blocksmap
|
||||
* @param replication the block's replication factor
|
||||
*/
|
||||
public BlockInfo(int replication) {
|
||||
public BlockInfo(short replication) {
|
||||
this.triplets = new Object[3*replication];
|
||||
this.bc = null;
|
||||
}
|
||||
|
||||
public BlockInfo(Block blk, int replication) {
|
||||
public BlockInfo(Block blk, short replication) {
|
||||
super(blk);
|
||||
this.triplets = new Object[3*replication];
|
||||
this.bc = null;
|
||||
|
|
|
@ -153,14 +153,14 @@ public class BlockInfoUnderConstruction extends BlockInfo {
|
|||
* Create block and set its state to
|
||||
* {@link BlockUCState#UNDER_CONSTRUCTION}.
|
||||
*/
|
||||
public BlockInfoUnderConstruction(Block blk, int replication) {
|
||||
public BlockInfoUnderConstruction(Block blk, short replication) {
|
||||
this(blk, replication, BlockUCState.UNDER_CONSTRUCTION, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a block that is currently being constructed.
|
||||
*/
|
||||
public BlockInfoUnderConstruction(Block blk, int replication,
|
||||
public BlockInfoUnderConstruction(Block blk, short replication,
|
||||
BlockUCState state,
|
||||
DatanodeStorageInfo[] targets) {
|
||||
super(blk, replication);
|
||||
|
|
|
@ -1990,7 +1990,7 @@ public class BlockManager {
|
|||
|
||||
// place a delimiter in the list which separates blocks
|
||||
// that have been reported from those that have not
|
||||
BlockInfo delimiter = new BlockInfo(new Block(), 1);
|
||||
BlockInfo delimiter = new BlockInfo(new Block(), (short) 1);
|
||||
boolean added = storageInfo.addBlock(delimiter);
|
||||
assert added : "Delimiting block cannot be present in the node";
|
||||
int headIndex = 0; //currently the delimiter is in the head of the list
|
||||
|
|
|
@ -48,7 +48,7 @@ public class TestBlockInfo {
|
|||
|
||||
@Test
|
||||
public void testAddStorage() throws Exception {
|
||||
BlockInfo blockInfo = new BlockInfo(3);
|
||||
BlockInfo blockInfo = new BlockInfo((short) 3);
|
||||
|
||||
final DatanodeStorageInfo storage = DFSTestUtil.createDatanodeStorageInfo("storageID", "127.0.0.1");
|
||||
|
||||
|
@ -70,7 +70,7 @@ public class TestBlockInfo {
|
|||
|
||||
// Create a few dummy blocks and add them to the first storage.
|
||||
for (int i = 0; i < NUM_BLOCKS; ++i) {
|
||||
blockInfos[i] = new BlockInfo(3);
|
||||
blockInfos[i] = new BlockInfo((short) 3);
|
||||
storage1.addBlock(blockInfos[i]);
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ public class TestBlockInfo {
|
|||
LOG.info("Building block list...");
|
||||
for (int i = 0; i < MAX_BLOCKS; i++) {
|
||||
blockList.add(new Block(i, 0, GenerationStamp.LAST_RESERVED_STAMP));
|
||||
blockInfoList.add(new BlockInfo(blockList.get(i), 3));
|
||||
blockInfoList.add(new BlockInfo(blockList.get(i), (short) 3));
|
||||
dd.addBlock(blockInfoList.get(i));
|
||||
|
||||
// index of the datanode should be 0
|
||||
|
|
|
@ -41,7 +41,7 @@ public class TestBlockInfoUnderConstruction {
|
|||
dd1.isAlive = dd2.isAlive = dd3.isAlive = true;
|
||||
BlockInfoUnderConstruction blockInfo = new BlockInfoUnderConstruction(
|
||||
new Block(0, 0, GenerationStamp.LAST_RESERVED_STAMP),
|
||||
3,
|
||||
(short) 3,
|
||||
BlockUCState.UNDER_CONSTRUCTION,
|
||||
new DatanodeStorageInfo[] {s1, s2, s3});
|
||||
|
||||
|
|
|
@ -385,7 +385,7 @@ public class TestBlockManager {
|
|||
|
||||
private BlockInfo blockOnNodes(long blkId, List<DatanodeDescriptor> nodes) {
|
||||
Block block = new Block(blkId);
|
||||
BlockInfo blockInfo = new BlockInfo(block, 3);
|
||||
BlockInfo blockInfo = new BlockInfo(block, (short) 3);
|
||||
|
||||
for (DatanodeDescriptor dn : nodes) {
|
||||
for (DatanodeStorageInfo storage : dn.getStorageInfos()) {
|
||||
|
|
|
@ -57,8 +57,8 @@ public class TestDatanodeDescriptor {
|
|||
public void testBlocksCounter() throws Exception {
|
||||
DatanodeDescriptor dd = BlockManagerTestUtil.getLocalDatanodeDescriptor(true);
|
||||
assertEquals(0, dd.numBlocks());
|
||||
BlockInfo blk = new BlockInfo(new Block(1L), 1);
|
||||
BlockInfo blk1 = new BlockInfo(new Block(2L), 2);
|
||||
BlockInfo blk = new BlockInfo(new Block(1L), (short) 1);
|
||||
BlockInfo blk1 = new BlockInfo(new Block(2L), (short) 2);
|
||||
DatanodeStorageInfo[] storages = dd.getStorageInfos();
|
||||
assertTrue(storages.length > 0);
|
||||
final String storageID = storages[0].getStorageID();
|
||||
|
|
|
@ -172,7 +172,7 @@ public class TestHeartbeatHandling {
|
|||
dd2.getStorageInfos()[0],
|
||||
dd3.getStorageInfos()[0]};
|
||||
BlockInfoUnderConstruction blockInfo = new BlockInfoUnderConstruction(
|
||||
new Block(0, 0, GenerationStamp.LAST_RESERVED_STAMP), 3,
|
||||
new Block(0, 0, GenerationStamp.LAST_RESERVED_STAMP), (short) 3,
|
||||
BlockUCState.UNDER_RECOVERY, storages);
|
||||
dd1.addBlockToBeRecovered(blockInfo);
|
||||
DatanodeCommand[] cmds =
|
||||
|
@ -194,7 +194,7 @@ public class TestHeartbeatHandling {
|
|||
dd2.setLastUpdate(System.currentTimeMillis() - 40 * 1000);
|
||||
dd3.setLastUpdate(System.currentTimeMillis());
|
||||
blockInfo = new BlockInfoUnderConstruction(
|
||||
new Block(0, 0, GenerationStamp.LAST_RESERVED_STAMP), 3,
|
||||
new Block(0, 0, GenerationStamp.LAST_RESERVED_STAMP), (short) 3,
|
||||
BlockUCState.UNDER_RECOVERY, storages);
|
||||
dd1.addBlockToBeRecovered(blockInfo);
|
||||
cmds = NameNodeAdapter.sendHeartBeat(nodeReg1, dd1, namesystem).getCommands();
|
||||
|
@ -215,7 +215,7 @@ public class TestHeartbeatHandling {
|
|||
dd2.setLastUpdate(System.currentTimeMillis() - 40 * 1000);
|
||||
dd3.setLastUpdate(System.currentTimeMillis() - 80 * 1000);
|
||||
blockInfo = new BlockInfoUnderConstruction(
|
||||
new Block(0, 0, GenerationStamp.LAST_RESERVED_STAMP), 3,
|
||||
new Block(0, 0, GenerationStamp.LAST_RESERVED_STAMP), (short) 3,
|
||||
BlockUCState.UNDER_RECOVERY, storages);
|
||||
dd1.addBlockToBeRecovered(blockInfo);
|
||||
cmds = NameNodeAdapter.sendHeartBeat(nodeReg1, dd1, namesystem).getCommands();
|
||||
|
|
|
@ -63,7 +63,7 @@ public class TestCommitBlockSynchronization {
|
|||
|
||||
FSNamesystem namesystemSpy = spy(namesystem);
|
||||
BlockInfoUnderConstruction blockInfo = new BlockInfoUnderConstruction(
|
||||
block, 1, HdfsServerConstants.BlockUCState.UNDER_CONSTRUCTION, targets);
|
||||
block, (short) 1, HdfsServerConstants.BlockUCState.UNDER_CONSTRUCTION, targets);
|
||||
blockInfo.setBlockCollection(file);
|
||||
blockInfo.setGenerationStamp(genStamp);
|
||||
blockInfo.initializeBlockRecovery(genStamp);
|
||||
|
@ -100,7 +100,7 @@ public class TestCommitBlockSynchronization {
|
|||
lastBlock, genStamp, length, false, false, newTargets, null);
|
||||
|
||||
// Simulate 'completing' the block.
|
||||
BlockInfo completedBlockInfo = new BlockInfo(block, 1);
|
||||
BlockInfo completedBlockInfo = new BlockInfo(block, (short) 1);
|
||||
completedBlockInfo.setBlockCollection(file);
|
||||
completedBlockInfo.setGenerationStamp(genStamp);
|
||||
doReturn(completedBlockInfo).when(namesystemSpy)
|
||||
|
@ -171,7 +171,7 @@ public class TestCommitBlockSynchronization {
|
|||
namesystemSpy.commitBlockSynchronization(
|
||||
lastBlock, genStamp, length, true, false, newTargets, null);
|
||||
|
||||
BlockInfo completedBlockInfo = new BlockInfo(block, 1);
|
||||
BlockInfo completedBlockInfo = new BlockInfo(block, (short) 1);
|
||||
completedBlockInfo.setBlockCollection(file);
|
||||
completedBlockInfo.setGenerationStamp(genStamp);
|
||||
doReturn(completedBlockInfo).when(namesystemSpy)
|
||||
|
|
Loading…
Reference in New Issue