예제 #1
0
 /**
  * Update a modified child and republish a new snapshot. This may indicate a deleted child or a
  * child with modified data.
  */
 private void processChildEvent(WatchedEvent event) throws Exception {
   HashMap<String, JSONObject> cacheCopy = new HashMap<String, JSONObject>(m_publicCache.get());
   ByteArrayCallback cb = new ByteArrayCallback();
   m_zk.getData(event.getPath(), m_childWatch, cb, null);
   try {
     byte payload[] = cb.getData();
     JSONObject jsObj = new JSONObject(new String(payload, "UTF-8"));
     cacheCopy.put(cb.getPath(), jsObj);
   } catch (KeeperException.NoNodeException e) {
     cacheCopy.remove(event.getPath());
   }
   m_publicCache.set(ImmutableMap.copyOf(cacheCopy));
 }
예제 #2
0
 private void handleChildUpdate(final WatchedEvent event) {
   m_zk.getChildren(
       event.getPath(), constructMailboxChildWatcher(), constructChildRetrievalCallback(), null);
 }