HADOOP-10169. Merge change r1552820 from trunk.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1552822 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
76185bf7a3
commit
68164b197b
|
@ -109,6 +109,9 @@ Release 2.4.0 - UNRELEASED
|
|||
|
||||
HADOOP-10164. Allow UGI to login with a known Subject (bobby)
|
||||
|
||||
HADOOP-10169. Remove the unnecessary synchronized in JvmMetrics class.
|
||||
(Liang Xie via jing9)
|
||||
|
||||
OPTIMIZATIONS
|
||||
|
||||
HADOOP-9748. Reduce blocking on UGI.ensureInitialized (daryn)
|
||||
|
|
|
@ -24,10 +24,8 @@ import java.lang.management.MemoryUsage;
|
|||
import java.lang.management.ThreadInfo;
|
||||
import java.lang.management.ThreadMXBean;
|
||||
import java.lang.management.GarbageCollectorMXBean;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.apache.hadoop.classification.InterfaceAudience;
|
||||
import org.apache.hadoop.log.metrics.EventCounter;
|
||||
|
@ -67,7 +65,8 @@ public class JvmMetrics implements MetricsSource {
|
|||
ManagementFactory.getGarbageCollectorMXBeans();
|
||||
final ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
|
||||
final String processName, sessionId;
|
||||
final Map<String, MetricsInfo[]> gcInfoCache = Maps.newHashMap();
|
||||
final ConcurrentHashMap<String, MetricsInfo[]> gcInfoCache =
|
||||
new ConcurrentHashMap<String, MetricsInfo[]>();
|
||||
|
||||
JvmMetrics(String processName, String sessionId) {
|
||||
this.processName = processName;
|
||||
|
@ -123,13 +122,17 @@ public class JvmMetrics implements MetricsSource {
|
|||
.addCounter(GcTimeMillis, timeMillis);
|
||||
}
|
||||
|
||||
private synchronized MetricsInfo[] getGcInfo(String gcName) {
|
||||
private MetricsInfo[] getGcInfo(String gcName) {
|
||||
MetricsInfo[] gcInfo = gcInfoCache.get(gcName);
|
||||
if (gcInfo == null) {
|
||||
gcInfo = new MetricsInfo[2];
|
||||
gcInfo[0] = Interns.info("GcCount"+ gcName, "GC Count for "+ gcName);
|
||||
gcInfo[1] = Interns.info("GcTimeMillis"+ gcName, "GC Time for "+ gcName);
|
||||
gcInfoCache.put(gcName, gcInfo);
|
||||
gcInfo[0] = Interns.info("GcCount" + gcName, "GC Count for " + gcName);
|
||||
gcInfo[1] = Interns
|
||||
.info("GcTimeMillis" + gcName, "GC Time for " + gcName);
|
||||
MetricsInfo[] previousGcInfo = gcInfoCache.putIfAbsent(gcName, gcInfo);
|
||||
if (previousGcInfo != null) {
|
||||
return previousGcInfo;
|
||||
}
|
||||
}
|
||||
return gcInfo;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue