jiajunwang commented on a change in pull request #1035:
URL: https://github.com/apache/helix/pull/1035#discussion_r436204267
##########
File path:
zookeeper-api/src/main/java/org/apache/helix/zookeeper/zkclient/ZkClient.java
##########
@@ -1082,7 +1082,51 @@ public Stat getStat(final String path) {
}
private Stat getStat(final String path, final boolean watch) {
- return getStat(path, watch, false);
+ long startT = System.currentTimeMillis();
+ final Stat stat;
+ try {
+ stat = retryUntilConnected(
+ () -> ((ZkConnection) getConnection()).getZookeeper().exists(path,
watch));
+ record(path, null, startT, ZkClientMonitor.AccessType.READ);
+ return stat;
+ } catch (Exception e) {
+ recordFailure(path, ZkClientMonitor.AccessType.READ);
+ throw e;
+ } finally {
+ long endT = System.currentTimeMillis();
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("exists, path: " + path + ", time: " + (endT - startT) + "
ms");
+ }
+ }
+ }
+
+ /*
+ * This one installs watch only if path is there. Meant to avoid leaking
watch in Zk server.
+ */
+ private Stat installWatchOnlyPathExist(final String path) {
+ long startT = System.currentTimeMillis();
+ final Stat stat;
+ try {
+ stat = new Stat();
+ try {
+ LOG.debug("installWatchOnlyPathExist with path: {} ", path);
+ retryUntilConnected(() -> ((ZkConnection)
getConnection()).getZookeeper().getData(path, true, stat));
+ } catch (ZkNoNodeException e) {
+ LOG.debug("installWatchOnlyPathExist path not existing: {}", path);
+ record(path, null, startT, ZkClientMonitor.AccessType.READ);
+ return null;
+ }
+ record(path, null, startT, ZkClientMonitor.AccessType.READ);
+ return stat;
+ } catch (Exception e) {
+ recordFailure(path, ZkClientMonitor.AccessType.READ);
+ throw e;
+ } finally {
+ long endT = System.currentTimeMillis();
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("exists, path: " + path + ", time: " + (endT - startT) + "
ms");
Review comment:
nit, getdata
----------------------------------------------------------------
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]