BlockInfo extends Block implements LightWeightGSet.LinkedElement { DatanodeStorageInfo getStorageInfo(int index) { assert this.triplets != null : "BlockInfo is not initialized"; assert index >= 0 && index*3 < triplets.length : "Index is out of bound"; return (DatanodeStorageInfo)triplets[index*3]; } BlockInfo(short size);  BlockInfo(Block blk, short size); short getReplication(); void setReplication(short repl); long getBlockCollectionId(); void setBlockCollectionId(long id); boolean isDeleted(); DatanodeDescriptor getDatanode(int index); int getCapacity(); abstract int numNodes(); abstract boolean isStriped(); BlockInfo moveBlockToHead(BlockInfo head, DatanodeStorageInfo storage,
      int curIndex, int headIndex); @Override int hashCode(); @Override boolean equals(Object obj); @Override LightWeightGSet.LinkedElement getNext(); @Override void setNext(LightWeightGSet.LinkedElement next); BlockUnderConstructionFeature getUnderConstructionFeature(); BlockUCState getBlockUCState(); boolean isComplete(); void convertToBlockUnderConstruction(BlockUCState s,
      DatanodeStorageInfo[] targets); void setGenerationStampAndVerifyReplicas(long genStamp); static final BlockInfo[] EMPTY_ARRAY; }
@Test public void testReplaceStorage() throws Exception { final DatanodeStorageInfo storage1 = DFSTestUtil.createDatanodeStorageInfo("storageID1", "127.0.0.1"); final DatanodeStorageInfo storage2 = new DatanodeStorageInfo(storage1.getDatanodeDescriptor(), new DatanodeStorage("storageID2")); final int NUM_BLOCKS = 10; BlockInfo[] blockInfos = new BlockInfo[NUM_BLOCKS]; for (int i = 0; i < NUM_BLOCKS; ++i) { blockInfos[i] = new BlockInfoContiguous((short) 3); storage1.addBlock(blockInfos[i]); } boolean added = storage2.addBlock(blockInfos[NUM_BLOCKS / 2]) == AddBlockResult.ADDED; Assert.assertThat(added, is(false)); Assert.assertThat(blockInfos[NUM_BLOCKS/2].getStorageInfo(0), is(storage2)); }