BlockInfo extends Block implements LightWeightGSet.LinkedElement { abstract boolean addStorage(DatanodeStorageInfo storage, Block reportedBlock); BlockInfo(short size);  BlockInfo(Block blk, short size); short getReplication(); void setReplication(short repl); long getBlockCollectionId(); void setBlockCollectionId(long id); void delete(); boolean isDeleted(); Iterator<DatanodeStorageInfo> getStorageInfos(); DatanodeDescriptor getDatanode(int index); int getCapacity(); abstract int numNodes(); abstract boolean isStriped(); abstract BlockType getBlockType(); @Override int hashCode(); @Override boolean equals(Object obj); @Override LightWeightGSet.LinkedElement getNext(); @Override void setNext(LightWeightGSet.LinkedElement next); BlockUnderConstructionFeature getUnderConstructionFeature(); BlockUCState getBlockUCState(); boolean isComplete(); boolean isUnderRecovery(); final boolean isCompleteOrCommitted(); void convertToBlockUnderConstruction(BlockUCState s,
      DatanodeStorageInfo[] targets); List<ReplicaUnderConstruction> setGenerationStampAndVerifyReplicas(
      long genStamp); static final BlockInfo[] EMPTY_ARRAY; }
@Test public void testAddStorage() throws Exception { BlockInfo blockInfo = new BlockInfoContiguous((short) 3); final DatanodeStorageInfo storage = DFSTestUtil.createDatanodeStorageInfo( "storageID", "127.0.0.1"); boolean added = blockInfo.addStorage(storage, blockInfo); Assert.assertTrue(added); Assert.assertEquals(storage, blockInfo.getStorageInfo(0)); }
@Test(expected=IllegalArgumentException.class) public void testAddStorageWithDifferentBlock() throws Exception { BlockInfo blockInfo1 = new BlockInfoContiguous(new Block(1000L), (short) 3); BlockInfo blockInfo2 = new BlockInfoContiguous(new Block(1001L), (short) 3); final DatanodeStorageInfo storage = DFSTestUtil.createDatanodeStorageInfo( "storageID", "127.0.0.1"); blockInfo1.addStorage(storage, blockInfo2); }