HADOOP-11361. Fix a race condition in MetricsSourceAdapter.updateJmxCache. Contributed by Brahma Reddy Battula.
(cherry picked from commit 4356e8a5ef
)
Conflicts:
hadoop-common-project/hadoop-common/CHANGES.txt
This commit is contained in:
parent
47dfb69a26
commit
2b7e6f7dfd
|
@ -25,6 +25,9 @@ Release 2.7.3 - UNRELEASED
|
|||
HADOOP-12374. Updated expunge command description.
|
||||
(WeiWei Yang via eyang)
|
||||
|
||||
HADOOP-11361. Fix a race condition in MetricsSourceAdapter.updateJmxCache.
|
||||
(Brahma Reddy Battula via ozawa)
|
||||
|
||||
Release 2.7.2 - UNRELEASED
|
||||
|
||||
INCOMPATIBLE CHANGES
|
||||
|
|
|
@ -154,31 +154,28 @@ class MetricsSourceAdapter implements DynamicMBean {
|
|||
|
||||
private void updateJmxCache() {
|
||||
boolean getAllMetrics = false;
|
||||
synchronized(this) {
|
||||
synchronized (this) {
|
||||
if (Time.now() - jmxCacheTS >= jmxCacheTTL) {
|
||||
// temporarilly advance the expiry while updating the cache
|
||||
jmxCacheTS = Time.now() + jmxCacheTTL;
|
||||
if (lastRecs == null) {
|
||||
getAllMetrics = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (getAllMetrics) {
|
||||
MetricsCollectorImpl builder = new MetricsCollectorImpl();
|
||||
getMetrics(builder, true);
|
||||
}
|
||||
if (getAllMetrics) {
|
||||
MetricsCollectorImpl builder = new MetricsCollectorImpl();
|
||||
getMetrics(builder, true);
|
||||
}
|
||||
|
||||
synchronized(this) {
|
||||
updateAttrCache();
|
||||
if (getAllMetrics) {
|
||||
updateInfoCache();
|
||||
}
|
||||
jmxCacheTS = Time.now();
|
||||
lastRecs = null; // in case regular interval update is not running
|
||||
lastRecs = null; // in case regular interval update is not running
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue