/** * Set the configuration based on the service id given in the argv * @param argv argument list * @param conf configuration * @return argument list without service name argument */ public static String[] setGenericConf(String[] argv, Configuration conf) { String[] serviceId = new String[1]; serviceId[0] = ""; String[] filteredArgv = getServiceName(argv, serviceId); if (!serviceId[0].equals("")) { if (!NameNode.validateServiceName(conf, serviceId[0])) { throw new IllegalArgumentException("Service Id doesn't match the config"); } setGenericConf(conf, serviceId[0], NameNode.NAMESERVICE_SPECIFIC_KEYS); NameNode.setupDefaultURI(conf); } return filteredArgv; }
public static NameNode createNameNode(String argv[], Configuration conf) throws IOException { if (conf == null) conf = new Configuration(); StartupOptionAndService startOpt = parseArguments(argv); if (startOpt == null) { printUsage(); return null; } if (!validateServiceName(conf, startOpt.serviceName)) { return null; } initializeGenericKeys(conf, startOpt.serviceName); setupDefaultURI(conf); setStartupOption(conf, startOpt.startupOption); switch (startOpt.startupOption) { case FORMAT: boolean aborted = format(conf, true); System.exit(aborted ? 1 : 0); case FINALIZE: aborted = finalize(conf, true); System.exit(aborted ? 1 : 0); default: } NameNode namenode = new NameNode(conf, startOpt.failOnTxIdMismatch); namenode.nameserviceId = startOpt.serviceName; return namenode; }