Source:
<code>public void testRouterInAddedEvalAfterExplicitInit() throws InjectionException, InterruptedException { final int numTotalBlocks = 1024; final int numInitialMemoryStores = 4; final int numThreads = 8; final CountDownLatch threadLatch = new CountDownLatch(numThreads); final int initStoreId0 = 0; <START> final int addedStoreId4 = 4; END> final OperationRouter<?> routerInInitStoreId0 = newOperationRouter(numInitialMemoryStores, numTotalBlocks, initStoreId0, false); final OperationRouter<?> routerInAddedStoreId4 = newOperationRouter(numInitialMemoryStores, numTotalBlocks, addedStoreId4, true); final String endpointId0 = EVAL_ID_PREFIX + initStoreId0; final String endpointId4 = EVAL_ID_PREFIX + addedStoreId4; routerInInitStoreId0.initialize(endpointId0); routerInAddedStoreId4.initialize(endpointId4); assertTrue(initLatch.await(10, TimeUnit.SECONDS)); final Runnable[] threads = new Runnable[numThreads]; for (int idx = 0; idx < numThreads; idx++) { threads[idx] = new Runnable() { @Override public void run() { for (int blockId = 0; blockId < numTotalBlocks; blockId++) { final Optional<String> evalIdFromRouter0 = routerInInitStoreId0.resolveEval(blockId); final Optional<String> evalIdFromRouter4 = routerInAddedStoreId4.resolveEval(blockId); if (!evalIdFromRouter0.isPresent()) { assertEquals(endpointId0, evalIdFromRouter4.get()); } else if (!evalIdFromRouter4.isPresent()) { assertEquals(endpointId4, evalIdFromRouter0.get()); } else { assertEquals(evalIdFromRouter0.get(), evalIdFromRouter4.get()); } } threadLatch.countDown(); } }; } ThreadUtils.runConcurrently(threads); assertTrue(threadLatch.await(30, TimeUnit.SECONDS)); verify(evalMsgSender, times(1)).sendRoutingTableInitReqMsg(any(TraceInfo.class)); }</code><technical_language>Id0 Id4 a bit verbose. Do need names</technical_language>

Target:
public void testRouterInAddedEvalAfterExplicitInit() throws InjectionException, InterruptedException { final int numTotalBlocks = 1024; final int numInitialMemoryStores = 4; final int numThreads = 8; final CountDownLatch threadLatch = new CountDownLatch(numThreads); final int initStoreId = 0; final int addedStoreId = 4; final OperationRouter<?> routerInInitStore = newOperationRouter(numInitialMemoryStores, numTotalBlocks, initStoreId, false); final OperationRouter<?> routerInAddedStore = newOperationRouter(numInitialMemoryStores, numTotalBlocks, addedStoreId, true); final String endpointIdForInitEval = EVAL_ID_PREFIX + initStoreId; final String endpointIdForAddedEval = EVAL_ID_PREFIX + addedStoreId; routerInInitStore.initialize(endpointIdForInitEval); routerInAddedStore.initialize(endpointIdForAddedEval); assertTrue(initLatch.await(10, TimeUnit.SECONDS)); verify(evalMsgSender, times(1)).sendRoutingTableInitReqMsg(any(TraceInfo.class)); final Runnable[] threads = new Runnable[numThreads]; for (int idx = 0; idx < numThreads; idx++) { threads[idx] = new Runnable() { @Override public void run() { for (int blockId = 0; blockId < numTotalBlocks; blockId++) { final Optional<String> evalIdFromInitRouter = routerInInitStore.resolveEval(blockId); final Optional<String> evalIdFromAddedRouter = routerInAddedStore.resolveEval(blockId); if (!evalIdFromInitRouter.isPresent()) { assertEquals(endpointIdForInitEval, evalIdFromAddedRouter.get()); } else if (!evalIdFromAddedRouter.isPresent()) { assertEquals(endpointIdForAddedEval, evalIdFromInitRouter.get()); } else { assertEquals(evalIdFromInitRouter.get(), evalIdFromAddedRouter.get()); } } threadLatch.countDown(); } }; } ThreadUtils.runConcurrently(threads); assertTrue(threadLatch.await(30, TimeUnit.SECONDS)); verify(evalMsgSender, times(1)).sendRoutingTableInitReqMsg(any(TraceInfo.class)); }