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