コード例 #1
0
 public ZooKeeperResult <string[]> GetChildren(string path, IWatcher watcher = null)
 {
     LogGetChildren(path, watcher);
     return(ExecuteOperation(
                path,
                () =>
     {
         var builder = Curator.getChildren();
         if (watcher != null)
         {
             builder = (GetChildrenBuilder)builder.usingWatcher(WrapWatcher(watcher));
         }
         return ((List)builder.forPath(path)).toArray().Select(o => o.ToString()).ToArray();
     }));
 }
コード例 #2
0
        public ZooKeeperResult <Tuple <string[], Stat> > GetChildrenWithStat(string path, IWatcher watcher = null)
        {
            LogGetChildren(path, watcher);
            return(ExecuteOperation(
                       path,
                       () =>
            {
                var builder = Curator.getChildren();

                if (watcher != null)
                {
                    builder = (GetChildrenBuilder)builder.usingWatcher(WrapWatcher(watcher));
                }

                var stat = new org.apache.zookeeper.data.Stat();

                var pathable = (WatchPathable)builder.storingStatIn(stat);

                var children = ((List)pathable.forPath(path)).toArray().Select(o => o.ToString()).ToArray();

                return Tuple.Create(children, new Stat(stat));
            }));
        }