本文整理汇总了Java中net.sourceforge.argparse4j.inf.Namespace.getInt方法的典型用法代码示例。如果您正苦于以下问题:Java Namespace.getInt方法的具体用法?Java Namespace.getInt怎么用?Java Namespace.getInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sourceforge.argparse4j.inf.Namespace
的用法示例。
在下文中一共展示了Namespace.getInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createConsumer
import net.sourceforge.argparse4j.inf.Namespace; //导入方法依赖的package包/类
private static KafkaConsumer<String, String> createConsumer(Namespace parsedArgs) {
String consumerGroup = parsedArgs.getString("consumerGroup");
String brokerList = parsedArgs.getString("brokerList");
Integer numMessagesPerTransaction = parsedArgs.getInt("messagesPerTransaction");
Properties props = new Properties();
props.put(ConsumerConfig.GROUP_ID_CONFIG, consumerGroup);
props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, brokerList);
props.put(ConsumerConfig.ISOLATION_LEVEL_CONFIG, "read_committed");
props.put(ConsumerConfig.MAX_POLL_RECORDS_CONFIG, numMessagesPerTransaction.toString());
props.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, "false");
props.put(ConsumerConfig.SESSION_TIMEOUT_MS_CONFIG, "10000");
props.put(ConsumerConfig.HEARTBEAT_INTERVAL_MS_CONFIG, "3000");
props.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");
props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG,
"org.apache.kafka.common.serialization.StringDeserializer");
props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG,
"org.apache.kafka.common.serialization.StringDeserializer");
return new KafkaConsumer<>(props);
}
示例2: handle
import net.sourceforge.argparse4j.inf.Namespace; //导入方法依赖的package包/类
@Override
public void handle(Namespace args) throws Exception
{
UserSecurityProvider usp = new UserSecurityProvider(makeCLIPasswordProvider(args.get(CLI.ARG_PASSWORD_FILE)));
ArchiveInfoContext aic = new ArchiveInfoContext(args.get(CLI.ARG_ARCHIVE_PATH), usp);
IFFTraversalTarget t = InventoryPather.traverse(aic.getInventory(), args.getString(ARG_PATH));
if (t.isAFile())
{
throw new CLIException("'path' target must be a folder, not a file.");
}
else
{
IFFContainer c = (IFFContainer) t;
int maxDepth = Integer.MAX_VALUE;
if (args.get(ARG_DEPTH) != null) maxDepth = args.getInt(ARG_DEPTH);
printBreadthFirstFindTree(c, args.get(ARG_PATH), args.get(ARG_PREFIX),
args.get(ARG_SUFFIX),
args.get(ARG_TYPE), maxDepth);
}
}
示例3: generateAssignmentPlan
import net.sourceforge.argparse4j.inf.Namespace; //导入方法依赖的package包/类
private static void generateAssignmentPlan(Namespace ns, List<String> assignmentPlans, String topic,
boolean rackAware) throws ReplicaAssignmentException {
KafkaBalancer balancer = null;
Integer repFactor = ns.getInt(SET_REPLICATION_FACTOR);
if (repFactor != -1) {
System.out.println("Replication Factor Set: " + repFactor);
balancer = new ReplicationSetterBalancer(topic, rackAware, repFactor);
} else {
String task = ns.getString(TASK);
switch (task) {
case REASSIGN_UNDER_REPLICATED_PARTITIONS:
balancer = new UnderReplicatedTopicBalancer(topic, rackAware);
break;
case BALANCE_PARTITIONS:
case BALANCE_FOLLOWERS:
case BALANCE_LEADERS:
balancer = new TopicBalancer(topic, rackAware, task);
break;
}
}
String plan = balancer.generateAssignmentPlan();
if (plan != null && !plan.isEmpty()) {
assignmentPlans.add(plan);
}
}
示例4: createFromArgs
import net.sourceforge.argparse4j.inf.Namespace; //导入方法依赖的package包/类
public static VerifiableConsumer createFromArgs(ArgumentParser parser, String[] args) throws ArgumentParserException {
Namespace res = parser.parseArgs(args);
String topic = res.getString("topic");
boolean useAutoCommit = res.getBoolean("useAutoCommit");
int maxMessages = res.getInt("maxMessages");
boolean verbose = res.getBoolean("verbose");
String configFile = res.getString("consumer.config");
Properties consumerProps = new Properties();
if (configFile != null) {
try {
consumerProps.putAll(Utils.loadProps(configFile));
} catch (IOException e) {
throw new ArgumentParserException(e.getMessage(), parser);
}
}
consumerProps.put(ConsumerConfig.GROUP_ID_CONFIG, res.getString("groupId"));
consumerProps.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, res.getString("brokerList"));
consumerProps.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, useAutoCommit);
consumerProps.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, res.getString("resetPolicy"));
consumerProps.put(ConsumerConfig.SESSION_TIMEOUT_MS_CONFIG, Integer.toString(res.getInt("sessionTimeout")));
consumerProps.put(ConsumerConfig.PARTITION_ASSIGNMENT_STRATEGY_CONFIG, res.getString("assignmentStrategy"));
StringDeserializer deserializer = new StringDeserializer();
KafkaConsumer<String, String> consumer = new KafkaConsumer<>(consumerProps, deserializer, deserializer);
return new VerifiableConsumer(
consumer,
System.out,
topic,
maxMessages,
useAutoCommit,
false,
verbose);
}
示例5: TestConfig
import net.sourceforge.argparse4j.inf.Namespace; //导入方法依赖的package包/类
TestConfig(Namespace res) {
this.bootstrapServer = res.getString("bootstrapServer");
this.topic = res.getString("topic");
this.offsetsForTimesSupported = res.getBoolean("offsetsForTimesSupported");
this.expectClusterId = res.getBoolean("clusterIdSupported");
this.expectRecordTooLargeException = res.getBoolean("expectRecordTooLargeException");
this.numClusterNodes = res.getInt("numClusterNodes");
this.createTopicsSupported = res.getBoolean("createTopicsSupported");
this.describeAclsSupported = res.getBoolean("describeAclsSupported");
}
示例6: initPCAPPseudonymizer
import net.sourceforge.argparse4j.inf.Namespace; //导入方法依赖的package包/类
private static DumpFilePseudonymizer initPCAPPseudonymizer(final Namespace cmdResult) throws InvalidKeyException, IOException {
final Integer mt = cmdResult.getInt("multithread");
if (mt == null) {
return new SingleThreadedPCAPPseudonymizer(initPseudonymizerWith(cmdResult));
}
else {
final List<FramePseudonymizer> pseudonymizers = initMultiplePseudonymizers(cmdResult, mt);
return new MultiThreadedPCAPPseudonymizer(pseudonymizers);
}
}
示例7: initPCAPPNGseudonymizer
import net.sourceforge.argparse4j.inf.Namespace; //导入方法依赖的package包/类
private static DumpFilePseudonymizer initPCAPPNGseudonymizer(final Namespace cmdResult) throws IOException, InvalidKeyException {
final Integer mt = cmdResult.getInt("multithread");
if (mt == null) {
return new SingleThreadedPCAPNGPseudonymizer(initPseudonymizerWith(cmdResult));
}
else {
final List<FramePseudonymizer> pseudonymizers = initMultiplePseudonymizers(cmdResult, mt);
return new MultiThreadedPCAPNGPseudonymizer(pseudonymizers);
}
}
示例8: main
import net.sourceforge.argparse4j.inf.Namespace; //导入方法依赖的package包/类
/**
* Cluster the C-alpha chains of a set of PDB ids.
* @param args the input args - currently none taken
* @throws IOException an error reading from the URL or the seqeunce file
*/
public static void main(String[] args) throws IOException {
// Read the arguments
Namespace ns = parseArgs(args);
// Get the actual arguments
String alignMethod = ns.getString("align");
String filePath = ns.getString("hadoop");
int minLength = ns.getInt("minlength");
double sample = ns.getDouble("sample");
boolean useFiles = ns.getBoolean("files");
// Get the list of PDB ids
List<String> pdbIdList = ns.<String> getList("pdbId");
// Get the chains that correpspond to that
JavaPairRDD<String, Atom[]> chainRDD;
if(pdbIdList.size()>0){
if(useFiles==true){
StructureDataRDD structureDataRDD = new StructureDataRDD(
BiojavaSparkUtils.getFromList(convertToFiles(pdbIdList))
.mapToPair(t -> new Tuple2<String, StructureDataInterface>(t._1, BiojavaSparkUtils.convertToStructDataInt(t._2))));
chainRDD = BiojavaSparkUtils.getChainRDD(structureDataRDD, minLength);
}
else{
chainRDD = BiojavaSparkUtils.getChainRDD(pdbIdList, minLength);
}
}
else if(!filePath.equals(defaultPath)){
chainRDD = BiojavaSparkUtils.getChainRDD(filePath, minLength, sample);
}
else{
System.out.println("Must specify PDB ids or an hadoop sequence file");
return;
}
System.out.println("Analysisng " + chainRDD.count() + " chains");
JavaPairRDD<Tuple2<String,Atom[]>,Tuple2<String, Atom[]>> comparisons = SparkUtils.getHalfCartesian(chainRDD, chainRDD.getNumPartitions());
JavaRDD<Tuple3<String, String, AFPChain>> similarities = comparisons.map(t -> new Tuple3<String, String, AFPChain>(t._1._1, t._2._1,
AlignmentTools.getBiojavaAlignment(t._1._2, t._2._2, alignMethod)));
JavaRDD<Tuple6<String, String, Double, Double, Double, Double>> allScores = similarities.map(t -> new Tuple6<String, String, Double, Double, Double, Double>(
t._1(), t._2(), t._3().getTMScore(), t._3().getTotalRmsdOpt(), (double) t._3().getTotalLenOpt(), t._3().getAlignScore())).cache();
if(alignMethod.equals("DUMMY")){
JavaDoubleRDD doubleDist = allScores.mapToDouble(t -> t._3());
System.out.println("Average dist: "+doubleDist.mean());
}
else{
writeData(allScores);
}
}
示例9: run
import net.sourceforge.argparse4j.inf.Namespace; //导入方法依赖的package包/类
@Override
protected void run(Environment environment, Namespace namespace, EmoConfiguration configuration)
throws Exception {
String id = namespace.getString("id");
AllTablesReportOptions options = new AllTablesReportOptions();
options.setReadOnly(namespace.getBoolean("readOnly"));
List<String> placements = namespace.getList("placements");
if (placements != null && !placements.isEmpty()) {
options.setPlacements(ImmutableSet.copyOf(placements));
}
Integer shardId = namespace.getInt("shard");
if (shardId != null) {
options.setFromShardId(shardId);
}
String table = namespace.getString("table");
if (table != null) {
options.setFromTableUuid(TableUuidFormat.decode(table));
}
Injector injector = Guice.createInjector(new EmoModule(configuration, environment, EmoServiceMode.CLI_TOOL));
ContainerLifeCycle containerLifeCycle = new ContainerLifeCycle();
environment.lifecycle().attach(containerLifeCycle);
containerLifeCycle.start();
try {
AllTablesReportGenerator generator = injector.getInstance(AllTablesReportGenerator.class);
AllTablesReportResult result = generator.runReport(id, options);
System.out.println(result);
} finally {
containerLifeCycle.stop();
}
}
示例10: run
import net.sourceforge.argparse4j.inf.Namespace; //导入方法依赖的package包/类
@Override public void run(Bootstrap<?> bootstrap, Namespace namespace) throws Exception {
char[] password = namespace.getString("storepass").toCharArray();
Path destination = Paths.get(namespace.get("keystore"));
int keySize = namespace.getInt("keysize");
String alias = namespace.getString("alias");
generate(password, destination, keySize, alias, SecureRandom.getInstanceStrong());
System.out.println(format("Generated a %d-bit AES key at %s with alias %s", keySize,
destination.toAbsolutePath(), alias));
}
示例11: ItemSimilarityProcessor
import net.sourceforge.argparse4j.inf.Namespace; //导入方法依赖的package包/类
public ItemSimilarityProcessor(final Namespace ns)
{
this.windowSecs = ns.getInt("window_secs");
this.windowProcessed = ns.getInt("window_processed");
this.outputTopic = ns.getString("output_topic");
this.kafkaServers = ns.getString("kafka");
System.out.println(ns);
this.streamJaccard = new StreamingJaccardSimilarity(windowSecs, ns.getInt("hashes"), ns.getInt("min_activity"));
//createOutputSimilaritiesTimer(ns);
}
示例12: createOutputSimilaritiesTimer
import net.sourceforge.argparse4j.inf.Namespace; //导入方法依赖的package包/类
public void createOutputSimilaritiesTimer(Namespace ns)
{
int windowSecs = ns.getInt("output_poll_secs");
int timer_ms = windowSecs * 1000;
System.out.println("Scheduling at "+timer_ms);
outputTimer = new Timer(true);
outputTimer.scheduleAtFixedRate(new TimerTask() {
public void run()
{
long time = ItemSimilarityProcessor.this.outputSimilaritiesTime.get();
if (time > 0)
{
SimpleDateFormat sdf = new SimpleDateFormat("MMMM d, yyyy 'at' h:mm a");
String date = sdf.format(time*1000);
System.out.println("getting similarities at "+date);
List<JaccardSimilarity> res = streamJaccard.getSimilarity(time);
System.out.println("Results size "+res.size()+". Sending Messages...");
sendMessages(res, time);
System.out.println("Messages sent");
ItemSimilarityProcessor.this.outputSimilaritiesTime.set(0);
}
else
{
System.out.println("Timer: not outputing similarities");
}
}
}, timer_ms, timer_ms);
}
示例13: run
import net.sourceforge.argparse4j.inf.Namespace; //导入方法依赖的package包/类
@Override
protected void run(Bootstrap<EmoConfiguration> bootstrap, Namespace namespace, EmoConfiguration config)
throws Exception {
String host = namespace.getString("host");
int limit = namespace.getInt("limit");
String subscription = namespace.getString("subscription");
String apiKey = namespace.getString("api_key");
Set<String> tables = Sets.newHashSet(namespace.<String>getList("table"));
List<String> keys = namespace.getList("key");
Set<String> keySet = keys != null ? Sets.newHashSet(keys) : null;
System.out.println("Connecting...");
URI uri = URI.create(host).resolve(DatabusClient.SERVICE_PATH + "/_raw");
MetricRegistry metricRegistry = bootstrap.getMetricRegistry();
Client client = createDefaultJerseyClient(config.getHttpClientConfiguration(), metricRegistry, "");
QueueService databus = QueueServiceAuthenticator.proxied(new QueueClient(uri, new JerseyEmoClient(client)))
.usingCredentials(apiKey);
for (;;) {
List<Message> events = databus.peek(subscription, 5000);
List<String> ids = Lists.newArrayList();
for (Message event : events) {
//noinspection unchecked
Map<String, String> coord = (Map<String, String>) checkNotNull(event.getPayload());
String table = checkNotNull(coord.get("table"));
String key = checkNotNull(coord.get("key"));
if (tables.contains(table) && (keySet == null || keySet.contains(key))) {
ids.add(event.getId());
if (--limit <= 0) {
break;
}
}
}
if (ids.isEmpty()) {
System.out.println("All matching events of the first " + events.size() + " have been purged.");
break;
}
System.out.println("Purging " + ids.size() + " events...");
databus.acknowledge(subscription, ids);
if (limit == 0) {
System.out.println("Limit reached.");
break;
}
}
}
示例14: main
import net.sourceforge.argparse4j.inf.Namespace; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
ArgumentParser parser = ArgumentParsers.newArgumentParser(ALGO).description("SSSJ in " + ALGO + " mode.")
.defaultHelp(true);
parser.addArgument("-t", "--theta").metavar("theta").type(Double.class).choices(Arguments.range(0.0, 1.0))
.setDefault(DEFAULT_THETA).help("similarity threshold");
parser.addArgument("-l", "--lambda").metavar("lambda").type(Double.class)
.choices(Arguments.range(0.0, Double.MAX_VALUE)).setDefault(DEFAULT_LAMBDA).help("forgetting factor");
parser.addArgument("-r", "--report").metavar("period").type(Integer.class).setDefault(DEFAULT_REPORT_PERIOD)
.help("progress report period");
parser.addArgument("-i", "--index").type(IndexType.class)
.choices(IndexType.INV, IndexType.L2AP, IndexType.L2).setDefault(IndexType.INV)
.help("type of indexing");
parser.addArgument("-f", "--format").type(Format.class).choices(Format.values()).setDefault(Format.BINARY)
.help("input format");
parser.addArgument("input").metavar("file")
.type(Arguments.fileType().verifyExists().verifyIsFile().verifyCanRead()).help("input file");
Namespace opts = parser.parseArgsOrFail(args);
final double theta = opts.get("theta");
final double lambda = opts.get("lambda");
final int reportPeriod = opts.getInt("report");
final IndexType idxType = opts.<IndexType>get("index");
final Format fmt = opts.<Format>get("format");
final File file = opts.<File>get("input");
final VectorStream stream = VectorStreamFactory.getVectorStream(file, fmt, new Sequential());
final long numVectors = stream.numVectors();
final ProgressTracker tracker = new ProgressTracker(numVectors, reportPeriod);
final String header = String.format(ALGO + " [d=%s, t=%f, l=%f, i=%s]", file.getName(), theta, lambda,
idxType.toString());
System.out.println(header);
log.info(header);
final long start = System.currentTimeMillis();
final IndexStatistics stats = compute(stream, theta, lambda, idxType, tracker);
final long elapsed = System.currentTimeMillis() - start;
final String csvLine = Joiner.on(",").join(ALGO, file.getName(), theta, lambda, idxType.toString(), elapsed,
stats.numPostingEntries(), stats.numCandidates(), stats.numSimilarities(), stats.numMatches());
System.out.println(csvLine);
log.info(String.format(ALGO + " [d=%s, t=%f, l=%f, i=%s, time=%d]", file.getName(), theta, lambda,
idxType.toString(), elapsed));
}
示例15: main
import net.sourceforge.argparse4j.inf.Namespace; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
ArgumentParser parser = ArgumentParsers.newArgumentParser(ALGO).description("SSSJ in " + ALGO + " mode.")
.defaultHelp(true);
parser.addArgument("-t", "--theta").metavar("theta").type(Double.class).choices(Arguments.range(0.0, 1.0))
.setDefault(DEFAULT_THETA).help("similarity threshold");
parser.addArgument("-l", "--lambda").metavar("lambda").type(Double.class)
.choices(Arguments.range(0.0, Double.MAX_VALUE)).setDefault(DEFAULT_LAMBDA).help("forgetting factor");
parser.addArgument("-r", "--report").metavar("period").type(Integer.class).setDefault(DEFAULT_REPORT_PERIOD)
.help("progress report period");
parser.addArgument("-i", "--index").type(IndexType.class)
.choices(IndexType.INV, IndexType.AP, IndexType.L2AP, IndexType.L2)
.setDefault(IndexType.INV).help("type of indexing");
parser.addArgument("-f", "--format").type(Format.class).choices(Format.values()).setDefault(Format.BINARY)
.help("input format");
parser.addArgument("input").metavar("file")
.type(Arguments.fileType().verifyExists().verifyIsFile().verifyCanRead()).help("input file");
Namespace opts = parser.parseArgsOrFail(args);
final double theta = opts.get("theta");
final double lambda = opts.get("lambda");
final int reportPeriod = opts.getInt("report");
final IndexType idxType = opts.<IndexType>get("index");
final Format fmt = opts.<Format>get("format");
final File file = opts.<File>get("input");
final VectorStream stream = VectorStreamFactory.getVectorStream(file, fmt, new Sequential());
final long numVectors = stream.numVectors();
final ProgressTracker tracker = new ProgressTracker(numVectors, reportPeriod);
final String header = String.format(ALGO + " [d=%s, t=%f, l=%f, i=%s]", file.getName(), theta, lambda,
idxType.toString());
System.out.println(header);
log.info(header);
final long start = System.currentTimeMillis();
final IndexStatistics stats = compute(stream, theta, lambda, idxType, tracker);
final long elapsed = System.currentTimeMillis() - start;
final String csvLine = Joiner.on(",").join(ALGO, file.getName(), theta, lambda, idxType.toString(), elapsed,
stats.numPostingEntries(), stats.numCandidates(), stats.numSimilarities(), stats.numMatches());
System.out.println(csvLine);
log.info(String.format(ALGO + " [d=%s, t=%f, l=%f, i=%s, time=%d]", file.getName(), theta, lambda,
idxType.toString(), elapsed));
}