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