Package ml.shifu.guagua.hadoop.io
Class GuaguaOptionsParser
- java.lang.Object
-
- ml.shifu.guagua.hadoop.io.GuaguaOptionsParser
-
public class GuaguaOptionsParser extends Object
Copy from hadoop GenericOptionsParser and extend it.Add other parameter support like -w, -m ...
- See Also:
Tool,ToolRunner
-
-
Constructor Summary
Constructors Constructor Description GuaguaOptionsParser(String[] args)Create an options parser to parse the args.GuaguaOptionsParser(org.apache.commons.cli.Options opts, String[] args)Create an options parser with the given options to parse the args.GuaguaOptionsParser(org.apache.hadoop.conf.Configuration conf, String[] args)Create aGuaguaOptionsParserto parse only the generic Hadoop arguments.GuaguaOptionsParser(org.apache.hadoop.conf.Configuration conf, org.apache.commons.cli.Options options, String[] args)Create aGuaguaOptionsParserto parse given options as well as generic Hadoop options.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apache.commons.cli.CommandLinegetCommandLine()Returns the commons-cliCommandLineobject to process the parsed arguments.org.apache.hadoop.conf.ConfigurationgetConfiguration()Get the modified configurationstatic URL[]getLibJars(org.apache.hadoop.conf.Configuration conf)If libjars are set in the conf, parse the libjars.String[]getRemainingArgs()Returns an array of Strings containing only application-specific arguments.static voidprintGenericCommandUsage(PrintStream out)Print the usage message for generic command-line options supported.
-
-
-
Constructor Detail
-
GuaguaOptionsParser
public GuaguaOptionsParser(org.apache.commons.cli.Options opts, String[] args) throws IOExceptionCreate an options parser with the given options to parse the args.- Parameters:
opts- the optionsargs- the command line arguments- Throws:
IOException
-
GuaguaOptionsParser
public GuaguaOptionsParser(String[] args) throws IOException
Create an options parser to parse the args.- Parameters:
args- the command line arguments- Throws:
IOException
-
GuaguaOptionsParser
public GuaguaOptionsParser(org.apache.hadoop.conf.Configuration conf, String[] args) throws IOExceptionCreate aGuaguaOptionsParserto parse only the generic Hadoop arguments. The array of string arguments other than the generic arguments can be obtained bygetRemainingArgs().- Parameters:
conf- theConfigurationto modify.args- command-line arguments.- Throws:
IOException
-
GuaguaOptionsParser
public GuaguaOptionsParser(org.apache.hadoop.conf.Configuration conf, org.apache.commons.cli.Options options, String[] args) throws IOExceptionCreate aGuaguaOptionsParserto parse given options as well as generic Hadoop options. The resultingCommandLineobject can be obtained bygetCommandLine().- Parameters:
conf- the configuration to modifyoptions- options built by the callerargs- User-specified arguments- Throws:
IOException
-
-
Method Detail
-
getRemainingArgs
public String[] getRemainingArgs()
Returns an array of Strings containing only application-specific arguments.- Returns:
- array of
Strings containing the un-parsed arguments or empty array if commandLine was not defined.
-
getConfiguration
public org.apache.hadoop.conf.Configuration getConfiguration()
Get the modified configuration- Returns:
- the configuration that has the modified parameters.
-
getCommandLine
public org.apache.commons.cli.CommandLine getCommandLine()
Returns the commons-cliCommandLineobject to process the parsed arguments. Note: If the object is created withGuaguaOptionsParser(Configuration, String[]), then returned object will only contain parsed generic options.- Returns:
CommandLinerepresenting list of arguments parsed against Options descriptor.
-
getLibJars
public static URL[] getLibJars(org.apache.hadoop.conf.Configuration conf) throws IOException
If libjars are set in the conf, parse the libjars.- Throws:
IOException
-
printGenericCommandUsage
public static void printGenericCommandUsage(PrintStream out)
Print the usage message for generic command-line options supported.- Parameters:
out- stream to print the usage message to.
-
-