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