ReplicaMap { ReplicaInfo remove(String bpid, Block block) { checkBlockPool(bpid); checkBlock(block); synchronized(mutex) { LightWeightResizableGSet<Block, ReplicaInfo> m = map.get(bpid); if (m != null) { ReplicaInfo replicaInfo = m.get(block); if (replicaInfo != null && block.getGenerationStamp() == replicaInfo.getGenerationStamp()) { return m.remove(block); } } } return null; } ReplicaMap(Object mutex);   }
@Test public void testRemove() { try { map.remove(bpid, null); fail("Expected exception not thrown"); } catch (IllegalArgumentException expected) { } Block b = new Block(block); b.setGenerationStamp(0); assertNull(map.remove(bpid, b)); b.setGenerationStamp(block.getGenerationStamp()); b.setBlockId(0); assertNull(map.remove(bpid, b)); assertNotNull(map.remove(bpid, block)); assertNull(map.remove(bpid, 0)); map.add(bpid, new FinalizedReplica(block, null, null)); assertNotNull(map.remove(bpid, block.getBlockId())); }