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