1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.hadoop.hbase.replication.regionserver;
20
21 import org.apache.hadoop.metrics2.lib.MutableFastCounter;
22 import org.apache.hadoop.metrics2.lib.MutableGaugeLong;
23 import org.apache.hadoop.metrics2.lib.MutableHistogram;
24
25 public class MetricsReplicationSinkSourceImpl implements MetricsReplicationSinkSource {
26
27 @Deprecated
28 private final MutableGaugeLong ageGauge;
29 private final MutableHistogram ageHist;
30 private final MutableFastCounter batchesCounter;
31 private final MutableFastCounter opsCounter;
32 private final MutableFastCounter hfilesCounter;
33
34 public MetricsReplicationSinkSourceImpl(MetricsReplicationSourceImpl rms) {
35 ageGauge = rms.getMetricsRegistry().
36 getCompatibilityRegistry().getGauge(SINK_AGE_OF_LAST_APPLIED_OP, 0L);
37 ageHist = rms.getMetricsRegistry().getHistogram(SINK_AGE_OF_LAST_APPLIED_OP);
38 batchesCounter = rms.getMetricsRegistry().getCounter(SINK_APPLIED_BATCHES, 0L);
39 opsCounter = rms.getMetricsRegistry().getCounter(SINK_APPLIED_OPS, 0L);
40 hfilesCounter = rms.getMetricsRegistry().getCounter(SINK_APPLIED_HFILES, 0L);
41 }
42
43 @Override public void setLastAppliedOpAge(long age) {
44 ageHist.add(age);
45 ageGauge.set(getLastAppliedOpAge());
46 }
47
48 @Override public void incrAppliedBatches(long batches) {
49 batchesCounter.incr(batches);
50 }
51
52 @Override public void incrAppliedOps(long batchsize) {
53 opsCounter.incr(batchsize);
54 }
55
56 @Override
57 public long getLastAppliedOpAge() {
58 return ageHist.getMax();
59 }
60
61 @Override
62 public void incrAppliedHFiles(long hfiles) {
63 hfilesCounter.incr(hfiles);
64 }
65 }