hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject hbase git commit: HBASE-13923 Loaded region coprocessors are not reported in shell status command (Ashish Singhi)
Date Wed, 24 Jun 2015 04:24:54 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1 92f4e30f4 -> 41aa84124


HBASE-13923 Loaded region coprocessors are not reported in shell status command (Ashish Singhi)


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/41aa8412
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/41aa8412
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/41aa8412

Branch: refs/heads/branch-1
Commit: 41aa8412410fec33242afa40bb7c52c511eb30e2
Parents: 92f4e30
Author: tedyu <yuzhihong@gmail.com>
Authored: Tue Jun 23 21:24:55 2015 -0700
Committer: tedyu <yuzhihong@gmail.com>
Committed: Tue Jun 23 21:24:55 2015 -0700

----------------------------------------------------------------------
 .../hbase/regionserver/HRegionServer.java       | 16 ++++++---
 .../hbase/coprocessor/TestClassLoading.java     | 37 +++++++++++++-------
 2 files changed, 36 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/41aa8412/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
index af3cb5e..38e62a7 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
@@ -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;
@@ -1169,17 +1170,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);

http://git-wip-us.apache.org/repos/asf/hbase/blob/41aa8412/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestClassLoading.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestClassLoading.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestClassLoading.java
index 632e9c2..2a139da 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestClassLoading.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestClassLoading.java
@@ -74,6 +74,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();
@@ -446,7 +450,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);
   }
 
   /**
@@ -477,20 +481,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();
@@ -499,8 +501,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;
@@ -512,6 +516,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


Mime
View raw message