}
}
@Test
public void testLbDefaultClientTwoHostsBatch() throws Exception {
Server s1 = null, s2 = null;
RpcClient c = null;
try{
LoadBalancedAvroHandler h1 = new LoadBalancedAvroHandler();
LoadBalancedAvroHandler h2 = new LoadBalancedAvroHandler();
s1 = RpcTestUtils.startServer(h1);
s2 = RpcTestUtils.startServer(h2);
Properties p = new Properties();
p.put("hosts", "h1 h2");
p.put("client.type", "default_loadbalance");
p.put("hosts.h1", "127.0.0.1:" + s1.getPort());
p.put("hosts.h2", "127.0.0.1:" + s2.getPort());
c = RpcClientFactory.getInstance(p);
Assert.assertTrue(c instanceof LoadBalancingRpcClient);
for (int i = 0; i < 100; i++) {
c.appendBatch(getBatchedEvent(i));
}
Assert.assertEquals(50, h1.getAppendBatchCount());
Assert.assertEquals(50, h2.getAppendBatchCount());
} finally {
if (s1 != null) s1.close();
if (s2 != null) s2.close();
if (c != null) c.close();
}
}