Ejemplo n.º 1
0
 @Override
 public void performBackgroundOperation(final OperationAndData<String> operationAndData)
     throws Exception {
   final TimeTrace trace = client.getZookeeperClient().startTracer("ExistsBuilderImpl-Background");
   AsyncCallback.StatCallback callback =
       new AsyncCallback.StatCallback() {
         @Override
         public void processResult(int rc, String path, Object ctx, Stat stat) {
           trace.commit();
           CuratorEvent event =
               new CuratorEventImpl(
                   CuratorEventType.EXISTS, rc, path, null, ctx, stat, null, null, null, null);
           client.processBackgroundOperation(operationAndData, event);
         }
       };
   if (watching.isWatched()) {
     client
         .getZooKeeper()
         .exists(operationAndData.getData(), true, callback, backgrounding.getContext());
   } else {
     client
         .getZooKeeper()
         .exists(
             operationAndData.getData(),
             watching.getWatcher(),
             callback,
             backgrounding.getContext());
   }
 }
Ejemplo n.º 2
0
 private Stat pathInForeground(final String path) throws Exception {
   TimeTrace trace = client.getZookeeperClient().startTracer("ExistsBuilderImpl-Foreground");
   Stat returnStat =
       RetryLoop.callWithRetry(
           client.getZookeeperClient(),
           new Callable<Stat>() {
             @Override
             public Stat call() throws Exception {
               Stat returnStat;
               if (watching.isWatched()) {
                 returnStat = client.getZooKeeper().exists(path, true);
               } else {
                 returnStat = client.getZooKeeper().exists(path, watching.getWatcher());
               }
               return returnStat;
             }
           });
   trace.commit();
   return returnStat;
 }