Example #1
0
 /// <summary>
 /// Recursively expand the path into the supplied string builder, increasing
 /// the indentation by
 /// <see cref="Indent"/>
 /// as it proceeds (depth first) down
 /// the tree
 /// </summary>
 /// <param name="builder">string build to append to</param>
 /// <param name="path">path to examine</param>
 /// <param name="indent">current indentation</param>
 private void Expand(StringBuilder builder, string path, int indent)
 {
     try
     {
         GetChildrenBuilder childrenBuilder = curator.GetChildren();
         IList <string>     children        = childrenBuilder.ForPath(path);
         foreach (string child in children)
         {
             string        childPath = path + "/" + child;
             string        body;
             Stat          stat        = curator.CheckExists().ForPath(childPath);
             StringBuilder bodyBuilder = new StringBuilder(256);
             bodyBuilder.Append("  [").Append(stat.GetDataLength()).Append("]");
             if (stat.GetEphemeralOwner() > 0)
             {
                 bodyBuilder.Append("*");
             }
             if (verbose)
             {
                 // verbose: extract ACLs
                 builder.Append(" -- ");
                 IList <ACL> acls = curator.GetACL().ForPath(childPath);
                 foreach (ACL acl in acls)
                 {
                     builder.Append(RegistrySecurity.AclToString(acl));
                     builder.Append(" ");
                 }
             }
             body = bodyBuilder.ToString();
             // print each child
             Append(builder, indent, ' ');
             builder.Append('/').Append(child);
             builder.Append(body);
             builder.Append('\n');
             // recurse
             Expand(builder, childPath, indent + Indent);
         }
     }
     catch (Exception e)
     {
         builder.Append(e.ToString()).Append("\n");
     }
 }
Example #2
0
        /// <summary>List all children of a path</summary>
        /// <param name="path">path of operation</param>
        /// <returns>a possibly empty list of children</returns>
        /// <exception cref="System.IO.IOException"/>
        public virtual IList <string> ZkList(string path)
        {
            CheckServiceLive();
            string fullpath = CreateFullPath(path);

            try
            {
                if (Log.IsDebugEnabled())
                {
                    Log.Debug("ls {}", fullpath);
                }
                GetChildrenBuilder builder  = curator.GetChildren();
                IList <string>     children = builder.ForPath(fullpath);
                return(children);
            }
            catch (Exception e)
            {
                throw OperationFailure(path, "ls()", e);
            }
        }