hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject svn commit: r1230188 - in /hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver: metrics/RegionServerMetrics.java wal/HLog.java
Date Wed, 11 Jan 2012 19:02:29 GMT
Author: tedyu
Date: Wed Jan 11 19:02:28 2012
New Revision: 1230188

URL: http://svn.apache.org/viewvc?rev=1230188&view=rev
Log:
HBASE-3565 Add metrics to keep track of slow HLog appends (Mubarak)

Modified:
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/metrics/RegionServerMetrics.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/metrics/RegionServerMetrics.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/metrics/RegionServerMetrics.java?rev=1230188&r1=1230187&r2=1230188&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/metrics/RegionServerMetrics.java
(original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/metrics/RegionServerMetrics.java
Wed Jan 11 19:02:28 2012
@@ -232,6 +232,12 @@ public class RegionServerMetrics impleme
 
   protected final PersistentMetricsTimeVaryingRate flushSize =
     new PersistentMetricsTimeVaryingRate("flushSize", registry);
+  
+  public final MetricsLongValue slowHLogAppendCount =
+      new MetricsLongValue("slowHLogAppendCount", registry);
+  
+  public final MetricsTimeVaryingRate slowHLogAppendTime =
+      new MetricsTimeVaryingRate("slowHLogAppendTime", registry);
 
   public RegionServerMetrics() {
     MetricsContext context = MetricsUtil.getContext("hbase");
@@ -323,6 +329,8 @@ public class RegionServerMetrics impleme
       addHLogMetric(HLog.getWriteTime(), this.fsWriteLatency);
       addHLogMetric(HLog.getWriteSize(), this.fsWriteSize);
       addHLogMetric(HLog.getSyncTime(), this.fsSyncLatency);
+      addHLogMetric(HLog.getSlowAppendTime(), this.slowHLogAppendTime);
+      this.slowHLogAppendCount.set(HLog.getSlowAppendCount());
       // HFile metrics, sequential reads
       int ops = HFile.getReadOps(); 
       if (ops != 0) this.fsReadLatency.inc(ops, HFile.getReadTimeMs());
@@ -345,6 +353,7 @@ public class RegionServerMetrics impleme
       this.compactionSize.pushMetric(this.metricsRecord);
       this.flushTime.pushMetric(this.metricsRecord);
       this.flushSize.pushMetric(this.metricsRecord);
+      this.slowHLogAppendCount.pushMetric(this.metricsRecord);
     }
     this.metricsRecord.update();
   }
@@ -367,6 +376,7 @@ public class RegionServerMetrics impleme
     this.fsWriteLatency.resetMinMax();
     this.fsWriteSize.resetMinMax();
     this.fsSyncLatency.resetMinMax();
+    this.slowHLogAppendTime.resetMinMax();
   }
 
   /**
@@ -457,6 +467,8 @@ public class RegionServerMetrics impleme
         Long.valueOf(this.blockCacheHitCachingRatio.get())+"%");
     sb = Strings.appendKeyValue(sb, this.hdfsBlocksLocalityIndex.getName(),
         Long.valueOf(this.hdfsBlocksLocalityIndex.get()));
+    sb = Strings.appendKeyValue(sb, "slowHLogAppendCount",
+        Long.valueOf(this.slowHLogAppendCount.get()));
     return sb.toString();
   }
 }

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java?rev=1230188&r1=1230187&r2=1230188&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java Wed Jan 11
19:02:28 2012
@@ -296,6 +296,9 @@ public class HLog implements Syncable {
   // For measuring latency of syncs
   private static Metric syncTime = new Metric();
   private static AtomicLong syncBatchSize = new AtomicLong();
+  //For measuring slow HLog appends
+  private static AtomicLong slowHLogAppendCount = new AtomicLong();
+  private static Metric slowHLogAppendTime = new Metric();
   
   public static Metric getWriteTime() {
     return writeTime.get();
@@ -312,6 +315,14 @@ public class HLog implements Syncable {
   public static long getSyncBatchSize() {
     return syncBatchSize.getAndSet(0);
   }
+  
+  public static long getSlowAppendCount() {
+    return slowHLogAppendCount.get();
+  }
+  
+  public static Metric getSlowAppendTime() {
+    return slowHLogAppendTime.get();
+  }
 
   /**
    * Constructor.
@@ -1407,6 +1418,8 @@ public class HLog implements Syncable {
           "%s took %d ms appending an edit to hlog; editcount=%d, len~=%s",
           Thread.currentThread().getName(), took, this.numEntries.get(),
           StringUtils.humanReadableInt(len)));
+        slowHLogAppendCount.incrementAndGet();
+        slowHLogAppendTime.inc(took);
       }
     } catch (IOException e) {
       LOG.fatal("Could not append. Requesting close of hlog", e);



Mime
View raw message