List of usage examples for org.apache.commons.configuration Configuration getBoolean
Boolean getBoolean(String key, Boolean defaultValue);
From source file:org.apache.blur.titan.BlurIndex.java
public BlurIndex(Configuration config) { _tableNamePrefix = config.getString(BLUR_TABLE_PREFIX, DEFAULT_TABLE_NAME_PREFIX); _defaultShardCount = config.getInt(BLUR_TABLE_DEFAULT_SHARD_COUNT, DEFAULT_SHARD_COUNT); _controllerConnectionString = config.getString(BLUR_CONTROLLER_CONNECTION, ""); _family = config.getString(BLUR_FAMILY_DEFAULT, TITAN); _waitToBeVisible = config.getBoolean(BLUR_WAIT_TO_BE_VISIBLE, DEFAULT_BLUR_WAIT_TO_BE_VISIBLE); _wal = config.getBoolean(BLUR_WRITE_AHEAD_LOG, DEFAULT_BLUR_WRITE_AHEAD_LOG); Preconditions.checkArgument(StringUtils.isNotBlank(_controllerConnectionString), "Need to configure connection string for Blur (" + BLUR_CONTROLLER_CONNECTION + ")"); LOG.info("Blur using connection [" + _controllerConnectionString + "] with table prefix of [" + _tableNamePrefix + "]"); }
From source file:org.apache.bookkeeper.common.conf.ConfigKey.java
/** * Retrieve the setting from the configuration <tt>conf</tt> as a {@link Boolean} value. * * @param conf configuration to retrieve the setting * @return the value as a boolean flag/*from ww w. j a va 2s . co m*/ */ public boolean getBoolean(Configuration conf) { checkArgument(type() == Type.BOOLEAN, "'" + name() + "' is NOT a BOOL numeric setting"); return conf.getBoolean(name(), (Boolean) defaultValue()); }
From source file:org.apache.bookkeeper.stats.prometheus.PrometheusMetricsProvider.java
@Override public void start(Configuration conf) { boolean httpEnabled = conf.getBoolean(PROMETHEUS_STATS_HTTP_ENABLE, DEFAULT_PROMETHEUS_STATS_HTTP_ENABLE); boolean bkHttpServerEnabled = conf.getBoolean("httpServerEnabled", false); // only start its own http server when prometheus http is enabled and bk http server is not enabled. if (httpEnabled && !bkHttpServerEnabled) { int httpPort = conf.getInt(PROMETHEUS_STATS_HTTP_PORT, DEFAULT_PROMETHEUS_STATS_HTTP_PORT); InetSocketAddress httpEndpoint = InetSocketAddress.createUnresolved("0.0.0.0", httpPort); this.server = new Server(httpEndpoint); ServletContextHandler context = new ServletContextHandler(); context.setContextPath("/"); server.setHandler(context);//from www . java 2 s . com context.addServlet(new ServletHolder(new PrometheusServlet(this)), "/metrics"); try { server.start(); log.info("Started Prometheus stats endpoint at {}", httpEndpoint); } catch (Exception e) { throw new RuntimeException(e); } } // Include standard JVM stats registerMetrics(new StandardExports()); registerMetrics(new MemoryPoolsExports()); registerMetrics(new GarbageCollectorExports()); registerMetrics(new ThreadExports()); // Add direct memory allocated through unsafe registerMetrics(Gauge.build("jvm_memory_direct_bytes_used", "-").create().setChild(new Child() { @Override public double get() { return directMemoryUsage != null ? directMemoryUsage.longValue() : Double.NaN; } })); registerMetrics(Gauge.build("jvm_memory_direct_bytes_max", "-").create().setChild(new Child() { @Override public double get() { return PlatformDependent.maxDirectMemory(); } })); executor = Executors.newSingleThreadScheduledExecutor(new DefaultThreadFactory("metrics")); int latencyRolloverSeconds = conf.getInt(PROMETHEUS_STATS_LATENCY_ROLLOVER_SECONDS, DEFAULT_PROMETHEUS_STATS_LATENCY_ROLLOVER_SECONDS); executor.scheduleAtFixedRate(() -> { rotateLatencyCollection(); }, 1, latencyRolloverSeconds, TimeUnit.SECONDS); }
From source file:org.apache.bookkeeper.stats.twitter.ostrich.OstrichProvider.java
@Override public void start(Configuration conf) { if (conf.getBoolean(STATS_EXPORT, false)) { statsExporter = new com.twitter.ostrich.admin.AdminServiceFactory(conf.getInt(STATS_HTTP_PORT, 9002), 20, List$.MODULE$.<StatsFactory>empty(), Some.apply(""), List$.MODULE$.<Regex>empty(), OstrichProvider.<String, CustomHttpHandler>emptyMap(), list(Duration.apply(1, TimeUnit.MINUTES))).apply(RuntimeEnvironment.apply(this, new String[0])); }/*www. j a va 2s .c om*/ }
From source file:org.apache.bookkeeper.stats.twitter.science.TwitterStatsProvider.java
@Override public void start(Configuration conf) { if (conf.getBoolean(STATS_EXPORT, false)) { statsExporter = new HTTPStatsExporter(conf.getInt(STATS_HTTP_PORT, 9002)); }/*from w ww . j a va 2s . c om*/ if (null != statsExporter) { try { statsExporter.start(); } catch (Exception e) { LOG.error("Fail to start stats exporter : ", e); } } }
From source file:org.apache.james.mailbox.elasticsearch.ElasticSearchMailboxConfiguration.java
private static IndexAttachments provideIndexAttachments(Configuration configuration) { if (configuration.getBoolean(ELASTICSEARCH_INDEX_ATTACHMENTS, DEFAULT_INDEX_ATTACHMENTS)) { return IndexAttachments.YES; }//w ww . j a va 2 s .c o m return IndexAttachments.NO; }
From source file:org.apache.james.modules.data.JPAEntityManagerModule.java
@Provides @Singleton//from w ww. j a v a 2 s. co m JPAConfiguration provideConfiguration(PropertiesProvider propertiesProvider) throws FileNotFoundException, ConfigurationException { Configuration dataSource = propertiesProvider.getConfiguration("james-database"); return JPAConfiguration.builder().driverName(dataSource.getString("database.driverClassName")) .driverURL(dataSource.getString("database.url")) .testOnBorrow(dataSource.getBoolean("datasource.testOnBorrow", false)) .validationQueryTimeoutSec(dataSource.getInt("datasource.validationQueryTimeoutSec", JPAConstants.VALIDATION_NO_TIMEOUT)) .validationQuery(dataSource.getString("datasource.validationQuery", null)).build(); }
From source file:org.apache.james.modules.mailbox.TikaConfigurationReader.java
public static TikaConfiguration readTikaConfiguration(Configuration configuration) { AbstractConfiguration.setDefaultListDelimiter(','); Optional<Boolean> enabled = Optional.ofNullable(configuration.getBoolean(TIKA_ENABLED, null)); Optional<Boolean> cacheEnabled = Optional.ofNullable(configuration.getBoolean(TIKA_CACHE_ENABLED, null)); Optional<String> host = Optional.ofNullable(configuration.getString(TIKA_HOST, null)); Optional<Integer> port = Optional.ofNullable(configuration.getInteger(TIKA_PORT, null)); Optional<Integer> timeoutInMillis = Optional.ofNullable(configuration.getInteger(TIKA_TIMEOUT_IN_MS, null)); Optional<Duration> cacheEvictionPeriod = Optional .ofNullable(configuration.getString(TIKA_CACHE_EVICTION_PERIOD, null)) .map(rawString -> TimeConverter.getMilliSeconds(rawString, TimeConverter.Unit.SECONDS)) .map(Duration::ofMillis); Optional<Long> cacheWeight = Optional.ofNullable(configuration.getString(TIKA_CACHE_WEIGHT_MAX, null)) .map(Throwing.function(Size::parse)).map(Size::asBytes); Set<String> contentTypeBlacklist = StreamUtils .ofNullable(configuration.getStringArray(TIKA_CONTENT_TYPE_BLACKLIST)).map(String::trim) .collect(ImmutableSet.toImmutableSet()); return TikaConfiguration.builder().enable(enabled).host(host).port(port).timeoutInMillis(timeoutInMillis) .cacheEnable(cacheEnabled).cacheEvictionPeriod(cacheEvictionPeriod).cacheWeightInBytes(cacheWeight) .contentTypeBlacklist(contentTypeBlacklist).build(); }
From source file:org.apache.james.modules.server.ElasticSearchMetricReporterModule.java
private boolean isMetricEnable(Configuration propertiesReader) { return propertiesReader.getBoolean("elasticsearch.metrics.reports.enabled", DEFAULT_DISABLE); }
From source file:org.apache.james.modules.server.JmxConfiguration.java
public static JmxConfiguration fromProperties(Configuration configuration) { boolean jmxEnabled = configuration.getBoolean("jmx.enabled", true); if (!jmxEnabled) { return DISABLED; }//w w w .j av a 2s. c om String address = configuration.getString("jmx.address", LOCALHOST); int port = configuration.getInt("jmx.port", DEFAULT_PORT); return new JmxConfiguration(ENABLED, Optional.of(Host.from(address, port))); }