コード例 #1
0
ファイル: RegistryUtils.cs プロジェクト: orf53975/hadoop.net
        /// <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);
        }
コード例 #2
0
        public virtual void TestAnonReadAccess()
        {
            RMRegistryOperationsService rmRegistryOperations = StartRMRegistryOperations();

            Describe(Log, "testAnonReadAccess");
            RegistryOperations operations = RegistryOperationsFactory.CreateAnonymousInstance
                                                (zkClientConf);

            AddToTeardown(operations);
            operations.Start();
            NUnit.Framework.Assert.IsFalse("RegistrySecurity.isClientSASLEnabled()==true", RegistrySecurity
                                           .IsClientSASLEnabled());
            operations.List(PathSystemServices);
        }
コード例 #3
0
        public virtual void TestUserZookeeperHomePathAccess()
        {
            RMRegistryOperationsService rmRegistryOperations = StartRMRegistryOperations();
            string home = rmRegistryOperations.InitUserRegistry(Zookeeper);

            Describe(Log, "Creating ZK client");
            RegistryOperations operations = zookeeperUGI.DoAs(new _PrivilegedExceptionAction_232
                                                                  (this));

            operations.List(home);
            string path = home + "/subpath";

            operations.Mknode(path, false);
            operations.Delete(path, true);
        }
コード例 #4
0
        public virtual void TestAlicePathRestrictedAnonAccess()
        {
            RMRegistryOperationsService rmRegistryOperations = StartRMRegistryOperations();
            string aliceHome = rmRegistryOperations.InitUserRegistry(Alice);

            Describe(Log, "Creating anonymous accessor");
            RegistryOperations anonOperations = RegistryOperationsFactory.CreateAnonymousInstance
                                                    (zkClientConf);

            AddToTeardown(anonOperations);
            anonOperations.Start();
            anonOperations.List(aliceHome);
            ExpectMkNodeFailure(anonOperations, aliceHome + "/anon");
            ExpectDeleteFailure(anonOperations, aliceHome, true);
        }
コード例 #5
0
        public virtual int Ls(string[] args)
        {
            Options           lsOption = new Options();
            CommandLineParser parser   = new GnuParser();

            try
            {
                CommandLine    line     = parser.Parse(lsOption, args);
                IList <string> argsList = line.GetArgList();
                if (argsList.Count != 2)
                {
                    return(UsageError("ls requires exactly one path argument", LsUsage));
                }
                if (!ValidatePath(argsList[1]))
                {
                    return(-1);
                }
                try
                {
                    IList <string> children = registry.List(argsList[1]);
                    foreach (string child in children)
                    {
                        sysout.WriteLine(child);
                    }
                    return(0);
                }
                catch (Exception e)
                {
                    syserr.WriteLine(AnalyzeException("ls", e, argsList));
                }
                return(-1);
            }
            catch (ParseException exp)
            {
                return(UsageError("Invalid syntax " + exp, LsUsage));
            }
        }