HBASE-14157 Interfaces implemented by subclasses should be checked when registering CoprocessorService
This commit is contained in:
parent
30f7d127c3
commit
34f9a84445
|
@ -22,6 +22,7 @@ package org.apache.hadoop.hbase.master;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.ClassUtils;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
|
@ -91,7 +92,8 @@ public class MasterCoprocessorHost
|
||||||
public MasterEnvironment createEnvironment(final Class<?> implClass,
|
public MasterEnvironment createEnvironment(final Class<?> implClass,
|
||||||
final Coprocessor instance, final int priority, final int seq,
|
final Coprocessor instance, final int priority, final int seq,
|
||||||
final Configuration conf) {
|
final Configuration conf) {
|
||||||
for (Class<?> c : implClass.getInterfaces()) {
|
for (Object itf : ClassUtils.getAllInterfaces(implClass)) {
|
||||||
|
Class<?> c = (Class<?>) itf;
|
||||||
if (CoprocessorService.class.isAssignableFrom(c)) {
|
if (CoprocessorService.class.isAssignableFrom(c)) {
|
||||||
masterServices.registerService(((CoprocessorService)instance).getService());
|
masterServices.registerService(((CoprocessorService)instance).getService());
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@ import com.google.protobuf.Service;
|
||||||
|
|
||||||
import org.apache.commons.collections.map.AbstractReferenceMap;
|
import org.apache.commons.collections.map.AbstractReferenceMap;
|
||||||
import org.apache.commons.collections.map.ReferenceMap;
|
import org.apache.commons.collections.map.ReferenceMap;
|
||||||
|
import org.apache.commons.lang.ClassUtils;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics;
|
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics;
|
||||||
|
@ -370,7 +371,8 @@ public class RegionCoprocessorHost
|
||||||
// uses a different way to be registered and executed.
|
// uses a different way to be registered and executed.
|
||||||
// It uses a visitor pattern to invoke registered Endpoint
|
// It uses a visitor pattern to invoke registered Endpoint
|
||||||
// method.
|
// method.
|
||||||
for (Class<?> c : implClass.getInterfaces()) {
|
for (Object itf : ClassUtils.getAllInterfaces(implClass)) {
|
||||||
|
Class<?> c = (Class<?>) itf;
|
||||||
if (CoprocessorService.class.isAssignableFrom(c)) {
|
if (CoprocessorService.class.isAssignableFrom(c)) {
|
||||||
region.registerService( ((CoprocessorService)instance).getService() );
|
region.registerService( ((CoprocessorService)instance).getService() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ import java.io.IOException;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.ClassUtils;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.apache.hadoop.hbase.classification.InterfaceAudience;
|
import org.apache.hadoop.hbase.classification.InterfaceAudience;
|
||||||
|
@ -281,9 +282,11 @@ public class RegionServerCoprocessorHost extends
|
||||||
final Configuration conf, final RegionServerServices services) {
|
final Configuration conf, final RegionServerServices services) {
|
||||||
super(impl, priority, seq, conf);
|
super(impl, priority, seq, conf);
|
||||||
this.regionServerServices = services;
|
this.regionServerServices = services;
|
||||||
for (Class c : implClass.getInterfaces()) {
|
for (Object itf : ClassUtils.getAllInterfaces(implClass)) {
|
||||||
|
Class<?> c = (Class<?>) itf;
|
||||||
if (SingletonCoprocessorService.class.isAssignableFrom(c)) {
|
if (SingletonCoprocessorService.class.isAssignableFrom(c)) {
|
||||||
this.regionServerServices.registerService(((SingletonCoprocessorService) impl).getService());
|
this.regionServerServices.registerService(
|
||||||
|
((SingletonCoprocessorService) impl).getService());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ import java.util.List;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
|
import org.apache.hadoop.hbase.Coprocessor;
|
||||||
import org.apache.hadoop.hbase.HBaseTestingUtility;
|
import org.apache.hadoop.hbase.HBaseTestingUtility;
|
||||||
import org.apache.hadoop.hbase.HColumnDescriptor;
|
import org.apache.hadoop.hbase.HColumnDescriptor;
|
||||||
import org.apache.hadoop.hbase.HTableDescriptor;
|
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.ResultScanner;
|
||||||
import org.apache.hadoop.hbase.client.Scan;
|
import org.apache.hadoop.hbase.client.Scan;
|
||||||
import org.apache.hadoop.hbase.client.Table;
|
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.User;
|
||||||
import org.apache.hadoop.hbase.security.access.Permission.Action;
|
import org.apache.hadoop.hbase.security.access.Permission.Action;
|
||||||
import org.apache.hadoop.hbase.testclassification.LargeTests;
|
import org.apache.hadoop.hbase.testclassification.LargeTests;
|
||||||
|
@ -466,6 +471,24 @@ public class TestAccessController2 extends SecureTestUtil {
|
||||||
verifyDenied(TESTGROUP1_USER1, scanTableActionForGroupWithQualifierLevelAccess);
|
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
|
@Test
|
||||||
public void testACLZNodeDeletion() throws Exception {
|
public void testACLZNodeDeletion() throws Exception {
|
||||||
String baseAclZNode = "/hbase/acl/";
|
String baseAclZNode = "/hbase/acl/";
|
||||||
|
|
Loading…
Reference in New Issue