Source:
public void announce(String path, byte[] bytes, boolean removeParentIfCreated) { synchronized (toAnnounce) { if (!started) { toAnnounce.add(new Announceable(path, bytes, removeParentIfCreated)); return; } } final ZKPaths.PathAndNode pathAndNode = ZKPaths.getPathAndNode(path); final String parentPath = pathAndNode.getPath(); boolean buildParentPath = false; byte[] value = announcements.get(path); if (value == null) { try { if (curator.checkExists().forPath(parentPath) == null) { buildParentPath = true; } } catch (Exception e) { log.debug(e, "Problem checking if the parent existed, ignoring."); } synchronized (toAnnounce) { if (!listeners.containsKey(path)) { final NodeCache cache = new NodeCache(curator, path, true); cache.getListenable().addListener( new NodeCacheListener() { @Override public void nodeChanged() throws Exception { ChildData currentData = cache.getCurrentData(); if (currentData == null) { final byte[] value = announcements.get(path); if (value != null) { log.info("Node[%s] dropped, reinstating.", path); createAnnouncement(path, value); } } } } ); if (started) { if (buildParentPath) { createPath(parentPath, removeParentIfCreated); } startCache(cache); listeners.put(path, cache); } } } } boolean created = false; synchronized (toAnnounce) { if (started) { byte[] oldBytes = announcements.putIfAbsent(path, bytes); if (oldBytes == null) { created = true; } else if (!Arrays.equals(oldBytes, bytes)) { throw new IAE("Cannot reannounce different values under the same path"); } } } if (created) { try { createAnnouncement(path, bytes); } catch (Exception e) { throw Throwables.propagate(e); } } }

Target:
public void announce(String path, byte[] bytes, boolean removeParentIfCreated) { synchronized (toAnnounce) { if (!started) { toAnnounce.add(new Announceable(path, bytes, removeParentIfCreated)); return; } } final String parentPath = ZKPathsUtils.getParentPath(path); boolean buildParentPath = false; byte[] value = announcedPaths.get(path); if (value == null) { try { if (curator.checkExists().forPath(parentPath) == null) { buildParentPath = true; } } catch (Exception e) { log.debug(e, "Problem checking if the parent existed, ignoring."); } synchronized (toAnnounce) { if (!listeners.containsKey(path)) { final NodeCache cache = new NodeCache(curator, path, true); cache.getListenable().addListener( new NodeCacheListener() { @Override public void nodeChanged() throws Exception { ChildData currentData = cache.getCurrentData(); if (currentData == null) { final byte[] value = announcedPaths.get(path); if (value != null) { log.info("Node[%s] dropped, reinstating.", path); createAnnouncement(path, value); } } } } ); if (started) { if (buildParentPath) { createPath(parentPath, removeParentIfCreated); } startCache(cache); listeners.put(path, cache); } } } } boolean created = false; synchronized (toAnnounce) { if (started) { byte[] oldBytes = announcedPaths.putIfAbsent(path, bytes); if (oldBytes == null) { created = true; } else if (!Arrays.equals(oldBytes, bytes)) { throw new IAE("Cannot reannounce different values under the same path"); } } } if (created) { try { createAnnouncement(path, bytes); } catch (Exception e) { throw new RuntimeException(e); } } }