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