1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.hadoop.hbase.client.backoff;
19
20 import org.apache.hadoop.hbase.classification.InterfaceAudience;
21 import org.apache.hadoop.hbase.protobuf.generated.ClientProtos;
22 import org.apache.hadoop.hbase.util.Bytes;
23
24 import java.util.Map;
25 import java.util.TreeMap;
26
27
28
29
30 @InterfaceAudience.Private
31 public class ServerStatistics {
32
33 private Map<byte[], RegionStatistics>
34 stats = new TreeMap<byte[], RegionStatistics>(Bytes.BYTES_COMPARATOR);
35
36
37
38
39
40
41
42 public void update(byte[] region, ClientProtos.RegionLoadStats currentStats) {
43 RegionStatistics regionStat = this.stats.get(region);
44 if(regionStat == null){
45 regionStat = new RegionStatistics();
46 this.stats.put(region, regionStat);
47 }
48
49 regionStat.update(currentStats);
50 }
51
52 @InterfaceAudience.Private
53 public RegionStatistics getStatsForRegion(byte[] regionName){
54 return stats.get(regionName);
55 }
56
57 public static class RegionStatistics {
58 private int memstoreLoad = 0;
59 private int heapOccupancy = 0;
60 private int compactionPressure = 0;
61
62 public void update(ClientProtos.RegionLoadStats currentStats) {
63 this.memstoreLoad = currentStats.getMemstoreLoad();
64 this.heapOccupancy = currentStats.getHeapOccupancy();
65 this.compactionPressure = currentStats.getCompactionPressure();
66 }
67
68 public int getMemstoreLoadPercent(){
69 return this.memstoreLoad;
70 }
71
72 public int getHeapOccupancyPercent(){
73 return this.heapOccupancy;
74 }
75
76 public int getCompactionPressure() {
77 return compactionPressure;
78 }
79
80 }
81 }