ResourcePartitionMap { public void addReader(String resource, String partition, Reader r) throws UnsupportedOperationException { Pair<String, String> readerMapKey = new ImmutablePair(resource, partition); synchronized (this) { if (readerMap.containsKey(readerMapKey)) { LOG.warn("Resource : " + resource + " Partition : " + partition + " already exists."); return; } readerMap.put(readerMapKey, r); incrementPartitionCount(resource); } } ResourcePartitionMap(); void addReader(String resource,
                        String partition,
                        Reader r); Reader removeReader(String resource, String partition); Reader getReader(String resource, String partition); void close();  }
@Test public void testAddReader() throws Exception { String resource = "resource1"; TestReader reader1 = new TestReader(); resourcePartitionMap.addReader(resource, "part1", reader1); assertEquals(reader1, resourcePartitionMap.getReader(resource, "part1")); TestReader reader2 = new TestReader(); resourcePartitionMap.addReader(resource, "part1", reader2); assertEquals(reader1, resourcePartitionMap.getReader(resource, "part1")); testGetExceptionErrorCode(resource, "part2", TerrapinGetErrorCode.NOT_SERVING_PARTITION); testGetExceptionErrorCode("resource2", "part1", TerrapinGetErrorCode.NOT_SERVING_RESOURCE); }