Beispiel #1
0
        /**
         * Return the children of the given path sorted by sequence number
         *
         * @param zookeeper the client
         * @param path      the path
         * @return sorted list of children
         * @throws InterruptedException thread interruption
         * @throws org.apache.zookeeper.KeeperException
         *                              zookeeper errors
         */

        public static List <String> GetSortedChildren(IZooKeeper zookeeper, String path)
        {
            var children   = zookeeper.GetChildren(path, false);
            var sortedList = new List <string>(children.OrderBy(x => x));

            return(sortedList);
        }
Beispiel #2
0
        public static List <string> GetSortedChildren(IZooKeeper client, string basePath, string lockName,
                                                      ILockInternalsSorter sorter)
        {
            var children = client.GetChildren(basePath, false);

            return(GetSortedChildren(lockName, sorter, children));
        }
Beispiel #3
0
            public void Process(WatchedEvent @event)
            {
                if (@event.Type == EventType.NodeDeleted && @event.Path == penultimatePath)
                {
                    var names       = zooKeeper.GetChildren(path, false);
                    var sortedNames = new SortedSet <ZNodeName>();

                    foreach (var name in names)
                    {
                        sortedNames.Add(new ZNodeName(name));
                    }

                    if (SmallestZNode(sortedNames))
                    {
                        election.IsOwner = true;
                        watcher.TakeLeadership();
                    }
                }
            }
Beispiel #4
0
        public void GetZKTree(ZKTree tree)
        {
            IEnumerable <string> names = zookeeper.GetChildren(tree.Path == null?"/": tree.Path, false);

            if (names != null)
            {
                tree.Children = new List <ZKTree>();
                foreach (var name in names)
                {
                    ZKTree child = new ZKTree();
                    child.Name = name;
                    child.Path = tree.Path + "/" + name;
                    child.Data = zookeeper.GetData(child.Path, false, null);
                    tree.Children.Add(child);
                    GetZKTree(child);
                }
            }
            else
            {
                return;
            }
        }
Beispiel #5
0
 /**
  * Return the children of the given path sorted by sequence number
  *
  * @param zookeeper the client
  * @param path      the path
  * @return sorted list of children
  * @throws InterruptedException thread interruption
  * @throws org.apache.zookeeper.KeeperException
  *                              zookeeper errors
  */
 public static List<String> GetSortedChildren(IZooKeeper zookeeper, String path)
 {
     var children = zookeeper.GetChildren(path, false);
     var sortedList = new List<string>(children.OrderBy(x => x));
     return sortedList;
 }