Search in sources :

Example 26 with Request

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);
}
Also used : Request(org.apache.zookeeper.server.Request) Test(org.junit.jupiter.api.Test)

Example 27 with Request

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);
}
Also used : Request(org.apache.zookeeper.server.Request) Test(org.junit.jupiter.api.Test)

Example 28 with Request

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);
}
Also used : Request(org.apache.zookeeper.server.Request) Test(org.junit.jupiter.api.Test)

Example 29 with Request

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);
}
Also used : Request(org.apache.zookeeper.server.Request) Test(org.junit.jupiter.api.Test)

Example 30 with Request

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);
}
Also used : Request(org.apache.zookeeper.server.Request) Test(org.junit.jupiter.api.Test)

Aggregations

Request (org.apache.zookeeper.server.Request)51 Test (org.junit.jupiter.api.Test)25 CreateRequest (org.apache.zookeeper.proto.CreateRequest)15 IOException (java.io.IOException)9 ByteBuffer (java.nio.ByteBuffer)9 GetDataRequest (org.apache.zookeeper.proto.GetDataRequest)9 SetDataRequest (org.apache.zookeeper.proto.SetDataRequest)9 TxnHeader (org.apache.zookeeper.txn.TxnHeader)9 HashSet (java.util.HashSet)8 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 BinaryOutputArchive (org.apache.jute.BinaryOutputArchive)6 Record (org.apache.jute.Record)6 KeeperException (org.apache.zookeeper.KeeperException)5 SetDataTxn (org.apache.zookeeper.txn.SetDataTxn)5 Id (org.apache.zookeeper.data.Id)4 ErrorTxn (org.apache.zookeeper.txn.ErrorTxn)4 OutputArchive (org.apache.jute.OutputArchive)3 ZooKeeper (org.apache.zookeeper.ZooKeeper)3 TxnLogEntry (org.apache.zookeeper.server.TxnLogEntry)3 QuorumVerifier (org.apache.zookeeper.server.quorum.flexible.QuorumVerifier)3