Source:
<code>public void testSimplePreferredPool() throws InterruptedException, IOException { MockIface iface1 = new Response1Iface(); MockIface iface2 = new Response1Iface(); startMockPartitionServerThread1(iface1, 1); startMockPartitionServerThread2(iface2, 1); Map<Host, List<HostConnection>> hostToConnectionsMap = new HashMap<Host, List<HostConnection>>(); int tryLockTimeoutMs = 0; int establishConnectionTimeoutMs = 0; int queryTimeoutMs = 0; int bulkQueryTimeoutMs = 0; mockHost1.setEnvironmentFlags(Collections.singletonMap("REGION", "REG1")); mockHost2.setEnvironmentFlags(Collections.singletonMap("REGION", "REG2")); hostToConnectionsMap.put(mockHost1, Collections.singletonList(new HostConnection(mockHost1, tryLockTimeoutMs, establishConnectionTimeoutMs, queryTimeoutMs, bulkQueryTimeoutMs))); hostToConnectionsMap.put(mockHost2, Collections.singletonList(new HostConnection(mockHost2, tryLockTimeoutMs, establishConnectionTimeoutMs, queryTimeoutMs, bulkQueryTimeoutMs))); HostConnectionPool hostConnectionPool = new HostConnectionPool(hostToConnectionsMap, null, Sets.newHashSet(mockHost1)); mockHost1.setState(HostState.SERVING); mockHost2.setState(HostState.SERVING); int numHits = 0; for (int i = 0; i < 10; ++i) { HankResponse response = hostConnectionPool.get(mockDomain, KEY_1, 1, null); if (response.is_set_value()) { assertEquals(RESPONSE_1, response); ++numHits; } } assertEquals("Gets should be distributed accross hosts", 10, iface1.numGets); assertEquals("Gets should be distributed accross hosts", 0, iface2.numGets); <START> assertEquals("Half the keys should have been found", 10, numHits); <END> }</code><technical_language>assertEquals("Gets hit host", 10, iface1.numGets); assertEquals("Gets hit host", 0, iface2.numGets); assertEquals("All keys found", 10, numHits);</technical_language>

Target:
public void testSimplePreferredPool() throws InterruptedException, IOException { MockIface iface1 = new Response1Iface(); MockIface iface2 = new Response1Iface(); startMockPartitionServerThread1(iface1, 1); startMockPartitionServerThread2(iface2, 1); Map<Host, List<HostConnection>> hostToConnectionsMap = new HashMap<Host, List<HostConnection>>(); int tryLockTimeoutMs = 0; int establishConnectionTimeoutMs = 0; int queryTimeoutMs = 0; int bulkQueryTimeoutMs = 0; mockHost1.setEnvironmentFlags(Collections.singletonMap("REGION", "REG1")); mockHost2.setEnvironmentFlags(Collections.singletonMap("REGION", "REG2")); hostToConnectionsMap.put(mockHost1, Collections.singletonList(new HostConnection(mockHost1, tryLockTimeoutMs, establishConnectionTimeoutMs, queryTimeoutMs, bulkQueryTimeoutMs))); hostToConnectionsMap.put(mockHost2, Collections.singletonList(new HostConnection(mockHost2, tryLockTimeoutMs, establishConnectionTimeoutMs, queryTimeoutMs, bulkQueryTimeoutMs))); HostConnectionPool hostConnectionPool = new HostConnectionPool(hostToConnectionsMap, null, Sets.newHashSet(mockHost1)); mockHost1.setState(HostState.SERVING); mockHost2.setState(HostState.SERVING); int numHits = 0; for (int i = 0; i < 10; ++i) { HankResponse response = hostConnectionPool.get(mockDomain, KEY_1, 1, null); if (response.is_set_value()) { assertEquals(RESPONSE_1, response); ++numHits; } } assertEquals("Gets should all hit first host", 10, iface1.numGets); assertEquals("Gets should not hit second host", 0, iface2.numGets); assertEquals("All keys should have been found", 10, numHits); }