use of java.util.LongSummaryStatistics in project scalecube by scalecube.
the class ClusterMessagingStressTest method clusterMessagingStressTest.
@Test
public void clusterMessagingStressTest() throws Exception {
// Init transports
Cluster echoServer = Cluster.joinAwait();
Cluster[] latentNodes = new Cluster[ClusterConfig.DEFAULT_PING_REQ_MEMBERS];
Cluster client1 = null;
// Init measured params
long sentTime = 0;
long receivedTime = 0;
LongSummaryStatistics rttStats = null;
// Run experiment
try {
// Subscribe echo server handler
echoServer.listen().subscribe(msg -> echoServer.send(msg.sender(), msg));
// Start latent nodes (for indirect pings)
for (int i = 0; i < latentNodes.length; i++) {
latentNodes[i] = Cluster.joinAwait(echoServer.address());
}
// Init client
CountDownLatch measureLatch = new CountDownLatch(msgCount);
ArrayList<Long> rttRecords = new ArrayList<>(msgCount);
client1 = Cluster.joinAwait(echoServer.address());
client1.listen().subscribe(msg -> {
long sentAt = Long.valueOf(msg.data());
long rttTime = System.currentTimeMillis() - sentAt;
rttRecords.add(rttTime);
measureLatch.countDown();
});
// Subscribe on member removed event
AtomicBoolean receivedMemberRemovedEvent = new AtomicBoolean(false);
client1.listenMembership().filter(MembershipEvent::isRemoved).subscribe(event -> {
LOGGER.warn("Received member removed event: {}", event);
receivedMemberRemovedEvent.set(true);
});
// Measure
long startAt = System.currentTimeMillis();
for (int i = 0; i < msgCount; i++) {
client1.send(echoServer.address(), Message.fromData(Long.toString(System.currentTimeMillis())));
}
sentTime = System.currentTimeMillis() - startAt;
measureLatch.await(timeoutSeconds, TimeUnit.SECONDS);
receivedTime = System.currentTimeMillis() - startAt;
rttStats = rttRecords.stream().mapToLong(v -> v).summaryStatistics();
assertTrue(measureLatch.getCount() == 0);
assertFalse("Received member removed event", receivedMemberRemovedEvent.get());
} finally {
// Print results
LOGGER.info("Finished sending {} messages in {} ms", msgCount, sentTime);
LOGGER.info("Finished receiving {} messages in {} ms", msgCount, receivedTime);
LOGGER.info("Round trip stats (ms): {}", rttStats);
// Shutdown
shutdown(echoServer);
shutdown(latentNodes);
shutdown(client1);
}
}
use of java.util.LongSummaryStatistics in project scalecube by scalecube.
the class GossipProtocolTest method computeMessageSentStats.
private LongSummaryStatistics computeMessageSentStats(List<GossipProtocolImpl> gossipProtocols) {
List<Long> messageSentPerNode = new ArrayList<>(gossipProtocols.size());
for (GossipProtocolImpl gossipProtocol : gossipProtocols) {
Transport transport = gossipProtocol.getTransport();
messageSentPerNode.add(transport.networkEmulator().totalMessageSentCount());
}
return messageSentPerNode.stream().mapToLong(v -> v).summaryStatistics();
}
use of java.util.LongSummaryStatistics in project eclipse-collections by eclipse.
the class SerializableLongSummaryStatisticsTest method valuesEqual.
@Test
public void valuesEqual() {
SerializableLongSummaryStatistics with = SerializableLongSummaryStatistics.with(1, 2, 3);
LongSummaryStatistics without = new LongSummaryStatistics();
without.accept(1L);
without.accept(2L);
without.accept(3L);
Assert.assertTrue(with.valuesEqual(without));
}
use of java.util.LongSummaryStatistics in project keycloak by keycloak.
the class ClosingLongStream method summaryStatistics.
@Override
public LongSummaryStatistics summaryStatistics() {
LongSummaryStatistics result = delegate.summaryStatistics();
close();
return result;
}
use of java.util.LongSummaryStatistics in project accumulo by apache.
the class DefaultCompactionStrategyTest method simulationTest.
@Test
public void simulationTest() throws Exception {
for (int n = 1; n < 10; n++) {
LongSummaryStatistics lss = new LongSummaryStatistics();
SimulatedTablet simuTablet = new SimulatedTablet(10, 15);
for (int i = 0; i < 1000; i++) {
simuTablet.addFiles(n, 1000, 10);
simuTablet.compact(MajorCompactionReason.NORMAL);
lss.accept(simuTablet.getNumFiles());
}
while (simuTablet.compact(MajorCompactionReason.NORMAL) > 0) {
lss.accept(simuTablet.getNumFiles());
}
assertTrue(simuTablet.getTotalRead() < 6 * simuTablet.getTotalAdded());
assertTrue(lss.getAverage() < (n >= 8 ? 15 : 7));
}
}
Aggregations