Java Code Examples for org.apache.commons.configuration.Configuration#getInteger()

The following examples show how to use org.apache.commons.configuration.Configuration#getInteger() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AtlasRepositoryConfiguration.java    From atlas with Apache License 2.0 6 votes vote down vote up
public static int getTypeUpdateLockMaxWaitTimeInSeconds() {
    Integer ret = typeUpdateLockMaxWaitTimeInSeconds;

    if (ret == null) {
        try {
            Configuration config = ApplicationProperties.get();

            ret = config.getInteger(CONFIG_TYPE_UPDATE_LOCK_MAX_WAIT_TIME_IN_SECONDS, DEFAULT_TYPE_UPDATE_LOCK_MAX_WAIT_TIME_IN_SECONDS);

            typeUpdateLockMaxWaitTimeInSeconds = ret;
        } catch (AtlasException e) {
            // ignore
        }
    }

    return ret == null ? DEFAULT_TYPE_UPDATE_LOCK_MAX_WAIT_TIME_IN_SECONDS : ret;
}
 
Example 2
Source File: AddressResolverConfig.java    From servicecomb-java-chassis with Apache License 2.0 6 votes vote down vote up
private static int getPositiveIntProperty(Configuration configSource, int defaultValue, String... keys) {
  configSource = guardConfigSource(configSource);
  if (configSource == null) {
    return defaultValue;
  }
  for (String key : keys) {
    Integer val = configSource.getInteger(key, null);
    if (val != null && val <= 0) {
      LOGGER.warn("Address resover key:{}'s value:{} is not positive, please check!", key, val);
      continue;
    }
    if (val != null) {
      return val;
    }
  }
  return defaultValue;
}
 
Example 3
Source File: TestAddressResolverConfig.java    From servicecomb-java-chassis with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetResoverFromResource(@Mocked Configuration finalConfig) {
  ArchaiusUtils.resetConfig();
  ArchaiusUtils.setProperty("addressResolver.servers", "8.8.8.8,8.8.4.4");
  new Expectations() {
    {
      finalConfig.getStringArray("addressResolver.servers");
      result = new String[] {"6.6.6.6", "6.6.4.4"};
      finalConfig.getStringArray("addressResolver.searchDomains");
      result = new String[] {"default.svc.local.cluster"};
      finalConfig.getInteger("addressResolver.queryTimeout", null);
      result = 2000;
      finalConfig.getInteger("addressResolver.maxQueries", null);
      result = -2;
    }
  };
  AddressResolverOptions aroc = AddressResolverConfig.getAddressResover("test", finalConfig);
  Assert.assertThat(aroc.getServers(), is(Arrays.asList("6.6.6.6", "6.6.4.4")));
  Assert.assertThat(aroc.getSearchDomains(),
      is(Arrays.asList("default.svc.local.cluster")));
  Assert.assertEquals(aroc.getQueryTimeout(),
      2000);
  Assert.assertNotEquals(aroc.getMaxQueries(),
      -2);
}
 
Example 4
Source File: CodahaleMetricsServletProvider.java    From distributedlog with Apache License 2.0 6 votes vote down vote up
@Override
public void start(Configuration conf) {
    super.start(conf);
    Integer httpPort = conf.getInteger("codahaleStatsHttpPort", null);
    if (null != httpPort) {
        servletReporter = new ServletReporter(
                getMetrics(),
                healthCheckRegistry,
                httpPort);
        try {
            servletReporter.start();
        } catch (Exception e) {
            logger.warn("Encountered error on starting the codahale metrics servlet", e);
        }
    }
}
 
Example 5
Source File: CodahaleMetricsServletProvider.java    From distributedlog with Apache License 2.0 6 votes vote down vote up
@Override
public void start(Configuration conf) {
    super.start(conf);
    Integer httpPort = conf.getInteger("codahaleStatsHttpPort", null);
    if (null != httpPort) {
        servletReporter = new ServletReporter(
                getMetrics(),
                healthCheckRegistry,
                httpPort);
        try {
            servletReporter.start();
        } catch (Exception e) {
            logger.warn("Encountered error on starting the codahale metrics servlet", e);
        }
    }
}
 
Example 6
Source File: AtlasRepositoryConfiguration.java    From incubator-atlas with Apache License 2.0 6 votes vote down vote up
public static int getTypeUpdateLockMaxWaitTimeInSeconds() {
    Integer ret = typeUpdateLockMaxWaitTimeInSeconds;

    if (ret == null) {
        try {
            Configuration config = ApplicationProperties.get();

            ret = config.getInteger(CONFIG_TYPE_UPDATE_LOCK_MAX_WAIT_TIME_IN_SECONDS, DEFAULT_TYPE_UPDATE_LOCK_MAX_WAIT_TIME_IN_SECONDS);

            typeUpdateLockMaxWaitTimeInSeconds = ret;
        } catch (AtlasException e) {
            // ignore
        }
    }

    return ret == null ? DEFAULT_TYPE_UPDATE_LOCK_MAX_WAIT_TIME_IN_SECONDS : ret;
}
 
Example 7
Source File: AdWordsSession.java    From googleads-java-lib with Apache License 2.0 5 votes vote down vote up
/**
 * Reads properties from the provided {@link Configuration} object.<br><br>
 * Known properties:
 * <ul>
 * <li>api.adwords.clientCustomerId</li>
 * <li>api.adwords.userAgent</li>
 * <li>api.adwords.developerToken</li>
 * <li>api.adwords.isPartialFailure</li>
 * <li>api.adwords.endpoint</li>
 * <li>api.adwords.reporting.skipHeader</li>
 * <li>api.adwords.reporting.skipColumnHeader</li>
 * <li>api.adwords.reporting.skipSummary</li>
 * </ul>
 *
 * @param config
 * @return Builder populated from the Configuration
 */
@Override
public Builder from(Configuration config) {
  this.clientCustomerId = config.getString("api.adwords.clientCustomerId", null);
  this.userAgent = config.getString("api.adwords.userAgent", null);
  this.developerToken = config.getString("api.adwords.developerToken", null);
  this.isPartialFailure = config.getBoolean("api.adwords.isPartialFailure", null);
  this.endpoint = config.getString("api.adwords.endpoint", null);

  // Only create a ReportConfiguration for this object if at least one reporting
  // configuration config value is present.
  Boolean isSkipReportHeader = config.getBoolean("api.adwords.reporting.skipHeader", null);
  Boolean isSkipColumnHeader =
      config.getBoolean("api.adwords.reporting.skipColumnHeader", null);
  Boolean isSkipReportSummary = config.getBoolean("api.adwords.reporting.skipSummary", null);
  Boolean isUseRawEnumValues =
      config.getBoolean("api.adwords.reporting.useRawEnumValues", null);
  Integer reportDownloadTimeout = config.getInteger("api.adwords.reportDownloadTimeout", null);
  this.reportingConfiguration =
      new ReportingConfiguration.Builder()
          .skipReportHeader(isSkipReportHeader)
          .skipColumnHeader(isSkipColumnHeader)
          .skipReportSummary(isSkipReportSummary)
          .useRawEnumValues(isUseRawEnumValues)
          .reportDownloadTimeout(reportDownloadTimeout)
          .build();

  return this;
}