You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zy...@apache.org on 2018/07/10 04:39:04 UTC

[42/50] [abbrv] hbase git commit: HBASE-20396 Remove redundant metrics from thrift metrics

HBASE-20396 Remove redundant metrics from thrift metrics


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/6df7f234
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/6df7f234
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/6df7f234

Branch: refs/heads/HBASE-18477
Commit: 6df7f2346ca75fe46f95427680aea32aba768cc7
Parents: 3bca018
Author: Guangxu Cheng <gu...@gmail.com>
Authored: Thu Apr 12 17:40:57 2018 +0800
Committer: Guangxu Cheng <gu...@gmail.com>
Committed: Mon Jul 9 10:33:36 2018 +0800

----------------------------------------------------------------------
 .../MetricsThriftServerSourceFactoryImpl.java   | 24 ++++++++++++--------
 1 file changed, 15 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/6df7f234/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/thrift/MetricsThriftServerSourceFactoryImpl.java
----------------------------------------------------------------------
diff --git a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/thrift/MetricsThriftServerSourceFactoryImpl.java b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/thrift/MetricsThriftServerSourceFactoryImpl.java
index 002985a..3ce2d5d 100644
--- a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/thrift/MetricsThriftServerSourceFactoryImpl.java
+++ b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/thrift/MetricsThriftServerSourceFactoryImpl.java
@@ -30,25 +30,31 @@ public class MetricsThriftServerSourceFactoryImpl implements MetricsThriftServer
    * A singleton used to make sure that only one thrift metrics source per server type is ever
    * created.
    */
-  private static enum FactoryStorage {
+  private enum FactoryStorage {
     INSTANCE;
-    MetricsThriftServerSourceImpl thriftOne = new MetricsThriftServerSourceImpl(METRICS_NAME,
-        METRICS_DESCRIPTION,
-        THRIFT_ONE_METRICS_CONTEXT,
-        THRIFT_ONE_JMX_CONTEXT);
-    MetricsThriftServerSourceImpl thriftTwo = new MetricsThriftServerSourceImpl(METRICS_NAME,
-        METRICS_DESCRIPTION,
-        THRIFT_TWO_METRICS_CONTEXT,
-        THRIFT_TWO_JMX_CONTEXT);
+    MetricsThriftServerSourceImpl thriftOne;
+    MetricsThriftServerSourceImpl thriftTwo;
   }
 
   @Override
   public MetricsThriftServerSource createThriftOneSource() {
+    if (FactoryStorage.INSTANCE.thriftOne == null) {
+      FactoryStorage.INSTANCE.thriftOne = new MetricsThriftServerSourceImpl(METRICS_NAME,
+          METRICS_DESCRIPTION,
+          THRIFT_ONE_METRICS_CONTEXT,
+          THRIFT_ONE_JMX_CONTEXT);
+    }
     return FactoryStorage.INSTANCE.thriftOne;
   }
 
   @Override
   public MetricsThriftServerSource createThriftTwoSource() {
+    if (FactoryStorage.INSTANCE.thriftTwo == null) {
+      FactoryStorage.INSTANCE.thriftTwo = new MetricsThriftServerSourceImpl(METRICS_NAME,
+          METRICS_DESCRIPTION,
+          THRIFT_TWO_METRICS_CONTEXT,
+          THRIFT_TWO_JMX_CONTEXT);
+    }
     return FactoryStorage.INSTANCE.thriftTwo;
   }
 }