From 1901c501c894c4e33c87c22ad0a9160eadc626ba Mon Sep 17 00:00:00 2001 From: Todd Lipcon Date: Tue, 25 Sep 2012 23:16:20 +0000 Subject: [PATCH] HADOOP-3957. Change MutableQuantiles to use a shared thread for rolling over metrics. Contributed by Andrew Wang. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1390211 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-common-project/hadoop-common/CHANGES.txt | 3 +++ .../org/apache/hadoop/metrics2/lib/MutableQuantiles.java | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 43b7a965428..45da8b3acf0 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -22,6 +22,9 @@ Release 2.0.3-alpha - Unreleased HADOOP-8812. ExitUtil#terminate should print Exception#toString. (eli) + HADOOP-3957. Change MutableQuantiles to use a shared thread for rolling + over metrics. (Andrew Wang via todd) + OPTIMIZATIONS BUG FIXES diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableQuantiles.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableQuantiles.java index e8992983a53..af579851782 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableQuantiles.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableQuantiles.java @@ -35,6 +35,7 @@ import org.apache.hadoop.metrics2.util.Quantile; import org.apache.hadoop.metrics2.util.SampleQuantiles; import com.google.common.annotations.VisibleForTesting; +import com.google.common.util.concurrent.ThreadFactoryBuilder; /** * Watches a stream of long values, maintaining online estimates of specific @@ -60,8 +61,9 @@ public class MutableQuantiles extends MutableMetric { @VisibleForTesting protected Map previousSnapshot = null; - private final ScheduledExecutorService scheduler = Executors - .newScheduledThreadPool(1); + private static final ScheduledExecutorService scheduler = Executors + .newScheduledThreadPool(1, new ThreadFactoryBuilder().setDaemon(true) + .setNameFormat("MutableQuantiles-%d").build()); /** * Instantiates a new {@link MutableQuantiles} for a metric that rolls itself