HBASE-18954 Make *CoprocessorHost classes private.

Change-Id: I89fded0f74ad83c9bcc2a2b2de925f56aed4e11b
This commit is contained in:
Apekshit Sharma 2017-10-06 16:10:51 -07:00
parent 240b4b16ff
commit 202e414eb2
18 changed files with 38 additions and 41 deletions

View File

@ -53,6 +53,7 @@ import org.apache.hadoop.hbase.mapreduce.ResultSerialization;
import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.DelegationToken;
import org.apache.hadoop.hbase.protobuf.generated.ExportProtos;
import org.apache.hadoop.hbase.regionserver.HRegion;
import org.apache.hadoop.hbase.regionserver.InternalScanner;
import org.apache.hadoop.hbase.regionserver.Region;
import org.apache.hadoop.hbase.regionserver.RegionScanner;
@ -377,10 +378,10 @@ public class Export extends ExportProtos.ExportService implements RegionCoproces
private static class ScanCoprocessor {
private final Region region;
private final HRegion region;
ScanCoprocessor(final Region region) {
this.region = region;
this.region = (HRegion) region;
}
RegionScanner checkScannerOpen(final Scan scan) throws IOException {

View File

@ -84,7 +84,7 @@ public class SecureBulkLoadEndpoint extends SecureBulkLoadService implements Reg
try {
SecureBulkLoadManager secureBulkLoadManager = this.rsServices.getSecureBulkLoadManager();
String bulkToken = secureBulkLoadManager.prepareBulkLoad(this.env.getRegion(),
String bulkToken = secureBulkLoadManager.prepareBulkLoad((HRegion) this.env.getRegion(),
convert(request));
done.run(PrepareBulkLoadResponse.newBuilder().setBulkToken(bulkToken).build());
} catch (IOException e) {
@ -110,7 +110,7 @@ public class SecureBulkLoadEndpoint extends SecureBulkLoadService implements Reg
RpcCallback<CleanupBulkLoadResponse> done) {
try {
SecureBulkLoadManager secureBulkLoadManager = this.rsServices.getSecureBulkLoadManager();
secureBulkLoadManager.cleanupBulkLoad(this.env.getRegion(), convert(request));
secureBulkLoadManager.cleanupBulkLoad((HRegion) this.env.getRegion(), convert(request));
done.run(CleanupBulkLoadResponse.newBuilder().build());
} catch (IOException e) {
CoprocessorRpcUtils.setControllerException(controller, e);

View File

@ -21,8 +21,16 @@ package org.apache.hadoop.hbase.coprocessor;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.*;
import org.apache.hadoop.hbase.Coprocessor;
import org.apache.hadoop.hbase.CoprocessorEnvironment;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.MiniHBaseCluster;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.regionserver.HRegion;
import org.apache.hadoop.hbase.regionserver.Region;
import org.apache.hadoop.hbase.regionserver.TestServerCustomProtocol;
import org.apache.hadoop.hbase.testclassification.CoprocessorTests;
@ -176,7 +184,7 @@ public class TestClassLoading {
boolean found1 = true, found2 = true, found2_k1 = true, found2_k2 = true, found2_k3 = true;
Map<Region, Set<ClassLoader>> regionsActiveClassLoaders = new HashMap<>();
MiniHBaseCluster hbase = TEST_UTIL.getHBaseCluster();
for (Region region:
for (HRegion region:
hbase.getRegionServer(0).getOnlineRegionsLocalContext()) {
if (region.getRegionInfo().getRegionNameAsString().startsWith(tableName.getNameAsString())) {
foundTableRegion = true;
@ -245,7 +253,7 @@ public class TestClassLoading {
// verify that the coprocessor was loaded
boolean found = false;
MiniHBaseCluster hbase = TEST_UTIL.getHBaseCluster();
for (Region region: hbase.getRegionServer(0).getOnlineRegionsLocalContext()) {
for (HRegion region: hbase.getRegionServer(0).getOnlineRegionsLocalContext()) {
if (region.getRegionInfo().getRegionNameAsString().startsWith(cpName3)) {
found = (region.getCoprocessorHost().findCoprocessor(cpName3) != null);
}
@ -270,7 +278,7 @@ public class TestClassLoading {
// verify that the coprocessor was loaded correctly
boolean found = false;
MiniHBaseCluster hbase = TEST_UTIL.getHBaseCluster();
for (Region region: hbase.getRegionServer(0).getOnlineRegionsLocalContext()) {
for (HRegion region: hbase.getRegionServer(0).getOnlineRegionsLocalContext()) {
if (region.getRegionInfo().getRegionNameAsString().startsWith(cpName4)) {
Coprocessor cp = region.getCoprocessorHost().findCoprocessor(cpName4);
if (cp != null) {
@ -341,7 +349,7 @@ public class TestClassLoading {
found6_k4 = false;
MiniHBaseCluster hbase = TEST_UTIL.getHBaseCluster();
for (Region region: hbase.getRegionServer(0).getOnlineRegionsLocalContext()) {
for (HRegion region: hbase.getRegionServer(0).getOnlineRegionsLocalContext()) {
if (region.getRegionInfo().getRegionNameAsString().startsWith(tableName.getNameAsString())) {
found_1 = found_1 ||
(region.getCoprocessorHost().findCoprocessor(cpName1) != null);
@ -429,7 +437,7 @@ public class TestClassLoading {
boolean found1 = false, found2 = false, found2_k1 = false,
found2_k2 = false, found2_k3 = false;
MiniHBaseCluster hbase = TEST_UTIL.getHBaseCluster();
for (Region region: hbase.getRegionServer(0).getOnlineRegionsLocalContext()) {
for (HRegion region: hbase.getRegionServer(0).getOnlineRegionsLocalContext()) {
if (region.getRegionInfo().getRegionNameAsString().startsWith(tableName.getNameAsString())) {
CoprocessorEnvironment env;
env = region.getCoprocessorHost().findCoprocessorEnvironment(cpName1);

View File

@ -58,8 +58,7 @@ import org.apache.hadoop.hbase.util.SortedList;
* @param <E> type of specific coprocessor environment this host requires.
* provides
*/
@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.COPROC)
@InterfaceStability.Evolving
@InterfaceAudience.Private
public abstract class CoprocessorHost<C extends Coprocessor, E extends CoprocessorEnvironment<C>> {
public static final String REGION_COPROCESSOR_CONF_KEY =
"hbase.coprocessor.region.classes";

View File

@ -7906,7 +7906,6 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
}
/** @return the coprocessor host */
@Override
public RegionCoprocessorHost getCoprocessorHost() {
return coprocessorHost;
}

View File

@ -3086,7 +3086,7 @@ public class HRegionServer extends HasThread implements
protected boolean closeRegion(String encodedName, final boolean abort, final ServerName sn)
throws NotServingRegionException {
//Check for permissions to close.
Region actualRegion = this.getRegion(encodedName);
HRegion actualRegion = this.getRegion(encodedName);
// Can be null if we're calling close on a region that's not online
if ((actualRegion != null) && (actualRegion.getCoprocessorHost() != null)) {
try {
@ -3205,7 +3205,7 @@ public class HRegionServer extends HasThread implements
* @return HRegion for the passed binary <code>regionName</code> or null if
* named region is not member of the online regions.
*/
public Region getOnlineRegion(final byte[] regionName) {
public HRegion getOnlineRegion(final byte[] regionName) {
String encodedRegionName = RegionInfo.encodeRegionName(regionName);
return this.onlineRegions.get(encodedRegionName);
}

View File

@ -2120,7 +2120,6 @@ public class HStore implements Store, HeapSize, StoreConfigInformation, Propagat
return this.region;
}
@Override
public RegionCoprocessorHost getCoprocessorHost() {
return this.region.getCoprocessorHost();
}

View File

@ -453,10 +453,6 @@ public interface Region extends ConfigurationObserver {
*/
void put(Put put) throws IOException;
/** @return the coprocessor host */
// TODO To be removed by HBASE-18954
RegionCoprocessorHost getCoprocessorHost();
///////////////////////////////////////////////////////////////////////////
// Flushes, compactions, splits, etc.
// Wizards only, please

View File

@ -91,8 +91,7 @@ import org.apache.yetus.audience.InterfaceStability;
* Implements the coprocessor environment and runtime support for coprocessors
* loaded within a {@link Region}.
*/
@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.COPROC)
@InterfaceStability.Evolving
@InterfaceAudience.Private
public class RegionCoprocessorHost
extends CoprocessorHost<RegionCoprocessor, RegionCoprocessorEnvironment> {

View File

@ -39,8 +39,7 @@ import org.apache.hadoop.hbase.security.User;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.yetus.audience.InterfaceStability;
@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.COPROC)
@InterfaceStability.Evolving
@InterfaceAudience.Private
public class RegionServerCoprocessorHost extends
CoprocessorHost<RegionServerCoprocessor, RegionServerCoprocessorEnvironment> {

View File

@ -132,7 +132,7 @@ public class SecureBulkLoadManager {
public void stop() throws IOException {
}
public String prepareBulkLoad(final Region region, final PrepareBulkLoadRequest request)
public String prepareBulkLoad(final HRegion region, final PrepareBulkLoadRequest request)
throws IOException {
User user = getActiveUser();
region.getCoprocessorHost().prePrepareBulkLoad(user);
@ -144,7 +144,7 @@ public class SecureBulkLoadManager {
return bulkToken;
}
public void cleanupBulkLoad(final Region region, final CleanupBulkLoadRequest request)
public void cleanupBulkLoad(final HRegion region, final CleanupBulkLoadRequest request)
throws IOException {
region.getCoprocessorHost().preCleanupBulkLoad(getActiveUser());

View File

@ -204,8 +204,6 @@ public interface Store {
*/
RegionInfo getRegionInfo();
RegionCoprocessorHost getCoprocessorHost();
boolean areWritesEnabled();
/**

View File

@ -44,7 +44,6 @@ import org.apache.hadoop.hbase.coprocessor.RegionObserver;
import org.apache.hadoop.hbase.regionserver.HRegionServer;
import org.apache.hadoop.hbase.regionserver.MiniBatchOperationInProgress;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.regionserver.Region;
import org.apache.hadoop.hbase.regionserver.RegionScanner;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HColumnDescriptor;
@ -960,7 +959,7 @@ public class TestFromClientSide3 {
HRegion region = (HRegion) find(tableName);
assertEquals(0, region.getLockedRows().size());
}
private static Region find(final TableName tableName)
private static HRegion find(final TableName tableName)
throws IOException, InterruptedException {
HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(tableName);
List<HRegion> regions = rs.getRegions(tableName);
@ -970,7 +969,7 @@ public class TestFromClientSide3 {
private static <T extends RegionObserver> T find(final TableName tableName,
Class<T> clz) throws IOException, InterruptedException {
Region region = find(tableName);
HRegion region = find(tableName);
Coprocessor cp = region.getCoprocessorHost().findCoprocessor(clz.getName());
assertTrue("The cp instance should be " + clz.getName()
+ ", current instance is " + cp.getClass().getName(), clz.isInstance(cp));

View File

@ -209,7 +209,7 @@ public class TestRegionObserverScannerOpenHook {
byte[][] FAMILIES = new byte[][] { A };
Configuration conf = HBaseConfiguration.create();
Region region = initHRegion(TABLE, getClass().getName(), conf, FAMILIES);
HRegion region = initHRegion(TABLE, getClass().getName(), conf, FAMILIES);
RegionCoprocessorHost h = region.getCoprocessorHost();
h.load(NoDataFromScan.class, Coprocessor.PRIORITY_HIGHEST, conf);
h.load(EmptyRegionObsever.class, Coprocessor.PRIORITY_USER, conf);

View File

@ -60,7 +60,7 @@ import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
import org.apache.hadoop.hbase.protobuf.generated.AccessControlProtos;
import org.apache.hadoop.hbase.protobuf.generated.AccessControlProtos.AccessControlService;
import org.apache.hadoop.hbase.protobuf.generated.AccessControlProtos.CheckPermissionsRequest;
import org.apache.hadoop.hbase.regionserver.Region;
import org.apache.hadoop.hbase.regionserver.HRegion;
import org.apache.hadoop.hbase.security.AccessDeniedException;
import org.apache.hadoop.hbase.security.User;
import org.apache.hadoop.hbase.security.access.Permission.Action;
@ -305,7 +305,7 @@ public class SecureTestUtil {
private static List<AccessController> getAccessControllers(MiniHBaseCluster cluster) {
List<AccessController> result = Lists.newArrayList();
for (RegionServerThread t: cluster.getLiveRegionServerThreads()) {
for (Region region: t.getRegionServer().getOnlineRegionsLocalContext()) {
for (HRegion region: t.getRegionServer().getOnlineRegionsLocalContext()) {
Coprocessor cp = region.getCoprocessorHost().findCoprocessor(AccessController.class);
if (cp != null) {
result.add((AccessController)cp);

View File

@ -112,8 +112,8 @@ import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
import org.apache.hadoop.hbase.protobuf.generated.AccessControlProtos;
import org.apache.hadoop.hbase.protobuf.generated.AccessControlProtos.AccessControlService;
import org.apache.hadoop.hbase.protobuf.generated.AccessControlProtos.CheckPermissionsRequest;
import org.apache.hadoop.hbase.regionserver.HRegion;
import org.apache.hadoop.hbase.regionserver.HRegionServer;
import org.apache.hadoop.hbase.regionserver.Region;
import org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost;
import org.apache.hadoop.hbase.regionserver.RegionServerCoprocessorHost;
import org.apache.hadoop.hbase.regionserver.ScanType;
@ -275,7 +275,7 @@ public class TestAccessController extends SecureTestUtil {
htd.setOwner(USER_OWNER);
createTable(TEST_UTIL, htd, new byte[][] { Bytes.toBytes("s") });
Region region = TEST_UTIL.getHBaseCluster().getRegions(TEST_TABLE).get(0);
HRegion region = TEST_UTIL.getHBaseCluster().getRegions(TEST_TABLE).get(0);
RegionCoprocessorHost rcpHost = region.getCoprocessorHost();
RCP_ENV = rcpHost.createEnvironment(ACCESS_CONTROLLER, Coprocessor.PRIORITY_HIGHEST, 1, conf);
@ -2605,7 +2605,7 @@ public class TestAccessController extends SecureTestUtil {
for (JVMClusterUtil.RegionServerThread thread:
TEST_UTIL.getMiniHBaseCluster().getRegionServerThreads()) {
HRegionServer rs = thread.getRegionServer();
for (Region region: rs.getRegions(TEST_TABLE)) {
for (HRegion region: rs.getRegions(TEST_TABLE)) {
region.getCoprocessorHost().load(PingCoprocessor.class,
Coprocessor.PRIORITY_USER, conf);
}

View File

@ -37,8 +37,8 @@ import org.apache.hadoop.hbase.coprocessor.ObserverContextImpl;
import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment;
import org.apache.hadoop.hbase.coprocessor.RegionServerCoprocessorEnvironment;
import org.apache.hadoop.hbase.master.MasterCoprocessorHost;
import org.apache.hadoop.hbase.regionserver.HRegion;
import org.apache.hadoop.hbase.regionserver.HRegionServer;
import org.apache.hadoop.hbase.regionserver.Region;
import org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost;
import org.apache.hadoop.hbase.regionserver.RegionServerCoprocessorHost;
import org.apache.hadoop.hbase.security.User;
@ -214,7 +214,7 @@ public class TestAccessController3 extends SecureTestUtil {
htd.setOwner(USER_OWNER);
createTable(TEST_UTIL, htd, new byte[][] { Bytes.toBytes("s") });
Region region = TEST_UTIL.getHBaseCluster().getRegions(TEST_TABLE).get(0);
HRegion region = TEST_UTIL.getHBaseCluster().getRegions(TEST_TABLE).get(0);
RegionCoprocessorHost rcpHost = region.getCoprocessorHost();
RCP_ENV = rcpHost.createEnvironment(ACCESS_CONTROLLER, Coprocessor.PRIORITY_HIGHEST, 1, conf);

View File

@ -58,8 +58,8 @@ import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment;
import org.apache.hadoop.hbase.coprocessor.RegionServerCoprocessorEnvironment;
import org.apache.hadoop.hbase.filter.BinaryComparator;
import org.apache.hadoop.hbase.master.MasterCoprocessorHost;
import org.apache.hadoop.hbase.regionserver.HRegion;
import org.apache.hadoop.hbase.regionserver.MiniBatchOperationInProgress;
import org.apache.hadoop.hbase.regionserver.Region;
import org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost;
import org.apache.hadoop.hbase.regionserver.RegionScanner;
import org.apache.hadoop.hbase.regionserver.RegionServerCoprocessorHost;
@ -189,7 +189,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
admin.createTable(htd, new byte[][] { Bytes.toBytes("s") });
TEST_UTIL.waitUntilAllRegionsAssigned(TEST_TABLE.getTableName());
Region region = TEST_UTIL.getHBaseCluster().getRegions(TEST_TABLE.getTableName()).get(0);
HRegion region = TEST_UTIL.getHBaseCluster().getRegions(TEST_TABLE.getTableName()).get(0);
RegionCoprocessorHost rcpHost = region.getCoprocessorHost();
RCP_ENV = rcpHost.createEnvironment(ACCESS_CONTROLLER,
Coprocessor.PRIORITY_HIGHEST, 1, TEST_UTIL.getConfiguration());