Skip to content

Commit

Permalink
HBASE-22530 The metrics of store files count of region are returned t…
Browse files Browse the repository at this point in the history
…o clients incorrectly (Eungsop Yoo)

Signed-off-by: Xu Cang <[email protected]>
  • Loading branch information
apurtell committed Jun 14, 2019
1 parent 9ba7651 commit 8e15f4e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public static ClusterStatusProtos.RegionLoad toRegionLoad(RegionMetrics regionMe
.setRootIndexSizeKB((int) regionMetrics.getStoreFileRootLevelIndexSize()
.get(Size.Unit.KILOBYTE))
.setStores(regionMetrics.getStoreCount())
.setStorefiles(regionMetrics.getStoreCount())
.setStorefiles(regionMetrics.getStoreFileCount())
.setStoreRefCount(regionMetrics.getStoreRefCount())
.setStorefileSizeMB((int) regionMetrics.getStoreFileSize().get(Size.Unit.MEGABYTE))
.addAllStoreCompleteSequenceId(toStoreSequenceId(regionMetrics.getStoreSequenceId()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.EnumSet;
Expand Down Expand Up @@ -130,6 +132,27 @@ public void testRegionMetrics() throws Exception {
regionMetrics.stream().map(r -> Bytes.toString(r.getRegionName())).
collect(Collectors.toList()));
assertEquals(serverMetrics.getRegionMetrics().size(), regionMetrics.size());
checkMetricsValue(regionMetrics, serverMetrics);
}
}

private void checkMetricsValue(List<RegionMetrics> regionMetrics, ServerMetrics serverMetrics)
throws InvocationTargetException, IllegalAccessException {
for (RegionMetrics fromRM : regionMetrics) {
RegionMetrics fromSM = serverMetrics.getRegionMetrics().get(fromRM.getRegionName());
Class clazz = RegionMetrics.class;
for (Method method : clazz.getMethods()) {
// check numeric values only
if (method.getReturnType().equals(Size.class)
|| method.getReturnType().equals(int.class)
|| method.getReturnType().equals(long.class)
|| method.getReturnType().equals(float.class)) {
Object valueRm = method.invoke(fromRM);
Object valueSM = method.invoke(fromSM);
assertEquals("Return values of method " + method.getName() + " are different",
valueRm.toString(), valueSM.toString());
}
}
}
}

Expand Down

0 comments on commit 8e15f4e

Please sign in to comment.