/// <summary> /// List children of a directory and retrieve their /// <see cref="Org.Apache.Hadoop.Registry.Client.Types.RegistryPathStatus"/> /// values. /// <p> /// This is not an atomic operation; A child may be deleted /// during the iteration through the child entries. If this happens, /// the <code>PathNotFoundException</code> is caught and that child /// entry ommitted. /// </summary> /// <param name="path">path</param> /// <returns> /// a possibly empty map of child entries listed by /// their short name. /// </returns> /// <exception cref="Org.Apache.Hadoop.FS.PathNotFoundException">path is not in the registry. /// </exception> /// <exception cref="Org.Apache.Hadoop.Registry.Client.Exceptions.InvalidPathnameException /// ">the path is invalid.</exception> /// <exception cref="System.IO.IOException">Any other IO Exception</exception> public static IDictionary <string, RegistryPathStatus> StatChildren(RegistryOperations registryOperations, string path) { IList <string> childNames = registryOperations.List(path); IDictionary <string, RegistryPathStatus> results = new Dictionary <string, RegistryPathStatus >(); foreach (string childName in childNames) { string child = RegistryPathUtils.Join(path, childName); try { RegistryPathStatus stat = registryOperations.Stat(child); results[childName] = stat; } catch (PathNotFoundException pnfe) { if (Log.IsDebugEnabled()) { Log.Debug("stat failed on {}: moved? {}", child, pnfe, pnfe); } } } // and continue return(results); }
public virtual void TestDigestAccess() { RMRegistryOperationsService registryAdmin = StartRMRegistryOperations(); string id = "username"; string pass = "******"; registryAdmin.AddWriteAccessor(id, pass); IList <ACL> clientAcls = registryAdmin.GetClientAcls(); Log.Info("Client ACLS=\n{}", RegistrySecurity.AclsToString(clientAcls)); string @base = "/digested"; registryAdmin.Mknode(@base, false); IList <ACL> baseACLs = registryAdmin.ZkGetACLS(@base); string aclset = RegistrySecurity.AclsToString(baseACLs); Log.Info("Base ACLs=\n{}", aclset); ACL found = null; foreach (ACL acl in baseACLs) { if (ZookeeperConfigOptions.SchemeDigest.Equals(acl.GetId().GetScheme())) { found = acl; break; } } NUnit.Framework.Assert.IsNotNull("Did not find digest entry in ACLs " + aclset, found ); zkClientConf.Set(KeyRegistryUserAccounts, "sasl:[email protected], sasl:other" ); RegistryOperations operations = RegistryOperationsFactory.CreateAuthenticatedInstance (zkClientConf, id, pass); AddToTeardown(operations); operations.Start(); RegistryOperationsClient operationsClient = (RegistryOperationsClient)operations; IList <ACL> digestClientACLs = operationsClient.GetClientAcls(); Log.Info("digest client ACLs=\n{}", RegistrySecurity.AclsToString(digestClientACLs )); operations.Stat(@base); operations.Mknode(@base + "/subdir", false); ZKPathDumper pathDumper = registryAdmin.DumpPath(true); Log.Info(pathDumper.ToString()); }
/// <summary>Assert a path exists</summary> /// <param name="path">path in the registry</param> /// <exception cref="System.IO.IOException"/> public virtual void AssertPathExists(string path) { operations.Stat(path); }