@Override public StandaloneJobClusterConfiguration createResult(@Nonnull CommandLine commandLine) { final String configDir = commandLine.getOptionValue(CONFIG_DIR_OPTION.getOpt()); final Properties dynamicProperties = commandLine.getOptionProperties(DYNAMIC_PROPERTY_OPTION.getOpt()); final String restPortString = commandLine.getOptionValue(REST_PORT_OPTION.getOpt(), "-1"); final int restPort = Integer.parseInt(restPortString); final String hostname = commandLine.getOptionValue(HOST_OPTION.getOpt()); final String jobClassName = commandLine.getOptionValue(JOB_CLASS_NAME_OPTION.getOpt()); final SavepointRestoreSettings savepointRestoreSettings = CliFrontendParser.createSavepointRestoreSettings(commandLine); return new StandaloneJobClusterConfiguration( configDir, dynamicProperties, commandLine.getArgs(), hostname, restPort, jobClassName, savepointRestoreSettings); } }
/** * Parse the command line arguments */ public boolean parse(String[] args) { try { commandLine = new GnuParser().parse(options, args); execString = commandLine.getOptionValue('e'); fileName = commandLine.getOptionValue('f'); main = commandLine.getOptionValue("main"); Properties p = commandLine.getOptionProperties("hiveconf"); for(String key : p.stringPropertyNames()) { vars.put(key, p.getProperty(key)); } p = commandLine.getOptionProperties("hivevar"); for(String key : p.stringPropertyNames()) { vars.put(key, p.getProperty(key)); } p = commandLine.getOptionProperties("define"); for(String key : p.stringPropertyNames()) { vars.put(key, p.getProperty(key)); } } catch (ParseException e) { System.err.println(e.getMessage()); return false; } return true; }
/** * Add the hiveconf properties to the Java system properties, override * anything therein. * * @return a copy of the properties specified in hiveconf */ public Properties addHiveconfToSystemProperties() { Properties confProps = commandLine.getOptionProperties("hiveconf"); for (String propKey : confProps.stringPropertyNames()) { if (verbose) { System.err.println( "hiveconf: " + propKey + "=" + confProps.getProperty(propKey)); } if (propKey.equalsIgnoreCase("hive.root.logger")) { splitAndSetLogger(propKey, confProps); } else { System.setProperty(propKey, confProps.getProperty(propKey)); } } return confProps; }
/** * Add the hiveconf properties to the Java system properties, override * anything therein. * * @return a copy of the properties specified in hiveconf */ public Properties addHiveconfToSystemProperties() { Properties confProps = commandLine.getOptionProperties("hiveconf"); for (String propKey : confProps.stringPropertyNames()) { if (verbose) { System.err.println( "hiveconf: " + propKey + "=" + confProps.getProperty(propKey)); } if (propKey.equalsIgnoreCase("hive.root.logger")) { splitAndSetLogger(propKey, confProps); } else { System.setProperty(propKey, confProps.getProperty(propKey)); } } return confProps; }
public boolean process_stage1(String[] argv) { try { commandLine = new GnuParser().parse(options, argv); Properties confProps = commandLine.getOptionProperties("hiveconf"); for (String propKey : confProps.stringPropertyNames()) { // with HIVE-11304, hive.root.logger cannot have both logger name and log level. // if we still see it, split logger and level separately for hive.root.logger // and hive.log.level respectively if (propKey.equalsIgnoreCase("hive.root.logger")) { CommonCliOptions.splitAndSetLogger(propKey, confProps); } else { System.setProperty(propKey, confProps.getProperty(propKey)); } } Properties hiveVars = commandLine.getOptionProperties("define"); for (String propKey : hiveVars.stringPropertyNames()) { hiveVariables.put(propKey, hiveVars.getProperty(propKey)); } Properties hiveVars2 = commandLine.getOptionProperties("hivevar"); for (String propKey : hiveVars2.stringPropertyNames()) { hiveVariables.put(propKey, hiveVars2.getProperty(propKey)); } } catch (ParseException e) { System.err.println(e.getMessage()); printUsage(); return false; } return true; }
final Properties properties = cmd.getOptionProperties(dynamicproperties.getOpt());
public boolean process_stage2(CliSessionState ss) { ss.getConf(); if (commandLine.hasOption('H')) { printUsage(); return false; } ss.setIsSilent(commandLine.hasOption('S')); ss.database = commandLine.getOptionValue("database"); ss.execString = commandLine.getOptionValue('e'); ss.fileName = commandLine.getOptionValue('f'); ss.setIsVerbose(commandLine.hasOption('v')); String[] initFiles = commandLine.getOptionValues('i'); if (null != initFiles) { ss.initFiles = Arrays.asList(initFiles); } if (ss.execString != null && ss.fileName != null) { System.err.println("The '-e' and '-f' options cannot be specified simultaneously"); printUsage(); return false; } if (commandLine.hasOption("hiveconf")) { Properties confProps = commandLine.getOptionProperties("hiveconf"); for (String propKey : confProps.stringPropertyNames()) { ss.cmdProperties.setProperty(propKey, confProps.getProperty(propKey)); } } return true; }
static RunOptions createRunOptions(CommandLine cli) throws Exception { Properties confProps = cli.getOptionProperties("hiveconf"); for (String propKey : confProps.stringPropertyNames()) { LOG.info("Setting {}={}", propKey, confProps.getProperty(propKey));
hiveconf = commandLine.getOptionProperties(OPTION_HIVECONF); } else { hiveconf = new Properties();
Properties lineOptionProperties = commandLine.getOptionProperties( Character.toString( CLIManager.SET_SYSTEM_PROPERTY ) );
Properties configProps = cli.getOptionProperties("hiveconf");
Properties systemProperties = commandLine.getOptionProperties("D"); Context context = new Context();
hiveConf = cl.getOptionProperties(HIVECONF.getLongOpt());
Properties confProps = commandLine.getOptionProperties("hiveconf"); for (String propKey : confProps.stringPropertyNames()) {
Properties confProps = commandLine.getOptionProperties("hiveconf"); for (String propKey : confProps.stringPropertyNames()) { setHiveConfVar(propKey, confProps.getProperty(propKey)); Properties hiveVars = commandLine.getOptionProperties("define"); for (String propKey : hiveVars.stringPropertyNames()) { getOpts().getHiveConfVariables().put(propKey, hiveVars.getProperty(propKey)); Properties hiveVars2 = commandLine.getOptionProperties("hivevar"); for (String propKey : hiveVars2.stringPropertyNames()) { getOpts().getHiveConfVariables().put(propKey, hiveVars2.getProperty(propKey));
setConfProperties(conf, cmdLine.getOptionProperties("D"));
@Test public void testPropertiesOption2() throws Exception { String[] args = new String[] { "-Dparam1", "-Dparam2=value2", "-D"}; Options options = new Options(); options.addOption(OptionBuilder.withValueSeparator().hasOptionalArgs(2).create('D')); CommandLine cl = parser.parse(options, args); Properties props = cl.getOptionProperties("D"); assertNotNull("null properties", props); assertEquals("number of properties in " + props, 2, props.size()); assertEquals("property 1", "true", props.getProperty("param1")); assertEquals("property 2", "value2", props.getProperty("param2")); List<?> argsleft = cl.getArgList(); assertEquals("Should be no arg left", 0, argsleft.size()); }
@Override public int run(CommandLine cl) throws AlluxioException, IOException { String[] args = cl.getArgs(); if (args.length == 0) { Map<String, MountPointInfo> mountTable = mFileSystem.getMountTable(); UfsCommand.printMountInfo(mountTable); return 0; } AlluxioURI alluxioPath = new AlluxioURI(args[0]); AlluxioURI ufsPath = new AlluxioURI(args[1]); MountPOptions.Builder optionsBuilder = MountPOptions.newBuilder(); if (cl.hasOption(READONLY_OPTION.getLongOpt())) { optionsBuilder.setReadOnly(true); } if (cl.hasOption(SHARED_OPTION.getLongOpt())) { optionsBuilder.setShared(true); } if (cl.hasOption(OPTION_OPTION.getLongOpt())) { Properties properties = cl.getOptionProperties(OPTION_OPTION.getLongOpt()); optionsBuilder.putAllProperties(Maps.fromProperties(properties)); } mFileSystem.mount(alluxioPath, ufsPath, optionsBuilder.build()); System.out.println("Mounted " + ufsPath + " at " + alluxioPath); return 0; }
@Test public void testGetOptionProperties() throws Exception { String[] args = new String[] { "-Dparam1=value1", "-Dparam2=value2", "-Dparam3", "-Dparam4=value4", "-D", "--property", "foo=bar" }; Options options = new Options(); options.addOption(OptionBuilder.withValueSeparator().hasOptionalArgs(2).create('D')); options.addOption(OptionBuilder.withValueSeparator().hasArgs(2).withLongOpt("property").create()); Parser parser = new GnuParser(); CommandLine cl = parser.parse(options, args); Properties props = cl.getOptionProperties("D"); assertNotNull("null properties", props); assertEquals("number of properties in " + props, 4, props.size()); assertEquals("property 1", "value1", props.getProperty("param1")); assertEquals("property 2", "value2", props.getProperty("param2")); assertEquals("property 3", "true", props.getProperty("param3")); assertEquals("property 4", "value4", props.getProperty("param4")); assertEquals("property with long format", "bar", cl.getOptionProperties("property").getProperty("foo")); }
Properties hiveVars = cl.getOptionProperties("hivevar"); for (String key : hiveVars.stringPropertyNames()) { getOpts().getHiveVariables().put(key, hiveVars.getProperty(key)); Properties hiveConfs = cl.getOptionProperties("hiveconf"); for (String key : hiveConfs.stringPropertyNames()) { setHiveConfVar(key, hiveConfs.getProperty(key));