HBASE-13923 Loaded region coprocessors are not reported in shell status command (Ashish Singhi)
This commit is contained in:
parent
92f4e30f45
commit
41aa841241
|
@ -115,6 +115,7 @@ import org.apache.hadoop.hbase.protobuf.generated.ClusterStatusProtos;
|
||||||
import org.apache.hadoop.hbase.protobuf.generated.ClusterStatusProtos.RegionLoad;
|
import org.apache.hadoop.hbase.protobuf.generated.ClusterStatusProtos.RegionLoad;
|
||||||
import org.apache.hadoop.hbase.protobuf.generated.ClusterStatusProtos.RegionStoreSequenceIds;
|
import org.apache.hadoop.hbase.protobuf.generated.ClusterStatusProtos.RegionStoreSequenceIds;
|
||||||
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.Coprocessor;
|
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.Coprocessor;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.Coprocessor.Builder;
|
||||||
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.NameStringPair;
|
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.NameStringPair;
|
||||||
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionServerInfo;
|
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionServerInfo;
|
||||||
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionSpecifier;
|
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionSpecifier;
|
||||||
|
@ -1169,17 +1170,22 @@ public class HRegionServer extends HasThread implements
|
||||||
serverLoad.setUsedHeapMB((int)(memory.getUsed() / 1024 / 1024));
|
serverLoad.setUsedHeapMB((int)(memory.getUsed() / 1024 / 1024));
|
||||||
serverLoad.setMaxHeapMB((int) (memory.getMax() / 1024 / 1024));
|
serverLoad.setMaxHeapMB((int) (memory.getMax() / 1024 / 1024));
|
||||||
Set<String> coprocessors = getWAL(null).getCoprocessorHost().getCoprocessors();
|
Set<String> coprocessors = getWAL(null).getCoprocessorHost().getCoprocessors();
|
||||||
|
Builder coprocessorBuilder = Coprocessor.newBuilder();
|
||||||
for (String coprocessor : coprocessors) {
|
for (String coprocessor : coprocessors) {
|
||||||
serverLoad.addCoprocessors(
|
serverLoad.addCoprocessors(coprocessorBuilder.setName(coprocessor).build());
|
||||||
Coprocessor.newBuilder().setName(coprocessor).build());
|
|
||||||
}
|
}
|
||||||
RegionLoad.Builder regionLoadBldr = RegionLoad.newBuilder();
|
RegionLoad.Builder regionLoadBldr = RegionLoad.newBuilder();
|
||||||
RegionSpecifier.Builder regionSpecifier = RegionSpecifier.newBuilder();
|
RegionSpecifier.Builder regionSpecifier = RegionSpecifier.newBuilder();
|
||||||
for (Region region : regions) {
|
for (Region region : regions) {
|
||||||
|
Set<String> regionCoprocessors = region.getCoprocessorHost().getCoprocessors();
|
||||||
|
Iterator<String> iterator = regionCoprocessors.iterator();
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
serverLoad.addCoprocessors(coprocessorBuilder.setName(iterator.next()).build());
|
||||||
|
}
|
||||||
serverLoad.addRegionLoads(createRegionLoad(region, regionLoadBldr, regionSpecifier));
|
serverLoad.addRegionLoads(createRegionLoad(region, regionLoadBldr, regionSpecifier));
|
||||||
for (String coprocessor :
|
for (String coprocessor : getWAL(region.getRegionInfo()).getCoprocessorHost()
|
||||||
getWAL(region.getRegionInfo()).getCoprocessorHost().getCoprocessors()) {
|
.getCoprocessors()) {
|
||||||
serverLoad.addCoprocessors(Coprocessor.newBuilder().setName(coprocessor).build());
|
serverLoad.addCoprocessors(coprocessorBuilder.setName(coprocessor).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
serverLoad.setReportStartTime(reportStartTime);
|
serverLoad.setReportStartTime(reportStartTime);
|
||||||
|
|
|
@ -74,6 +74,10 @@ public class TestClassLoading {
|
||||||
regionServerCoprocessor.getSimpleName()
|
regionServerCoprocessor.getSimpleName()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private static final String[] masterRegionServerSystemCoprocessors = new String[] {
|
||||||
|
regionCoprocessor1.getSimpleName(), MultiRowMutationEndpoint.class.getSimpleName(),
|
||||||
|
regionServerCoprocessor.getSimpleName() };
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUpBeforeClass() throws Exception {
|
public static void setUpBeforeClass() throws Exception {
|
||||||
Configuration conf = TEST_UTIL.getConfiguration();
|
Configuration conf = TEST_UTIL.getConfiguration();
|
||||||
|
@ -446,7 +450,7 @@ public class TestClassLoading {
|
||||||
// This was a test for HBASE-4070.
|
// This was a test for HBASE-4070.
|
||||||
// We are removing coprocessors from region load in HBASE-5258.
|
// We are removing coprocessors from region load in HBASE-5258.
|
||||||
// Therefore, this test now only checks system coprocessors.
|
// Therefore, this test now only checks system coprocessors.
|
||||||
assertAllRegionServers(regionServerSystemCoprocessors,null);
|
assertAllRegionServers(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -477,20 +481,18 @@ public class TestClassLoading {
|
||||||
return serverLoadHashMap;
|
return serverLoadHashMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
void assertAllRegionServers(String[] expectedCoprocessors, String tableName)
|
void assertAllRegionServers(String tableName) throws InterruptedException {
|
||||||
throws InterruptedException {
|
|
||||||
Map<ServerName, ServerLoad> servers;
|
Map<ServerName, ServerLoad> servers;
|
||||||
String[] actualCoprocessors = null;
|
String[] actualCoprocessors = null;
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
for(int i = 0; i < 5; i++) {
|
String[] expectedCoprocessors = regionServerSystemCoprocessors;
|
||||||
if (tableName == null) {
|
if (tableName == null) {
|
||||||
//if no tableName specified, use all servers.
|
// if no tableName specified, use all servers.
|
||||||
servers =
|
servers = TEST_UTIL.getMiniHBaseCluster().getMaster().getServerManager().getOnlineServers();
|
||||||
TEST_UTIL.getMiniHBaseCluster().getMaster().getServerManager().
|
} else {
|
||||||
getOnlineServers();
|
servers = serversForTable(tableName);
|
||||||
} else {
|
}
|
||||||
servers = serversForTable(tableName);
|
for (int i = 0; i < 5; i++) {
|
||||||
}
|
|
||||||
boolean any_failed = false;
|
boolean any_failed = false;
|
||||||
for(Map.Entry<ServerName,ServerLoad> server: servers.entrySet()) {
|
for(Map.Entry<ServerName,ServerLoad> server: servers.entrySet()) {
|
||||||
actualCoprocessors = server.getValue().getRsCoprocessors();
|
actualCoprocessors = server.getValue().getRsCoprocessors();
|
||||||
|
@ -499,8 +501,10 @@ public class TestClassLoading {
|
||||||
Arrays.toString(actualCoprocessors) +
|
Arrays.toString(actualCoprocessors) +
|
||||||
" ; expected: " + Arrays.toString(expectedCoprocessors));
|
" ; expected: " + Arrays.toString(expectedCoprocessors));
|
||||||
any_failed = true;
|
any_failed = true;
|
||||||
|
expectedCoprocessors = switchExpectedCoprocessors(expectedCoprocessors);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
expectedCoprocessors = switchExpectedCoprocessors(expectedCoprocessors);
|
||||||
}
|
}
|
||||||
if (any_failed == false) {
|
if (any_failed == false) {
|
||||||
success = true;
|
success = true;
|
||||||
|
@ -512,6 +516,15 @@ public class TestClassLoading {
|
||||||
assertTrue(success);
|
assertTrue(success);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String[] switchExpectedCoprocessors(String[] expectedCoprocessors) {
|
||||||
|
if (Arrays.equals(regionServerSystemCoprocessors, expectedCoprocessors)) {
|
||||||
|
expectedCoprocessors = masterRegionServerSystemCoprocessors;
|
||||||
|
} else {
|
||||||
|
expectedCoprocessors = regionServerSystemCoprocessors;
|
||||||
|
}
|
||||||
|
return expectedCoprocessors;
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMasterCoprocessorsReported() {
|
public void testMasterCoprocessorsReported() {
|
||||||
// HBASE 4070: Improve region server metrics to report loaded coprocessors
|
// HBASE 4070: Improve region server metrics to report loaded coprocessors
|
||||||
|
|
Loading…
Reference in New Issue