anmolnar commented on a change in pull request #800: ZOOKEEPER-3268: Add commit 
processor metrics
URL: https://github.com/apache/zookeeper/pull/800#discussion_r271276644
 
 

 ##########
 File path: 
zookeeper-server/src/test/java/org/apache/zookeeper/server/quorum/CommitProcessorMetricsTest.java
 ##########
 @@ -0,0 +1,483 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.zookeeper.server.quorum;
+
+import org.apache.zookeeper.ZKTestCase;
+import org.apache.zookeeper.ZooDefs;
+import org.apache.zookeeper.server.*;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.nio.ByteBuffer;
+import java.util.Map;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import static org.hamcrest.Matchers.*;
+
+public class CommitProcessorMetricsTest extends ZKTestCase {
+    protected static final Logger LOG =
+            LoggerFactory.getLogger(CommitProcessorMetricsTest.class);
+    CommitProcessor commitProcessor;
+    DummyFinalProcessor finalProcessor;
+
+    CountDownLatch requestScheduled = null;
+    CountDownLatch requestSeen = null;
+    CountDownLatch commitSeen = null;
+    CountDownLatch poolEmpytied = null;
+
+    @Before
+    public void setup() {
+        LOG.info("setup");
+        ServerMetrics.resetAll();
+    }
+
+    public void setupProcessors(int commitWorkers, int finalProcTime ) {
+        finalProcessor = new DummyFinalProcessor(finalProcTime);
+        commitProcessor = new TestCommitProcessor(finalProcessor, 
commitWorkers);
+        commitProcessor.start();
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        LOG.info("tearDown starting");
+
+        commitProcessor.shutdown();
+        commitProcessor.join();
+    }
+
+    private class TestCommitProcessor extends CommitProcessor {
+        int numWorkerThreads;
+
+        public TestCommitProcessor(RequestProcessor finalProcessor, int 
numWorkerThreads) {
+            super(finalProcessor, "1", true, null);
+            this.numWorkerThreads = numWorkerThreads;
+        }
+
+        @Override
+        public void start() {
+            super.workerPool = new TestWorkerService(numWorkerThreads);
+            super.start();
+            // the sleep is needed to make sure that the thread is in the wait 
status
+            // and it won't start to process a request before the required 
countdown latch
+            // is set
 
 Review comment:
   Do you mean the `WorkerService`?
   Why not add another latch to join the threads here?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to