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-14157 Interfaces implemented by subclasses should be checked when registering CoprocessorService
Date Tue, 28 Jul 2015 18:11:50 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1.1 8a54799ce -> 67e9f6ba3


HBASE-14157 Interfaces implemented by subclasses should be checked when registering CoprocessorService


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

Branch: refs/heads/branch-1.1
Commit: 67e9f6ba302d23ee40b8c4f1a474fdb4db7adf44
Parents: 8a54799
Author: tedyu <yuzhihong@gmail.com>
Authored: Tue Jul 28 11:11:43 2015 -0700
Committer: tedyu <yuzhihong@gmail.com>
Committed: Tue Jul 28 11:11:43 2015 -0700

----------------------------------------------------------------------
 .../hbase/master/MasterCoprocessorHost.java     |  4 +++-
 .../regionserver/RegionCoprocessorHost.java     |  4 +++-
 .../RegionServerCoprocessorHost.java            |  7 ++++--
 .../security/access/TestAccessController2.java  | 23 ++++++++++++++++++++
 4 files changed, 34 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/67e9f6ba/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterCoprocessorHost.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterCoprocessorHost.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterCoprocessorHost.java
index 858e674..1026db3 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterCoprocessorHost.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterCoprocessorHost.java
@@ -22,6 +22,7 @@ package org.apache.hadoop.hbase.master;
 import java.io.IOException;
 import java.util.List;
 
+import org.apache.commons.lang.ClassUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
@@ -87,7 +88,8 @@ public class MasterCoprocessorHost
   public MasterEnvironment createEnvironment(final Class<?> implClass,
       final Coprocessor instance, final int priority, final int seq,
       final Configuration conf) {
-    for (Class<?> c : implClass.getInterfaces()) {
+    for (Object itf : ClassUtils.getAllInterfaces(implClass)) {
+      Class<?> c = (Class<?>) itf;
       if (CoprocessorService.class.isAssignableFrom(c)) {
         masterServices.registerService(((CoprocessorService)instance).getService());
       }

http://git-wip-us.apache.org/repos/asf/hbase/blob/67e9f6ba/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionCoprocessorHost.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionCoprocessorHost.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionCoprocessorHost.java
index 92d10e8..d528b55 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionCoprocessorHost.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionCoprocessorHost.java
@@ -33,6 +33,7 @@ import java.util.regex.Matcher;
 
 import org.apache.commons.collections.map.AbstractReferenceMap;
 import org.apache.commons.collections.map.ReferenceMap;
+import org.apache.commons.lang.ClassUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.commons.math.stat.descriptive.DescriptiveStatistics;
@@ -370,7 +371,8 @@ public class RegionCoprocessorHost
     // uses a different way to be registered and executed.
     // It uses a visitor pattern to invoke registered Endpoint
     // method.
-    for (Class<?> c : implClass.getInterfaces()) {
+    for (Object itf : ClassUtils.getAllInterfaces(implClass)) {
+      Class<?> c = (Class<?>) itf;
       if (CoprocessorService.class.isAssignableFrom(c)) {
         region.registerService( ((CoprocessorService)instance).getService() );
       }

http://git-wip-us.apache.org/repos/asf/hbase/blob/67e9f6ba/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionServerCoprocessorHost.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionServerCoprocessorHost.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionServerCoprocessorHost.java
index ab8e948..d96b2ab 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionServerCoprocessorHost.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionServerCoprocessorHost.java
@@ -22,6 +22,7 @@ import java.io.IOException;
 import java.util.Comparator;
 import java.util.List;
 
+import org.apache.commons.lang.ClassUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.hbase.classification.InterfaceAudience;
@@ -281,9 +282,11 @@ public class RegionServerCoprocessorHost extends
         final Configuration conf, final RegionServerServices services) {
       super(impl, priority, seq, conf);
       this.regionServerServices = services;
-      for (Class c : implClass.getInterfaces()) {
+      for (Object itf : ClassUtils.getAllInterfaces(implClass)) {
+        Class<?> c = (Class<?>) itf;
         if (SingletonCoprocessorService.class.isAssignableFrom(c)) {
-          this.regionServerServices.registerService(((SingletonCoprocessorService) impl).getService());
+          this.regionServerServices.registerService(
+            ((SingletonCoprocessorService) impl).getService());
           break;
         }
       }

http://git-wip-us.apache.org/repos/asf/hbase/blob/67e9f6ba/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController2.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController2.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController2.java
index dce8874..0055740 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController2.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController2.java
@@ -29,6 +29,7 @@ import java.util.List;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.Coprocessor;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.HColumnDescriptor;
 import org.apache.hadoop.hbase.HTableDescriptor;
@@ -43,6 +44,10 @@ import org.apache.hadoop.hbase.client.Result;
 import org.apache.hadoop.hbase.client.ResultScanner;
 import org.apache.hadoop.hbase.client.Scan;
 import org.apache.hadoop.hbase.client.Table;
+import org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment;
+import org.apache.hadoop.hbase.coprocessor.RegionServerCoprocessorEnvironment;
+import org.apache.hadoop.hbase.master.MasterCoprocessorHost;
+import org.apache.hadoop.hbase.regionserver.RegionServerCoprocessorHost;
 import org.apache.hadoop.hbase.security.User;
 import org.apache.hadoop.hbase.security.access.Permission.Action;
 import org.apache.hadoop.hbase.testclassification.LargeTests;
@@ -463,6 +468,24 @@ public class TestAccessController2 extends SecureTestUtil {
     verifyDenied(TESTGROUP1_USER1, scanTableActionForGroupWithQualifierLevelAccess);
   }
 
+  public static class MyAccessController extends AccessController {
+  }
+
+  @Test
+  public void testCoprocessorLoading() throws Exception {
+    MasterCoprocessorHost cpHost =
+        TEST_UTIL.getMiniHBaseCluster().getMaster().getMasterCoprocessorHost();
+    cpHost.load(MyAccessController.class, Coprocessor.PRIORITY_HIGHEST, conf);
+    AccessController ACCESS_CONTROLLER = (AccessController) cpHost.findCoprocessor(
+      MyAccessController.class.getName());
+    MasterCoprocessorEnvironment CP_ENV = cpHost.createEnvironment(
+      MyAccessController.class, ACCESS_CONTROLLER, Coprocessor.PRIORITY_HIGHEST, 1, conf);
+    RegionServerCoprocessorHost rsHost = TEST_UTIL.getMiniHBaseCluster().getRegionServer(0)
+        .getRegionServerCoprocessorHost();
+    RegionServerCoprocessorEnvironment RSCP_ENV = rsHost.createEnvironment(
+      MyAccessController.class, ACCESS_CONTROLLER, Coprocessor.PRIORITY_HIGHEST, 1, conf);
+  }
+
   @Test
   public void testACLZNodeDeletion() throws Exception {
     String baseAclZNode = "/hbase/acl/";


Mime
View raw message