You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by rx...@apache.org on 2020/11/06 05:31:54 UTC

[pulsar] branch branch-2.6 updated: Fix zk cache expiration check (#8458)

This is an automated email from the ASF dual-hosted git repository.

rxl pushed a commit to branch branch-2.6
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/branch-2.6 by this push:
     new 156b4be  Fix zk cache expiration check (#8458)
156b4be is described below

commit 156b4be4a1bd55a9f9a6b25c3a46836236cc1390
Author: hrsakai <hs...@yahoo-corp.jp>
AuthorDate: Fri Nov 6 14:28:44 2020 +0900

    Fix zk cache expiration check (#8458)
    
    ### Motivation
    Currently, zk cache is refreshed every time because the units of comparison are different(ns and ms).
    We should check the zk cache expiration time in the same unit.
    
    (cherry picked from commit 37453b5f7990fc0e1432cfbf1137102077f9e95a)
---
 .../src/main/java/org/apache/pulsar/zookeeper/ZooKeeperCache.java       | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pulsar-zookeeper-utils/src/main/java/org/apache/pulsar/zookeeper/ZooKeeperCache.java b/pulsar-zookeeper-utils/src/main/java/org/apache/pulsar/zookeeper/ZooKeeperCache.java
index 89ba630..26eb058 100644
--- a/pulsar-zookeeper-utils/src/main/java/org/apache/pulsar/zookeeper/ZooKeeperCache.java
+++ b/pulsar-zookeeper-utils/src/main/java/org/apache/pulsar/zookeeper/ZooKeeperCache.java
@@ -400,7 +400,7 @@ public abstract class ZooKeeperCache implements Watcher {
         if (result != null && result.isDone()) {
             Pair<Entry<Object, Stat>, Long> entryPair = result.getNow(null);
             if (entryPair != null && entryPair.getRight() != null) {
-                if ((System.nanoTime() - entryPair.getRight()) > TimeUnit.SECONDS.toMillis(cacheExpirySeconds)) {
+                if ((System.nanoTime() - entryPair.getRight()) > TimeUnit.SECONDS.toNanos(cacheExpirySeconds)) {
                     this.zkSession.get().getData(path, this, (rc, path1, ctx, content, stat) -> {
                         if (rc != Code.OK.intValue()) {
                             log.warn("Failed to refresh zookeeper-cache for {} due to {}", path, rc);