You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2018/01/03 01:40:36 UTC
[04/34] hbase git commit: HBASE-19667 Get rid of
MasterEnvironment#supportGroupCPs
HBASE-19667 Get rid of MasterEnvironment#supportGroupCPs
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/32e01077
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/32e01077
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/32e01077
Branch: refs/heads/HBASE-19397
Commit: 32e0107751f06528d356752a29e41e596c114ebb
Parents: f6f57d3
Author: Chia-Ping Tsai <ch...@gmail.com>
Authored: Fri Dec 29 20:34:14 2017 +0800
Committer: Chia-Ping Tsai <ch...@gmail.com>
Committed: Wed Jan 3 04:59:38 2018 +0800
----------------------------------------------------------------------
.../hbase/coprocessor/CoprocessorHost.java | 58 -------------------
.../hbase/master/MasterCoprocessorHost.java | 60 +++++---------------
2 files changed, 14 insertions(+), 104 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/32e01077/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/CoprocessorHost.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/CoprocessorHost.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/CoprocessorHost.java
index ca08992..42da86a 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/CoprocessorHost.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/CoprocessorHost.java
@@ -460,49 +460,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.
*/
private static final Set<Class<? extends Coprocessor>> legacyWarning =
@@ -518,21 +475,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
* observer they can handle. For e.g. RegionCoprocessorHost will use 3 getters, one for
http://git-wip-us.apache.org/repos/asf/hbase/blob/32e01077/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 ee7bcd6..9eb2ec8 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
@@ -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);
}
});
}