當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。