Exemple #1
0
 /// <summary>Main method that runs the tool for given arguments.</summary>
 /// <param name="args">arguments</param>
 /// <returns>return status of the command</returns>
 private int DoWork(string[] args)
 {
     if (args.Length >= 1)
     {
         GetConf.CommandHandler handler = GetConf.Command.GetHandler(args[0]);
         if (handler != null)
         {
             return(handler.DoWork(this, Arrays.CopyOfRange(args, 1, args.Length)));
         }
     }
     PrintUsage();
     return(-1);
 }
Exemple #2
0
        /// <summary>
        /// Tests commands other than
        /// <see cref="Command.Namenode"/>
        /// ,
        /// <see cref="Command.Backup"/>
        /// ,
        /// <see cref="Command.Secondary"/>
        /// and
        /// <see cref="Command.Nnrpcaddresses"/>
        /// </summary>
        /// <exception cref="System.Exception"/>
        public virtual void TestTool()
        {
            HdfsConfiguration conf = new HdfsConfiguration(false);

            foreach (GetConf.Command cmd in GetConf.Command.Values())
            {
                GetConf.CommandHandler handler = GetConf.Command.GetHandler(cmd.GetName());
                if (handler.key != null && !"-confKey".Equals(cmd.GetName()))
                {
                    // Add the key to the conf and ensure tool returns the right value
                    string[] args = new string[] { cmd.GetName() };
                    conf.Set(handler.key, "value");
                    NUnit.Framework.Assert.IsTrue(RunTool(conf, args, true).Contains("value"));
                }
            }
        }
Exemple #3
0
        /// <summary>Test empty configuration</summary>
        /// <exception cref="System.Exception"/>
        public virtual void TestEmptyConf()
        {
            HdfsConfiguration conf = new HdfsConfiguration(false);

            // Verify getting addresses fails
            GetAddressListFromTool(TestGetConf.TestType.Namenode, conf, false);
            System.Console.Out.WriteLine(GetAddressListFromTool(TestGetConf.TestType.Backup,
                                                                conf, false));
            GetAddressListFromTool(TestGetConf.TestType.Secondary, conf, false);
            GetAddressListFromTool(TestGetConf.TestType.Nnrpcaddresses, conf, false);
            foreach (GetConf.Command cmd in GetConf.Command.Values())
            {
                string arg = cmd.GetName();
                GetConf.CommandHandler handler = GetConf.Command.GetHandler(arg);
                NUnit.Framework.Assert.IsNotNull("missing handler: " + cmd, handler);
                if (handler.key != null)
                {
                    // First test with configuration missing the required key
                    string[] args = new string[] { handler.key };
                    RunTool(conf, args, false);
                }
            }
        }