当前位置: 首页>>代码示例>>Java>>正文


Java Option.setRequired方法代码示例

本文整理汇总了Java中org.apache.commons.cli.Option.setRequired方法的典型用法代码示例。如果您正苦于以下问题:Java Option.setRequired方法的具体用法?Java Option.setRequired怎么用?Java Option.setRequired使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.cli.Option的用法示例。


在下文中一共展示了Option.setRequired方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.apache.commons.cli.Option; //导入方法依赖的package包/类
public static void main(String[] args) throws ParseException {
  Options options = new Options();
  Option nameOption = new Option("n", true, "Name to resolve");
  nameOption.setRequired(true);
  options.addOption(nameOption);
  CommandLineParser parser = new BasicParser();
  CommandLine cmd = parser.parse(options, args);

  BasicConfigurator.configure();
  Logger.getRootLogger().setLevel(Level.DEBUG);
  PodCIDRToNodeMapping plugin = new PodCIDRToNodeMapping();
  Configuration conf = new Configuration();
  plugin.setConf(conf);

  String nameToResolve = cmd.getOptionValue(nameOption.getOpt());
  List<String> networkPathDirs = plugin.resolve(Lists.newArrayList(nameToResolve));
  log.info("Resolved " + nameToResolve + " to " + networkPathDirs);
}
 
开发者ID:apache-spark-on-k8s,项目名称:kubernetes-HDFS,代码行数:19,代码来源:PodCIDRToNodeMapping.java

示例2: parseCommandLine

import org.apache.commons.cli.Option; //导入方法依赖的package包/类
/**
 *  Usage:  DoctorKafkaMain  --zookeeper datazk001:2181/data07 \
 *             --topic brokerstats kafkahost  \
 *             --tsdhost  localhost:18321  --ostrichport 2051
 *             --uptimeinseconds 43200
 */
private static CommandLine parseCommandLine(String[] args) {
  Option configPath = new Option(CONFIG_PATH, true, "config file path");
  Option zookeeper = new Option(ZOOKEEPER, true, "zk url for metrics topic");
  zookeeper.setRequired(false);
  Option topic = new Option(METRICS_TOPIC, true, "kafka topic for metric messages");
  topic.setRequired(false);
  Option tsdHostPort = new Option(TSD_HOSTPORT, true, "tsd host and port, e.g. localhost:18621");
  tsdHostPort.setRequired(false);
  Option ostrichPort = new Option(OSTRICH_PORT, true, "ostrich port");
  ostrichPort.setRequired(false);
  Option uptimeInSeconds = new Option(UPTIME_IN_SECONDS, true, "uptime in seconds");
  uptimeInSeconds.setRequired(false);

  options.addOption(configPath).addOption(zookeeper).addOption(topic)
      .addOption(tsdHostPort).addOption(ostrichPort).addOption(uptimeInSeconds);

  if (args.length < 1) {
    printUsageAndExit();
  }
  CommandLineParser parser = new DefaultParser();
  CommandLine cmd = null;
  try {
    cmd = parser.parse(options, args);
  } catch (ParseException | NumberFormatException e) {
    printUsageAndExit();
  }
  return cmd;
}
 
开发者ID:pinterest,项目名称:doctorkafka,代码行数:35,代码来源:DoctorKafkaMain.java

示例3: ArgumentParser

import org.apache.commons.cli.Option; //导入方法依赖的package包/类
public ArgumentParser() {
    final Option input =
            new Option(KEY_INPUT, longOptInput, true,
                    "read in this S3 URI to get inventory manifest files");
    final Option output =
            new Option(KEY_OUTPUT, longOptOutput, true,
                    "write new files back to this output S3 URI prefix");
    this.options = new Options();
    input.setRequired(true);
    this.options.addOption(input);
    output.setRequired(true);
    this.options.addOption(output);
    this.parser = new PosixParser();
}
 
开发者ID:awslabs,项目名称:s3-inventory-usage-examples,代码行数:15,代码来源:ArgumentParser.java

示例4: parseCommandLine

import org.apache.commons.cli.Option; //导入方法依赖的package包/类
/**
 *  Usage:  com.pinterest.kafka.KafkaStatsMain  --host kafkahost --port 9999
 *             --zookeeper datazk001:2181/data05  --topic  kafka_metrics
 *             --tsdhost  localhost:18321  --ostrichport 2051
 *             --uptimeinseconds 43200 --pollinginterval 15
 *             --kafka_config  /etc/kafka/server.properties
 */
private static CommandLine parseCommandLine(String[] args) {

  Option host = new Option(BROKER_NAME, true, "kafka broker");
  host.setRequired(false);
  Option jmxPort = new Option(JMX_PORT, true, "kafka jmx port number");
  jmxPort.setArgName("kafka jmx port number");

  Option zookeeper = new Option(ZOOKEEPER, true, "zk url for metrics topic");
  Option topic = new Option(METRICS_TOPIC, true, "kafka topic for metric messages");
  Option tsdHostPort = new Option(TSD_HOSTPORT, true, "tsd host and port, e.g. localhost:18621");
  Option ostrichPort = new Option(OSTRICH_PORT, true, "ostrich port");
  Option uptimeInSeconds = new Option(UPTIME_IN_SECONDS, true, "uptime in seconds");
  Option pollingInterval = new Option(POLLING_INTERVAL, true, "polling interval in seconds");
  Option kafkaConfig = new Option(KAFKA_CONFIG, true, "kafka server properties file path");

  options.addOption(jmxPort).addOption(host).addOption(zookeeper).addOption(topic)
      .addOption(tsdHostPort).addOption(ostrichPort).addOption(uptimeInSeconds)
      .addOption(pollingInterval).addOption(kafkaConfig);

  if (args.length < 6) {
    printUsageAndExit();
  }
  CommandLineParser parser = new DefaultParser();
  CommandLine cmd = null;
  try {
    cmd = parser.parse(options, args);
  } catch (ParseException | NumberFormatException e) {
    printUsageAndExit();
  }
  return cmd;
}
 
开发者ID:pinterest,项目名称:doctorkafka,代码行数:39,代码来源:KafkaStatsMain.java

示例5: buildCommandlineOptions

import org.apache.commons.cli.Option; //导入方法依赖的package包/类
@Override
public Options buildCommandlineOptions(Options options) {
    Option opt = new Option("t", "topic", true, "topic name");
    opt.setRequired(true);
    options.addOption(opt);
    return options;
}
 
开发者ID:lyy4j,项目名称:rmq4note,代码行数:8,代码来源:TopicStatusSubCommand.java

示例6: buildCommandlineOptions

import org.apache.commons.cli.Option; //导入方法依赖的package包/类
@Override
public Options buildCommandlineOptions(Options options) {
    Option opt = new Option("b", "brokerName", true, "broker name");
    opt.setRequired(true);
    options.addOption(opt);
    return options;
}
 
开发者ID:lyy4j,项目名称:rmq4note,代码行数:8,代码来源:WipeWritePermSubCommand.java

示例7: buildCommandlineOptions

import org.apache.commons.cli.Option; //导入方法依赖的package包/类
@Override
public Options buildCommandlineOptions(Options options) {
    Option opt = new Option("g", "consumerGroup", true, "consumer group name");
    opt.setRequired(true);
    options.addOption(opt);

    return options;
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:9,代码来源:ConsumerConnectionSubCommand.java

示例8: parseCommandLine

import org.apache.commons.cli.Option; //导入方法依赖的package包/类
private static void parseCommandLine(String[] args) {
	Options options = new Options();

	Option input = new Option("n", "timed-iterations", true, "number of iterations of timing loop");
	input.setRequired(false);
	options.addOption(input);

	Option output = new Option("w", "warmup-iterations", true, "number of warm-up iterations before timing loop");
	output.setRequired(false);
	options.addOption(output);

	Option hourly = new Option("h", "hourly", false, "whether to use hourly data");
	hourly.setRequired(false);
	options.addOption(hourly);

	CommandLineParser parser = new DefaultParser();
	HelpFormatter formatter = new HelpFormatter();
	CommandLine cmd;

	try {
		cmd = parser.parse(options, args);
	} catch (ParseException e) {
		System.out.println(e.getMessage());
		formatter.printHelp("StlPerfTest", options);

		System.exit(1);
		return;
	}

	if (cmd.hasOption("hourly")) {
		System.out.println("Running hourly stress test");
		fRunCo2 = false;
		fTimedIterations = 200;
		fWarmupIterations = 30;
	} else {
		System.out.println("Running CO2 test");
		fTimedIterations = 2000;
		fWarmupIterations = 30;
	}

	String nStr = cmd.getOptionValue("number");
	if (nStr != null)
		fTimedIterations = Integer.parseInt(nStr);

	String wStr = cmd.getOptionValue("warmup-iterations");
	if (wStr != null)
		fWarmupIterations = Integer.parseInt(wStr);

}
 
开发者ID:ServiceNow,项目名称:stl-decomp-4j,代码行数:50,代码来源:StlPerfTest.java

示例9: buildCommandlineOptions

import org.apache.commons.cli.Option; //导入方法依赖的package包/类
@Override
public Options buildCommandlineOptions(Options options) {
    Option opt = new Option("i", "messageId", true, "unique message ID");
    opt.setRequired(false);
    options.addOption(opt);
    return options;
}
 
开发者ID:lyy4j,项目名称:rmq4note,代码行数:8,代码来源:DecodeMessageIdCommond.java

示例10: buildCommandlineOptions

import org.apache.commons.cli.Option; //导入方法依赖的package包/类
@Override
public Options buildCommandlineOptions(Options options) {
    Option opt = new Option("c", "clusterModel", false, "clusterModel");
    opt.setRequired(false);
    options.addOption(opt);

    return options;
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:9,代码来源:TopicListSubCommand.java

示例11: main

import org.apache.commons.cli.Option; //导入方法依赖的package包/类
public static void main(String[] args) {
	//les paramètres
	String filenameNote = null;
	String dburi = null;
	String dbuser = null;
	String dbpwd = null;
	
	//les options de la ligne de commande
	Options options = new Options();
	Option note = new Option("n", "note", true, "nom du fichier .csv contenant les notes");
	note.setRequired(true);
	options.addOption(note);
	Option uri = new Option("r", "uri", true, "uri de la bd");
	uri.setRequired(true);
	options.addOption(uri);
	Option user = new Option("u", "user", true, "nom utilisateur");
	user.setRequired(true);
	options.addOption(user);
	Option pwd = new Option("p", "password", true, "mot de passe utilisateur");
	pwd.setRequired(true);
	options.addOption(pwd);

	//parser la ligne de commande
    CommandLineParser parser = new DefaultParser();
    try {
        CommandLine line = parser.parse( options, args );
        if (line.hasOption("n")) {
			filenameNote = line.getOptionValue("n");
		}
        if (line.hasOption("r")) {
			dburi = line.getOptionValue("r");
		}
        if (line.hasOption("u")) {
			dbuser = line.getOptionValue("u");
		}
        if (line.hasOption("p")) {
			dbpwd = line.getOptionValue("p");
		}
    }
    catch( ParseException exp ) {
    	LOG.severe("Erreur dans la ligne de commande");
    	HelpFormatter formatter = new HelpFormatter();
    	formatter.printHelp( "epreuveloader", options );
    	System.exit(1);
    }
  //traitement
    ImportNote ino = new ImportNote(filenameNote);
    DBManager.URI= dburi;
    DBManager.USER = dbuser;
    DBManager.PASSWORD = dbpwd;
    CSVParser pa = null;
    try {
		pa = ino.buildCVSParser();
		ino.updateDB(pa);
		pa = ino.buildCVSParser();
		ino.updateFkDB(pa);
	} catch (IOException e) {
		LOG.severe(e.getMessage());
	}
    
}
 
开发者ID:HanBnrd,项目名称:projectBAC,代码行数:62,代码来源:Main.java

示例12: main

import org.apache.commons.cli.Option; //导入方法依赖的package包/类
public static void main(String[] args) {
	//les paramètres
	String nameSerie = null;
	String numberTour = null;
	String dburi = null;
	String dbuser = null;
	String dbpwd = null;
	
	//les options de la ligne de commande
	Options options = new Options();
	Option serie = new Option("s", "serie", true, "série à exporter");
	serie.setRequired(true);
	options.addOption(serie);
	Option tour = new Option("t", "tour", true, "premier ou deuxième ou remplacables");
	tour.setRequired(true);
	options.addOption(tour);
	Option uri = new Option("r", "uri", true, "uri de la bd");
	uri.setRequired(true);
	options.addOption(uri);
	Option user = new Option("u", "user", true, "nom utilisateur");
	user.setRequired(true);
	options.addOption(user);
	Option pwd = new Option("p", "password", true, "mot de passe utilisateur");
	pwd.setRequired(true);
	options.addOption(pwd);

	//parser la ligne de commande
    CommandLineParser parser = new DefaultParser();
    try {
        CommandLine line = parser.parse( options, args );
        if (line.hasOption("s")) {
			nameSerie = line.getOptionValue("s");
		}
        if (line.hasOption("t")) {
			numberTour = line.getOptionValue("t");
		}
        if (line.hasOption("r")) {
			dburi = line.getOptionValue("r");
		}
        if (line.hasOption("u")) {
			dbuser = line.getOptionValue("u");
		}
        if (line.hasOption("p")) {
			dbpwd = line.getOptionValue("p");
		}
    }
    catch( ParseException exp ) {
    	LOG.severe("Erreur dans la ligne de commande");
    	HelpFormatter formatter = new HelpFormatter();
    	formatter.printHelp( "epreuveloader", options );
    	System.exit(1);
    }
    //traitement
    ExportNote eno = new ExportNote("../samples/export/note.csv");
    DBManager.URI= dburi;
    DBManager.USER = dbuser;
    DBManager.PASSWORD = dbpwd;
    CSVPrinter pr = null;
    try {
		pr = eno.buildCVSPrinter();
		eno.writeDB(pr,nameSerie,numberTour);
	} catch (IOException e) {
		LOG.severe(e.getMessage());
	}
    
}
 
开发者ID:HanBnrd,项目名称:projectBAC,代码行数:67,代码来源:Main.java

示例13: main

import org.apache.commons.cli.Option; //导入方法依赖的package包/类
public static void main(String[] args) {
	//les paramètres
	String idCandidat = null;
	String dburi = null;
	String dbuser = null;
	String dbpwd = null;
	
	//les options de la ligne de commande
	Options options = new Options();
	Option candidat = new Option("c", "candidat", true, "id du candidat à supprimer");
	candidat.setRequired(true);
	options.addOption(candidat);
	Option uri = new Option("r", "uri", true, "uri de la bd");
	uri.setRequired(true);
	options.addOption(uri);
	Option user = new Option("u", "user", true, "nom utilisateur");
	user.setRequired(true);
	options.addOption(user);
	Option pwd = new Option("p", "password", true, "mot de passe utilisateur");
	pwd.setRequired(true);
	options.addOption(pwd);

	//parser la ligne de commande
    CommandLineParser parser = new DefaultParser();
    try {
        CommandLine line = parser.parse( options, args );
        if (line.hasOption("c")) {
			idCandidat = line.getOptionValue("c");
		}
        if (line.hasOption("r")) {
			dburi = line.getOptionValue("r");
		}
        if (line.hasOption("u")) {
			dbuser = line.getOptionValue("u");
		}
        if (line.hasOption("p")) {
			dbpwd = line.getOptionValue("p");
		}
    }
    catch( ParseException exp ) {
    	LOG.severe("Erreur dans la ligne de commande");
    	HelpFormatter formatter = new HelpFormatter();
    	formatter.printHelp( "epreuveloader", options );
    	System.exit(1);
    }
  //traitement
    SupprCandidat sca = new SupprCandidat(idCandidat);
    DBManager.URI= dburi;
    DBManager.USER = dbuser;
    DBManager.PASSWORD = dbpwd;
    sca.updateDB(idCandidat);
	
}
 
开发者ID:HanBnrd,项目名称:projectBAC,代码行数:54,代码来源:Main.java

示例14: buildOptions

import org.apache.commons.cli.Option; //导入方法依赖的package包/类
/**
 * Builds the options for this application
 * 
 * @return The options collection
 */
public static Options buildOptions() {

	Options options = new Options();
	options.addOption("b", OptionNames.BENCHMARK.toString(), false, "Just print runtimes and delete results.");
	options.addOption("c", OptionNames.COUNT.toString(), false, "COUNT result without storing the table.");
	options.addOption("e", OptionNames.EXPAND.toString(), false, "Expand URI prefixes.");
	
	Option databaseOption = new Option("d", OptionNames.DATABASE.toString(), true, "The database to use.");
	databaseOption.setRequired(true);
	options.addOption(databaseOption);

	Option formatOption = new Option("f", OptionNames.FORMAT.toString(), true, "The database format the query is built for.\n"
			+ Format.PROPERTYTABLE.toString() + ": (see 'Sempala: Interactive SPARQL Query Processing on Hadoop')\n"
			+ Format.COMPLEX_PROPERTY_TABLE.toString()
			+ ": see Sempala Complex Property Table Master project paper (Impala Version) \n"
			+ Format.COMPLEX_PROPERTY_TABLE_SPARK.toString()
			+ ": see Sempala Complex Property Table Master project paper (Spark Version) \n" + Format.SINGLETABLE.toString()
			+ ": see ExtVP Bigtable, Master's Thesis: S2RDF, Skilevic Simon \n" + Format.EXTVP.toString()
			+ ": see Extended Vertical Partitioning, Master's Thesis: S2RDF, Skilevic Simon\n");
	formatOption.setRequired(true);
	options.addOption(formatOption);
	
	options.addOption("h", OptionNames.HELP.toString(), false, "Print this help.");
	
	options.addOption("H", OptionNames.HOST.toString(), true, "The host to connect to.");
	
	Option inputOption = new Option("i", OptionNames.INPUT.toString(), true,
			"SPARQL query file to translate or folder containing sparql query files.");
	inputOption.setRequired(true);
	options.addOption(inputOption);

	options.addOption("opt", OptionNames.OPTIMIZE.toString(), false, "turn on SPARQL algebra optimization");

	options.addOption("p", OptionNames.PORT.toString(), true, "The port to connect to. (Defaults to 21050)");

	options.addOption("rn", OptionNames.RESULT_TABLE_NAME.toString(), true,
			"Result Table Name format if results tables are stored.");

	options.addOption("s", OptionNames.STRAIGHJOIN.toString(), false,
			"Executes query with Straight join. Default (Impala sets the join order of tables)");

	options.addOption("t", OptionNames.THRESHOLD.toString(), true,
			"Threshold of ExtVP if ExtVP format is selected. Default (SF=1)");

	options.addOption("sp", OptionNames.SPARKPARTITIONS.toString(), true,
			"Number of partitions in Spark. See DataFrame#partitions.");

	return options;
}
 
开发者ID:aschaetzle,项目名称:Sempala,代码行数:55,代码来源:Main.java

示例15: main

import org.apache.commons.cli.Option; //导入方法依赖的package包/类
public static void main(String[] args) {
	//les paramètres
	String filenameCandidat = null;
	String dburi = null;
	String dbuser = null;
	String dbpwd = null;
	
	//les options de la ligne de commande
	Options options = new Options();
	Option candidat = new Option("c", "candidat", true, "nom du fichier .csv contenant les candidats");
	candidat.setRequired(true);
	options.addOption(candidat);
	Option uri = new Option("r", "uri", true, "uri de la bd");
	uri.setRequired(true);
	options.addOption(uri);
	Option user = new Option("u", "user", true, "nom utilisateur");
	user.setRequired(true);
	options.addOption(user);
	Option pwd = new Option("p", "password", true, "mot de passe utilisateur");
	pwd.setRequired(true);
	options.addOption(pwd);

	//parser la ligne de commande
    CommandLineParser parser = new DefaultParser();
    try {
        CommandLine line = parser.parse( options, args );
        if (line.hasOption("c")) {
			filenameCandidat = line.getOptionValue("c");
		}
        if (line.hasOption("r")) {
			dburi = line.getOptionValue("r");
		}
        if (line.hasOption("u")) {
			dbuser = line.getOptionValue("u");
		}
        if (line.hasOption("p")) {
			dbpwd = line.getOptionValue("p");
		}
    }
    catch( ParseException exp ) {
    	LOG.severe("Erreur dans la ligne de commande");
    	HelpFormatter formatter = new HelpFormatter();
    	formatter.printHelp( "epreuveloader", options );
    	System.exit(1);
    }
    //traitement
    ImportCandidat ica = new ImportCandidat(filenameCandidat);
    DBManager.URI= dburi;
    DBManager.USER = dbuser;
    DBManager.PASSWORD = dbpwd;
    CSVParser pa = null;
    try {
		pa = ica.buildCVSParser();
		ica.updateDB(pa);
	} catch (IOException e) {
		LOG.severe(e.getMessage());
	}
    
}
 
开发者ID:HanBnrd,项目名称:projectBAC,代码行数:60,代码来源:Main.java


注:本文中的org.apache.commons.cli.Option.setRequired方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。