use of org.apache.zookeeper.server.Request in project zookeeper by apache.
the class CommitProcessorMetricsTest method testWriteFinalProcTime.
@Test
public void testWriteFinalProcTime() throws Exception {
setupProcessors(0, 1000);
Request req1 = createWriteRequest(1L, 2);
processRequestWithWait(req1);
// no request sent to next processor yet
Map<String, Object> values = MetricsUtils.currentServerMetrics();
assertEquals(0L, values.get("cnt_write_final_proc_time_ms"));
commitWithWait(req1);
values = MetricsUtils.currentServerMetrics();
assertEquals(1L, values.get("cnt_write_final_proc_time_ms"));
checkTimeMetric((long) values.get("max_write_final_proc_time_ms"), 1000L, 2000L);
}
use of org.apache.zookeeper.server.Request in project zookeeper by apache.
the class CommitProcessorMetricsTest method testWritesQueuedInCommitProcessor.
@Test
public void testWritesQueuedInCommitProcessor() throws Exception {
setupProcessors(0, 0);
Request req1 = createWriteRequest(1L, 1);
processRequestWithWait(req1);
Request req2 = createWriteRequest(1L, 2);
processRequestWithWait(req2);
// since we haven't got any commit request, the write request stays in the queue
// recorded writes in the queue are 1, 2
checkMetrics("write_commit_proc_req_queued", 1L, 2L, 1.5d, 2, 3);
commitWithWait(req1);
// recording is done before commit request is processed, so writes in the queue are: 1, 2, 2
checkMetrics("write_commit_proc_req_queued", 1L, 2L, 1.6667d, 3, 5);
commitWithWait(req2);
// writes in the queue are 1, 2, 2, 1
checkMetrics("write_commit_proc_req_queued", 1L, 2L, 1.5d, 4, 6);
// send a read request to trigger the recording, this time the write queue should be empty
// writes in the queue are 1, 2, 2, 1, 0
processRequestWithWait(createReadRequest(1L, 1));
checkMetrics("write_commit_proc_req_queued", 0L, 2L, 1.2d, 5, 6);
}
use of org.apache.zookeeper.server.Request in project zookeeper by apache.
the class CommitProcessorMetricsTest method testLocalWriteCommittedTime.
@Test
public void testLocalWriteCommittedTime() throws Exception {
setupProcessors(0, 0);
Request req1 = createWriteRequest(1L, 2);
processRequestWithWait(req1);
commitWithWait(req1);
Map<String, Object> values = MetricsUtils.currentServerMetrics();
assertEquals(1L, values.get("cnt_local_write_committed_time_ms"));
checkTimeMetric((long) values.get("max_local_write_committed_time_ms"), 0L, 1000L);
Request req2 = createWriteRequest(1L, 2);
processRequestWithWait(req2);
// the second write will be stuck in the session queue for at least one second
// but the LOCAL_WRITE_COMMITTED_TIME is from when the commit is received
Thread.sleep(1000);
commitWithWait(req2);
values = MetricsUtils.currentServerMetrics();
assertEquals(2L, values.get("cnt_local_write_committed_time_ms"));
checkTimeMetric((long) values.get("max_local_write_committed_time_ms"), 0L, 1000L);
}
use of org.apache.zookeeper.server.Request in project zookeeper by apache.
the class CommitProcessorMetricsTest method testReadsAfterWriteInSessionQueue.
@Test
public void testReadsAfterWriteInSessionQueue() throws Exception {
setupProcessors(0, 0);
// this read request is before write
processRequestWithWait(createReadRequest(1L, 1));
// one write request
Request req1 = createWriteRequest(1L, 1);
processRequestWithWait(req1);
// three read requests after the write
processRequestWithWait(createReadRequest(1L, 2));
processRequestWithWait(createReadRequest(1L, 3));
processRequestWithWait(createReadRequest(1L, 4));
// commit the write
commitWithWait(req1);
checkMetrics("reads_after_write_in_session_queue", 3L, 3L, 3d, 1, 3);
}
use of org.apache.zookeeper.server.Request in project zookeeper by apache.
the class CommitProcessorMetricsTest method testWriteCommitProcTime.
@Test
public void testWriteCommitProcTime() throws Exception {
setupProcessors(0, 0);
Request req1 = createWriteRequest(1L, 2);
processRequestWithWait(req1);
commitWithWait(req1);
Map<String, Object> values = MetricsUtils.currentServerMetrics();
assertEquals(1L, values.get("cnt_write_commitproc_time_ms"));
checkTimeMetric((long) values.get("max_write_commitproc_time_ms"), 0L, 1000L);
Request req2 = createWriteRequest(1L, 2);
processRequestWithWait(req2);
// the second write will be stuck in the session queue for at least one second
Thread.sleep(1000);
commitWithWait(req2);
values = MetricsUtils.currentServerMetrics();
assertEquals(2L, values.get("cnt_write_commitproc_time_ms"));
checkTimeMetric((long) values.get("max_write_commitproc_time_ms"), 1000L, 2000L);
}
Aggregations