jiajunwang commented on a change in pull request #1295:
URL: https://github.com/apache/helix/pull/1295#discussion_r490636370



##########
File path: 
zookeeper-api/src/main/java/org/apache/helix/zookeeper/zkclient/metric/ZkClientMonitor.java
##########
@@ -96,6 +96,12 @@ public static ObjectName getObjectName(String monitorType, 
String monitorKey,
             (monitorKey + (monitorInstanceName == null ? "" : "." + 
monitorInstanceName)));
   }
 
+  public void setAndInitZkEventThreadMonitor(ZkEventThread zkEventThread) {
+    if (_zkEventThreadMetric == null) {
+      _zkEventThreadMetric = new ZkThreadMetric(zkEventThread);

Review comment:
       BTW, you can check for registration status by checking _objectName with 
a synchronized lock on the monitor object.

##########
File path: 
zookeeper-api/src/main/java/org/apache/helix/zookeeper/zkclient/metric/ZkClientMonitor.java
##########
@@ -96,6 +96,12 @@ public static ObjectName getObjectName(String monitorType, 
String monitorKey,
             (monitorKey + (monitorInstanceName == null ? "" : "." + 
monitorInstanceName)));
   }
 
+  public void setAndInitZkEventThreadMonitor(ZkEventThread zkEventThread) {
+    if (_zkEventThreadMetric == null) {
+      _zkEventThreadMetric = new ZkThreadMetric(zkEventThread);

Review comment:
       nit, throw Exception if the _zkEventThreadMetric has already been set or 
the monitor object has already been registered. Otherwise, we may see an 
unexpected monitor value in the final result.

##########
File path: 
zookeeper-api/src/test/java/org/apache/helix/zookeeper/impl/client/TestRawZkClient.java
##########
@@ -285,18 +285,20 @@ public void testZkClientMonitor()
     Assert.assertTrue(beanServer.isRegistered(idealStatename));
 
     Assert.assertEquals((long) beanServer.getAttribute(name, 
"DataChangeEventCounter"), 0);
-    Assert.assertEquals((long) beanServer.getAttribute(name, 
"StateChangeEventCounter"), 0);
+    Assert.assertEquals((long) beanServer.getAttribute(name, 
"StateChangeEventCounter"), 1);
     Assert.assertEquals((long) beanServer.getAttribute(name, 
"ExpiredSessionCounter"), 0);
     Assert.assertEquals((long) beanServer.getAttribute(name, 
"OutstandingRequestGauge"), 0);
-    // account for doAsyncSync()
-    Assert.assertEquals((long) beanServer.getAttribute(name, 
"TotalCallbackCounter"), 1);

Review comment:
       Is this value still validatable?




----------------------------------------------------------------
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:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to