com.typesafe.config.Config.getLong()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(193)

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

Config.getLong介绍

暂无

代码示例

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

@Override
  public Object extractValue(Config config, String path)
  {
    return config.getLong(path);
  }
},

代码示例来源:origin: apache/drill

@Override
public long getLong(String path) {
 return c.getLong(path);
}

代码示例来源:origin: apache/incubator-gobblin

/**
  * Constructor from a typesafe config object
  * @param serviceCfg    the service configuration; must be local, i.e. any service namespace
  *                      prefix should be removed using {@link Config#getConfig(String)}.
  **/
 public StandardServiceConfig(Config serviceCfg) {
  Config effectiveCfg = serviceCfg.withFallback(DEFAULT_CFG);
  this.startUpTimeoutMs = effectiveCfg.getLong(STARTUP_TIMEOUT_MS_PROP);
  this.shutDownTimeoutMs = effectiveCfg.getLong(SHUTDOWN_TIMEOUT_MS_PROP);
 }
}

代码示例来源:origin: apache/incubator-gobblin

/**
 * Return {@link Long} value at <code>path</code> if <code>config</code> has path. If not return <code>def</code>
 *
 * @param config in which the path may be present
 * @param path key to look for in the config object
 * @return {@link Long} value at <code>path</code> if <code>config</code> has path. If not return <code>def</code>
 */
public static Long getLong(Config config, String path, Long def) {
 if (config.hasPath(path)) {
  return Long.valueOf(config.getLong(path));
 }
 return def;
}

代码示例来源:origin: apache/incubator-gobblin

public QPSPolicy(Config config) {
 Preconditions.checkArgument(config.hasPath(QPS), "QPS required.");
 this.qps = config.getLong(QPS);
 long fullRequestTimeoutMillis = config.hasPath(FULL_REQUEST_TIMEOUT_MILLIS)
   ? config.getLong(FULL_REQUEST_TIMEOUT_MILLIS) : DEFAULT_FULL_REQUEST_TIMEOUT;
 long maxBucketSizeMillis = config.hasPath(MAX_BUCKET_SIZE_MILLIS)
   ? config.getLong(MAX_BUCKET_SIZE_MILLIS) : DEFAULT_MAX_BUCKET_SIZE;
 this.tokenBucket = new DynamicTokenBucket(qps, fullRequestTimeoutMillis, maxBucketSizeMillis);
}

代码示例来源:origin: apache/incubator-gobblin

/** Config accessor from a no namespaced typesafe config. */
public ConfigAccessor(Config cfg) {
 Config effectiveCfg = cfg.withFallback(getDefaultConfig().getConfig(CONFIG_PREFIX));
 this.startTimeoutMs = effectiveCfg.getLong(START_TIMEOUT_MS);
 this.shutdownTimeoutMs = effectiveCfg.getLong(SHUTDOWN_TIMEOUT_MS);
}

代码示例来源:origin: jooby-project/jooby

protected void slong(final String path, final Config config, final String name,
  final Consumer<Long> setter) {
 if (config.hasPath(name)) {
  long value = config.getLong(name);
  log.debug("setting {}.{} = {}", path, name, value);
  setter.accept(value);
 }
}

代码示例来源:origin: apache/incubator-gobblin

@Override
 public ThrottlingPolicy createPolicy(SharedLimiterKey key, SharedResourcesBroker<ThrottlingServerScopes> broker, Config config) {
  Preconditions.checkArgument(config.hasPath(COUNT_KEY), "Missing key " + COUNT_KEY);
  return new CountBasedPolicy(config.getLong(COUNT_KEY));
 }
}

代码示例来源:origin: apache/incubator-gobblin

@Override
 public Limiter buildLimiter(Config config) {
  if (!config.hasPath(MAX_SECONDS_KEY)) {
   throw new RuntimeException("Missing key " + MAX_SECONDS_KEY);
  }
  return new TimeBasedLimiter(config.getLong(MAX_SECONDS_KEY));
 }
}

代码示例来源:origin: apache/incubator-gobblin

@Override
 public Limiter buildLimiter(Config config) {
  if (!config.hasPath(QPS_KEY)) {
   throw new RuntimeException("Missing key " + QPS_KEY);
  }
  return new RateBasedLimiter(config.getLong(QPS_KEY));
 }
}

代码示例来源:origin: ethereum/ethereumj

@ValidateMe
public long getMineMinBlockTimeoutMsec() {
  return config.getLong("mine.minBlockTimeoutMsec");
}

代码示例来源:origin: apache/incubator-gobblin

@Override
 public Limiter buildLimiter(Config config) {
  if (!config.hasPath(COUNT_KEY)) {
   throw new IllegalArgumentException("Missing key " + COUNT_KEY);
  }
  return new CountBasedLimiter(config.getLong(COUNT_KEY));
 }
}

代码示例来源:origin: ethereum/ethereumj

@ValidateMe
public long databaseResetBlock() {
  return config.getLong("database.resetBlock");
}

代码示例来源:origin: apache/incubator-gobblin

public YarnAppSecurityManager(Config config, HelixManager helixManager, FileSystem fs, Path tokenFilePath)
  throws IOException {
 this.config = config;
 this.helixManager = helixManager;
 this.fs = fs;
 this.tokenFilePath = tokenFilePath;
 this.fs.makeQualified(tokenFilePath);
 this.loginUser = UserGroupInformation.getLoginUser();
 this.loginIntervalInMinutes = config.getLong(GobblinYarnConfigurationKeys.LOGIN_INTERVAL_IN_MINUTES);
 this.tokenRenewIntervalInMinutes = config.getLong(GobblinYarnConfigurationKeys.TOKEN_RENEW_INTERVAL_IN_MINUTES);
 this.loginExecutor = Executors.newSingleThreadScheduledExecutor(
   ExecutorsUtils.newThreadFactory(Optional.of(LOGGER), Optional.of("KeytabReLoginExecutor")));
 this.tokenRenewExecutor = Executors.newSingleThreadScheduledExecutor(
   ExecutorsUtils.newThreadFactory(Optional.of(LOGGER), Optional.of("TokenRenewExecutor")));
}

代码示例来源:origin: ben-manes/caffeine

/** Adds the maximum size and weight bounding settings. */
private void addMaximum() {
 if (isSet("policy.maximum.size")) {
  configuration.setMaximumSize(OptionalLong.of(merged.getLong("policy.maximum.size")));
 }
 if (isSet("policy.maximum.weight")) {
  configuration.setMaximumWeight(OptionalLong.of(merged.getLong("policy.maximum.weight")));
 }
 if (isSet("policy.maximum.weigher")) {
  configuration.setWeigherFactory(Optional.of(
    FactoryBuilder.factoryOf(merged.getString("policy.maximum.weigher"))));
 }
}

代码示例来源:origin: apache/incubator-gobblin

/**
 * Generate a dagId from the given {@link Dag} instance.
 * @param dag instance of a {@link Dag}.
 * @return a String id associated corresponding to the {@link Dag} instance.
 */
static String generateDagId(Dag<JobExecutionPlan> dag) {
 Config jobConfig = dag.getStartNodes().get(0).getValue().getJobSpec().getConfig();
 String flowGroup = jobConfig.getString(ConfigurationKeys.FLOW_GROUP_KEY);
 String flowName = jobConfig.getString(ConfigurationKeys.FLOW_NAME_KEY);
 Long flowExecutionId = jobConfig.getLong(ConfigurationKeys.FLOW_EXECUTION_ID_KEY);
 return Joiner.on("_").join(flowGroup, flowName, flowExecutionId);
}

代码示例来源:origin: apache/incubator-gobblin

private static <T> Retryer<T> newExponentialRetryer(Config config) {

  return RetryerBuilder.<T> newBuilder()
    .retryIfException(RETRY_EXCEPTION_PREDICATE)
    .withWaitStrategy(WaitStrategies.exponentialWait(config.getLong(RETRY_MULTIPLIER),
                             config.getLong(RETRY_INTERVAL_MS),
                             TimeUnit.MILLISECONDS))
    .withStopStrategy(StopStrategies.stopAfterDelay(config.getLong(RETRY_TIME_OUT_MS), TimeUnit.MILLISECONDS))
    .build();
 }
}

代码示例来源:origin: ethereum/ethereumj

public Ethash(SystemProperties config, long blockNumber) {
  this.config = config;
  this.blockNumber = blockNumber;
  this.epoch = blockNumber / ethashAlgo.getParams().getEPOCH_LENGTH();
  if (config.getConfig().hasPath("mine.startNonce")) {
    startNonce = config.getConfig().getLong("mine.startNonce");
  }
}

代码示例来源:origin: apache/incubator-gobblin

private static <T> Retryer<T> newFixedRetryer(Config config) {
 return RetryerBuilder.<T> newBuilder()
   .retryIfException(RETRY_EXCEPTION_PREDICATE)
   .withWaitStrategy(WaitStrategies.fixedWait(config.getLong(RETRY_INTERVAL_MS), TimeUnit.MILLISECONDS))
   .withStopStrategy(StopStrategies.stopAfterDelay(config.getLong(RETRY_TIME_OUT_MS), TimeUnit.MILLISECONDS))
   .build();
}

代码示例来源:origin: apache/incubator-gobblin

@Test
public void testFromProperties() {
 Properties props = new Properties();
 props.put("a1", "a_value");
 props.put("a2.b", "1");
 props.put("a2.c.d", "12.34");
 props.put("a2.c.d2", "true");
 DefaultConfigurableImpl c = DefaultConfigurableImpl.createFromProperties(props);
 Assert.assertEquals(c.getConfig().getString("a1"), "a_value");
 Assert.assertEquals(c.getConfig().getLong("a2.b"), 1L);
 Assert.assertEquals(c.getConfig().getDouble("a2.c.d"), 12.34);
 Assert.assertTrue(c.getConfig().getBoolean("a2.c.d2"));
}

相关文章