示例#1
0
        /// <summary>Main entry point for ToolRunner (see ToolRunner docs)</summary>
        /// <param name="argv">The parameters passed to this program.</param>
        /// <returns>0 on success, non zero on error.</returns>
        /// <exception cref="System.Exception"/>
        public virtual int Run(string[] argv)
        {
            Options options = BuildOptions();

            if (argv.Length == 0)
            {
                PrintHelp();
                return(-1);
            }
            CommandLineParser parser = new PosixParser();
            CommandLine       cmd;

            try
            {
                cmd = parser.Parse(options, argv);
            }
            catch (ParseException e)
            {
                System.Console.Out.WriteLine("Error parsing command-line options: " + e.Message);
                PrintHelp();
                return(-1);
            }
            if (cmd.HasOption("h"))
            {
                // print help and exit
                PrintHelp();
                return(-1);
            }
            string inputFileName  = cmd.GetOptionValue("i");
            string outputFileName = cmd.GetOptionValue("o");
            string processor      = cmd.GetOptionValue("p");

            if (processor == null)
            {
                processor = defaultProcessor;
            }
            OfflineEditsViewer.Flags flags = new OfflineEditsViewer.Flags();
            if (cmd.HasOption("r"))
            {
                flags.SetRecoveryMode();
            }
            if (cmd.HasOption("f"))
            {
                flags.SetFixTxIds();
            }
            if (cmd.HasOption("v"))
            {
                flags.SetPrintToScreen();
            }
            return(Go(inputFileName, outputFileName, processor, flags, null));
        }
示例#2
0
 /// <summary>Run OfflineEditsViewer</summary>
 /// <param name="inFilename">input edits filename</param>
 /// <param name="outFilename">oputput edits filename</param>
 /// <exception cref="System.IO.IOException"/>
 private int RunOev(string inFilename, string outFilename, string processor, bool
                    recovery)
 {
     Log.Info("Running oev [" + inFilename + "] [" + outFilename + "]");
     Org.Apache.Hadoop.Hdfs.Tools.OfflineEditsViewer.OfflineEditsViewer oev = new Org.Apache.Hadoop.Hdfs.Tools.OfflineEditsViewer.OfflineEditsViewer
                                                                                  ();
     OfflineEditsViewer.Flags flags = new OfflineEditsViewer.Flags();
     flags.SetPrintToScreen();
     if (recovery)
     {
         flags.SetRecoveryMode();
     }
     return(oev.Go(inFilename, outFilename, processor, flags, null));
 }