HBASE-19667 Get rid of MasterEnvironment#supportGroupCPs
This commit is contained in:
parent
f6f57d38f7
commit
32e0107751
|
@ -459,49 +459,6 @@ public abstract class CoprocessorHost<C extends Coprocessor, E extends Coprocess
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to gracefully handle fallback to deprecated methods when we
|
||||
* evolve coprocessor APIs.
|
||||
*
|
||||
* When a particular Coprocessor API is updated to change methods, hosts can support fallback
|
||||
* to the deprecated API by using this method to determine if an instance implements the new API.
|
||||
* In the event that said support is partial, then in the face of a runtime issue that prevents
|
||||
* proper operation {@link #legacyWarning(Class, String)} should be used to let operators know.
|
||||
*
|
||||
* For examples of this in action, see the implementation of
|
||||
* <ul>
|
||||
* <li>{@link org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost}
|
||||
* <li>{@link org.apache.hadoop.hbase.regionserver.wal.WALCoprocessorHost}
|
||||
* </ul>
|
||||
*
|
||||
* @param clazz Coprocessor you wish to evaluate
|
||||
* @param methodName the name of the non-deprecated method version
|
||||
* @param parameterTypes the Class of the non-deprecated method's arguments in the order they are
|
||||
* declared.
|
||||
*/
|
||||
@InterfaceAudience.Private
|
||||
protected static boolean useLegacyMethod(final Class<? extends Coprocessor> clazz,
|
||||
final String methodName, final Class<?>... parameterTypes) {
|
||||
boolean useLegacy;
|
||||
// Use reflection to see if they implement the non-deprecated version
|
||||
try {
|
||||
clazz.getDeclaredMethod(methodName, parameterTypes);
|
||||
LOG.debug("Found an implementation of '" + methodName + "' that uses updated method " +
|
||||
"signature. Skipping legacy support for invocations in '" + clazz +"'.");
|
||||
useLegacy = false;
|
||||
} catch (NoSuchMethodException exception) {
|
||||
useLegacy = true;
|
||||
} catch (SecurityException exception) {
|
||||
LOG.warn("The Security Manager denied our attempt to detect if the coprocessor '" + clazz +
|
||||
"' requires legacy support; assuming it does. If you get later errors about legacy " +
|
||||
"coprocessor use, consider updating your security policy to allow access to the package" +
|
||||
" and declared members of your implementation.");
|
||||
LOG.debug("Details of Security Manager rejection.", exception);
|
||||
useLegacy = true;
|
||||
}
|
||||
return useLegacy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to limit legacy handling to once per Coprocessor class per classloader.
|
||||
*/
|
||||
|
@ -517,21 +474,6 @@ public abstract class CoprocessorHost<C extends Coprocessor, E extends Coprocess
|
|||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* limits the amount of logging to once per coprocessor class.
|
||||
* Used in concert with {@link #useLegacyMethod(Class, String, Class[])} when a runtime issue
|
||||
* prevents properly supporting the legacy version of a coprocessor API.
|
||||
* Since coprocessors can be in tight loops this serves to limit the amount of log spam we create.
|
||||
*/
|
||||
@InterfaceAudience.Private
|
||||
protected void legacyWarning(final Class<? extends Coprocessor> clazz, final String message) {
|
||||
if(legacyWarning.add(clazz)) {
|
||||
LOG.error("You have a legacy coprocessor loaded and there are events we can't map to the " +
|
||||
" deprecated API. Your coprocessor will not see these events. Please update '" + clazz +
|
||||
"'. Details of the problem: " + message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementations defined function to get an observer of type {@code O} from a coprocessor of
|
||||
* type {@code C}. Concrete implementations of CoprocessorHost define one getter for each
|
||||
|
|
|
@ -47,7 +47,6 @@ import org.apache.hadoop.hbase.coprocessor.MasterCoprocessor;
|
|||
import org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment;
|
||||
import org.apache.hadoop.hbase.coprocessor.MasterObserver;
|
||||
import org.apache.hadoop.hbase.coprocessor.MetricsCoprocessor;
|
||||
import org.apache.hadoop.hbase.coprocessor.ObserverContext;
|
||||
import org.apache.hadoop.hbase.master.locking.LockProcedure;
|
||||
import org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv;
|
||||
import org.apache.hadoop.hbase.metrics.MetricRegistry;
|
||||
|
@ -80,7 +79,6 @@ public class MasterCoprocessorHost
|
|||
*/
|
||||
private static class MasterEnvironment extends BaseEnvironment<MasterCoprocessor>
|
||||
implements MasterCoprocessorEnvironment {
|
||||
private final boolean supportGroupCPs;
|
||||
private final MetricRegistry metricRegistry;
|
||||
private final MasterServices services;
|
||||
|
||||
|
@ -88,8 +86,6 @@ public class MasterCoprocessorHost
|
|||
final Configuration conf, final MasterServices services) {
|
||||
super(impl, priority, seq, conf);
|
||||
this.services = services;
|
||||
supportGroupCPs = !useLegacyMethod(impl.getClass(),
|
||||
"preBalanceRSGroup", ObserverContext.class, String.class);
|
||||
this.metricRegistry =
|
||||
MetricsCoprocessor.createRegistryForMasterCoprocessor(impl.getClass().getName());
|
||||
}
|
||||
|
@ -1264,9 +1260,7 @@ public class MasterCoprocessorHost
|
|||
execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
|
||||
@Override
|
||||
public void call(MasterObserver observer) throws IOException {
|
||||
if(((MasterEnvironment)getEnvironment()).supportGroupCPs) {
|
||||
observer.preMoveServersAndTables(this, servers, tables, targetGroup);
|
||||
}
|
||||
observer.preMoveServersAndTables(this, servers, tables, targetGroup);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1276,9 +1270,7 @@ public class MasterCoprocessorHost
|
|||
execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
|
||||
@Override
|
||||
public void call(MasterObserver observer) throws IOException {
|
||||
if(((MasterEnvironment)getEnvironment()).supportGroupCPs) {
|
||||
observer.postMoveServersAndTables(this, servers, tables, targetGroup);
|
||||
}
|
||||
observer.postMoveServersAndTables(this, servers, tables, targetGroup);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1288,9 +1280,7 @@ public class MasterCoprocessorHost
|
|||
execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
|
||||
@Override
|
||||
public void call(MasterObserver observer) throws IOException {
|
||||
if(((MasterEnvironment)getEnvironment()).supportGroupCPs) {
|
||||
observer.preMoveServers(this, servers, targetGroup);
|
||||
}
|
||||
observer.preMoveServers(this, servers, targetGroup);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1300,9 +1290,7 @@ public class MasterCoprocessorHost
|
|||
execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
|
||||
@Override
|
||||
public void call(MasterObserver observer) throws IOException {
|
||||
if(((MasterEnvironment)getEnvironment()).supportGroupCPs) {
|
||||
observer.postMoveServers(this, servers, targetGroup);
|
||||
}
|
||||
observer.postMoveServers(this, servers, targetGroup);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1312,9 +1300,7 @@ public class MasterCoprocessorHost
|
|||
execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
|
||||
@Override
|
||||
public void call(MasterObserver observer) throws IOException {
|
||||
if(((MasterEnvironment)getEnvironment()).supportGroupCPs) {
|
||||
observer.preMoveTables(this, tables, targetGroup);
|
||||
}
|
||||
observer.preMoveTables(this, tables, targetGroup);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1324,9 +1310,7 @@ public class MasterCoprocessorHost
|
|||
execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
|
||||
@Override
|
||||
public void call(MasterObserver observer) throws IOException {
|
||||
if(((MasterEnvironment)getEnvironment()).supportGroupCPs) {
|
||||
observer.postMoveTables(this, tables, targetGroup);
|
||||
}
|
||||
observer.postMoveTables(this, tables, targetGroup);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1336,9 +1320,7 @@ public class MasterCoprocessorHost
|
|||
execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
|
||||
@Override
|
||||
public void call(MasterObserver observer) throws IOException {
|
||||
if(((MasterEnvironment)getEnvironment()).supportGroupCPs) {
|
||||
observer.preAddRSGroup(this, name);
|
||||
}
|
||||
observer.preAddRSGroup(this, name);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1348,9 +1330,7 @@ public class MasterCoprocessorHost
|
|||
execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
|
||||
@Override
|
||||
public void call(MasterObserver observer) throws IOException {
|
||||
if (((MasterEnvironment)getEnvironment()).supportGroupCPs) {
|
||||
observer.postAddRSGroup(this, name);
|
||||
}
|
||||
observer.postAddRSGroup(this, name);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1360,9 +1340,7 @@ public class MasterCoprocessorHost
|
|||
execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
|
||||
@Override
|
||||
public void call(MasterObserver observer) throws IOException {
|
||||
if(((MasterEnvironment)getEnvironment()).supportGroupCPs) {
|
||||
observer.preRemoveRSGroup(this, name);
|
||||
}
|
||||
observer.preRemoveRSGroup(this, name);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1372,9 +1350,7 @@ public class MasterCoprocessorHost
|
|||
execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
|
||||
@Override
|
||||
public void call(MasterObserver observer) throws IOException {
|
||||
if(((MasterEnvironment)getEnvironment()).supportGroupCPs) {
|
||||
observer.postRemoveRSGroup(this, name);
|
||||
}
|
||||
observer.postRemoveRSGroup(this, name);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1384,9 +1360,7 @@ public class MasterCoprocessorHost
|
|||
execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
|
||||
@Override
|
||||
public void call(MasterObserver observer) throws IOException {
|
||||
if(((MasterEnvironment)getEnvironment()).supportGroupCPs) {
|
||||
observer.preBalanceRSGroup(this, name);
|
||||
}
|
||||
observer.preBalanceRSGroup(this, name);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1396,9 +1370,7 @@ public class MasterCoprocessorHost
|
|||
execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
|
||||
@Override
|
||||
public void call(MasterObserver observer) throws IOException {
|
||||
if(((MasterEnvironment)getEnvironment()).supportGroupCPs) {
|
||||
observer.postBalanceRSGroup(this, name, balanceRan);
|
||||
}
|
||||
observer.postBalanceRSGroup(this, name, balanceRan);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1408,9 +1380,7 @@ public class MasterCoprocessorHost
|
|||
execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
|
||||
@Override
|
||||
public void call(MasterObserver observer) throws IOException {
|
||||
if(((MasterEnvironment)getEnvironment()).supportGroupCPs) {
|
||||
observer.preRemoveServers(this, servers);
|
||||
}
|
||||
observer.preRemoveServers(this, servers);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1420,9 +1390,7 @@ public class MasterCoprocessorHost
|
|||
execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
|
||||
@Override
|
||||
public void call(MasterObserver observer) throws IOException {
|
||||
if(((MasterEnvironment)getEnvironment()).supportGroupCPs) {
|
||||
observer.postRemoveServers(this, servers);
|
||||
}
|
||||
observer.postRemoveServers(this, servers);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue