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