net.sourceforge.argparse4j.inf.Namespace.getInt()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(9.4k)|赞(0)|评价(0)|浏览(95)

本文整理了Java中net.sourceforge.argparse4j.inf.Namespace.getInt()方法的一些代码示例,展示了Namespace.getInt()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Namespace.getInt()方法的具体详情如下:
包路径:net.sourceforge.argparse4j.inf.Namespace
类名称:Namespace
方法名:getInt

Namespace.getInt介绍

[英]Returns attribute as Integer with given attribute name dest.
[中]以给定属性名dest的整数形式返回属性。

代码示例

代码示例来源:origin: spotify/helios

/**
 * Return the timeout value to use, first checking the argument provided to the CLI invocation,
 * then an environment variable, then the default value.
 */
private static int parseTimeout(
  final Namespace options, final String dest,
  final String envVarName, final int defaultValue) {
 if (options.getInt(dest) != null) {
  return options.getInt(dest);
 }
 if (System.getenv(envVarName) != null) {
  // if this is not an integer then let it blow up
  return Integer.parseInt(System.getenv(envVarName));
 }
 return defaultValue;
}

代码示例来源:origin: SeldonIO/seldon-server

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);
}

代码示例来源:origin: spotify/helios

public int getZooKeeperConnectionTimeoutMillis() {
 return options.getInt(zooKeeperConnectiontimeoutArg.getDest());
}

代码示例来源:origin: spotify/helios

public int getZooKeeperSessionTimeoutMillis() {
 return options.getInt(zooKeeperSessiontimeoutArg.getDest());
}

代码示例来源:origin: SeldonIO/seldon-server

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);
}

代码示例来源:origin: dropwizard/dropwizard

@Override
public void run(Namespace namespace, Liquibase liquibase) throws Exception {
  final String context = getContext(namespace);
  final Integer count = namespace.getInt("count");
  if (count != null) {
    liquibase.futureRollbackSQL(count, context, new OutputStreamWriter(outputStream, StandardCharsets.UTF_8));
  } else {
    liquibase.futureRollbackSQL(context, new OutputStreamWriter(outputStream, StandardCharsets.UTF_8));
  }
}

代码示例来源:origin: spotify/helios

public int run() {
 try {
  final BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
  return parser.getCommand().run(parser.getNamespace(), parser.getTargets(), out, err,
    parser.getUsername(), parser.getJson(), stdin);
 } catch (Exception e) {
  // print entire stack trace in verbose mode, otherwise just the exception message
  if (parser.getNamespace().getInt("verbose") > 0) {
   e.printStackTrace(err);
  } else {
   err.println(e.getMessage());
  }
  return 1;
 }
}

代码示例来源:origin: dropwizard/dropwizard

@Override
public void run(Namespace namespace, Liquibase liquibase) throws Exception {
  final String tag = namespace.getString("tag");
  final Integer count = namespace.getInt("count");
  final Date date = namespace.get("date");
  final boolean dryRun = namespace.getBoolean("dry-run") == null ? false : namespace.getBoolean("dry-run");
  final String context = getContext(namespace);
  if (Stream.of(tag, count, date).filter(Objects::nonNull).count() != 1) {
    throw new IllegalArgumentException("Must specify either a count, a tag, or a date.");
  }
  if (count != null) {
    if (dryRun) {
      liquibase.rollback(count, context, new OutputStreamWriter(outputStream, StandardCharsets.UTF_8));
    } else {
      liquibase.rollback(count, context);
    }
  } else if (tag != null) {
    if (dryRun) {
      liquibase.rollback(tag, context, new OutputStreamWriter(outputStream, StandardCharsets.UTF_8));
    } else {
      liquibase.rollback(tag, context);
    }
  } else {
    if (dryRun) {
      liquibase.rollback(date, context, new OutputStreamWriter(outputStream, StandardCharsets.UTF_8));
    } else {
      liquibase.rollback(date, context);
    }
  }
}

代码示例来源:origin: dropwizard/dropwizard

@Override
@SuppressWarnings("UseOfSystemOutOrSystemErr")
public void run(Namespace namespace, Liquibase liquibase) throws Exception {
  final String context = getContext(namespace);
  final Integer count = namespace.getInt("count");
  final boolean dryRun = namespace.getBoolean("dry-run") == null ? false : namespace.getBoolean("dry-run");
  if (count != null) {
    if (dryRun) {
      liquibase.update(count, context, new OutputStreamWriter(outputStream, StandardCharsets.UTF_8));
    } else {
      liquibase.update(count, context);
    }
  } else {
    if (dryRun) {
      liquibase.update(context, new OutputStreamWriter(outputStream, StandardCharsets.UTF_8));
    } else {
      liquibase.update(context);
    }
  }
}

代码示例来源:origin: spotify/helios

final String name = options.getString(nameArg.getDest());
final boolean full = options.getBoolean(fullArg.getDest());
final Integer interval = options.getInt(intervalArg.getDest());
final DateTimeFormatter formatter = DateTimeFormat.forPattern(DATE_TIME_PATTERN);

代码示例来源:origin: spotify/helios

@Override
int run(final Namespace options, final List<TargetAndClient> clients,
    final PrintStream out, final boolean json, final BufferedReader stdin)
  throws ExecutionException, InterruptedException, IOException {
 final boolean exact = options.getBoolean(exactArg.getDest());
 final List<String> prefixes = options.getList(prefixesArg.getDest());
 final String jobIdString = options.getString(jobsArg.getDest());
 final List<ListenableFuture<Map<JobId, Job>>> jobIdFutures = Lists.newArrayList();
 for (final TargetAndClient cc : clients) {
  jobIdFutures.add(cc.getClient().jobs(jobIdString));
 }
 final Set<JobId> jobIds = Sets.newHashSet();
 for (final ListenableFuture<Map<JobId, Job>> future : jobIdFutures) {
  jobIds.addAll(future.get().keySet());
 }
 watchJobsOnHosts(out, exact, prefixes, jobIds, options.getInt(intervalArg.getDest()),
   clients);
 return 0;
}

代码示例来源:origin: signalapp/Signal-Server

@Override
@SuppressWarnings("UseOfSystemOutOrSystemErr")
public void run(Namespace namespace, Liquibase liquibase) throws Exception {
 final String context = getContext(namespace);
 final Integer count = namespace.getInt("count");
 final Boolean dryRun = namespace.getBoolean("dry-run");
 if (count != null) {
  if (dryRun) {
   liquibase.update(count, context, new OutputStreamWriter(System.out, Charsets.UTF_8));
  } else {
   liquibase.update(count, context);
  }
 } else {
  if (dryRun) {
   liquibase.update(context, new OutputStreamWriter(System.out, Charsets.UTF_8));
  } else {
   liquibase.update(context);
  }
 }
}

代码示例来源:origin: spotify/helios

protected FastForwardConfig ffwdConfig(final Namespace options) {
  if (!options.getBoolean(ffwdEnabled.getDest())) {
   return null;
  }

  return new FastForwardConfig(
    Optional.ofNullable(options.getString(ffwdAddress.getDest())),
    options.getInt(ffwdInterval.getDest()),
    options.getString(ffwdMetricKey.getDest()));
 }
}

代码示例来源:origin: linkedin/kafka-monitor

if (res.getInt("replicationFactor") != null)
 props.put(TopicManagementServiceConfig.TOPIC_REPLICATION_FACTOR_CONFIG, res.getInt("replicationFactor"));
if (res.getInt("rebalanceMs") != null)
 props.put(MultiClusterTopicManagementServiceConfig.REBALANCE_INTERVAL_MS_CONFIG, res.getInt("rebalanceMs"));

代码示例来源:origin: spotify/helios

options.getInt(intervalArg.getDest()), client);

代码示例来源:origin: atomix/atomix

/**
 * Builds a REST service for the given Atomix instance from the given namespace.
 *
 * @param atomix the Atomix instance
 * @param namespace the namespace from which to build the service
 * @return the managed REST service
 */
private static ManagedRestService buildRestService(Atomix atomix, Namespace namespace) {
 final String httpHost = namespace.getString("http_host");
 final Integer httpPort = namespace.getInt("http_port");
 return RestService.builder()
   .withAtomix(atomix)
   .withAddress(Address.from(httpHost, httpPort))
   .build();
}

代码示例来源:origin: signalapp/Signal-Server

if (namespace.getInt("keyId") == null) {
 System.out.print("No key id specified!");
 return;
int          keyId = namespace.getInt("keyId");

代码示例来源:origin: spotify/helios

public LoggingConfig getLoggingConfig() {
 return new LoggingConfig(options.getInt(verboseArg.getDest()),
   options.getBoolean(syslogArg.getDest()),
   (File) options.get(logconfigArg.getDest()),
   options.getBoolean(noLogSetupArg.getDest()));
}

代码示例来源:origin: spotify/helios

this.username = (username == null) ? cliConfig.getUsername() : username;
this.json = equal(options.getBoolean(globalArgs.jsonArg.getDest()), true);
this.loggingConfig = new LoggingConfig(options.getInt(globalArgs.verbose.getDest()),
  false, null,
  options.getBoolean(globalArgs.noLogSetup.getDest()));

代码示例来源:origin: spotify/helios

.setZooKeeperConnectionTimeoutMillis(getZooKeeperConnectionTimeoutMillis())
.setZooKeeperClusterId(getZooKeeperClusterId())
.setZooKeeperRegistrationTtlMinutes(options.getInt(zkRegistrationTtlMinutesArg.getDest()))
.setZooKeeperEnableAcls(getZooKeeperEnableAcls())
.setZookeeperAclMasterUser(getZooKeeperAclMasterUser())
.setFfwdConfig(ffwdConfig(options))
.setJobHistoryDisabled(options.getBoolean(disableJobHistory.getDest()))
.setConnectionPoolSize(firstNonNull(options.getInt(connectionPoolSize.getDest()), -1));

相关文章