Org.apache.hadoop.util.GenericOptionsParser Mark
The main parsing command line to the RM parameters, there is no good analysis of the use of the Hadoop CLI tool, the command tool parameters set to the Yarnconfiguration
/**
* Modify configuration according user-specified generic options
* @param conf Configuration to be modified
* @param line user-specified generic options
*/
private void Processgeneraloptions (Configuration conf,
CommandLine line) throws IOException {
if (line.hasoption ("FS")) {
Filesystem.setdefaulturi (conf, Line.getoptionvalue ("FS"));
}
if (line.hasoption ("JT")) {
String OptionValue = Line.getoptionvalue ("JT");
if (Optionvalue.equalsignorecase ("local")) {
Conf.set ("Mapreduce.framework.name", OptionValue);
}
Conf.set ("Yarn.resourcemanager.address", OptionValue,
"FROM-JT command line option");
}
if (line.hasoption ("conf")) {
String[] values = line.getoptionvalues ("conf");
for (String value:values) {
Conf.addresource (new Path (value));
}
}
if (line.hasoption (' D ')) {
String[] Property = Line.getoptionvalues (' D ');
for (String Prop:property) {
string[] Keyval = prop.split ("=", 2);
if (keyval.length = = 2) {
Conf.set (Keyval[0], keyval[1], "from command line");
}
}
}
if (Line.hasoption ("Libjars")) {
Conf.set ("Tmpjars",
Validatefiles (Line.getoptionvalue ("Libjars"), conf),
"From-libjars command line option");
Setting Libjars in Client Classpath
url[] Libjars = getlibjars (conf);
if (libjars!=null && libjars.length>0) {
Conf.setclassloader (New URLClassLoader (Libjars, Conf.getclassloader ()));
Thread.CurrentThread (). Setcontextclassloader (
New URLClassLoader (Libjars,
Thread.CurrentThread (). Getcontextclassloader ());
}
}
if (line.hasoption ("files")) {
Conf.set ("Tmpfiles",
Validatefiles (Line.getoptionvalue ("Files"), conf),
"From-files command line option");
}
if (line.hasoption ("Archives")) {
Conf.set ("Tmparchives",
Validatefiles (Line.getoptionvalue ("Archives"), conf),
"From-archives command line option");
}
Conf.setboolean ("mapreduce.client.genericoptionsparser.used", true);
Tokensfile
if (line.hasoption ("Tokencachefile")) {
String fileName = Line.getoptionvalue ("Tokencachefile");
Check if the local file exists
FileSystem Localfs = filesystem.getlocal (conf);
Path p = localfs.makequalified (New path (fileName));
if (!localfs.exists (p)) {
throw new FileNotFoundException ("File" +filename+ "does not exist.");
}
if (log.isdebugenabled ()) {
Log.debug ("Setting conf tokensfile:" + fileName);
}
Usergroupinformation.getcurrentuser (). Addcredentials (
Credentials.readtokenstoragefile (P, conf));
Conf.set ("Mapreduce.job.credentials.binary", p.tostring (),
"From-tokencachefile command line option");
}
}
ResourceManager command-line parsing section