Skip to content

Commit

Permalink
Reload zk cache asynchronously (apache#5049)
Browse files Browse the repository at this point in the history
  • Loading branch information
merlimat authored Aug 27, 2019
1 parent 40d6248 commit d22e014
Showing 1 changed file with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,12 @@ public void invalidate(final String path) {

@Override
public void reloadCache(final String path) {
try {
if (LOG.isDebugEnabled()) {
LOG.debug("Reloading ZooKeeperDataCache at path {}", path);
}
cache.invalidate(path);
Optional<Entry<T, Stat>> cacheEntry = cache.getData(path, this, this);
if (LOG.isDebugEnabled()) {
LOG.debug("Reloading ZooKeeperDataCache at path {}", path);
}
cache.invalidate(path);

cache.getDataAsync(path, this, this).thenAccept(cacheEntry -> {
if (!cacheEntry.isPresent()) {
if (LOG.isDebugEnabled()) {
LOG.debug("Node [{}] does not exist", path);
Expand All @@ -134,9 +134,10 @@ public void reloadCache(final String path) {
LOG.debug("Notified listener {} at path {}", listener, path);
}
}
} catch (Exception e) {
LOG.warn("Reloading ZooKeeperDataCache failed at path: {}", path, e);
}
}).exceptionally(ex -> {
LOG.warn("Reloading ZooKeeperDataCache failed at path: {}", path, ex);
return null;
});
}

@Override
Expand Down

0 comments on commit d22e014

Please sign in to comment.