You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@helix.apache.org by GitBox <gi...@apache.org> on 2021/03/06 06:50:51 UTC

[GitHub] [helix] jiajunwang commented on a change in pull request #1663: Track failures for async read/write in ZkClient

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



##########
File path: zookeeper-api/src/test/java/org/apache/helix/zookeeper/impl/client/TestZkClientAsyncFailure.java
##########
@@ -0,0 +1,207 @@
+package org.apache.helix.zookeeper.impl.client;
+
+/*
+ * 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.
+ */
+
+import java.lang.management.ManagementFactory;
+import javax.management.JMException;
+import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
+import org.apache.helix.zookeeper.datamodel.ZNRecord;
+import org.apache.helix.zookeeper.datamodel.serializer.ZNRecordSerializer;
+import org.apache.helix.zookeeper.impl.ZkTestBase;
+import org.apache.helix.zookeeper.zkclient.callback.ZkAsyncCallMonitorContext;
+import org.apache.helix.zookeeper.zkclient.callback.ZkAsyncCallbacks;
+import org.apache.helix.zookeeper.zkclient.metric.ZkClientMonitor;
+import org.apache.helix.zookeeper.zkclient.metric.ZkClientPathMonitor;
+import org.apache.zookeeper.KeeperException;
+import org.testng.Assert;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import static org.apache.helix.zookeeper.zkclient.callback.ZkAsyncCallbacks.UNKNOWN_RET_CODE;
+
+public class TestZkClientAsyncFailure extends ZkTestBase {

Review comment:
       I would suggest combining this test with TestZkClientAsyncRetry. There is some common logic.
   Maybe you can just add several test methods there or modifying the existing logic a little bit and then check the metrics to verify that it works fine. I bet that would be easier than writing a whole new test.

##########
File path: zookeeper-api/src/main/java/org/apache/helix/zookeeper/zkclient/callback/ZkAsyncCallbacks.java
##########
@@ -50,6 +50,10 @@ public void processResult(int rc, String path, Object ctx, byte[] data, Stat sta
         if (_data != null && ctx != null && ctx instanceof ZkAsyncCallMonitorContext) {
           ((ZkAsyncCallMonitorContext) ctx).setBytes(_data.length);
         }
+      } else if(rc != Code.NONODE.intValue()) {
+        if (ctx instanceof ZkAsyncCallMonitorContext) {
+          ((ZkAsyncCallMonitorContext) ctx).recordFailure(path);
+        }
       }
       callback(rc, path, ctx);

Review comment:
       Why not process the result in the callback method? So that you process all the results in one place. The current version only records failures of 2 out of 5 zk calls.




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org