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.metrics.BaseSourceImpl;
22 import org.apache.hadoop.metrics2.MetricHistogram;
23 import org.apache.hadoop.metrics2.lib.MetricMutableCounterLong;
24
25
26
27
28
29
30 public class MetricsWALSourceImpl extends BaseSourceImpl implements MetricsWALSource {
31
32 private final MetricHistogram appendSizeHisto;
33 private final MetricHistogram appendTimeHisto;
34 private final MetricMutableCounterLong appendCount;
35 private final MetricMutableCounterLong slowAppendCount;
36 private final MetricHistogram syncTimeHisto;
37 private final MetricMutableCounterLong logRollRequested;
38 private final MetricMutableCounterLong lowReplicationLogRollRequested;
39 private final MetricMutableCounterLong writtenBytes;
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().newTimeHistogram(APPEND_TIME, APPEND_TIME_DESC);
53 appendSizeHisto = this.getMetricsRegistry().newSizeHistogram(APPEND_SIZE, APPEND_SIZE_DESC);
54 appendCount = this.getMetricsRegistry().newCounter(APPEND_COUNT, APPEND_COUNT_DESC, 0l);
55 slowAppendCount =
56 this.getMetricsRegistry().newCounter(SLOW_APPEND_COUNT, SLOW_APPEND_COUNT_DESC, 0l);
57 syncTimeHisto = this.getMetricsRegistry().newTimeHistogram(SYNC_TIME, SYNC_TIME_DESC);
58 logRollRequested =
59 this.getMetricsRegistry().newCounter(ROLL_REQUESTED, ROLL_REQUESTED_DESC, 0L);
60 lowReplicationLogRollRequested = this.getMetricsRegistry()
61 .newCounter(LOW_REPLICA_ROLL_REQUESTED, LOW_REPLICA_ROLL_REQUESTED_DESC, 0L);
62 writtenBytes = this.getMetricsRegistry().newCounter(WRITTEN_BYTES, WRITTEN_BYTES_DESC, 0l);
63 }
64
65 @Override
66 public void incrementAppendSize(long size) {
67 appendSizeHisto.add(size);
68 }
69
70 @Override
71 public void incrementAppendTime(long time) {
72 appendTimeHisto.add(time);
73 }
74
75 @Override
76 public void incrementAppendCount() {
77 appendCount.incr();
78 }
79
80 @Override
81 public void incrementSlowAppendCount() {
82 slowAppendCount.incr();
83 }
84
85 @Override
86 public void incrementSyncTime(long time) {
87 syncTimeHisto.add(time);
88 }
89
90 @Override
91 public void incrementLogRollRequested() {
92 logRollRequested.incr();
93 }
94
95 @Override
96 public void incrementLowReplicationLogRoll() {
97 lowReplicationLogRollRequested.incr();
98 }
99
100 @Override
101 public void incrementWrittenBytes(long val) {
102 writtenBytes.incr(val);
103 }
104 }