use of org.apache.ratis.server.metrics.RaftServerMetricsImpl in project incubator-ratis by apache.
the class TestRaftServerWithGrpc method testRaftClientRequestMetrics.
void testRaftClientRequestMetrics(MiniRaftClusterWithGrpc cluster) throws IOException, ExecutionException, InterruptedException {
final RaftServer.Division leader = RaftTestUtil.waitForLeader(cluster);
final RaftServerMetricsImpl raftServerMetrics = getRaftServerMetrics(leader);
try (final RaftClient client = cluster.createClient()) {
final CompletableFuture<RaftClientReply> f1 = client.async().send(new SimpleMessage("testing"));
Assert.assertTrue(f1.get().isSuccess());
Assert.assertTrue(raftServerMetrics.getTimer(RAFT_CLIENT_WRITE_REQUEST).getCount() > 0);
final CompletableFuture<RaftClientReply> f2 = client.async().sendReadOnly(new SimpleMessage("testing"));
Assert.assertTrue(f2.get().isSuccess());
Assert.assertTrue(raftServerMetrics.getTimer(RAFT_CLIENT_READ_REQUEST).getCount() > 0);
final CompletableFuture<RaftClientReply> f3 = client.async().sendStaleRead(new SimpleMessage("testing"), 0, leader.getId());
Assert.assertTrue(f3.get().isSuccess());
Assert.assertTrue(raftServerMetrics.getTimer(RAFT_CLIENT_STALE_READ_REQUEST).getCount() > 0);
final CompletableFuture<RaftClientReply> f4 = client.async().watch(0, RaftProtos.ReplicationLevel.ALL);
Assert.assertTrue(f4.get().isSuccess());
Assert.assertTrue(raftServerMetrics.getTimer(String.format(RAFT_CLIENT_WATCH_REQUEST, "-ALL")).getCount() > 0);
final CompletableFuture<RaftClientReply> f5 = client.async().watch(0, RaftProtos.ReplicationLevel.MAJORITY);
Assert.assertTrue(f5.get().isSuccess());
Assert.assertTrue(raftServerMetrics.getTimer(String.format(RAFT_CLIENT_WATCH_REQUEST, "")).getCount() > 0);
}
}
Aggregations