use of org.apache.hadoop.metrics2.impl.MetricsConfig in project hadoop by apache.
the class MetricsConfig method getFilter.
MetricsFilter getFilter(String prefix) {
// don't create filter instances without out options
MetricsConfig conf = subset(prefix);
if (conf.isEmpty())
return null;
MetricsFilter filter = getPlugin(prefix);
if (filter != null)
return filter;
// glob filter is assumed if pattern is specified but class is not.
filter = new GlobFilter();
filter.init(conf);
return filter;
}
use of org.apache.hadoop.metrics2.impl.MetricsConfig in project hadoop by apache.
the class MetricsSystemImpl method registerSource.
synchronized void registerSource(String name, String desc, MetricsSource source) {
checkNotNull(config, "config");
MetricsConfig conf = sourceConfigs.get(name);
MetricsSourceAdapter sa = new MetricsSourceAdapter(prefix, name, desc, source, injectedTags, period, conf != null ? conf : config.subset(SOURCE_KEY));
sources.put(name, sa);
sa.start();
LOG.debug("Registered source " + name);
}
use of org.apache.hadoop.metrics2.impl.MetricsConfig in project hadoop by apache.
the class MetricsSystemImpl method configureSinks.
private synchronized void configureSinks() {
sinkConfigs = config.getInstanceConfigs(SINK_KEY);
long confPeriodMillis = 0;
for (Entry<String, MetricsConfig> entry : sinkConfigs.entrySet()) {
MetricsConfig conf = entry.getValue();
int sinkPeriod = conf.getInt(PERIOD_KEY, PERIOD_DEFAULT);
// Support configuring periodMillis for testing.
long sinkPeriodMillis = conf.getLong(PERIOD_MILLIS_KEY, sinkPeriod * 1000);
confPeriodMillis = confPeriodMillis == 0 ? sinkPeriodMillis : ArithmeticUtils.gcd(confPeriodMillis, sinkPeriodMillis);
String clsName = conf.getClassName("");
// sink can be registered later on
if (clsName == null)
continue;
String sinkName = entry.getKey();
try {
MetricsSinkAdapter sa = newSink(sinkName, conf.getString(DESC_KEY, sinkName), conf);
sa.start();
sinks.put(sinkName, sa);
} catch (Exception e) {
LOG.warn("Error creating sink '" + sinkName + "'", e);
}
}
long periodSec = config.getInt(PERIOD_KEY, PERIOD_DEFAULT);
period = confPeriodMillis > 0 ? confPeriodMillis : config.getLong(PERIOD_MILLIS_KEY, periodSec * 1000);
}
use of org.apache.hadoop.metrics2.impl.MetricsConfig in project hadoop by apache.
the class MetricsSystemImpl method registerSystemSource.
private void registerSystemSource() {
MetricsConfig sysConf = sourceConfigs.get(MS_NAME);
sysSource = new MetricsSourceAdapter(prefix, MS_STATS_NAME, MS_STATS_DESC, MetricsAnnotations.makeSource(this), injectedTags, period, sysConf == null ? config.subset(SOURCE_KEY) : sysConf);
sysSource.start();
}
use of org.apache.hadoop.metrics2.impl.MetricsConfig in project hadoop by apache.
the class MetricsSystemImpl method registerSink.
synchronized void registerSink(String name, String desc, MetricsSink sink) {
checkNotNull(config, "config");
MetricsConfig conf = sinkConfigs.get(name);
MetricsSinkAdapter sa = conf != null ? newSink(name, desc, sink, conf) : newSink(name, desc, sink, config.subset(SINK_KEY));
sinks.put(name, sa);
sa.start();
LOG.info("Registered sink " + name);
}
Aggregations