BlockInfo extends Block implements LightWeightGSet.LinkedElement { DatanodeStorageInfo getStorageInfo(int index) { assert this.storages != null : "BlockInfo is not initialized"; return storages[index]; } 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 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)); }