List of usage examples for org.apache.commons.configuration Configuration getInt
int getInt(String key, int 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 Integer} value. * * @param conf configuration to retrieve the setting * @return the value as an integer number *///w w w . j a v a2 s . co m public int getInt(Configuration conf) { checkArgument(type() == Type.INT, "'" + name() + "' is NOT a INT numeric setting"); return conf.getInt(name(), (Integer) defaultValue()); }
From source file:org.apache.bookkeeper.stats.codahale.CodahaleMetricsProvider.java
@Override public void start(Configuration conf) { initIfNecessary();//w w w . ja va 2s . c om int metricsOutputFrequency = conf.getInt("codahaleStatsOutputFrequencySeconds", 60); String prefix = conf.getString("codahaleStatsPrefix", ""); String graphiteHost = conf.getString("codahaleStatsGraphiteEndpoint"); String csvDir = conf.getString("codahaleStatsCSVEndpoint"); String slf4jCat = conf.getString("codahaleStatsSlf4jEndpoint"); String jmxDomain = conf.getString("codahaleStatsJmxEndpoint"); if (!Strings.isNullOrEmpty(graphiteHost)) { LOG.info("Configuring stats with graphite"); HostAndPort addr = HostAndPort.fromString(graphiteHost); final Graphite graphite = new Graphite(new InetSocketAddress(addr.getHostText(), addr.getPort())); reporters.add( GraphiteReporter.forRegistry(getMetrics()).prefixedWith(prefix).convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS).filter(MetricFilter.ALL).build(graphite)); } if (!Strings.isNullOrEmpty(csvDir)) { // NOTE: 1/ metrics output files are exclusive to a given process // 2/ the output directory must exist // 3/ if output files already exist they are not overwritten and there is no metrics output File outdir; if (!Strings.isNullOrEmpty(prefix)) { outdir = new File(csvDir, prefix); } else { outdir = new File(csvDir); } LOG.info("Configuring stats with csv output to directory [{}]", outdir.getAbsolutePath()); reporters.add(CsvReporter.forRegistry(getMetrics()).convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS).build(outdir)); } if (!Strings.isNullOrEmpty(slf4jCat)) { LOG.info("Configuring stats with slf4j"); reporters.add(Slf4jReporter.forRegistry(getMetrics()).outputTo(LoggerFactory.getLogger(slf4jCat)) .convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).build()); } if (!Strings.isNullOrEmpty(jmxDomain)) { LOG.info("Configuring stats with jmx"); jmx = JmxReporter.forRegistry(getMetrics()).inDomain(jmxDomain).convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS).build(); jmx.start(); } for (ScheduledReporter r : reporters) { r.start(metricsOutputFrequency, TimeUnit.SECONDS); } }
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 ww w .j a v a 2s . c om 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])); }//from www . j a v a 2s . co m }
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 w w .j ava 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.modules.data.JPAEntityManagerModule.java
@Provides @Singleton//from w ww .ja v a2 s. c o 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.server.ElasticSearchMetricReporterModule.java
@Provides public ESReporterConfiguration provideConfiguration(PropertiesProvider propertiesProvider) throws ConfigurationException { try {/*from www .j av a2 s . c o m*/ Configuration propertiesReader = propertiesProvider.getConfiguration(ELASTICSEARCH_CONFIGURATION_NAME); if (isMetricEnable(propertiesReader)) { return ESReporterConfiguration.builder().enabled() .onHost(locateHost(propertiesReader), propertiesReader.getInt("elasticsearch.http.port", DEFAULT_ES_HTTP_PORT)) .onIndex(propertiesReader.getString("elasticsearch.metrics.reports.index", null)) .periodInSecond(propertiesReader.getLong("elasticsearch.metrics.reports.period", null)) .build(); } } catch (FileNotFoundException e) { LOGGER.info("Can not locate " + ELASTICSEARCH_CONFIGURATION_NAME + " configuration"); } return ESReporterConfiguration.builder().disabled().build(); }
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; }//from w w w. j a v a 2s . co m 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))); }
From source file:org.apache.james.smtpserver.fastfail.MaxRcptHandler.java
@Override public void init(Configuration config) throws ConfigurationException { int maxRcpt = config.getInt("maxRcpt", 0); setMaxRcpt(maxRcpt);//from w w w .ja v a 2 s . c o m }