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