HADOOP-12348. MetricsSystemImpl creates MetricsSourceAdapter with wrong time unit parameter. (zxu via rkanter)
This commit is contained in:
parent
fba06a789c
commit
9538af0e1a
|
@ -1091,6 +1091,9 @@ Release 2.8.0 - UNRELEASED
|
||||||
HADOOP-12388. Fix components' version information in the web page
|
HADOOP-12388. Fix components' version information in the web page
|
||||||
'About the Cluster'. (Jun Gong via zxu)
|
'About the Cluster'. (Jun Gong via zxu)
|
||||||
|
|
||||||
|
HADOOP-12348. MetricsSystemImpl creates MetricsSourceAdapter with
|
||||||
|
wrong time unit parameter. (zxu via rkanter)
|
||||||
|
|
||||||
Release 2.7.2 - UNRELEASED
|
Release 2.7.2 - UNRELEASED
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -61,7 +61,7 @@ class MetricsSourceAdapter implements DynamicMBean {
|
||||||
|
|
||||||
private Iterable<MetricsRecordImpl> lastRecs;
|
private Iterable<MetricsRecordImpl> lastRecs;
|
||||||
private long jmxCacheTS = 0;
|
private long jmxCacheTS = 0;
|
||||||
private int jmxCacheTTL;
|
private long jmxCacheTTL;
|
||||||
private MBeanInfo infoCache;
|
private MBeanInfo infoCache;
|
||||||
private ObjectName mbeanName;
|
private ObjectName mbeanName;
|
||||||
private final boolean startMBeans;
|
private final boolean startMBeans;
|
||||||
|
@ -69,7 +69,7 @@ class MetricsSourceAdapter implements DynamicMBean {
|
||||||
MetricsSourceAdapter(String prefix, String name, String description,
|
MetricsSourceAdapter(String prefix, String name, String description,
|
||||||
MetricsSource source, Iterable<MetricsTag> injectedTags,
|
MetricsSource source, Iterable<MetricsTag> injectedTags,
|
||||||
MetricsFilter recordFilter, MetricsFilter metricFilter,
|
MetricsFilter recordFilter, MetricsFilter metricFilter,
|
||||||
int jmxCacheTTL, boolean startMBeans) {
|
long jmxCacheTTL, boolean startMBeans) {
|
||||||
this.prefix = checkNotNull(prefix, "prefix");
|
this.prefix = checkNotNull(prefix, "prefix");
|
||||||
this.name = checkNotNull(name, "name");
|
this.name = checkNotNull(name, "name");
|
||||||
this.source = checkNotNull(source, "source");
|
this.source = checkNotNull(source, "source");
|
||||||
|
@ -84,7 +84,7 @@ class MetricsSourceAdapter implements DynamicMBean {
|
||||||
|
|
||||||
MetricsSourceAdapter(String prefix, String name, String description,
|
MetricsSourceAdapter(String prefix, String name, String description,
|
||||||
MetricsSource source, Iterable<MetricsTag> injectedTags,
|
MetricsSource source, Iterable<MetricsTag> injectedTags,
|
||||||
int period, MetricsConfig conf) {
|
long period, MetricsConfig conf) {
|
||||||
this(prefix, name, description, source, injectedTags,
|
this(prefix, name, description, source, injectedTags,
|
||||||
conf.getFilter(RECORD_FILTER_KEY),
|
conf.getFilter(RECORD_FILTER_KEY),
|
||||||
conf.getFilter(METRIC_FILTER_KEY),
|
conf.getFilter(METRIC_FILTER_KEY),
|
||||||
|
@ -229,6 +229,10 @@ class MetricsSourceAdapter implements DynamicMBean {
|
||||||
return mbeanName;
|
return mbeanName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
long getJmxCacheTTL() {
|
||||||
|
return jmxCacheTTL;
|
||||||
|
}
|
||||||
|
|
||||||
private void updateInfoCache() {
|
private void updateInfoCache() {
|
||||||
LOG.debug("Updating info cache...");
|
LOG.debug("Updating info cache...");
|
||||||
|
|
|
@ -262,7 +262,7 @@ public class MetricsSystemImpl extends MetricsSystem implements MetricsSource {
|
||||||
checkNotNull(config, "config");
|
checkNotNull(config, "config");
|
||||||
MetricsConfig conf = sourceConfigs.get(name);
|
MetricsConfig conf = sourceConfigs.get(name);
|
||||||
MetricsSourceAdapter sa = new MetricsSourceAdapter(prefix, name, desc,
|
MetricsSourceAdapter sa = new MetricsSourceAdapter(prefix, name, desc,
|
||||||
source, injectedTags, period, conf != null ? conf
|
source, injectedTags, period * 1000L, conf != null ? conf
|
||||||
: config.subset(SOURCE_KEY));
|
: config.subset(SOURCE_KEY));
|
||||||
sources.put(name, sa);
|
sources.put(name, sa);
|
||||||
sa.start();
|
sa.start();
|
||||||
|
@ -359,7 +359,7 @@ public class MetricsSystemImpl extends MetricsSystem implements MetricsSource {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
logicalTime = 0;
|
logicalTime = 0;
|
||||||
long millis = period * 1000;
|
long millis = period * 1000L;
|
||||||
timer = new Timer("Timer for '"+ prefix +"' metrics system", true);
|
timer = new Timer("Timer for '"+ prefix +"' metrics system", true);
|
||||||
timer.scheduleAtFixedRate(new TimerTask() {
|
timer.scheduleAtFixedRate(new TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -550,7 +550,7 @@ public class MetricsSystemImpl extends MetricsSystem implements MetricsSource {
|
||||||
private void registerSystemSource() {
|
private void registerSystemSource() {
|
||||||
MetricsConfig sysConf = sourceConfigs.get(MS_NAME);
|
MetricsConfig sysConf = sourceConfigs.get(MS_NAME);
|
||||||
sysSource = new MetricsSourceAdapter(prefix, MS_STATS_NAME, MS_STATS_DESC,
|
sysSource = new MetricsSourceAdapter(prefix, MS_STATS_NAME, MS_STATS_DESC,
|
||||||
MetricsAnnotations.makeSource(this), injectedTags, period,
|
MetricsAnnotations.makeSource(this), injectedTags, period * 1000L,
|
||||||
sysConf == null ? config.subset(SOURCE_KEY) : sysConf);
|
sysConf == null ? config.subset(SOURCE_KEY) : sysConf);
|
||||||
sysSource.start();
|
sysSource.start();
|
||||||
}
|
}
|
||||||
|
|
|
@ -544,6 +544,19 @@ public class TestMetricsSystemImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRegisterSourceJmxCacheTTL() {
|
||||||
|
MetricsSystem ms = new MetricsSystemImpl();
|
||||||
|
ms.init("TestMetricsSystem");
|
||||||
|
TestSource ts = new TestSource("ts");
|
||||||
|
ms.register(ts);
|
||||||
|
MetricsSourceAdapter sa = ((MetricsSystemImpl) ms)
|
||||||
|
.getSourceAdapter("TestSource");
|
||||||
|
assertEquals(MetricsConfig.PERIOD_DEFAULT * 1000 + 1,
|
||||||
|
sa.getJmxCacheTTL());
|
||||||
|
ms.shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
@Metrics(context="test")
|
@Metrics(context="test")
|
||||||
private static class TestSource {
|
private static class TestSource {
|
||||||
@Metric("C1 desc") MutableCounterLong c1;
|
@Metric("C1 desc") MutableCounterLong c1;
|
||||||
|
|
Loading…
Reference in New Issue