You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by st...@apache.org on 2014/12/02 08:03:04 UTC

hadoop git commit: Revert "HBASE-11301 [optionally] update jmx cache to drop old metrics (Maysam Yabandeh via stack)"

Repository: hadoop
Updated Branches:
  refs/heads/branch-2 fd6a801dd -> 76245dfcc


Revert "HBASE-11301 [optionally] update jmx cache to drop old metrics (Maysam Yabandeh via stack)"

This reverts commit fd6a801ddb2d2db83f98e7aab183a6e07ce4890c.

Refers to an HBASE rather than HADOOP issue.


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/76245dfc
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/76245dfc
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/76245dfc

Branch: refs/heads/branch-2
Commit: 76245dfccdf120484fd61620600b93d3e93c61e2
Parents: fd6a801
Author: stack <st...@duboce.net>
Authored: Mon Dec 1 23:02:32 2014 -0800
Committer: stack <st...@duboce.net>
Committed: Mon Dec 1 23:02:32 2014 -0800

----------------------------------------------------------------------
 hadoop-common-project/hadoop-common/CHANGES.txt |  3 --
 .../metrics2/impl/MetricsSourceAdapter.java     |  5 +-
 .../metrics2/impl/TestMetricsSourceAdapter.java | 51 --------------------
 3 files changed, 3 insertions(+), 56 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/76245dfc/hadoop-common-project/hadoop-common/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt
index 58bc0ad..00212f6 100644
--- a/hadoop-common-project/hadoop-common/CHANGES.txt
+++ b/hadoop-common-project/hadoop-common/CHANGES.txt
@@ -41,9 +41,6 @@ Release 2.7.0 - UNRELEASED
 
     HADOOP-11341. KMS support for whitelist key ACLs. (Arun Suresh via wang)
 
-    HADOOP-11301. [optionally] update jmx cache to drop old metrics
-    (Maysam Yabandeh via stack)
-
   OPTIMIZATIONS
 
     HADOOP-11323. WritableComparator#compare keeps reference to byte array.

http://git-wip-us.apache.org/repos/asf/hadoop/blob/76245dfc/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsSourceAdapter.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsSourceAdapter.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsSourceAdapter.java
index b0b758c..de1b28c 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsSourceAdapter.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsSourceAdapter.java
@@ -173,8 +173,9 @@ class MetricsSourceAdapter implements DynamicMBean {
     }
 
     synchronized(this) {
-      updateAttrCache();
-      if (getAllMetrics) {
+      int oldCacheSize = attrCache.size();
+      int newCacheSize = updateAttrCache();
+      if (oldCacheSize < newCacheSize) {
         updateInfoCache();
       }
       jmxCacheTS = Time.now();

http://git-wip-us.apache.org/repos/asf/hadoop/blob/76245dfc/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/impl/TestMetricsSourceAdapter.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/impl/TestMetricsSourceAdapter.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/impl/TestMetricsSourceAdapter.java
index 22b594a..724d449 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/impl/TestMetricsSourceAdapter.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/impl/TestMetricsSourceAdapter.java
@@ -23,8 +23,6 @@ import static org.junit.Assert.*;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.hadoop.metrics2.MetricsCollector;
-import org.apache.hadoop.metrics2.MetricsRecordBuilder;
 import org.apache.hadoop.metrics2.MetricsSource;
 import org.apache.hadoop.metrics2.MetricsTag;
 import org.apache.hadoop.metrics2.annotation.Metric;
@@ -33,59 +31,10 @@ import org.apache.hadoop.metrics2.lib.MetricsAnnotations;
 import org.apache.hadoop.metrics2.lib.MetricsRegistry;
 import org.apache.hadoop.metrics2.lib.MetricsSourceBuilder;
 import org.apache.hadoop.metrics2.lib.MutableCounterLong;
-import static org.apache.hadoop.metrics2.lib.Interns.info;
-import static org.junit.Assert.assertEquals;
-
 import org.junit.Test;
 
-import javax.management.MBeanAttributeInfo;
-import javax.management.MBeanInfo;
-
 public class TestMetricsSourceAdapter {
 
-
-  @Test
-  public void testPurgeOldMetrics() throws Exception {
-    // create test source with a single metric counter of value 1
-    PurgableSource source = new PurgableSource();
-    MetricsSourceBuilder sb = MetricsAnnotations.newSourceBuilder(source);
-    final MetricsSource s = sb.build();
-
-    List<MetricsTag> injectedTags = new ArrayList<MetricsTag>();
-    MetricsSourceAdapter sa = new MetricsSourceAdapter(
-        "tst", "tst", "testdesc", s, injectedTags, null, null, 1, false);
-
-    MBeanInfo info = sa.getMBeanInfo();
-    boolean sawIt = false;
-    for (MBeanAttributeInfo mBeanAttributeInfo : info.getAttributes()) {
-      sawIt |= mBeanAttributeInfo.getName().equals(source.lastKeyName);
-    };
-    assertTrue("The last generated metric is not exported to jmx", sawIt);
-
-    Thread.sleep(1000); // skip JMX cache TTL
-
-    info = sa.getMBeanInfo();
-    sawIt = false;
-    for (MBeanAttributeInfo mBeanAttributeInfo : info.getAttributes()) {
-      sawIt |= mBeanAttributeInfo.getName().equals(source.lastKeyName);
-    };
-    assertTrue("The last generated metric is not exported to jmx", sawIt);
-  }
-
-  //generate a new key per each call
-  class PurgableSource implements MetricsSource {
-    int nextKey = 0;
-    String lastKeyName = null;
-    @Override
-    public void getMetrics(MetricsCollector collector, boolean all) {
-      MetricsRecordBuilder rb =
-          collector.addRecord("purgablesource")
-              .setContext("test");
-      lastKeyName = "key" + nextKey++;
-      rb.addGauge(info(lastKeyName, "desc"), 1);
-    }
-  }
-
   @Test
   public void testGetMetricsAndJmx() throws Exception {
     // create test source with a single metric counter of value 0