}
}
store.merge(rootbuilder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
storeS.flush();
final StandbyServer server = new StandbyServer(port, storeS, useSSL);
server.start();
System.setProperty(StandbyClient.CLIENT_ID_PROPERTY_NAME, "Bar");
StandbyClient cl = new StandbyClient("127.0.0.1", port, storeC, useSSL);
final MBeanServer jmxServer = ManagementFactory.getPlatformMBeanServer();
ObjectName status = new ObjectName(StandbyStatusMBean.JMX_NAME + ",id=*");
ObjectName clientStatus = new ObjectName(cl.getMBeanName());
ObjectName serverStatus = new ObjectName(server.getMBeanName());
long start = System.currentTimeMillis();
cl.run();
try {
Set<ObjectName> instances = jmxServer.queryNames(status, null);
assertEquals(3, instances.size());
ObjectName connectionStatus = null;
for (ObjectName s : instances) {
if (!s.equals(clientStatus) && !s.equals(serverStatus)) connectionStatus = s;
}
assertNotNull(connectionStatus);
long segments = ((Long)jmxServer.getAttribute(connectionStatus, "TransferredSegments")).longValue();
long bytes = ((Long)jmxServer.getAttribute(connectionStatus, "TransferredSegmentBytes")).longValue();
System.out.println("did transfer " + segments + " segments with " + bytes + " bytes in " + (System.currentTimeMillis() - start) / 1000 + " seconds.");
assertEquals(storeS.getHead(), storeC.getHead());
//compare(segments, "segment", minExpectedSegments, maxExpectedSegments);
//compare(bytes, "byte", minExpectedBytes, maxExpectedBytes);
} finally {
server.close();
cl.close();
}
}