1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.apache.hadoop.hbase;
22
23 import org.apache.hadoop.hbase.classification.InterfaceAudience;
24 import org.apache.hadoop.hbase.classification.InterfaceStability;
25 import org.apache.hadoop.hbase.protobuf.generated.ClusterStatusProtos;
26 import org.apache.hadoop.hbase.util.Bytes;
27 import org.apache.hadoop.hbase.util.Strings;
28
29
30
31
32 @InterfaceAudience.Public
33 @InterfaceStability.Evolving
34 public class RegionLoad {
35
36 protected ClusterStatusProtos.RegionLoad regionLoadPB;
37
38 public RegionLoad(ClusterStatusProtos.RegionLoad regionLoadPB) {
39 this.regionLoadPB = regionLoadPB;
40 }
41
42
43
44
45 public byte[] getName() {
46 return regionLoadPB.getRegionSpecifier().getValue().toByteArray();
47 }
48
49
50
51
52 public String getNameAsString() {
53 return Bytes.toString(getName());
54 }
55
56
57
58
59 public int getStores() {
60 return regionLoadPB.getStores();
61 }
62
63
64
65
66 public int getStorefiles() {
67 return regionLoadPB.getStorefiles();
68 }
69
70
71
72
73 public int getStorefileSizeMB() {
74 return regionLoadPB.getStorefileSizeMB();
75 }
76
77
78
79
80 public int getMemStoreSizeMB() {
81 return regionLoadPB.getMemstoreSizeMB();
82 }
83
84
85
86
87 public int getStorefileIndexSizeMB() {
88 return regionLoadPB.getStorefileIndexSizeMB();
89 }
90
91
92
93
94 public long getRequestsCount() {
95 return getReadRequestsCount() + getWriteRequestsCount();
96 }
97
98
99
100
101 public long getReadRequestsCount() {
102 return regionLoadPB.getReadRequestsCount();
103 }
104
105
106
107
108 public long getWriteRequestsCount() {
109 return regionLoadPB.getWriteRequestsCount();
110 }
111
112
113
114
115 public int getRootIndexSizeKB() {
116 return regionLoadPB.getRootIndexSizeKB();
117 }
118
119
120
121
122 public int getTotalStaticIndexSizeKB() {
123 return regionLoadPB.getTotalStaticIndexSizeKB();
124 }
125
126
127
128
129
130 public int getTotalStaticBloomSizeKB() {
131 return regionLoadPB.getTotalStaticBloomSizeKB();
132 }
133
134
135
136
137 public long getTotalCompactingKVs() {
138 return regionLoadPB.getTotalCompactingKVs();
139 }
140
141
142
143
144 public long getCurrentCompactedKVs() {
145 return regionLoadPB.getCurrentCompactedKVs();
146 }
147
148
149
150
151
152 public long getCompleteSequenceId() {
153 return regionLoadPB.getCompleteSequenceId();
154 }
155
156
157
158
159 public int getStoreUncompressedSizeMB() {
160 return regionLoadPB.getStoreUncompressedSizeMB();
161 }
162
163
164
165
166 public float getDataLocality() {
167 if (regionLoadPB.hasDataLocality()) {
168 return regionLoadPB.getDataLocality();
169 }
170 return 0.0f;
171 }
172
173
174
175 @Override
176 public String toString() {
177 StringBuilder sb = Strings.appendKeyValue(new StringBuilder(), "numberOfStores",
178 this.getStores());
179 sb = Strings.appendKeyValue(sb, "numberOfStorefiles",
180 this.getStorefiles());
181 sb = Strings.appendKeyValue(sb, "storefileUncompressedSizeMB",
182 this.getStoreUncompressedSizeMB());
183 sb = Strings.appendKeyValue(sb, "storefileSizeMB",
184 this.getStorefileSizeMB());
185 if (this.getStoreUncompressedSizeMB() != 0) {
186 sb = Strings.appendKeyValue(sb, "compressionRatio",
187 String.format("%.4f", (float) this.getStorefileSizeMB() /
188 (float) this.getStoreUncompressedSizeMB()));
189 }
190 sb = Strings.appendKeyValue(sb, "memstoreSizeMB",
191 this.getMemStoreSizeMB());
192 sb = Strings.appendKeyValue(sb, "storefileIndexSizeMB",
193 this.getStorefileIndexSizeMB());
194 sb = Strings.appendKeyValue(sb, "readRequestsCount",
195 this.getReadRequestsCount());
196 sb = Strings.appendKeyValue(sb, "writeRequestsCount",
197 this.getWriteRequestsCount());
198 sb = Strings.appendKeyValue(sb, "rootIndexSizeKB",
199 this.getRootIndexSizeKB());
200 sb = Strings.appendKeyValue(sb, "totalStaticIndexSizeKB",
201 this.getTotalStaticIndexSizeKB());
202 sb = Strings.appendKeyValue(sb, "totalStaticBloomSizeKB",
203 this.getTotalStaticBloomSizeKB());
204 sb = Strings.appendKeyValue(sb, "totalCompactingKVs",
205 this.getTotalCompactingKVs());
206 sb = Strings.appendKeyValue(sb, "currentCompactedKVs",
207 this.getCurrentCompactedKVs());
208 float compactionProgressPct = Float.NaN;
209 if (this.getTotalCompactingKVs() > 0) {
210 compactionProgressPct = ((float) this.getCurrentCompactedKVs() /
211 (float) this.getTotalCompactingKVs());
212 }
213 sb = Strings.appendKeyValue(sb, "compactionProgressPct",
214 compactionProgressPct);
215 sb = Strings.appendKeyValue(sb, "completeSequenceId",
216 this.getCompleteSequenceId());
217 sb = Strings.appendKeyValue(sb, "dataLocality",
218 this.getDataLocality());
219 return sb.toString();
220 }
221 }