HBASE-22530 The metrics of store files count of region are returned to clients incorrectly (Eungsop Yoo)

Signed-off-by: Xu Cang <xucang@apache.org>
This commit is contained in:
Andrew Purtell 2019-06-13 17:42:26 -07:00
parent 9ba7651889
commit 8e15f4ed61
No known key found for this signature in database
GPG Key ID: 8597754DD5365CCD
2 changed files with 24 additions and 1 deletions

View File

@ -111,7 +111,7 @@ public final class RegionMetricsBuilder {
.setRootIndexSizeKB((int) regionMetrics.getStoreFileRootLevelIndexSize() .setRootIndexSizeKB((int) regionMetrics.getStoreFileRootLevelIndexSize()
.get(Size.Unit.KILOBYTE)) .get(Size.Unit.KILOBYTE))
.setStores(regionMetrics.getStoreCount()) .setStores(regionMetrics.getStoreCount())
.setStorefiles(regionMetrics.getStoreCount()) .setStorefiles(regionMetrics.getStoreFileCount())
.setStoreRefCount(regionMetrics.getStoreRefCount()) .setStoreRefCount(regionMetrics.getStoreRefCount())
.setStorefileSizeMB((int) regionMetrics.getStoreFileSize().get(Size.Unit.MEGABYTE)) .setStorefileSizeMB((int) regionMetrics.getStoreFileSize().get(Size.Unit.MEGABYTE))
.addAllStoreCompleteSequenceId(toStoreSequenceId(regionMetrics.getStoreSequenceId())) .addAllStoreCompleteSequenceId(toStoreSequenceId(regionMetrics.getStoreSequenceId()))

View File

@ -20,6 +20,8 @@ package org.apache.hadoop.hbase;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.EnumSet; import java.util.EnumSet;
@ -130,6 +132,27 @@ public class TestRegionMetrics {
regionMetrics.stream().map(r -> Bytes.toString(r.getRegionName())). regionMetrics.stream().map(r -> Bytes.toString(r.getRegionName())).
collect(Collectors.toList())); collect(Collectors.toList()));
assertEquals(serverMetrics.getRegionMetrics().size(), regionMetrics.size()); 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());
}
}
} }
} }