1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.hadoop.hbase.regionserver.wal;
20
21 import org.apache.hadoop.classification.InterfaceAudience;
22 import org.apache.hadoop.hbase.metrics.BaseSourceImpl;
23 import org.apache.hadoop.metrics2.MetricHistogram;
24 import org.apache.hadoop.metrics2.lib.MutableCounterLong;
25
26
27
28
29
30
31
32 @InterfaceAudience.Private
33 public class MetricsWALSourceImpl extends BaseSourceImpl implements MetricsWALSource {
34
35 private final MetricHistogram appendSizeHisto;
36 private final MetricHistogram appendTimeHisto;
37 private final MetricHistogram syncTimeHisto;
38 private final MutableCounterLong appendCount;
39 private final MutableCounterLong slowAppendCount;
40
41 public MetricsWALSourceImpl() {
42 this(METRICS_NAME, METRICS_DESCRIPTION, METRICS_CONTEXT, METRICS_JMX_CONTEXT);
43 }
44
45 public MetricsWALSourceImpl(String metricsName,
46 String metricsDescription,
47 String metricsContext,
48 String metricsJmxContext) {
49 super(metricsName, metricsDescription, metricsContext, metricsJmxContext);
50
51
52 appendTimeHisto = this.getMetricsRegistry().newHistogram(APPEND_TIME, APPEND_TIME_DESC);
53 appendSizeHisto = this.getMetricsRegistry().newHistogram(APPEND_SIZE, APPEND_SIZE_DESC);
54 appendCount = this.getMetricsRegistry().newCounter(APPEND_COUNT, APPEND_COUNT_DESC, 0l);
55 slowAppendCount = this.getMetricsRegistry().newCounter(SLOW_APPEND_COUNT, SLOW_APPEND_COUNT_DESC, 0l);
56 syncTimeHisto = this.getMetricsRegistry().newHistogram(SYNC_TIME, SYNC_TIME_DESC);
57 }
58
59 @Override
60 public void incrementAppendSize(long size) {
61 appendSizeHisto.add(size);
62 }
63
64 @Override
65 public void incrementAppendTime(long time) {
66 appendTimeHisto.add(time);
67 }
68
69 @Override
70 public void incrementAppendCount() {
71 appendCount.incr();
72 }
73
74 @Override
75 public void incrementSlowAppendCount() {
76 slowAppendCount.incr();
77 }
78
79 @Override
80 public void incrementSyncTime(long time) {
81 syncTimeHisto.add(time);
82 }
83 }