Esempio n. 1
0
 internal static int PrintUsage()
 {
     System.Console.Out.WriteLine("wordcount [-m <maps>] [-r <reduces>] <input> <output>"
                                  );
     ToolRunner.PrintGenericCommandUsage(System.Console.Out);
     return(-1);
 }
Esempio n. 2
0
        /// <exception cref="System.Exception"/>
        public static void Main(string[] args)
        {
            // -files option is also used by GenericOptionsParser
            // Make sure that is not the first argument for fsck
            int res = -1;

            if ((args.Length == 0) || ("-files".Equals(args[0])))
            {
                PrintUsage(System.Console.Error);
                ToolRunner.PrintGenericCommandUsage(System.Console.Error);
            }
            else
            {
                if (DFSUtil.ParseHelpArgument(args, Usage, System.Console.Out, true))
                {
                    res = 0;
                }
                else
                {
                    res = ToolRunner.Run(new Org.Apache.Hadoop.Hdfs.Tools.DFSck(new HdfsConfiguration
                                                                                    ()), args);
                }
            }
            System.Environment.Exit(res);
        }
Esempio n. 3
0
 private static void Usage()
 {
     System.Console.Error.WriteLine("BigMapOutput -input <input-dir> -output <output-dir> "
                                    + "[-create <filesize in MB>]");
     ToolRunner.PrintGenericCommandUsage(System.Console.Error);
     System.Environment.Exit(1);
 }
Esempio n. 4
0
 // IGNORE
 private static void PrintUsage()
 {
     ToolRunner.PrintGenericCommandUsage(System.Console.Error);
     System.Console.Error.WriteLine("Usage: dfsthroughput [#reps]");
     System.Console.Error.WriteLine("Config properties:\n" + "  dfsthroughput.file.size:\tsize of each write/read (10GB)\n"
                                    + "  dfsthroughput.buffer.size:\tbuffer size for write/read (4k)\n");
 }
Esempio n. 5
0
        private static void PrintHelp(string cmd)
        {
            string summary = "scmadmin is the command to execute shared cache manager" + "administrative commands.\n"
                             + "The full syntax is: \n\n" + "hadoop scmadmin" + " [-runCleanerTask]" + " [-help [cmd]]\n";
            string runCleanerTask = "-runCleanerTask: Run cleaner task right away.\n";
            string help           = "-help [cmd]: \tDisplays help for the given command or all commands if none\n"
                                    + "\t\tis specified.\n";

            if ("runCleanerTask".Equals(cmd))
            {
                System.Console.Out.WriteLine(runCleanerTask);
            }
            else
            {
                if ("help".Equals(cmd))
                {
                    System.Console.Out.WriteLine(help);
                }
                else
                {
                    System.Console.Out.WriteLine(summary);
                    System.Console.Out.WriteLine(runCleanerTask);
                    System.Console.Out.WriteLine(help);
                    System.Console.Out.WriteLine();
                    ToolRunner.PrintGenericCommandUsage(System.Console.Out);
                }
            }
        }
Esempio n. 6
0
 internal static int PrintUsage()
 {
     System.Console.Out.WriteLine("randomtextwriter " + "[-outFormat <output format class>] "
                                  + "<output>");
     ToolRunner.PrintGenericCommandUsage(System.Console.Out);
     return(2);
 }
Esempio n. 7
0
 internal static int PrintUsage()
 {
     System.Console.Out.WriteLine("join [-r <reduces>] " + "[-inFormat <input format class>] "
                                  + "[-outFormat <output format class>] " + "[-outKey <output key class>] " + "[-outValue <output value class>] "
                                  + "[-joinOp <inner|outer|override>] " + "[input]* <input> <output>");
     ToolRunner.PrintGenericCommandUsage(System.Console.Out);
     return(2);
 }
Esempio n. 8
0
 internal static int PrintUsage()
 {
     System.Console.Out.WriteLine("sort [-r <reduces>] " + "[-inFormat <input format class>] "
                                  + "[-outFormat <output format class>] " + "[-outKey <output key class>] " + "[-outValue <output value class>] "
                                  + "[-totalOrder <pcnt> <num samples> <max splits>] " + "<input> <output>");
     ToolRunner.PrintGenericCommandUsage(System.Console.Out);
     return(2);
 }
Esempio n. 9
0
 /// <summary>Print usage messages</summary>
 public static int PrintUsage(string[] args, string usage)
 {
     err.WriteLine("args = " + Arrays.AsList(args));
     err.WriteLine();
     err.WriteLine("Usage: java " + usage);
     err.WriteLine();
     ToolRunner.PrintGenericCommandUsage(err);
     return(-1);
 }
Esempio n. 10
0
        /// <summary>This is the main routine for launching a distributed random write job.</summary>
        /// <remarks>
        /// This is the main routine for launching a distributed random write job.
        /// It runs 10 maps/node and each node writes 1 gig of data to a DFS file.
        /// The reduce doesn't do anything.
        /// </remarks>
        /// <exception cref="System.IO.IOException"></exception>
        /// <exception cref="System.Exception"/>
        public virtual int Run(string[] args)
        {
            if (args.Length == 0)
            {
                System.Console.Out.WriteLine("Usage: writer <out-dir>");
                ToolRunner.PrintGenericCommandUsage(System.Console.Out);
                return(2);
            }
            Path          outDir                = new Path(args[0]);
            Configuration conf                  = GetConf();
            JobClient     client                = new JobClient(conf);
            ClusterStatus cluster               = client.GetClusterStatus();
            int           numMapsPerHost        = conf.GetInt(MapsPerHost, 10);
            long          numBytesToWritePerMap = conf.GetLong(BytesPerMap, 1 * 1024 * 1024 * 1024);

            if (numBytesToWritePerMap == 0)
            {
                System.Console.Error.WriteLine("Cannot have" + BytesPerMap + " set to 0");
                return(-2);
            }
            long totalBytesToWrite = conf.GetLong(TotalBytes, numMapsPerHost * numBytesToWritePerMap
                                                  * cluster.GetTaskTrackers());
            int numMaps = (int)(totalBytesToWrite / numBytesToWritePerMap);

            if (numMaps == 0 && totalBytesToWrite > 0)
            {
                numMaps = 1;
                conf.SetLong(BytesPerMap, totalBytesToWrite);
            }
            conf.SetInt(MRJobConfig.NumMaps, numMaps);
            Job job = Job.GetInstance(conf);

            job.SetJarByClass(typeof(RandomWriter));
            job.SetJobName("random-writer");
            FileOutputFormat.SetOutputPath(job, outDir);
            job.SetOutputKeyClass(typeof(BytesWritable));
            job.SetOutputValueClass(typeof(BytesWritable));
            job.SetInputFormatClass(typeof(RandomWriter.RandomInputFormat));
            job.SetMapperClass(typeof(RandomWriter.RandomMapper));
            job.SetReducerClass(typeof(Reducer));
            job.SetOutputFormatClass(typeof(SequenceFileOutputFormat));
            System.Console.Out.WriteLine("Running " + numMaps + " maps.");
            // reducer NONE
            job.SetNumReduceTasks(0);
            DateTime startTime = new DateTime();

            System.Console.Out.WriteLine("Job started: " + startTime);
            int      ret     = job.WaitForCompletion(true) ? 0 : 1;
            DateTime endTime = new DateTime();

            System.Console.Out.WriteLine("Job ended: " + endTime);
            System.Console.Out.WriteLine("The job took " + (endTime.GetTime() - startTime.GetTime
                                                                ()) / 1000 + " seconds.");
            return(ret);
        }
Esempio n. 11
0
 internal static int PrintUsage()
 {
     System.Console.Out.WriteLine("sampler -r <reduces>\n" + "      [-inFormat <input format class>]\n"
                                  + "      [-keyClass <map input & output key class>]\n" + "      [-splitRandom <double pcnt> <numSamples> <maxsplits> | "
                                  + "             // Sample from random splits at random (general)\n" + "       -splitSample <numSamples> <maxsplits> | "
                                  + "             // Sample from first records in splits (random data)\n" + "       -splitInterval <double pcnt> <maxsplits>]"
                                  + "             // Sample from splits at intervals (sorted data)");
     System.Console.Out.WriteLine("Default sampler: -splitRandom 0.1 10000 10");
     ToolRunner.PrintGenericCommandUsage(System.Console.Out);
     return(-1);
 }
Esempio n. 12
0
 private int PrintUsage(string error)
 {
     if (error != null)
     {
         System.Console.Error.WriteLine("ERROR: " + error);
     }
     System.Console.Error.WriteLine("SleepJob [-m numMapper] [-r numReducer]" + " [-mt mapSleepTime (msec)] [-rt reduceSleepTime (msec)]"
                                    + " [-recordt recordSleepTime (msec)]");
     ToolRunner.PrintGenericCommandUsage(System.Console.Error);
     return(2);
 }
Esempio n. 13
0
 protected internal virtual void PrintUsage(TextWriter errOut)
 {
     errOut.WriteLine(GetUsageString());
     foreach (KeyValuePair <string, HAAdmin.UsageInfo> e in Usage)
     {
         string            cmd   = e.Key;
         HAAdmin.UsageInfo usage = e.Value;
         errOut.WriteLine("    [" + cmd + " " + usage.args + "]");
     }
     errOut.WriteLine();
     ToolRunner.PrintGenericCommandUsage(errOut);
 }
Esempio n. 14
0
        /// <summary>Parse arguments and then runs a map/reduce job.</summary>
        /// <returns>a non-zero value if there is an error. Otherwise, return 0.</returns>
        /// <exception cref="System.IO.IOException"/>
        public virtual int Run(string[] args)
        {
            if (args.Length != 4)
            {
                System.Console.Error.WriteLine("Usage: java " + GetType().FullName + " <startDigit> <nDigits> <nMaps> <workingDir>"
                                               );
                ToolRunner.PrintGenericCommandUsage(System.Console.Error);
                return(-1);
            }
            int    startDigit = System.Convert.ToInt32(args[0]);
            int    nDigits    = System.Convert.ToInt32(args[1]);
            int    nMaps      = System.Convert.ToInt32(args[2]);
            string workingDir = args[3];

            if (startDigit <= 0)
            {
                throw new ArgumentException("startDigit = " + startDigit + " <= 0");
            }
            else
            {
                if (nDigits <= 0)
                {
                    throw new ArgumentException("nDigits = " + nDigits + " <= 0");
                }
                else
                {
                    if (nDigits % BbpHexDigits != 0)
                    {
                        throw new ArgumentException("nDigits = " + nDigits + " is not a multiple of " + BbpHexDigits
                                                    );
                    }
                    else
                    {
                        if (nDigits - 1L + startDigit > ImplementationLimit + BbpHexDigits)
                        {
                            throw new NotSupportedException("nDigits - 1 + startDigit = " + (nDigits - 1L + startDigit
                                                                                             ) + " > IMPLEMENTATION_LIMIT + BBP_HEX_DIGITS," + ", where IMPLEMENTATION_LIMIT="
                                                            + ImplementationLimit + "and BBP_HEX_DIGITS=" + BbpHexDigits);
                        }
                        else
                        {
                            if (nMaps <= 0)
                            {
                                throw new ArgumentException("nMaps = " + nMaps + " <= 0");
                            }
                        }
                    }
                }
            }
            Compute(startDigit, nDigits, nMaps, workingDir, GetConf(), System.Console.Out);
            return(0);
        }
Esempio n. 15
0
 internal static int PrintUsage()
 {
     ToolRunner.PrintGenericCommandUsage(System.Console.Out);
     System.Console.Out.WriteLine("Usage: Task list:           -[no]r -[no]w\n" + "       Format:              -[no]seq -[no]txt\n"
                                  + "       CompressionCodec:    -[no]zip -[no]pln\n" + "       CompressionType:     -[no]blk -[no]rec\n"
                                  + "       Required:            -dir <working dir>\n" + "All valid combinations are implicitly enabled, unless an option is enabled\n"
                                  + "explicitly. For example, specifying \"-zip\", excludes -pln,\n" + "unless they are also explicitly included, as in \"-pln -zip\"\n"
                                  + "Note that CompressionType params only apply to SequenceFiles\n\n" + "Useful options to set:\n"
                                  + "-D fs.defaultFS=\"file:///\" \\\n" + "-D fs.file.impl=org.apache.hadoop.fs.RawLocalFileSystem \\\n"
                                  + "-D filebench.file.bytes=$((10*1024*1024*1024)) \\\n" + "-D filebench.key.words=5 \\\n"
                                  + "-D filebench.val.words=20\n");
     return(-1);
 }
Esempio n. 16
0
        /* Extracts matching regexs from input files and counts them. */
        // singleton
        /// <exception cref="System.Exception"/>
        public virtual int Run(string[] args)
        {
            if (args.Length < 3)
            {
                System.Console.Out.WriteLine("Grep <inDir> <outDir> <regex> [<group>]");
                ToolRunner.PrintGenericCommandUsage(System.Console.Out);
                return(2);
            }
            Path tempDir = new Path("grep-temp-" + Sharpen.Extensions.ToString(new Random().Next
                                                                                   (int.MaxValue)));
            Configuration conf = GetConf();

            conf.Set(RegexMapper.Pattern, args[2]);
            if (args.Length == 4)
            {
                conf.Set(RegexMapper.Group, args[3]);
            }
            Job grepJob = Job.GetInstance(conf);

            try
            {
                grepJob.SetJobName("grep-search");
                grepJob.SetJarByClass(typeof(Org.Apache.Hadoop.Examples.Grep));
                FileInputFormat.SetInputPaths(grepJob, args[0]);
                grepJob.SetMapperClass(typeof(RegexMapper));
                grepJob.SetCombinerClass(typeof(LongSumReducer));
                grepJob.SetReducerClass(typeof(LongSumReducer));
                FileOutputFormat.SetOutputPath(grepJob, tempDir);
                grepJob.SetOutputFormatClass(typeof(SequenceFileOutputFormat));
                grepJob.SetOutputKeyClass(typeof(Text));
                grepJob.SetOutputValueClass(typeof(LongWritable));
                grepJob.WaitForCompletion(true);
                Job sortJob = Job.GetInstance(conf);
                sortJob.SetJobName("grep-sort");
                sortJob.SetJarByClass(typeof(Org.Apache.Hadoop.Examples.Grep));
                FileInputFormat.SetInputPaths(sortJob, tempDir);
                sortJob.SetInputFormatClass(typeof(SequenceFileInputFormat));
                sortJob.SetMapperClass(typeof(InverseMapper));
                sortJob.SetNumReduceTasks(1);
                // write a single file
                FileOutputFormat.SetOutputPath(sortJob, new Path(args[1]));
                sortJob.SetSortComparatorClass(typeof(LongWritable.DecreasingComparator));
                // sort by decreasing freq
                sortJob.WaitForCompletion(true);
            }
            finally
            {
                FileSystem.Get(conf).Delete(tempDir, true);
            }
            return(0);
        }
Esempio n. 17
0
 /// <summary>Displays format of commands.</summary>
 /// <param name="cmd">The command that is being executed.</param>
 private static void PrintUsage(string cmd)
 {
     if ("-runCleanerTask".Equals(cmd))
     {
         System.Console.Error.WriteLine("Usage: yarn scmadmin" + " [-runCleanerTask]");
     }
     else
     {
         System.Console.Error.WriteLine("Usage: yarn scmadmin");
         System.Console.Error.WriteLine("           [-runCleanerTask]");
         System.Console.Error.WriteLine("           [-help [cmd]]");
         System.Console.Error.WriteLine();
         ToolRunner.PrintGenericCommandUsage(System.Console.Error);
     }
 }
Esempio n. 18
0
        /// <summary>Displays format of commands.</summary>
        /// <param name="cmd">The command that is being executed.</param>
        private static void PrintUsage(string cmd, bool isHAEnabled)
        {
            StringBuilder usageBuilder = new StringBuilder();

            if (AdminUsage.Contains(cmd) || Usage.Contains(cmd))
            {
                BuildIndividualUsageMsg(cmd, usageBuilder);
            }
            else
            {
                BuildUsageMsg(usageBuilder, isHAEnabled);
            }
            System.Console.Error.WriteLine(usageBuilder);
            ToolRunner.PrintGenericCommandUsage(System.Console.Error);
        }
Esempio n. 19
0
        /// <exception cref="System.Exception"/>
        public virtual int Run(string[] args)
        {
            if (args.Length < 1)
            {
                System.Console.Error.WriteLine("FailJob " + " (-failMappers|-failReducers)");
                ToolRunner.PrintGenericCommandUsage(System.Console.Error);
                return(2);
            }
            bool failMappers  = false;
            bool failReducers = false;

            for (int i = 0; i < args.Length; i++)
            {
                if (args[i].Equals("-failMappers"))
                {
                    failMappers = true;
                }
                else
                {
                    if (args[i].Equals("-failReducers"))
                    {
                        failReducers = true;
                    }
                }
            }
            if (!(failMappers ^ failReducers))
            {
                System.Console.Error.WriteLine("Exactly one of -failMappers or -failReducers must be specified."
                                               );
                return(3);
            }
            // Write a file with one line per mapper.
            FileSystem fs       = FileSystem.Get(GetConf());
            Path       inputDir = new Path(typeof(FailJob).Name + "_in");

            fs.Mkdirs(inputDir);
            for (int i_1 = 0; i_1 < GetConf().GetInt("mapred.map.tasks", 1); ++i_1)
            {
                BufferedWriter w = new BufferedWriter(new OutputStreamWriter(fs.Create(new Path(inputDir
                                                                                                , Sharpen.Extensions.ToString(i_1)))));
                w.Write(Sharpen.Extensions.ToString(i_1) + "\n");
                w.Close();
            }
            Job job = CreateJob(failMappers, failReducers, inputDir);

            return(job.WaitForCompletion(true) ? 0 : 1);
        }
Esempio n. 20
0
 private void PrintInfo(TextWriter @out, string cmd, bool showHelp)
 {
     if (cmd != null)
     {
         // display help or usage for one command
         Command instance = commandFactory.GetInstance("-" + cmd);
         if (instance == null)
         {
             throw new FsShell.UnknownCommandException(cmd);
         }
         if (showHelp)
         {
             PrintInstanceHelp(@out, instance);
         }
         else
         {
             PrintInstanceUsage(@out, instance);
         }
     }
     else
     {
         // display help or usage for all commands
         @out.WriteLine(usagePrefix);
         // display list of short usages
         AList <Command> instances = new AList <Command>();
         foreach (string name in commandFactory.GetNames())
         {
             Command instance = commandFactory.GetInstance(name);
             if (!instance.IsDeprecated())
             {
                 @out.WriteLine("\t[" + instance.GetUsage() + "]");
                 instances.AddItem(instance);
             }
         }
         // display long descriptions for each command
         if (showHelp)
         {
             foreach (Command instance in instances)
             {
                 @out.WriteLine();
                 PrintInstanceHelp(@out, instance);
             }
         }
         @out.WriteLine();
         ToolRunner.PrintGenericCommandUsage(@out);
     }
 }
Esempio n. 21
0
        private void DisplayUsage(string cmd)
        {
            string prefix = "Usage: JobQueueClient ";

            if ("-queueinfo".Equals(cmd))
            {
                System.Console.Error.WriteLine(prefix + "[" + cmd + "<job-queue-name> [-showJobs]]"
                                               );
            }
            else
            {
                System.Console.Error.Printf(prefix + "<command> <args>%n");
                System.Console.Error.Printf("\t[-list]%n");
                System.Console.Error.Printf("\t[-info <job-queue-name> [-showJobs]]%n");
                System.Console.Error.Printf("\t[-showacls] %n%n");
                ToolRunner.PrintGenericCommandUsage(System.Console.Out);
            }
        }
Esempio n. 22
0
        private static void PrintHelp(string cmd, bool isHAEnabled)
        {
            StringBuilder summary = new StringBuilder();

            summary.Append("rmadmin is the command to execute YARN administrative " + "commands.\n"
                           );
            summary.Append("The full syntax is: \n\n" + "yarn rmadmin" + " [-refreshQueues]"
                           + " [-refreshNodes]" + " [-refreshSuperUserGroupsConfiguration]" + " [-refreshUserToGroupsMappings]"
                           + " [-refreshAdminAcls]" + " [-refreshServiceAcl]" + " [-getGroup [username]]"
                           + " [[-addToClusterNodeLabels [label1,label2,label3]]" + " [-removeFromClusterNodeLabels [label1,label2,label3]]"
                           + " [-replaceLabelsOnNode [node1[:port]=label1,label2 node2[:port]=label1]" + " [-directlyAccessNodeLabelStore]]"
                           );
            if (isHAEnabled)
            {
                AppendHAUsage(summary);
            }
            summary.Append(" [-help [cmd]]");
            summary.Append("\n");
            StringBuilder helpBuilder = new StringBuilder();

            System.Console.Out.WriteLine(summary);
            foreach (string cmdKey in AdminUsage.Keys)
            {
                BuildHelpMsg(cmdKey, helpBuilder);
                helpBuilder.Append("\n");
            }
            if (isHAEnabled)
            {
                foreach (string cmdKey_1 in Usage.Keys)
                {
                    if (!cmdKey_1.Equals("-help"))
                    {
                        BuildHelpMsg(cmdKey_1, helpBuilder);
                        helpBuilder.Append("\n");
                    }
                }
            }
            helpBuilder.Append("   -help [cmd]: Displays help for the given command or all commands"
                               + " if none is specified.");
            System.Console.Out.WriteLine(helpBuilder);
            System.Console.Out.WriteLine();
            ToolRunner.PrintGenericCommandUsage(System.Console.Out);
        }
Esempio n. 23
0
        /// <summary>Parse arguments and then runs a map/reduce job.</summary>
        /// <remarks>
        /// Parse arguments and then runs a map/reduce job.
        /// Print output in standard out.
        /// </remarks>
        /// <returns>a non-zero if there is an error.  Otherwise, return 0.</returns>
        /// <exception cref="System.Exception"/>
        public virtual int Run(string[] args)
        {
            if (args.Length != 2)
            {
                System.Console.Error.WriteLine("Usage: " + GetType().FullName + " <nMaps> <nSamples>"
                                               );
                ToolRunner.PrintGenericCommandUsage(System.Console.Error);
                return(2);
            }
            int  nMaps    = System.Convert.ToInt32(args[0]);
            long nSamples = long.Parse(args[1]);
            long now      = Runtime.CurrentTimeMillis();
            int  rand     = new Random().Next(int.MaxValue);
            Path tmpDir   = new Path(TmpDirPrefix + "_" + now + "_" + rand);

            System.Console.Out.WriteLine("Number of Maps  = " + nMaps);
            System.Console.Out.WriteLine("Samples per Map = " + nSamples);
            System.Console.Out.WriteLine("Estimated value of Pi is " + EstimatePi(nMaps, nSamples
                                                                                  , tmpDir, GetConf()));
            return(0);
        }
Esempio n. 24
0
 // reducer will print the results
 /// <summary>Parse the command line arguments and initialize the data.</summary>
 /// <remarks>
 /// Parse the command line arguments and initialize the data.
 /// Only parse the first arg: -mr <numMapTasks> <mrOutDir> (MUST be first three Args)
 /// The rest are parsed by the Parent LoadGenerator
 /// </remarks>
 /// <exception cref="System.IO.IOException"/>
 private int ParseArgsMR(string[] args)
 {
     try
     {
         if (args.Length >= 3 && args[0].Equals("-mr"))
         {
             numMapTasks = System.Convert.ToInt32(args[1]);
             mrOutDir    = args[2];
             if (mrOutDir.StartsWith("-"))
             {
                 System.Console.Error.WriteLine("Missing output file parameter, instead got: " + mrOutDir
                                                );
                 System.Console.Error.WriteLine(Usage);
                 return(-1);
             }
         }
         else
         {
             System.Console.Error.WriteLine(Usage);
             ToolRunner.PrintGenericCommandUsage(System.Console.Error);
             return(-1);
         }
         string[] strippedArgs = new string[args.Length - 3];
         for (int i = 0; i < strippedArgs.Length; i++)
         {
             strippedArgs[i] = args[i + 3];
         }
         base.ParseArgs(true, strippedArgs);
     }
     catch (FormatException e)
     {
         // Parse normal LoadGenerator args
         System.Console.Error.WriteLine("Illegal parameter: " + e.GetLocalizedMessage());
         System.Console.Error.WriteLine(Usage);
         return(-1);
     }
     return(0);
 }
Esempio n. 25
0
        /// <summary>Print help.</summary>
        private void PrintHelp()
        {
            string summary = "Usage: bin/hdfs oev [OPTIONS] -i INPUT_FILE -o OUTPUT_FILE\n" +
                             "Offline edits viewer\n" + "Parse a Hadoop edits log file INPUT_FILE and save results\n"
                             + "in OUTPUT_FILE.\n" + "Required command line arguments:\n" + "-i,--inputFile <arg>   edits file to process, xml (case\n"
                             + "                       insensitive) extension means XML format,\n" + "                       any other filename means binary format\n"
                             + "-o,--outputFile <arg>  Name of output file. If the specified\n" + "                       file exists, it will be overwritten,\n"
                             + "                       format of the file is determined\n" + "                       by -p option\n"
                             + "\n" + "Optional command line arguments:\n" + "-p,--processor <arg>   Select which type of processor to apply\n"
                             + "                       against image file, currently supported\n" + "                       processors are: binary (native binary format\n"
                             + "                       that Hadoop uses), xml (default, XML\n" + "                       format), stats (prints statistics about\n"
                             + "                       edits file)\n" + "-h,--help              Display usage information and exit\n"
                             + "-f,--fix-txids         Renumber the transaction IDs in the input,\n" + "                       so that there are no gaps or invalid "
                             + "                       transaction IDs.\n" + "-r,--recover           When reading binary edit logs, use recovery \n"
                             + "                       mode.  This will give you the chance to skip \n" + "                       corrupt parts of the edit log.\n"
                             + "-v,--verbose           More verbose output, prints the input and\n" + "                       output filenames, for processors that write\n"
                             + "                       to a file, also output to screen. On large\n" + "                       image files this will dramatically increase\n"
                             + "                       processing time (default is false).\n";

            System.Console.Out.WriteLine(summary);
            System.Console.Out.WriteLine();
            ToolRunner.PrintGenericCommandUsage(System.Console.Out);
        }
Esempio n. 26
0
 /// <summary>Parse the command line arguments and initialize the data</summary>
 private int Init(string[] args)
 {
     try
     {
         // initialize file system handle
         fc = FileContext.GetFileContext(GetConf());
     }
     catch (IOException ioe)
     {
         System.Console.Error.WriteLine("Can not initialize the file system: " + ioe.GetLocalizedMessage
                                            ());
         return(-1);
     }
     for (int i = 0; i < args.Length; i++)
     {
         // parse command line
         if (args[i].Equals("-root"))
         {
             root = new Path(args[++i]);
         }
         else
         {
             if (args[i].Equals("-inDir"))
             {
                 inDir = new FilePath(args[++i]);
             }
             else
             {
                 System.Console.Error.WriteLine(Usage);
                 ToolRunner.PrintGenericCommandUsage(System.Console.Error);
                 System.Environment.Exit(-1);
             }
         }
     }
     return(0);
 }
Esempio n. 27
0
        /// <summary>Display usage of the command-line tool and terminate execution.</summary>
        private void DisplayUsage(string cmd)
        {
            string prefix            = "Usage: CLI ";
            string jobPriorityValues = GetJobPriorityNames();
            string taskStates        = "running, completed";

            if ("-submit".Equals(cmd))
            {
                System.Console.Error.WriteLine(prefix + "[" + cmd + " <job-file>]");
            }
            else
            {
                if ("-status".Equals(cmd) || "-kill".Equals(cmd))
                {
                    System.Console.Error.WriteLine(prefix + "[" + cmd + " <job-id>]");
                }
                else
                {
                    if ("-counter".Equals(cmd))
                    {
                        System.Console.Error.WriteLine(prefix + "[" + cmd + " <job-id> <group-name> <counter-name>]"
                                                       );
                    }
                    else
                    {
                        if ("-events".Equals(cmd))
                        {
                            System.Console.Error.WriteLine(prefix + "[" + cmd + " <job-id> <from-event-#> <#-of-events>]. Event #s start from 1."
                                                           );
                        }
                        else
                        {
                            if ("-history".Equals(cmd))
                            {
                                System.Console.Error.WriteLine(prefix + "[" + cmd + " <jobHistoryFile>]");
                            }
                            else
                            {
                                if ("-list".Equals(cmd))
                                {
                                    System.Console.Error.WriteLine(prefix + "[" + cmd + " [all]]");
                                }
                                else
                                {
                                    if ("-kill-task".Equals(cmd) || "-fail-task".Equals(cmd))
                                    {
                                        System.Console.Error.WriteLine(prefix + "[" + cmd + " <task-attempt-id>]");
                                    }
                                    else
                                    {
                                        if ("-set-priority".Equals(cmd))
                                        {
                                            System.Console.Error.WriteLine(prefix + "[" + cmd + " <job-id> <priority>]. " + "Valid values for priorities are: "
                                                                           + jobPriorityValues);
                                        }
                                        else
                                        {
                                            if ("-list-active-trackers".Equals(cmd))
                                            {
                                                System.Console.Error.WriteLine(prefix + "[" + cmd + "]");
                                            }
                                            else
                                            {
                                                if ("-list-blacklisted-trackers".Equals(cmd))
                                                {
                                                    System.Console.Error.WriteLine(prefix + "[" + cmd + "]");
                                                }
                                                else
                                                {
                                                    if ("-list-attempt-ids".Equals(cmd))
                                                    {
                                                        System.Console.Error.WriteLine(prefix + "[" + cmd + " <job-id> <task-type> <task-state>]. "
                                                                                       + "Valid values for <task-type> are " + GetTaskTypes() + ". " + "Valid values for <task-state> are "
                                                                                       + taskStates);
                                                    }
                                                    else
                                                    {
                                                        if ("-logs".Equals(cmd))
                                                        {
                                                            System.Console.Error.WriteLine(prefix + "[" + cmd + " <job-id> <task-attempt-id>]. "
                                                                                           + " <task-attempt-id> is optional to get task attempt logs.");
                                                        }
                                                        else
                                                        {
                                                            System.Console.Error.Printf(prefix + "<command> <args>%n");
                                                            System.Console.Error.Printf("\t[-submit <job-file>]%n");
                                                            System.Console.Error.Printf("\t[-status <job-id>]%n");
                                                            System.Console.Error.Printf("\t[-counter <job-id> <group-name> <counter-name>]%n"
                                                                                        );
                                                            System.Console.Error.Printf("\t[-kill <job-id>]%n");
                                                            System.Console.Error.Printf("\t[-set-priority <job-id> <priority>]. " + "Valid values for priorities are: "
                                                                                        + jobPriorityValues + "%n");
                                                            System.Console.Error.Printf("\t[-events <job-id> <from-event-#> <#-of-events>]%n"
                                                                                        );
                                                            System.Console.Error.Printf("\t[-history <jobHistoryFile>]%n");
                                                            System.Console.Error.Printf("\t[-list [all]]%n");
                                                            System.Console.Error.Printf("\t[-list-active-trackers]%n");
                                                            System.Console.Error.Printf("\t[-list-blacklisted-trackers]%n");
                                                            System.Console.Error.WriteLine("\t[-list-attempt-ids <job-id> <task-type> " + "<task-state>]. "
                                                                                           + "Valid values for <task-type> are " + GetTaskTypes() + ". " + "Valid values for <task-state> are "
                                                                                           + taskStates);
                                                            System.Console.Error.Printf("\t[-kill-task <task-attempt-id>]%n");
                                                            System.Console.Error.Printf("\t[-fail-task <task-attempt-id>]%n");
                                                            System.Console.Error.Printf("\t[-logs <job-id> <task-attempt-id>]%n%n");
                                                            ToolRunner.PrintGenericCommandUsage(System.Console.Out);
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 28
0
 /// <summary>
 /// Parse the command line arguments and initialize the data
 /// <pre>
 /// % hadoop credential create alias [-provider providerPath]
 /// % hadoop credential list [-provider providerPath]
 /// % hadoop credential delete alias [-provider providerPath] [-f]
 /// </pre>
 /// </summary>
 /// <param name="args"/>
 /// <returns>0 if the argument(s) were recognized, 1 otherwise</returns>
 /// <exception cref="System.IO.IOException"/>
 protected internal virtual int Init(string[] args)
 {
     // no args should print the help message
     if (0 == args.Length)
     {
         PrintCredShellUsage();
         ToolRunner.PrintGenericCommandUsage(System.Console.Error);
         return(1);
     }
     for (int i = 0; i < args.Length; i++)
     {
         // parse command line
         if (args[i].Equals("create"))
         {
             if (i == args.Length - 1)
             {
                 PrintCredShellUsage();
                 return(1);
             }
             string alias = args[++i];
             command = new CredentialShell.CreateCommand(this, alias);
             if (alias.Equals("-help"))
             {
                 PrintCredShellUsage();
                 return(0);
             }
         }
         else
         {
             if (args[i].Equals("delete"))
             {
                 if (i == args.Length - 1)
                 {
                     PrintCredShellUsage();
                     return(1);
                 }
                 string alias = args[++i];
                 command = new CredentialShell.DeleteCommand(this, alias);
                 if (alias.Equals("-help"))
                 {
                     PrintCredShellUsage();
                     return(0);
                 }
             }
             else
             {
                 if (args[i].Equals("list"))
                 {
                     command = new CredentialShell.ListCommand(this);
                 }
                 else
                 {
                     if (args[i].Equals("-provider"))
                     {
                         if (i == args.Length - 1)
                         {
                             PrintCredShellUsage();
                             return(1);
                         }
                         userSuppliedProvider = true;
                         GetConf().Set(CredentialProviderFactory.CredentialProviderPath, args[++i]);
                     }
                     else
                     {
                         if (args[i].Equals("-f") || (args[i].Equals("-force")))
                         {
                             interactive = false;
                         }
                         else
                         {
                             if (args[i].Equals("-v") || (args[i].Equals("-value")))
                             {
                                 value = args[++i];
                             }
                             else
                             {
                                 if (args[i].Equals("-help"))
                                 {
                                     PrintCredShellUsage();
                                     return(0);
                                 }
                                 else
                                 {
                                     PrintCredShellUsage();
                                     ToolRunner.PrintGenericCommandUsage(System.Console.Error);
                                     return(1);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return(0);
 }
Esempio n. 29
0
 /// <summary>Parse the command line arguments and initialize the data</summary>
 /// <exception cref="System.IO.IOException"/>
 protected internal virtual int ParseArgs(bool runAsMapReduce, string[] args)
 {
     try
     {
         for (int i = 0; i < args.Length; i++)
         {
             // parse command line
             if (args[i].Equals("-scriptFile"))
             {
                 scriptFile = args[++i];
                 if (durations[0] > 0)
                 {
                     System.Console.Error.WriteLine("Can't specify elapsedTime and use script.");
                     return(-1);
                 }
             }
             else
             {
                 if (args[i].Equals("-readProbability"))
                 {
                     if (scriptFile != null)
                     {
                         System.Console.Error.WriteLine("Can't specify probabilities and use script.");
                         return(-1);
                     }
                     readProbs[0] = double.ParseDouble(args[++i]);
                     if (readProbs[0] < 0 || readProbs[0] > 1)
                     {
                         System.Console.Error.WriteLine("The read probability must be [0, 1]: " + readProbs
                                                        [0]);
                         return(-1);
                     }
                 }
                 else
                 {
                     if (args[i].Equals("-writeProbability"))
                     {
                         if (scriptFile != null)
                         {
                             System.Console.Error.WriteLine("Can't specify probabilities and use script.");
                             return(-1);
                         }
                         writeProbs[0] = double.ParseDouble(args[++i]);
                         if (writeProbs[0] < 0 || writeProbs[0] > 1)
                         {
                             System.Console.Error.WriteLine("The write probability must be [0, 1]: " + writeProbs
                                                            [0]);
                             return(-1);
                         }
                     }
                     else
                     {
                         if (args[i].Equals("-root"))
                         {
                             root = new Path(args[++i]);
                         }
                         else
                         {
                             if (args[i].Equals("-maxDelayBetweenOps"))
                             {
                                 maxDelayBetweenOps = System.Convert.ToInt32(args[++i]);
                             }
                             else
                             {
                                 // in milliseconds
                                 if (args[i].Equals("-numOfThreads"))
                                 {
                                     numOfThreads = System.Convert.ToInt32(args[++i]);
                                     if (numOfThreads <= 0)
                                     {
                                         System.Console.Error.WriteLine("Number of threads must be positive: " + numOfThreads
                                                                        );
                                         return(-1);
                                     }
                                 }
                                 else
                                 {
                                     if (args[i].Equals("-startTime"))
                                     {
                                         startTime = long.Parse(args[++i]);
                                     }
                                     else
                                     {
                                         if (args[i].Equals("-elapsedTime"))
                                         {
                                             if (scriptFile != null)
                                             {
                                                 System.Console.Error.WriteLine("Can't specify elapsedTime and use script.");
                                                 return(-1);
                                             }
                                             durations[0] = long.Parse(args[++i]);
                                         }
                                         else
                                         {
                                             if (args[i].Equals("-seed"))
                                             {
                                                 seed = long.Parse(args[++i]);
                                                 r    = new Random(seed);
                                             }
                                             else
                                             {
                                                 if (args[i].Equals("-flagFile"))
                                                 {
                                                     Log.Info("got flagFile:" + flagFile);
                                                     flagFile = new Path(args[++i]);
                                                 }
                                                 else
                                                 {
                                                     System.Console.Error.WriteLine(Usage);
                                                     ToolRunner.PrintGenericCommandUsage(System.Console.Error);
                                                     return(-1);
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     catch (FormatException e)
     {
         System.Console.Error.WriteLine("Illegal parameter: " + e.GetLocalizedMessage());
         System.Console.Error.WriteLine(Usage);
         return(-1);
     }
     // Load Script File if not MR; for MR scriptFile is loaded by Mapper
     if (!runAsMapReduce && scriptFile != null)
     {
         if (LoadScriptFile(scriptFile, true) == -1)
         {
             return(-1);
         }
     }
     for (int i_1 = 0; i_1 < readProbs.Length; i_1++)
     {
         if (readProbs[i_1] + writeProbs[i_1] < 0 || readProbs[i_1] + writeProbs[i_1] > 1)
         {
             System.Console.Error.WriteLine("The sum of read probability and write probability must be [0, 1]: "
                                            + readProbs[i_1] + " " + writeProbs[i_1]);
             return(-1);
         }
     }
     return(0);
 }
Esempio n. 30
0
        /// <summary>
        /// Parse the command line arguments and initialize the data
        /// <pre>
        /// % hadoop key create keyName [-size size] [-cipher algorithm]
        /// [-provider providerPath]
        /// % hadoop key roll keyName [-provider providerPath]
        /// % hadoop key list [-provider providerPath]
        /// % hadoop key delete keyName [-provider providerPath] [-i]
        /// </pre>
        /// </summary>
        /// <param name="args">Command line arguments.</param>
        /// <returns>0 on success, 1 on failure.</returns>
        /// <exception cref="System.IO.IOException"/>
        private int Init(string[] args)
        {
            KeyProvider.Options          options    = KeyProvider.Options(GetConf());
            IDictionary <string, string> attributes = new Dictionary <string, string>();

            for (int i = 0; i < args.Length; i++)
            {
                // parse command line
                bool moreTokens = (i < args.Length - 1);
                if (args[i].Equals("create"))
                {
                    string keyName = "-help";
                    if (moreTokens)
                    {
                        keyName = args[++i];
                    }
                    command = new KeyShell.CreateCommand(this, keyName, options);
                    if ("-help".Equals(keyName))
                    {
                        PrintKeyShellUsage();
                        return(1);
                    }
                }
                else
                {
                    if (args[i].Equals("delete"))
                    {
                        string keyName = "-help";
                        if (moreTokens)
                        {
                            keyName = args[++i];
                        }
                        command = new KeyShell.DeleteCommand(this, keyName);
                        if ("-help".Equals(keyName))
                        {
                            PrintKeyShellUsage();
                            return(1);
                        }
                    }
                    else
                    {
                        if (args[i].Equals("roll"))
                        {
                            string keyName = "-help";
                            if (moreTokens)
                            {
                                keyName = args[++i];
                            }
                            command = new KeyShell.RollCommand(this, keyName);
                            if ("-help".Equals(keyName))
                            {
                                PrintKeyShellUsage();
                                return(1);
                            }
                        }
                        else
                        {
                            if ("list".Equals(args[i]))
                            {
                                command = new KeyShell.ListCommand(this);
                            }
                            else
                            {
                                if ("-size".Equals(args[i]) && moreTokens)
                                {
                                    options.SetBitLength(System.Convert.ToInt32(args[++i]));
                                }
                                else
                                {
                                    if ("-cipher".Equals(args[i]) && moreTokens)
                                    {
                                        options.SetCipher(args[++i]);
                                    }
                                    else
                                    {
                                        if ("-description".Equals(args[i]) && moreTokens)
                                        {
                                            options.SetDescription(args[++i]);
                                        }
                                        else
                                        {
                                            if ("-attr".Equals(args[i]) && moreTokens)
                                            {
                                                string[] attrval = args[++i].Split("=", 2);
                                                string   attr    = attrval[0].Trim();
                                                string   val     = attrval[1].Trim();
                                                if (attr.IsEmpty() || val.IsEmpty())
                                                {
                                                    @out.WriteLine("\nAttributes must be in attribute=value form, " + "or quoted\nlike \"attribute = value\"\n"
                                                                   );
                                                    PrintKeyShellUsage();
                                                    return(1);
                                                }
                                                if (attributes.Contains(attr))
                                                {
                                                    @out.WriteLine("\nEach attribute must correspond to only one value:\n" + "atttribute \""
                                                                   + attr + "\" was repeated\n");
                                                    PrintKeyShellUsage();
                                                    return(1);
                                                }
                                                attributes[attr] = val;
                                            }
                                            else
                                            {
                                                if ("-provider".Equals(args[i]) && moreTokens)
                                                {
                                                    userSuppliedProvider = true;
                                                    GetConf().Set(KeyProviderFactory.KeyProviderPath, args[++i]);
                                                }
                                                else
                                                {
                                                    if ("-metadata".Equals(args[i]))
                                                    {
                                                        GetConf().SetBoolean(ListMetadata, true);
                                                    }
                                                    else
                                                    {
                                                        if ("-f".Equals(args[i]) || ("-force".Equals(args[i])))
                                                        {
                                                            interactive = false;
                                                        }
                                                        else
                                                        {
                                                            if ("-help".Equals(args[i]))
                                                            {
                                                                PrintKeyShellUsage();
                                                                return(1);
                                                            }
                                                            else
                                                            {
                                                                PrintKeyShellUsage();
                                                                ToolRunner.PrintGenericCommandUsage(System.Console.Error);
                                                                return(1);
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if (command == null)
            {
                PrintKeyShellUsage();
                return(1);
            }
            if (!attributes.IsEmpty())
            {
                options.SetAttributes(attributes);
            }
            return(0);
        }