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.hbase.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
33 @InterfaceAudience.Private
34 public class MetricsWALSourceImpl extends BaseSourceImpl implements MetricsWALSource {
35
36 private final MetricHistogram appendSizeHisto;
37 private final MetricHistogram appendTimeHisto;
38 private final MetricHistogram syncTimeHisto;
39 private final MutableCounterLong appendCount;
40 private final MutableCounterLong slowAppendCount;
41 private final MutableCounterLong logRollRequested;
42 private final MutableCounterLong lowReplicationLogRollRequested;
43
44 public MetricsWALSourceImpl() {
45 this(METRICS_NAME, METRICS_DESCRIPTION, METRICS_CONTEXT, METRICS_JMX_CONTEXT);
46 }
47
48 public MetricsWALSourceImpl(String metricsName,
49 String metricsDescription,
50 String metricsContext,
51 String metricsJmxContext) {
52 super(metricsName, metricsDescription, metricsContext, metricsJmxContext);
53
54
55 appendTimeHisto = this.getMetricsRegistry().newTimeHistogram(APPEND_TIME, APPEND_TIME_DESC);
56 appendSizeHisto = this.getMetricsRegistry().newSizeHistogram(APPEND_SIZE, APPEND_SIZE_DESC);
57 appendCount = this.getMetricsRegistry().newCounter(APPEND_COUNT, APPEND_COUNT_DESC, 0l);
58 slowAppendCount =
59 this.getMetricsRegistry().newCounter(SLOW_APPEND_COUNT, SLOW_APPEND_COUNT_DESC, 0l);
60 syncTimeHisto = this.getMetricsRegistry().newTimeHistogram(SYNC_TIME, SYNC_TIME_DESC);
61 logRollRequested =
62 this.getMetricsRegistry().newCounter(ROLL_REQUESTED, ROLL_REQUESTED_DESC, 0L);
63 lowReplicationLogRollRequested = this.getMetricsRegistry()
64 .newCounter(LOW_REPLICA_ROLL_REQUESTED, LOW_REPLICA_ROLL_REQUESTED_DESC, 0L);
65 }
66
67 @Override
68 public void incrementAppendSize(long size) {
69 appendSizeHisto.add(size);
70 }
71
72 @Override
73 public void incrementAppendTime(long time) {
74 appendTimeHisto.add(time);
75 }
76
77 @Override
78 public void incrementAppendCount() {
79 appendCount.incr();
80 }
81
82 @Override
83 public void incrementSlowAppendCount() {
84 slowAppendCount.incr();
85 }
86
87 @Override
88 public void incrementSyncTime(long time) {
89 syncTimeHisto.add(time);
90 }
91
92 @Override
93 public void incrementLogRollRequested() {
94 logRollRequested.incr();
95 }
96
97 @Override
98 public void incrementLowReplicationLogRoll() {
99 lowReplicationLogRollRequested.incr();
100 }
101 }