Repository: bookkeeper Updated Branches: refs/heads/master d66b9f0b4 -> 40af841a3
Auditor is sometimes marking as failed a bookie switching from available to read-only mode â¦hing from available to read-only mode Author: Matteo Merli <[email protected]> Reviewers: Enrico Olivelli <[email protected]>, Guo Sijie <[email protected]> Closes #37 from merlimat/bk-919 Project: http://git-wip-us.apache.org/repos/asf/bookkeeper/repo Commit: http://git-wip-us.apache.org/repos/asf/bookkeeper/commit/40af841a Tree: http://git-wip-us.apache.org/repos/asf/bookkeeper/tree/40af841a Diff: http://git-wip-us.apache.org/repos/asf/bookkeeper/diff/40af841a Branch: refs/heads/master Commit: 40af841a366323d19fde2ae73d198824c16af688 Parents: d66b9f0 Author: Matteo Merli <[email protected]> Authored: Wed Apr 27 00:30:36 2016 -0700 Committer: Sijie Guo <[email protected]> Committed: Wed Apr 27 00:30:36 2016 -0700 ---------------------------------------------------------------------- .../java/org/apache/bookkeeper/client/BookieWatcher.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/40af841a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookieWatcher.java ---------------------------------------------------------------------- diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookieWatcher.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookieWatcher.java index 6f8e20d..0142827 100644 --- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookieWatcher.java +++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookieWatcher.java @@ -314,7 +314,7 @@ class BookieWatcher implements Watcher, ChildrenCallback { private static class ReadOnlyBookieWatcher implements Watcher, ChildrenCallback { private final static Logger LOG = LoggerFactory.getLogger(ReadOnlyBookieWatcher.class); - private HashSet<BookieSocketAddress> readOnlyBookies = new HashSet<BookieSocketAddress>(); + private volatile HashSet<BookieSocketAddress> readOnlyBookies = new HashSet<BookieSocketAddress>(); private BookKeeper bk; private String readOnlyBookieRegPath; @@ -363,7 +363,7 @@ class BookieWatcher implements Watcher, ChildrenCallback { void notifyBookiesChanged(final BookiesListener listener) throws BKException { try { - bk.getZkHandle().getChildren(this.readOnlyBookieRegPath, new Watcher() { + List<String> children = bk.getZkHandle().getChildren(this.readOnlyBookieRegPath, new Watcher() { public void process(WatchedEvent event) { // listen children changed event from ZooKeeper if (event.getType() == EventType.NodeChildrenChanged) { @@ -371,6 +371,10 @@ class BookieWatcher implements Watcher, ChildrenCallback { } } }); + + // Update the list of read-only bookies + HashSet<BookieSocketAddress> newReadOnlyBookies = convertToBookieAddresses(children); + readOnlyBookies = newReadOnlyBookies; } catch (KeeperException ke) { logger.error("Error registering watcher with zookeeper", ke); throw new BKException.ZKException();
