From b051ad5594884a4c2719810bb72552f6594db0a5 Mon Sep 17 00:00:00 2001 From: stack Date: Wed, 31 Mar 2021 16:15:50 -0700 Subject: [PATCH] Revert "HBASE-25713 Make an hbase-wal module" This reverts commit e58f1b24a6c1f3aaa511a71b2ac77280921fa210. --- hbase-client/pom.xml | 4 - .../org/apache/hadoop/hbase/Abortable.java | 11 +- .../org/apache/hadoop/hbase/Coprocessor.java | 8 +- .../hadoop/hbase/CoprocessorEnvironment.java | 0 .../hadoop/hbase/DoNotRetryIOException.java | 6 +- .../BigDecimalColumnInterpreter.java | 0 .../coprocessor/DoubleColumnInterpreter.java | 0 .../coprocessor/LongColumnInterpreter.java | 0 .../hbase/coprocessor/ColumnInterpreter.java | 0 .../coprocessor/CoprocessorException.java | 11 +- hbase-coprocessor/pom.xml | 102 ---------- hbase-server/pom.xml | 4 - .../hbase/coprocessor/BaseEnvironment.java | 14 +- .../hbase/coprocessor/CoprocessorHost.java | 55 +++--- .../hbase/coprocessor/CoreCoprocessor.java | 2 + .../hbase/coprocessor/ObserverContext.java | 13 +- .../coprocessor/ObserverContextImpl.java | 20 +- .../coprocessor/ReadOnlyConfiguration.java | 1 + .../RegionCoprocessorEnvironment.java | 1 + .../regionserver/RegionCoprocessorHost.java | 5 - .../regionserver/wal/WALCoprocessorHost.java | 4 - .../apache/hadoop/hbase/util/SortedList.java | 0 .../TestReadOnlyConfiguration.java | 15 +- .../security/access/TestAccessController.java | 176 +++++++++--------- .../access/TestAccessController3.java | 9 +- .../access/TestNamespaceCommands.java | 14 +- .../access/TestWithDisabledAuthorization.java | 84 ++++----- .../hadoop/hbase/util/TestSortedList.java | 0 pom.xml | 13 -- 29 files changed, 244 insertions(+), 328 deletions(-) rename {hbase-common => hbase-client}/src/main/java/org/apache/hadoop/hbase/Abortable.java (82%) rename {hbase-coprocessor => hbase-client}/src/main/java/org/apache/hadoop/hbase/Coprocessor.java (96%) rename {hbase-coprocessor => hbase-client}/src/main/java/org/apache/hadoop/hbase/CoprocessorEnvironment.java (100%) rename {hbase-common => hbase-client}/src/main/java/org/apache/hadoop/hbase/DoNotRetryIOException.java (93%) rename {hbase-endpoint => hbase-client}/src/main/java/org/apache/hadoop/hbase/client/coprocessor/BigDecimalColumnInterpreter.java (100%) rename {hbase-endpoint => hbase-client}/src/main/java/org/apache/hadoop/hbase/client/coprocessor/DoubleColumnInterpreter.java (100%) rename {hbase-endpoint => hbase-client}/src/main/java/org/apache/hadoop/hbase/client/coprocessor/LongColumnInterpreter.java (100%) rename {hbase-endpoint => hbase-client}/src/main/java/org/apache/hadoop/hbase/coprocessor/ColumnInterpreter.java (100%) rename {hbase-server => hbase-client}/src/main/java/org/apache/hadoop/hbase/coprocessor/CoprocessorException.java (88%) delete mode 100644 hbase-coprocessor/pom.xml rename {hbase-coprocessor => hbase-server}/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseEnvironment.java (95%) rename {hbase-coprocessor => hbase-server}/src/main/java/org/apache/hadoop/hbase/coprocessor/CoprocessorHost.java (95%) rename {hbase-coprocessor => hbase-server}/src/main/java/org/apache/hadoop/hbase/coprocessor/CoreCoprocessor.java (99%) rename {hbase-coprocessor => hbase-server}/src/main/java/org/apache/hadoop/hbase/coprocessor/ObserverContext.java (92%) rename {hbase-coprocessor => hbase-server}/src/main/java/org/apache/hadoop/hbase/coprocessor/ObserverContextImpl.java (74%) rename {hbase-coprocessor => hbase-server}/src/main/java/org/apache/hadoop/hbase/coprocessor/ReadOnlyConfiguration.java (99%) rename {hbase-common => hbase-server}/src/main/java/org/apache/hadoop/hbase/util/SortedList.java (100%) rename {hbase-coprocessor => hbase-server}/src/test/java/org/apache/hadoop/hbase/coprocessor/TestReadOnlyConfiguration.java (86%) rename {hbase-common => hbase-server}/src/test/java/org/apache/hadoop/hbase/util/TestSortedList.java (100%) diff --git a/hbase-client/pom.xml b/hbase-client/pom.xml index 8f61522eb171..08e917427873 100644 --- a/hbase-client/pom.xml +++ b/hbase-client/pom.xml @@ -72,10 +72,6 @@ test-jar test - - org.apache.hbase - hbase-coprocessor - org.apache.hbase hbase-common diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/Abortable.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/Abortable.java similarity index 82% rename from hbase-common/src/main/java/org/apache/hadoop/hbase/Abortable.java rename to hbase-client/src/main/java/org/apache/hadoop/hbase/Abortable.java index 52e9c691c9e5..8233071bc3fd 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/Abortable.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/Abortable.java @@ -1,5 +1,6 @@ -/* -* Licensed to the Apache Software Foundation (ASF) under one +/** + * + * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file @@ -22,8 +23,10 @@ /** * Interface to support the aborting of a given server or client. *

- * This is used primarily when we could get an unexpected and fatal exception; abort is called to - * exit the hosting process. + * This is used primarily for ZooKeeper usage when we could get an unexpected + * and fatal exception, requiring an abort. + *

+ * Implemented by the Master, RegionServer, and TableServers (client). */ @InterfaceAudience.Private public interface Abortable { diff --git a/hbase-coprocessor/src/main/java/org/apache/hadoop/hbase/Coprocessor.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/Coprocessor.java similarity index 96% rename from hbase-coprocessor/src/main/java/org/apache/hadoop/hbase/Coprocessor.java rename to hbase-client/src/main/java/org/apache/hadoop/hbase/Coprocessor.java index ea6ad93e485c..c0d9b603a8ab 100644 --- a/hbase-coprocessor/src/main/java/org/apache/hadoop/hbase/Coprocessor.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/Coprocessor.java @@ -18,9 +18,11 @@ */ package org.apache.hadoop.hbase; -import com.google.protobuf.Service; + import java.io.IOException; import java.util.Collections; + +import com.google.protobuf.Service; import org.apache.yetus.audience.InterfaceAudience; import org.apache.yetus.audience.InterfaceStability; @@ -95,8 +97,8 @@ default void stop(CoprocessorEnvironment env) throws IOException {} /** * Coprocessor endpoints providing protobuf services should override this method. - * @return Iterable of {@link Service}s or empty collection; implementations should not return - * null. + * @return Iterable of {@link Service}s or empty collection. Implementations should never + * return null. */ default Iterable getServices() { return Collections.EMPTY_SET; diff --git a/hbase-coprocessor/src/main/java/org/apache/hadoop/hbase/CoprocessorEnvironment.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/CoprocessorEnvironment.java similarity index 100% rename from hbase-coprocessor/src/main/java/org/apache/hadoop/hbase/CoprocessorEnvironment.java rename to hbase-client/src/main/java/org/apache/hadoop/hbase/CoprocessorEnvironment.java diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/DoNotRetryIOException.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/DoNotRetryIOException.java similarity index 93% rename from hbase-common/src/main/java/org/apache/hadoop/hbase/DoNotRetryIOException.java rename to hbase-client/src/main/java/org/apache/hadoop/hbase/DoNotRetryIOException.java index ae9f2ad805b4..509844e367d8 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/DoNotRetryIOException.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/DoNotRetryIOException.java @@ -1,4 +1,5 @@ -/* +/** + * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -20,7 +21,8 @@ import org.apache.yetus.audience.InterfaceAudience; /** - * Subclass if exception is not meant to be retried. + * Subclass if exception is not meant to be retried: e.g. + * {@link org.apache.hadoop.hbase.UnknownScannerException} */ @InterfaceAudience.Public public class DoNotRetryIOException extends HBaseIOException { diff --git a/hbase-endpoint/src/main/java/org/apache/hadoop/hbase/client/coprocessor/BigDecimalColumnInterpreter.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/coprocessor/BigDecimalColumnInterpreter.java similarity index 100% rename from hbase-endpoint/src/main/java/org/apache/hadoop/hbase/client/coprocessor/BigDecimalColumnInterpreter.java rename to hbase-client/src/main/java/org/apache/hadoop/hbase/client/coprocessor/BigDecimalColumnInterpreter.java diff --git a/hbase-endpoint/src/main/java/org/apache/hadoop/hbase/client/coprocessor/DoubleColumnInterpreter.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/coprocessor/DoubleColumnInterpreter.java similarity index 100% rename from hbase-endpoint/src/main/java/org/apache/hadoop/hbase/client/coprocessor/DoubleColumnInterpreter.java rename to hbase-client/src/main/java/org/apache/hadoop/hbase/client/coprocessor/DoubleColumnInterpreter.java diff --git a/hbase-endpoint/src/main/java/org/apache/hadoop/hbase/client/coprocessor/LongColumnInterpreter.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/coprocessor/LongColumnInterpreter.java similarity index 100% rename from hbase-endpoint/src/main/java/org/apache/hadoop/hbase/client/coprocessor/LongColumnInterpreter.java rename to hbase-client/src/main/java/org/apache/hadoop/hbase/client/coprocessor/LongColumnInterpreter.java diff --git a/hbase-endpoint/src/main/java/org/apache/hadoop/hbase/coprocessor/ColumnInterpreter.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/coprocessor/ColumnInterpreter.java similarity index 100% rename from hbase-endpoint/src/main/java/org/apache/hadoop/hbase/coprocessor/ColumnInterpreter.java rename to hbase-client/src/main/java/org/apache/hadoop/hbase/coprocessor/ColumnInterpreter.java diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/CoprocessorException.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/coprocessor/CoprocessorException.java similarity index 88% rename from hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/CoprocessorException.java rename to hbase-client/src/main/java/org/apache/hadoop/hbase/coprocessor/CoprocessorException.java index 99484a22846b..7b1ac43c4bfb 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/CoprocessorException.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/coprocessor/CoprocessorException.java @@ -1,4 +1,5 @@ -/* +/** + * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -25,6 +26,8 @@ */ @InterfaceAudience.Public public class CoprocessorException extends DoNotRetryIOException { + private static final long serialVersionUID = 4357922136679804887L; + /** Default Constructor */ public CoprocessorException() { super(); @@ -32,15 +35,19 @@ public CoprocessorException() { /** * Constructor with a Class object and exception message. + * @param clazz + * @param s */ public CoprocessorException(Class clazz, String s) { - super("Coprocessor [" + clazz.getName() + "]: " + s); + super( "Coprocessor [" + clazz.getName() + "]: " + s); } /** * Constructs the exception and supplies a string as the message + * @param s - message */ public CoprocessorException(String s) { super(s); } + } diff --git a/hbase-coprocessor/pom.xml b/hbase-coprocessor/pom.xml deleted file mode 100644 index 0bcfcef25d41..000000000000 --- a/hbase-coprocessor/pom.xml +++ /dev/null @@ -1,102 +0,0 @@ - - - - 4.0.0 - - hbase-build-configuration - org.apache.hbase - 2.5.0-SNAPSHOT - ../hbase-build-configuration - - - hbase-coprocessor - Apache HBase - Coprocessor - Base Coprocessor Types - - - - - src/test/resources - - log4j.properties - - - - - - - maven-assembly-plugin - - true - - - - - org.apache.maven.plugins - maven-source-plugin - - - net.revelc.code - warbucks-maven-plugin - - - - - - - org.apache.hbase - hbase-annotations - test-jar - test - - - org.slf4j - slf4j-api - - - junit - junit - test - - - org.slf4j - slf4j-log4j12 - test - - - log4j - log4j - provided - - - org.apache.hbase - hbase-common - - - org.apache.hbase - hbase-common - test-jar - test - - - diff --git a/hbase-server/pom.xml b/hbase-server/pom.xml index 93051e0745f5..48a9fbcd36e3 100644 --- a/hbase-server/pom.xml +++ b/hbase-server/pom.xml @@ -256,10 +256,6 @@ org.apache.hbase hbase-common - - org.apache.hbase - hbase-coprocessor - org.apache.hbase hbase-http diff --git a/hbase-coprocessor/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseEnvironment.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseEnvironment.java similarity index 95% rename from hbase-coprocessor/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseEnvironment.java rename to hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseEnvironment.java index 2e66a18315e7..2818dcd675f1 100644 --- a/hbase-coprocessor/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseEnvironment.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseEnvironment.java @@ -1,4 +1,5 @@ /* + * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -18,7 +19,6 @@ package org.apache.hadoop.hbase.coprocessor; -import java.io.IOException; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.Coprocessor; import org.apache.hadoop.hbase.CoprocessorEnvironment; @@ -27,6 +27,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.IOException; + /** * Encapsulation of the environment of each coprocessor */ @@ -35,21 +37,21 @@ public class BaseEnvironment implements CoprocessorEnviro private static final Logger LOG = LoggerFactory.getLogger(BaseEnvironment.class); /** The coprocessor */ - protected final C impl; + public C impl; /** Chaining priority */ protected int priority = Coprocessor.PRIORITY_USER; /** Current coprocessor state */ Coprocessor.State state = Coprocessor.State.UNINSTALLED; - private final int seq; - private final Configuration conf; - private final ClassLoader classLoader; + private int seq; + private Configuration conf; + private ClassLoader classLoader; /** * Constructor * @param impl the coprocessor instance * @param priority chaining priority */ - public BaseEnvironment(C impl, final int priority, int seq, Configuration conf) { + public BaseEnvironment(final C impl, final int priority, final int seq, final Configuration conf) { this.impl = impl; this.classLoader = impl.getClass().getClassLoader(); this.priority = priority; diff --git a/hbase-coprocessor/src/main/java/org/apache/hadoop/hbase/coprocessor/CoprocessorHost.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/CoprocessorHost.java similarity index 95% rename from hbase-coprocessor/src/main/java/org/apache/hadoop/hbase/coprocessor/CoprocessorHost.java rename to hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/CoprocessorHost.java index 676a053db0d2..442507630056 100644 --- a/hbase-coprocessor/src/main/java/org/apache/hadoop/hbase/coprocessor/CoprocessorHost.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/CoprocessorHost.java @@ -31,6 +31,10 @@ import java.util.concurrent.ConcurrentSkipListSet; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Function; + +import org.apache.yetus.audience.InterfaceAudience; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; import org.apache.hadoop.hbase.Abortable; @@ -38,18 +42,17 @@ import org.apache.hadoop.hbase.CoprocessorEnvironment; import org.apache.hadoop.hbase.DoNotRetryIOException; import org.apache.hadoop.hbase.HConstants; +import org.apache.hadoop.hbase.ipc.RpcServer; import org.apache.hadoop.hbase.security.User; import org.apache.hadoop.hbase.util.CoprocessorClassLoader; import org.apache.hadoop.hbase.util.SortedList; -import org.apache.yetus.audience.InterfaceAudience; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * Provides the common setup framework and runtime services for coprocessor * invocation from HBase services. * @param type of specific coprocessor this host will handle * @param type of specific coprocessor environment this host requires. + * provides */ @InterfaceAudience.Private public abstract class CoprocessorHost> { @@ -97,7 +100,8 @@ public CoprocessorHost(Abortable abortable) { * the intention is to preserve a history of all loaded coprocessors for * diagnosis in case of server crash (HBASE-4014). */ - private static final Set coprocessorNames = Collections.synchronizedSet(new HashSet<>()); + private static Set coprocessorNames = + Collections.synchronizedSet(new HashSet()); public static Set getLoadedCoprocessors() { synchronized (coprocessorNames) { @@ -135,9 +139,8 @@ protected void loadSystemCoprocessors(Configuration conf, String confKey) { // load default coprocessors from configure file String[] defaultCPClasses = conf.getStrings(confKey); - if (defaultCPClasses == null || defaultCPClasses.length == 0) { + if (defaultCPClasses == null || defaultCPClasses.length == 0) return; - } int currentSystemPriority = Coprocessor.PRIORITY_SYSTEM; for (String className : defaultCPClasses) { @@ -451,8 +454,15 @@ protected void handleCoprocessorThrowable(final E env, final Throwable e) throws // server is configured to abort. abortServer(env, e); } else { - // env will print the Region toString if a RegionCoprocessorEnvironment which includes table. - LOG.error("Removing coprocessor '" + env.toString() + "' from " + "environment", e); + // If available, pull a table name out of the environment + if(env instanceof RegionCoprocessorEnvironment) { + String tableName = ((RegionCoprocessorEnvironment)env).getRegionInfo().getTable().getNameAsString(); + LOG.error("Removing coprocessor '" + env.toString() + "' from table '"+ tableName + "'", e); + } else { + LOG.error("Removing coprocessor '" + env.toString() + "' from " + + "environment",e); + } + coprocEnvironments.remove(env); try { shutdown(env); @@ -470,13 +480,16 @@ protected void handleCoprocessorThrowable(final E env, final Throwable e) throws * Used to limit legacy handling to once per Coprocessor class per classloader. */ private static final Set> legacyWarning = - new ConcurrentSkipListSet<>(new Comparator>() { - @Override - public int compare(Class c1, Class c2) { - return c1.equals(c2) ? 0 : c1.getName().compareTo(c2.getName()); - } - } - ); + new ConcurrentSkipListSet<>( + new Comparator>() { + @Override + public int compare(Class c1, Class c2) { + if (c1.equals(c2)) { + return 0; + } + return c1.getName().compareTo(c2.getName()); + } + }); /** * Implementations defined function to get an observer of type {@code O} from a coprocessor of @@ -505,8 +518,7 @@ private abstract class ObserverOperation extends ObserverContextImpl { } ObserverOperation(ObserverGetter observerGetter, User user, boolean bypassable) { - // Used to get user from RpcServer if null -- removed. - super(user, bypassable); + super(user != null? user: RpcServer.getRequestUser().orElse(null), bypassable); this.observerGetter = observerGetter; } @@ -534,7 +546,7 @@ public ObserverOperationWithoutResult(ObserverGetter observerGetter, User } /** - * In case of coprocessors which have many kinds of observers (e.g. RegionCoprocessor + * In case of coprocessors which have many kinds of observers (for eg, {@link RegionCoprocessor} * has BulkLoadObserver, RegionObserver, etc), some implementations may not need all * observers, in which case they will return null for that observer's getter. * We simply ignore such cases. @@ -602,7 +614,7 @@ protected R execOperationWithResult( /** * @return True if we are to bypass (Can only be true if - * ObserverOperation#isBypassable()). + * ObserverOperation#isBypassable(). */ protected boolean execOperation(final ObserverOperation observerOperation) throws IOException { @@ -645,12 +657,11 @@ protected boolean execOperation(final ObserverOperation observerOperation * master/regionserver stop or cluster shutdown. (Refer: * HBASE-16663 * @return true if bypaas coprocessor execution, false if not. + * @throws IOException */ protected boolean execShutdown(final ObserverOperation observerOperation) throws IOException { - if (observerOperation == null) { - return false; - } + if (observerOperation == null) return false; boolean bypass = false; List envs = coprocEnvironments.get(); // Iterate the coprocessors and execute ObserverOperation's call() diff --git a/hbase-coprocessor/src/main/java/org/apache/hadoop/hbase/coprocessor/CoreCoprocessor.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/CoreCoprocessor.java similarity index 99% rename from hbase-coprocessor/src/main/java/org/apache/hadoop/hbase/coprocessor/CoreCoprocessor.java rename to hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/CoreCoprocessor.java index 948e754b5ebb..0eb5e156b7b3 100644 --- a/hbase-coprocessor/src/main/java/org/apache/hadoop/hbase/coprocessor/CoreCoprocessor.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/CoreCoprocessor.java @@ -1,4 +1,5 @@ /* + * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -18,6 +19,7 @@ package org.apache.hadoop.hbase.coprocessor; import org.apache.yetus.audience.InterfaceAudience; + import java.lang.annotation.ElementType; import java.lang.annotation.Inherited; import java.lang.annotation.Retention; diff --git a/hbase-coprocessor/src/main/java/org/apache/hadoop/hbase/coprocessor/ObserverContext.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/ObserverContext.java similarity index 92% rename from hbase-coprocessor/src/main/java/org/apache/hadoop/hbase/coprocessor/ObserverContext.java rename to hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/ObserverContext.java index c66c5b31009d..c756926fb213 100644 --- a/hbase-coprocessor/src/main/java/org/apache/hadoop/hbase/coprocessor/ObserverContext.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/ObserverContext.java @@ -17,18 +17,20 @@ */ package org.apache.hadoop.hbase.coprocessor; -import java.util.Optional; import org.apache.hadoop.hbase.CoprocessorEnvironment; import org.apache.hadoop.hbase.HBaseInterfaceAudience; import org.apache.hadoop.hbase.security.User; import org.apache.yetus.audience.InterfaceAudience; import org.apache.yetus.audience.InterfaceStability; +import java.util.Optional; + /** - * Carries the execution state for a given invocation of an Observer coprocessor method. The same - * ObserverContext instance is passed sequentially to all loaded coprocessors for a given Observer - * method trigger, with the CoprocessorEnvironment reference set appropriately for each - * Coprocessor type: + * Carries the execution state for a given invocation of an Observer coprocessor + * ({@link RegionObserver}, {@link MasterObserver}, or {@link WALObserver}) + * method. The same ObserverContext instance is passed sequentially to all loaded + * coprocessors for a given Observer method trigger, with the + * CoprocessorEnvironment reference set appropriately for each Coprocessor type: * e.g. the RegionCoprocessorEnvironment is passed to RegionCoprocessors, and so on. * @param The {@link CoprocessorEnvironment} subclass applicable to the * revelant Observer interface. @@ -67,6 +69,7 @@ public interface ObserverContext { */ void bypass(); + /** * Returns the active user for the coprocessor call. If an explicit {@code User} instance was * provided to the constructor, that will be returned, otherwise if we are in the context of an diff --git a/hbase-coprocessor/src/main/java/org/apache/hadoop/hbase/coprocessor/ObserverContextImpl.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/ObserverContextImpl.java similarity index 74% rename from hbase-coprocessor/src/main/java/org/apache/hadoop/hbase/coprocessor/ObserverContextImpl.java rename to hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/ObserverContextImpl.java index 043e9a5fd05e..b5370db9a9da 100644 --- a/hbase-coprocessor/src/main/java/org/apache/hadoop/hbase/coprocessor/ObserverContextImpl.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/ObserverContextImpl.java @@ -19,6 +19,7 @@ import java.util.Optional; import org.apache.hadoop.hbase.CoprocessorEnvironment; +import org.apache.hadoop.hbase.ipc.RpcServer; import org.apache.hadoop.hbase.security.User; import org.apache.yetus.audience.InterfaceAudience; @@ -41,9 +42,6 @@ public ObserverContextImpl(User caller) { } public ObserverContextImpl(User caller, boolean bypassable) { - // Used to do RpcServer.getRequestUser().orElse(null) if null but removed so no dependence on - // RPCServer. - assert caller != null; this.caller = caller; this.bypassable = bypassable; } @@ -89,5 +87,19 @@ public Optional getCaller() { return Optional.ofNullable(caller); } - + /** + * Instantiates a new ObserverContext instance if the passed reference is null and + * sets the environment in the new or existing instance. This allows deferring the instantiation + * of a ObserverContext until it is actually needed. + * @param The environment type for the context + * @param env The coprocessor environment to set + * @return An instance of ObserverContext with the environment set + */ + @Deprecated + // TODO: Remove this method, ObserverContext should not depend on RpcServer + public static ObserverContext createAndPrepare(E env) { + ObserverContextImpl ctx = new ObserverContextImpl<>(RpcServer.getRequestUser().orElse(null)); + ctx.prepare(env); + return ctx; + } } diff --git a/hbase-coprocessor/src/main/java/org/apache/hadoop/hbase/coprocessor/ReadOnlyConfiguration.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/ReadOnlyConfiguration.java similarity index 99% rename from hbase-coprocessor/src/main/java/org/apache/hadoop/hbase/coprocessor/ReadOnlyConfiguration.java rename to hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/ReadOnlyConfiguration.java index 485cd98a97a3..b805c50e1539 100644 --- a/hbase-coprocessor/src/main/java/org/apache/hadoop/hbase/coprocessor/ReadOnlyConfiguration.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/ReadOnlyConfiguration.java @@ -34,6 +34,7 @@ import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.regex.Pattern; + import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; import org.apache.yetus.audience.InterfaceAudience; diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/RegionCoprocessorEnvironment.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/RegionCoprocessorEnvironment.java index bbd7cd638b58..84e6d25e7699 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/RegionCoprocessorEnvironment.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/RegionCoprocessorEnvironment.java @@ -21,6 +21,7 @@ import java.io.IOException; import java.util.concurrent.ConcurrentMap; + import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.CoprocessorEnvironment; import org.apache.hadoop.hbase.HBaseInterfaceAudience; 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 8662c2ab0a32..6961bfdaf1a6 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 @@ -1689,9 +1689,4 @@ public void preCleanupBulkLoad(User user) throws IOException { } }); } - - @Override - public String toString() { - return "RegionCoprocessorHost{region=" + region + "} " + super.toString(); - } } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALCoprocessorHost.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALCoprocessorHost.java index 12e94483adb1..40d6d0fc948a 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALCoprocessorHost.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALCoprocessorHost.java @@ -90,10 +90,6 @@ public void shutdown() { super.shutdown(); MetricsCoprocessor.removeRegistry(this.metricRegistry); } - - @Override public String toString() { - return "WALEnvironment{wal=" + wal + '}'; - } } private final WAL wal; diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/SortedList.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/SortedList.java similarity index 100% rename from hbase-common/src/main/java/org/apache/hadoop/hbase/util/SortedList.java rename to hbase-server/src/main/java/org/apache/hadoop/hbase/util/SortedList.java diff --git a/hbase-coprocessor/src/test/java/org/apache/hadoop/hbase/coprocessor/TestReadOnlyConfiguration.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestReadOnlyConfiguration.java similarity index 86% rename from hbase-coprocessor/src/test/java/org/apache/hadoop/hbase/coprocessor/TestReadOnlyConfiguration.java rename to hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestReadOnlyConfiguration.java index 3056c68d3e64..a91c505f175a 100644 --- a/hbase-coprocessor/src/test/java/org/apache/hadoop/hbase/coprocessor/TestReadOnlyConfiguration.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestReadOnlyConfiguration.java @@ -1,4 +1,4 @@ -/* +/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -22,20 +22,25 @@ import org.apache.hadoop.hbase.testclassification.RegionServerTests; import org.apache.hadoop.hbase.testclassification.SmallTests; import org.junit.ClassRule; +import org.junit.Rule; import org.junit.Test; import org.junit.experimental.categories.Category; +import org.junit.rules.TestName; @Category({ RegionServerTests.class, SmallTests.class }) public class TestReadOnlyConfiguration { + @ClassRule public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestReadOnlyConfiguration.class); + HBaseClassTestRule.forClass(TestReadOnlyConfiguration.class); + + @Rule + public TestName name = new TestName(); - @Test (expected = UnsupportedOperationException.class) + @Test public void testAddDefaultResource() { Configuration configuration = new Configuration(); Configuration readOnlyConf = new ReadOnlyConfiguration(configuration); - readOnlyConf.addDefaultResource("abc.xml"); - readOnlyConf.setInt("any.old.config", 1); + configuration.addDefaultResource("abc.xml"); } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java index 84afba153410..94b2385f6879 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java @@ -24,6 +24,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; + import com.google.protobuf.BlockingRpcChannel; import com.google.protobuf.RpcCallback; import com.google.protobuf.RpcController; @@ -38,6 +39,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; + import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.CommonConfigurationKeys; import org.apache.hadoop.fs.FileStatus; @@ -79,9 +81,9 @@ import org.apache.hadoop.hbase.client.Table; import org.apache.hadoop.hbase.client.TableState; import org.apache.hadoop.hbase.client.security.SecurityCapability; + import org.apache.hadoop.hbase.coprocessor.CoprocessorHost; import org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment; -import org.apache.hadoop.hbase.coprocessor.ObserverContext; import org.apache.hadoop.hbase.coprocessor.ObserverContextImpl; import org.apache.hadoop.hbase.coprocessor.RegionCoprocessor; import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment; @@ -102,7 +104,6 @@ import org.apache.hadoop.hbase.io.hfile.HFile; import org.apache.hadoop.hbase.io.hfile.HFileContext; import org.apache.hadoop.hbase.io.hfile.HFileContextBuilder; -import org.apache.hadoop.hbase.ipc.RpcServer; import org.apache.hadoop.hbase.master.HMaster; import org.apache.hadoop.hbase.master.MasterCoprocessorHost; import org.apache.hadoop.hbase.master.RegionState; @@ -444,7 +445,7 @@ public void testTableCreate() throws Exception { public Object run() throws Exception { HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(name.getMethodName())); htd.addFamily(new HColumnDescriptor(TEST_FAMILY)); - ACCESS_CONTROLLER.preCreateTable(createAndPrepare(CP_ENV), htd, null); + ACCESS_CONTROLLER.preCreateTable(ObserverContextImpl.createAndPrepare(CP_ENV), htd, null); return null; } }; @@ -465,7 +466,8 @@ public Object run() throws Exception { HTableDescriptor htd = new HTableDescriptor(TEST_TABLE); htd.addFamily(new HColumnDescriptor(TEST_FAMILY)); htd.addFamily(new HColumnDescriptor("fam_" + User.getCurrent().getShortName())); - ACCESS_CONTROLLER.preModifyTable(createAndPrepare(CP_ENV), TEST_TABLE, null, htd); + ACCESS_CONTROLLER.preModifyTable(ObserverContextImpl.createAndPrepare(CP_ENV), TEST_TABLE, + null, htd); return null; } }; @@ -481,7 +483,7 @@ public void testTableDelete() throws Exception { @Override public Object run() throws Exception { ACCESS_CONTROLLER - .preDeleteTable(createAndPrepare(CP_ENV), TEST_TABLE); + .preDeleteTable(ObserverContextImpl.createAndPrepare(CP_ENV), TEST_TABLE); return null; } }; @@ -496,7 +498,9 @@ public void testTableTruncate() throws Exception { AccessTestAction truncateTable = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preTruncateTable(createAndPrepare(CP_ENV), TEST_TABLE); + ACCESS_CONTROLLER + .preTruncateTable(ObserverContextImpl.createAndPrepare(CP_ENV), + TEST_TABLE); return null; } }; @@ -511,7 +515,8 @@ public void testTableDisable() throws Exception { AccessTestAction disableTable = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preDisableTable(createAndPrepare(CP_ENV), TEST_TABLE); + ACCESS_CONTROLLER.preDisableTable(ObserverContextImpl.createAndPrepare(CP_ENV), + TEST_TABLE); return null; } }; @@ -519,7 +524,7 @@ public Object run() throws Exception { AccessTestAction disableAclTable = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preDisableTable(createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preDisableTable(ObserverContextImpl.createAndPrepare(CP_ENV), PermissionStorage.ACL_TABLE_NAME); return null; } @@ -539,7 +544,8 @@ public void testTableEnable() throws Exception { AccessTestAction enableTable = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preEnableTable(createAndPrepare(CP_ENV), TEST_TABLE); + ACCESS_CONTROLLER + .preEnableTable(ObserverContextImpl.createAndPrepare(CP_ENV), TEST_TABLE); return null; } }; @@ -614,8 +620,8 @@ public void testAbortProcedure() throws Exception { AccessTestAction abortProcedureAction = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preAbortProcedure(createAndPrepare(CP_ENV), procId); - return null; + ACCESS_CONTROLLER.preAbortProcedure(ObserverContextImpl.createAndPrepare(CP_ENV), procId); + return null; } }; @@ -635,7 +641,8 @@ public void testGetProcedures() throws Exception { AccessTestAction getProceduresAction = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.postGetProcedures(createAndPrepare(CP_ENV)); + ACCESS_CONTROLLER + .postGetProcedures(ObserverContextImpl.createAndPrepare(CP_ENV)); return null; } }; @@ -651,7 +658,7 @@ public void testGetLocks() throws Exception { AccessTestAction action = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preGetLocks(createAndPrepare(CP_ENV)); + ACCESS_CONTROLLER.preGetLocks(ObserverContextImpl.createAndPrepare(CP_ENV)); return null; } }; @@ -673,7 +680,8 @@ public void testMove() throws Exception { AccessTestAction action = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preMove(createAndPrepare(CP_ENV), hri, server, server); + ACCESS_CONTROLLER.preMove(ObserverContextImpl.createAndPrepare(CP_ENV), + hri, server, server); return null; } }; @@ -694,7 +702,7 @@ public void testAssign() throws Exception { AccessTestAction action = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preAssign(createAndPrepare(CP_ENV), hri); + ACCESS_CONTROLLER.preAssign(ObserverContextImpl.createAndPrepare(CP_ENV), hri); return null; } }; @@ -715,7 +723,7 @@ public void testUnassign() throws Exception { AccessTestAction action = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preUnassign(createAndPrepare(CP_ENV), hri); + ACCESS_CONTROLLER.preUnassign(ObserverContextImpl.createAndPrepare(CP_ENV), hri); return null; } }; @@ -736,7 +744,7 @@ public void testRegionOffline() throws Exception { AccessTestAction action = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preRegionOffline(createAndPrepare(CP_ENV), hri); + ACCESS_CONTROLLER.preRegionOffline(ObserverContextImpl.createAndPrepare(CP_ENV), hri); return null; } }; @@ -751,7 +759,7 @@ public void testSetSplitOrMergeEnabled() throws Exception { AccessTestAction action = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preSetSplitOrMergeEnabled(createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preSetSplitOrMergeEnabled(ObserverContextImpl.createAndPrepare(CP_ENV), true, MasterSwitchType.MERGE); return null; } @@ -767,7 +775,7 @@ public void testBalance() throws Exception { AccessTestAction action = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preBalance(createAndPrepare(CP_ENV)); + ACCESS_CONTROLLER.preBalance(ObserverContextImpl.createAndPrepare(CP_ENV)); return null; } }; @@ -782,7 +790,7 @@ public void testBalanceSwitch() throws Exception { AccessTestAction action = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preBalanceSwitch(createAndPrepare(CP_ENV), true); + ACCESS_CONTROLLER.preBalanceSwitch(ObserverContextImpl.createAndPrepare(CP_ENV), true); return null; } }; @@ -797,7 +805,7 @@ public void testShutdown() throws Exception { AccessTestAction action = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preShutdown(createAndPrepare(CP_ENV)); + ACCESS_CONTROLLER.preShutdown(ObserverContextImpl.createAndPrepare(CP_ENV)); return null; } }; @@ -812,7 +820,7 @@ public void testStopMaster() throws Exception { AccessTestAction action = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preStopMaster(createAndPrepare(CP_ENV)); + ACCESS_CONTROLLER.preStopMaster(ObserverContextImpl.createAndPrepare(CP_ENV)); return null; } }; @@ -835,7 +843,10 @@ public void testSplitWithSplitRow() throws Exception { AccessTestAction action = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preSplitRegion(createAndPrepare(CP_ENV), tableName, TEST_ROW); + ACCESS_CONTROLLER.preSplitRegion( + ObserverContextImpl.createAndPrepare(CP_ENV), + tableName, + TEST_ROW); return null; } }; @@ -850,7 +861,8 @@ public void testFlush() throws Exception { AccessTestAction action = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preFlush(createAndPrepare(RCP_ENV), FlushLifeCycleTracker.DUMMY); + ACCESS_CONTROLLER.preFlush(ObserverContextImpl.createAndPrepare(RCP_ENV), + FlushLifeCycleTracker.DUMMY); return null; } }; @@ -865,7 +877,7 @@ public void testCompact() throws Exception { AccessTestAction action = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preCompact(createAndPrepare(RCP_ENV), null, null, + ACCESS_CONTROLLER.preCompact(ObserverContextImpl.createAndPrepare(RCP_ENV), null, null, ScanType.COMPACT_RETAIN_DELETES, null, null); return null; } @@ -907,7 +919,7 @@ public Object run() throws Exception { // action for scanning AccessTestAction scanAction = new AccessTestAction() { - @SuppressWarnings("checkstyle:EmptyStatement") @Override + @Override public Object run() throws Exception { Scan s = new Scan(); s.addFamily(TEST_FAMILY); @@ -916,7 +928,7 @@ public Object run() throws Exception { ResultScanner scanner = table.getScanner(s); try { for (Result r = scanner.next(); r != null; r = scanner.next()) { - ; // do nothing + // do nothing } } finally { scanner.close(); @@ -1249,7 +1261,7 @@ public Object run() throws Exception { AccessTestAction preGrantAction = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preGrant(createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preGrant(ObserverContextImpl.createAndPrepare(CP_ENV), new UserPermission(USER_RO.getShortName(), Permission.newBuilder(TEST_TABLE) .withFamily(TEST_FAMILY).withActions(Action.READ).build()), false); @@ -1260,7 +1272,7 @@ public Object run() throws Exception { AccessTestAction preRevokeAction = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preRevoke(createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preRevoke(ObserverContextImpl.createAndPrepare(CP_ENV), new UserPermission(USER_RO.getShortName(), Permission.newBuilder(TEST_TABLE) .withFamily(TEST_FAMILY).withActions(Action.READ).build())); return null; @@ -1581,12 +1593,11 @@ public Object run() throws Exception { } private boolean hasFoundUserPermission(List userPermissions, - List perms) { + List perms) { return perms.containsAll(userPermissions); } - private boolean hasFoundUserPermission(UserPermission userPermission, - List perms) { + private boolean hasFoundUserPermission(UserPermission userPermission, List perms) { return perms.contains(userPermission); } @@ -1980,7 +1991,7 @@ public void testStopRegionServer() throws Exception { AccessTestAction action = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preStopRegionServer(createAndPrepare(RSCP_ENV)); + ACCESS_CONTROLLER.preStopRegionServer(ObserverContextImpl.createAndPrepare(RSCP_ENV)); return null; } }; @@ -1995,7 +2006,7 @@ public void testRollWALWriterRequest() throws Exception { AccessTestAction action = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preRollWALWriterRequest(createAndPrepare(RSCP_ENV)); + ACCESS_CONTROLLER.preRollWALWriterRequest(ObserverContextImpl.createAndPrepare(RSCP_ENV)); return null; } }; @@ -2010,7 +2021,7 @@ public void testOpenRegion() throws Exception { AccessTestAction action = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preOpen(createAndPrepare(RCP_ENV)); + ACCESS_CONTROLLER.preOpen(ObserverContextImpl.createAndPrepare(RCP_ENV)); return null; } }; @@ -2025,7 +2036,7 @@ public void testCloseRegion() throws Exception { AccessTestAction action = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preClose(createAndPrepare(RCP_ENV), false); + ACCESS_CONTROLLER.preClose(ObserverContextImpl.createAndPrepare(RCP_ENV), false); return null; } }; @@ -2044,7 +2055,7 @@ public void testSnapshot() throws Exception { AccessTestAction snapshotAction = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preSnapshot(createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preSnapshot(ObserverContextImpl.createAndPrepare(CP_ENV), snapshot, htd); return null; } @@ -2053,7 +2064,7 @@ public Object run() throws Exception { AccessTestAction deleteAction = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preDeleteSnapshot(createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preDeleteSnapshot(ObserverContextImpl.createAndPrepare(CP_ENV), snapshot); return null; } @@ -2062,7 +2073,7 @@ public Object run() throws Exception { AccessTestAction restoreAction = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preRestoreSnapshot(createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preRestoreSnapshot(ObserverContextImpl.createAndPrepare(CP_ENV), snapshot, htd); return null; } @@ -2071,7 +2082,7 @@ public Object run() throws Exception { AccessTestAction cloneAction = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preCloneSnapshot(createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preCloneSnapshot(ObserverContextImpl.createAndPrepare(CP_ENV), snapshot, null); return null; } @@ -2104,7 +2115,7 @@ public void testSnapshotWithOwner() throws Exception { AccessTestAction snapshotAction = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preSnapshot(createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preSnapshot(ObserverContextImpl.createAndPrepare(CP_ENV), snapshot, htd); return null; } @@ -2116,7 +2127,7 @@ public Object run() throws Exception { AccessTestAction deleteAction = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preDeleteSnapshot(createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preDeleteSnapshot(ObserverContextImpl.createAndPrepare(CP_ENV), snapshot); return null; } @@ -2128,7 +2139,7 @@ public Object run() throws Exception { AccessTestAction restoreAction = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preRestoreSnapshot(createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preRestoreSnapshot(ObserverContextImpl.createAndPrepare(CP_ENV), snapshot, htd); return null; } @@ -2140,7 +2151,7 @@ public Object run() throws Exception { AccessTestAction cloneAction = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preCloneSnapshot(createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preCloneSnapshot(ObserverContextImpl.createAndPrepare(CP_ENV), snapshot, htd); return null; } @@ -2285,8 +2296,7 @@ public void testTableDeletion() throws Exception { createTestTable(tableName); // Grant TABLE ADMIN privs - grantOnTable(TEST_UTIL, TABLE_ADMIN.getShortName(), tableName, null, null, - Permission.Action.ADMIN); + grantOnTable(TEST_UTIL, TABLE_ADMIN.getShortName(), tableName, null, null, Permission.Action.ADMIN); AccessTestAction deleteTableAction = new AccessTestAction() { @Override @@ -2514,8 +2524,8 @@ public Object run() throws Exception { // Revoke table READ & WRITE permission to testGrantRevoke. try { - revokeFromTableUsingAccessControlClient(TEST_UTIL, systemUserConnection, userName, TEST_TABLE, - null, null, Permission.Action.READ, Permission.Action.WRITE); + revokeFromTableUsingAccessControlClient(TEST_UTIL, systemUserConnection, userName, TEST_TABLE, null, null, + Permission.Action.READ, Permission.Action.WRITE); } catch (Throwable e) { LOG.error("error during call of AccessControlClient.revoke ", e); } @@ -2700,7 +2710,7 @@ public void testSetQuota() throws Exception { AccessTestAction setUserQuotaAction = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preSetUserQuota(createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preSetUserQuota(ObserverContextImpl.createAndPrepare(CP_ENV), null, null); return null; } @@ -2709,7 +2719,7 @@ public Object run() throws Exception { AccessTestAction setUserTableQuotaAction = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preSetUserQuota(createAndPrepare(CP_ENV), null, + ACCESS_CONTROLLER.preSetUserQuota(ObserverContextImpl.createAndPrepare(CP_ENV), null, TEST_TABLE, null); return null; } @@ -2718,7 +2728,7 @@ public Object run() throws Exception { AccessTestAction setUserNamespaceQuotaAction = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preSetUserQuota(createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preSetUserQuota(ObserverContextImpl.createAndPrepare(CP_ENV), null, (String)null, null); return null; } @@ -2727,7 +2737,7 @@ public Object run() throws Exception { AccessTestAction setTableQuotaAction = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preSetTableQuota(createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preSetTableQuota(ObserverContextImpl.createAndPrepare(CP_ENV), TEST_TABLE, null); return null; } @@ -2736,7 +2746,7 @@ public Object run() throws Exception { AccessTestAction setNamespaceQuotaAction = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preSetNamespaceQuota(createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preSetNamespaceQuota(ObserverContextImpl.createAndPrepare(CP_ENV), null, null); return null; } @@ -2745,7 +2755,7 @@ public Object run() throws Exception { AccessTestAction setRegionServerQuotaAction = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preSetRegionServerQuota(createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preSetRegionServerQuota(ObserverContextImpl.createAndPrepare(CP_ENV), null, null); return null; } @@ -2797,8 +2807,7 @@ public void testGetNamespacePermission() throws Exception { /** * List all user permissions match the given regular expression for namespace * and verify each of them. - * @param namespaceRegexWithoutPrefix the regualar expression for namespace, without - * NAMESPACE_PREFIX + * @param namespaceRegexWithoutPrefix the regualar expression for namespace, without NAMESPACE_PREFIX * @param expectedAmount the expected amount of user permissions returned * @param expectedNamespace the expected namespace of each user permission returned * @throws HBaseException in the case of any HBase exception when accessing hbase:acl table @@ -2935,14 +2944,14 @@ public void testPrepareAndCleanBulkLoad() throws Exception { AccessTestAction prepareBulkLoadAction = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.prePrepareBulkLoad(createAndPrepare(RCP_ENV)); + ACCESS_CONTROLLER.prePrepareBulkLoad(ObserverContextImpl.createAndPrepare(RCP_ENV)); return null; } }; AccessTestAction cleanupBulkLoadAction = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preCleanupBulkLoad(createAndPrepare(RCP_ENV)); + ACCESS_CONTROLLER.preCleanupBulkLoad(ObserverContextImpl.createAndPrepare(RCP_ENV)); return null; } }; @@ -2955,8 +2964,8 @@ public void testReplicateLogEntries() throws Exception { AccessTestAction replicateLogEntriesAction = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preReplicateLogEntries(createAndPrepare(RSCP_ENV)); - ACCESS_CONTROLLER.postReplicateLogEntries(createAndPrepare(RSCP_ENV)); + ACCESS_CONTROLLER.preReplicateLogEntries(ObserverContextImpl.createAndPrepare(RSCP_ENV)); + ACCESS_CONTROLLER.postReplicateLogEntries(ObserverContextImpl.createAndPrepare(RSCP_ENV)); return null; } }; @@ -2971,7 +2980,7 @@ public void testAddReplicationPeer() throws Exception { AccessTestAction action = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preAddReplicationPeer(createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preAddReplicationPeer(ObserverContextImpl.createAndPrepare(CP_ENV), "test", null); return null; } @@ -2986,7 +2995,7 @@ public void testRemoveReplicationPeer() throws Exception { AccessTestAction action = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preRemoveReplicationPeer(createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preRemoveReplicationPeer(ObserverContextImpl.createAndPrepare(CP_ENV), "test"); return null; } @@ -3001,7 +3010,7 @@ public void testEnableReplicationPeer() throws Exception { AccessTestAction action = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preEnableReplicationPeer(createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preEnableReplicationPeer(ObserverContextImpl.createAndPrepare(CP_ENV), "test"); return null; } @@ -3016,7 +3025,7 @@ public void testDisableReplicationPeer() throws Exception { AccessTestAction action = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preDisableReplicationPeer(createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preDisableReplicationPeer(ObserverContextImpl.createAndPrepare(CP_ENV), "test"); return null; } @@ -3032,7 +3041,7 @@ public void testGetReplicationPeerConfig() throws Exception { @Override public Object run() throws Exception { ACCESS_CONTROLLER.preGetReplicationPeerConfig( - createAndPrepare(CP_ENV), "test"); + ObserverContextImpl.createAndPrepare(CP_ENV), "test"); return null; } }; @@ -3047,7 +3056,7 @@ public void testUpdateReplicationPeerConfig() throws Exception { @Override public Object run() throws Exception { ACCESS_CONTROLLER.preUpdateReplicationPeerConfig( - createAndPrepare(CP_ENV), "test", new ReplicationPeerConfig()); + ObserverContextImpl.createAndPrepare(CP_ENV), "test", new ReplicationPeerConfig()); return null; } }; @@ -3061,7 +3070,7 @@ public void testListReplicationPeers() throws Exception { AccessTestAction action = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preListReplicationPeers(createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preListReplicationPeers(ObserverContextImpl.createAndPrepare(CP_ENV), "test"); return null; } @@ -3092,7 +3101,7 @@ public void testRemoteLocks() throws Exception { AccessTestAction namespaceLockAction = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preRequestLock(createAndPrepare(CP_ENV), namespace, + ACCESS_CONTROLLER.preRequestLock(ObserverContextImpl.createAndPrepare(CP_ENV), namespace, null, null, null); return null; } @@ -3106,7 +3115,7 @@ public void testRemoteLocks() throws Exception { AccessTestAction tableLockAction = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preRequestLock(createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preRequestLock(ObserverContextImpl.createAndPrepare(CP_ENV), null, tableName, null, null); return null; } @@ -3128,7 +3137,7 @@ public void testRemoteLocks() throws Exception { AccessTestAction regionsLockAction = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preRequestLock(createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preRequestLock(ObserverContextImpl.createAndPrepare(CP_ENV), null, null, regionInfos, null); return null; } @@ -3142,7 +3151,7 @@ public void testRemoteLocks() throws Exception { LockProcedure proc = new LockProcedure(conf, tableName, LockType.EXCLUSIVE, "test", null); AccessTestAction regionLockHeartbeatAction = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preLockHeartbeat(createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preLockHeartbeat(ObserverContextImpl.createAndPrepare(CP_ENV), proc.getTableName(), proc.getDescription()); return null; } @@ -3192,7 +3201,7 @@ public void testGetClusterStatus() throws Exception { AccessTestAction action = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preGetClusterMetrics(createAndPrepare(CP_ENV)); + ACCESS_CONTROLLER.preGetClusterMetrics(ObserverContextImpl.createAndPrepare(CP_ENV)); return null; } }; @@ -3206,7 +3215,7 @@ public void testExecuteProcedures() throws Exception { AccessTestAction action = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preExecuteProcedures(createAndPrepare(RSCP_ENV)); + ACCESS_CONTROLLER.preExecuteProcedures(ObserverContextImpl.createAndPrepare(RSCP_ENV)); return null; } }; @@ -3487,7 +3496,7 @@ public void testSwitchRpcThrottle() throws Exception { AccessTestAction action = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preSwitchRpcThrottle(createAndPrepare(CP_ENV), true); + ACCESS_CONTROLLER.preSwitchRpcThrottle(ObserverContextImpl.createAndPrepare(CP_ENV), true); return null; } }; @@ -3500,7 +3509,7 @@ public void testIsRpcThrottleEnabled() throws Exception { AccessTestAction action = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preIsRpcThrottleEnabled(createAndPrepare(CP_ENV)); + ACCESS_CONTROLLER.preIsRpcThrottleEnabled(ObserverContextImpl.createAndPrepare(CP_ENV)); return null; } }; @@ -3513,7 +3522,8 @@ public void testSwitchExceedThrottleQuota() throws Exception { AccessTestAction action = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preSwitchExceedThrottleQuota(createAndPrepare(CP_ENV), true); + ACCESS_CONTROLLER.preSwitchExceedThrottleQuota(ObserverContextImpl.createAndPrepare(CP_ENV), + true); return null; } }; @@ -3733,18 +3743,4 @@ public List getGroups(String user) throws IOException { } } } - - /** - * Instantiates a new ObserverContext instance if the passed reference is null and - * sets the environment in the new or existing instance. This allows deferring the instantiation - * of a ObserverContext until it is actually needed. - * @param The environment type for the context - * @param env The coprocessor environment to set - * @return An instance of ObserverContext with the environment set - */ - static ObserverContext createAndPrepare(E env) { - ObserverContextImpl ctx = new ObserverContextImpl<>(RpcServer.getRequestUser().orElse(null)); - ctx.prepare(env); - return ctx; - } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController3.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController3.java index 49999f2efc80..292005412af0 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController3.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController3.java @@ -1,4 +1,4 @@ -/* +/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -32,6 +32,7 @@ import org.apache.hadoop.hbase.client.Connection; import org.apache.hadoop.hbase.coprocessor.CoprocessorHost; import org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment; +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; @@ -43,6 +44,7 @@ import org.apache.hadoop.hbase.testclassification.MediumTests; import org.apache.hadoop.hbase.testclassification.SecurityTests; import org.apache.hadoop.hbase.util.Bytes; +import org.apache.hadoop.hbase.util.JVMClusterUtil; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.ClassRule; @@ -109,7 +111,7 @@ public class TestAccessController3 extends SecureTestUtil { // https://hbase.apache.org/book/appendix_acl_matrix.html // creating all Scope x Permission combinations - private static final byte[] TEST_FAMILY = Bytes.toBytes("f1"); + private static byte[] TEST_FAMILY = Bytes.toBytes("f1"); private static MasterCoprocessorEnvironment CP_ENV; private static AccessController ACCESS_CONTROLLER; @@ -279,8 +281,7 @@ public void testTableCreate() throws Exception { public Object run() throws Exception { HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(name.getMethodName())); htd.addFamily(new HColumnDescriptor(TEST_FAMILY)); - ACCESS_CONTROLLER.preCreateTable(TestAccessController. - createAndPrepare(CP_ENV), htd, null); + ACCESS_CONTROLLER.preCreateTable(ObserverContextImpl.createAndPrepare(CP_ENV), htd, null); return null; } }; diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestNamespaceCommands.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestNamespaceCommands.java index d4c19e7f43da..dbb5bfd10693 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestNamespaceCommands.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestNamespaceCommands.java @@ -248,7 +248,7 @@ public void testModifyNamespace() throws Exception { AccessTestAction modifyNamespace = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preModifyNamespace(TestAccessController.createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preModifyNamespace(ObserverContextImpl.createAndPrepare(CP_ENV), NamespaceDescriptor.create(TEST_NAMESPACE).addConfiguration("abc", "156").build()); return null; } @@ -266,7 +266,7 @@ public void testCreateAndDeleteNamespace() throws Exception { AccessTestAction createNamespace = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preCreateNamespace(TestAccessController.createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preCreateNamespace(ObserverContextImpl.createAndPrepare(CP_ENV), NamespaceDescriptor.create(TEST_NAMESPACE2).build()); return null; } @@ -275,7 +275,7 @@ public Object run() throws Exception { AccessTestAction deleteNamespace = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preDeleteNamespace(TestAccessController.createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preDeleteNamespace(ObserverContextImpl.createAndPrepare(CP_ENV), TEST_NAMESPACE2); return null; } @@ -300,7 +300,7 @@ public void testGetNamespaceDescriptor() throws Exception { AccessTestAction getNamespaceAction = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preGetNamespaceDescriptor(TestAccessController.createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preGetNamespaceDescriptor(ObserverContextImpl.createAndPrepare(CP_ENV), TEST_NAMESPACE); return null; } @@ -422,7 +422,7 @@ public Object run() throws Exception { AccessTestAction preGrantAction = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preGrant(TestAccessController.createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preGrant(ObserverContextImpl.createAndPrepare(CP_ENV), new UserPermission(testUser, Permission.newBuilder(TEST_NAMESPACE).withActions(Action.WRITE).build()), false); @@ -432,7 +432,7 @@ public Object run() throws Exception { AccessTestAction preRevokeAction = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preRevoke(TestAccessController.createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preRevoke(ObserverContextImpl.createAndPrepare(CP_ENV), new UserPermission(testUser, Permission.newBuilder(TEST_NAMESPACE).withActions(Action.WRITE).build())); return null; @@ -518,7 +518,7 @@ public void testCreateTableWithNamespace() throws Exception { public Object run() throws Exception { HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(TEST_TABLE)); htd.addFamily(new HColumnDescriptor(TEST_FAMILY)); - ACCESS_CONTROLLER.preCreateTable(TestAccessController.createAndPrepare(CP_ENV), htd, null); + ACCESS_CONTROLLER.preCreateTable(ObserverContextImpl.createAndPrepare(CP_ENV), htd, null); return null; } }; diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestWithDisabledAuthorization.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestWithDisabledAuthorization.java index b312ced83542..26507025a3fe 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestWithDisabledAuthorization.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestWithDisabledAuthorization.java @@ -472,7 +472,7 @@ public void testPassiveMasterOperations() throws Exception { public Object run() throws Exception { HTableDescriptor htd = new HTableDescriptor(testTable.getTableName()); htd.addFamily(new HColumnDescriptor(TEST_FAMILY)); - ACCESS_CONTROLLER.preCreateTable(TestAccessController.createAndPrepare(CP_ENV), htd, + ACCESS_CONTROLLER.preCreateTable(ObserverContextImpl.createAndPrepare(CP_ENV), htd, null); return null; } @@ -485,7 +485,7 @@ public Object run() throws Exception { HTableDescriptor htd = new HTableDescriptor(testTable.getTableName()); htd.addFamily(new HColumnDescriptor(TEST_FAMILY)); htd.addFamily(new HColumnDescriptor(TEST_FAMILY2)); - ACCESS_CONTROLLER.preModifyTable(TestAccessController.createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preModifyTable(ObserverContextImpl.createAndPrepare(CP_ENV), testTable.getTableName(), htd); return null; } @@ -495,7 +495,7 @@ public Object run() throws Exception { verifyAllowed(new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preDeleteTable(TestAccessController.createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preDeleteTable(ObserverContextImpl.createAndPrepare(CP_ENV), testTable.getTableName()); return null; } @@ -505,7 +505,7 @@ public Object run() throws Exception { verifyAllowed(new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preTruncateTable(TestAccessController.createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preTruncateTable(ObserverContextImpl.createAndPrepare(CP_ENV), testTable.getTableName()); return null; } @@ -515,7 +515,7 @@ public Object run() throws Exception { verifyAllowed(new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preEnableTable(TestAccessController.createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preEnableTable(ObserverContextImpl.createAndPrepare(CP_ENV), testTable.getTableName()); return null; } @@ -525,7 +525,7 @@ public Object run() throws Exception { verifyAllowed(new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preDisableTable(TestAccessController.createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preDisableTable(ObserverContextImpl.createAndPrepare(CP_ENV), testTable.getTableName()); return null; } @@ -538,7 +538,7 @@ public Object run() throws Exception { HRegionInfo region = new HRegionInfo(testTable.getTableName()); ServerName srcServer = ServerName.valueOf("1.1.1.1", 1, 0); ServerName destServer = ServerName.valueOf("2.2.2.2", 2, 0); - ACCESS_CONTROLLER.preMove(TestAccessController.createAndPrepare(CP_ENV), region, + ACCESS_CONTROLLER.preMove(ObserverContextImpl.createAndPrepare(CP_ENV), region, srcServer, destServer); return null; } @@ -549,7 +549,7 @@ public Object run() throws Exception { @Override public Object run() throws Exception { HRegionInfo region = new HRegionInfo(testTable.getTableName()); - ACCESS_CONTROLLER.preAssign(TestAccessController.createAndPrepare(CP_ENV), region); + ACCESS_CONTROLLER.preAssign(ObserverContextImpl.createAndPrepare(CP_ENV), region); return null; } }, SUPERUSER, USER_ADMIN, USER_RW, USER_RO, USER_OWNER, USER_CREATE, USER_QUAL, USER_NONE); @@ -559,7 +559,7 @@ public Object run() throws Exception { @Override public Object run() throws Exception { HRegionInfo region = new HRegionInfo(testTable.getTableName()); - ACCESS_CONTROLLER.preUnassign(TestAccessController.createAndPrepare(CP_ENV), region); + ACCESS_CONTROLLER.preUnassign(ObserverContextImpl.createAndPrepare(CP_ENV), region); return null; } }, SUPERUSER, USER_ADMIN, USER_RW, USER_RO, USER_OWNER, USER_CREATE, USER_QUAL, USER_NONE); @@ -568,7 +568,7 @@ public Object run() throws Exception { verifyAllowed(new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preBalance(TestAccessController.createAndPrepare(CP_ENV)); + ACCESS_CONTROLLER.preBalance(ObserverContextImpl.createAndPrepare(CP_ENV)); return null; } }, SUPERUSER, USER_ADMIN, USER_RW, USER_RO, USER_OWNER, USER_CREATE, USER_QUAL, USER_NONE); @@ -577,7 +577,7 @@ public Object run() throws Exception { verifyAllowed(new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preBalanceSwitch(TestAccessController.createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preBalanceSwitch(ObserverContextImpl.createAndPrepare(CP_ENV), true); return null; } @@ -589,7 +589,7 @@ public Object run() throws Exception { public Object run() throws Exception { SnapshotDescription snapshot = new SnapshotDescription("foo"); HTableDescriptor htd = new HTableDescriptor(testTable.getTableName()); - ACCESS_CONTROLLER.preSnapshot(TestAccessController.createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preSnapshot(ObserverContextImpl.createAndPrepare(CP_ENV), snapshot, htd); return null; } @@ -600,7 +600,7 @@ public Object run() throws Exception { @Override public Object run() throws Exception { SnapshotDescription snapshot = new SnapshotDescription("foo"); - ACCESS_CONTROLLER.preListSnapshot(TestAccessController.createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preListSnapshot(ObserverContextImpl.createAndPrepare(CP_ENV), snapshot); return null; } @@ -612,7 +612,7 @@ public Object run() throws Exception { public Object run() throws Exception { SnapshotDescription snapshot = new SnapshotDescription("foo"); HTableDescriptor htd = new HTableDescriptor(testTable.getTableName()); - ACCESS_CONTROLLER.preCloneSnapshot(TestAccessController.createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preCloneSnapshot(ObserverContextImpl.createAndPrepare(CP_ENV), snapshot, htd); return null; } @@ -624,7 +624,7 @@ public Object run() throws Exception { public Object run() throws Exception { SnapshotDescription snapshot = new SnapshotDescription("foo"); HTableDescriptor htd = new HTableDescriptor(testTable.getTableName()); - ACCESS_CONTROLLER.preRestoreSnapshot(TestAccessController.createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preRestoreSnapshot(ObserverContextImpl.createAndPrepare(CP_ENV), snapshot, htd); return null; } @@ -635,7 +635,7 @@ public Object run() throws Exception { @Override public Object run() throws Exception { SnapshotDescription snapshot = new SnapshotDescription("foo"); - ACCESS_CONTROLLER.preDeleteSnapshot(TestAccessController.createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preDeleteSnapshot(ObserverContextImpl.createAndPrepare(CP_ENV), snapshot); return null; } @@ -648,7 +648,7 @@ public Object run() throws Exception { List tableNamesList = Lists.newArrayList(); tableNamesList.add(testTable.getTableName()); List descriptors = Lists.newArrayList(); - ACCESS_CONTROLLER.preGetTableDescriptors(TestAccessController.createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preGetTableDescriptors(ObserverContextImpl.createAndPrepare(CP_ENV), tableNamesList, descriptors, ".+"); return null; } @@ -659,7 +659,7 @@ public Object run() throws Exception { @Override public Object run() throws Exception { List descriptors = Lists.newArrayList(); - ACCESS_CONTROLLER.preGetTableNames(TestAccessController.createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preGetTableNames(ObserverContextImpl.createAndPrepare(CP_ENV), descriptors, ".+"); return null; } @@ -670,7 +670,7 @@ public Object run() throws Exception { @Override public Object run() throws Exception { NamespaceDescriptor ns = NamespaceDescriptor.create("test").build(); - ACCESS_CONTROLLER.preCreateNamespace(TestAccessController.createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preCreateNamespace(ObserverContextImpl.createAndPrepare(CP_ENV), ns); return null; } @@ -680,7 +680,7 @@ public Object run() throws Exception { verifyAllowed(new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preDeleteNamespace(TestAccessController.createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preDeleteNamespace(ObserverContextImpl.createAndPrepare(CP_ENV), "test"); return null; } @@ -691,7 +691,7 @@ public Object run() throws Exception { @Override public Object run() throws Exception { NamespaceDescriptor ns = NamespaceDescriptor.create("test").build(); - ACCESS_CONTROLLER.preModifyNamespace(TestAccessController.createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preModifyNamespace(ObserverContextImpl.createAndPrepare(CP_ENV), ns); return null; } @@ -701,7 +701,7 @@ public Object run() throws Exception { verifyAllowed(new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preGetNamespaceDescriptor(TestAccessController.createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preGetNamespaceDescriptor(ObserverContextImpl.createAndPrepare(CP_ENV), "test"); return null; } @@ -712,7 +712,7 @@ public Object run() throws Exception { @Override public Object run() throws Exception { List descriptors = Lists.newArrayList(); - ACCESS_CONTROLLER.preListNamespaceDescriptors(TestAccessController.createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preListNamespaceDescriptors(ObserverContextImpl.createAndPrepare(CP_ENV), descriptors); return null; } @@ -723,7 +723,7 @@ public Object run() throws Exception { @Override public Object run() throws Exception { ACCESS_CONTROLLER.preSplitRegion( - TestAccessController.createAndPrepare(CP_ENV), + ObserverContextImpl.createAndPrepare(CP_ENV), testTable.getTableName(), Bytes.toBytes("ss")); return null; @@ -734,7 +734,7 @@ public Object run() throws Exception { verifyAllowed(new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preSetUserQuota(TestAccessController.createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preSetUserQuota(ObserverContextImpl.createAndPrepare(CP_ENV), "testuser", null); return null; } @@ -744,7 +744,7 @@ public Object run() throws Exception { verifyAllowed(new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preSetTableQuota(TestAccessController.createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preSetTableQuota(ObserverContextImpl.createAndPrepare(CP_ENV), testTable.getTableName(), null); return null; } @@ -754,7 +754,7 @@ public Object run() throws Exception { verifyAllowed(new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preSetNamespaceQuota(TestAccessController.createAndPrepare(CP_ENV), + ACCESS_CONTROLLER.preSetNamespaceQuota(ObserverContextImpl.createAndPrepare(CP_ENV), "test", null); return null; } @@ -769,7 +769,7 @@ public void testPassiveRegionServerOperations() throws Exception { verifyAllowed(new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preStopRegionServer(TestAccessController.createAndPrepare(RSCP_ENV)); + ACCESS_CONTROLLER.preStopRegionServer(ObserverContextImpl.createAndPrepare(RSCP_ENV)); return null; } }, SUPERUSER, USER_ADMIN, USER_RW, USER_RO, USER_OWNER, USER_CREATE, USER_QUAL, USER_NONE); @@ -778,7 +778,7 @@ public Object run() throws Exception { verifyAllowed(new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preRollWALWriterRequest(TestAccessController.createAndPrepare(RSCP_ENV)); + ACCESS_CONTROLLER.preRollWALWriterRequest(ObserverContextImpl.createAndPrepare(RSCP_ENV)); return null; } }, SUPERUSER, USER_ADMIN, USER_RW, USER_RO, USER_OWNER, USER_CREATE, USER_QUAL, USER_NONE); @@ -793,7 +793,7 @@ public void testPassiveRegionOperations() throws Exception { verifyAllowed(new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preOpen(TestAccessController.createAndPrepare(RCP_ENV)); + ACCESS_CONTROLLER.preOpen(ObserverContextImpl.createAndPrepare(RCP_ENV)); return null; } }, SUPERUSER, USER_ADMIN, USER_RW, USER_RO, USER_OWNER, USER_CREATE, USER_QUAL, USER_NONE); @@ -802,7 +802,7 @@ public Object run() throws Exception { verifyAllowed(new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preFlush(TestAccessController.createAndPrepare(RCP_ENV), + ACCESS_CONTROLLER.preFlush(ObserverContextImpl.createAndPrepare(RCP_ENV), FlushLifeCycleTracker.DUMMY); return null; } @@ -813,7 +813,7 @@ public Object run() throws Exception { @Override public Object run() throws Exception { List cells = Lists.newArrayList(); - ACCESS_CONTROLLER.preGetOp(TestAccessController.createAndPrepare(RCP_ENV), + ACCESS_CONTROLLER.preGetOp(ObserverContextImpl.createAndPrepare(RCP_ENV), new Get(TEST_ROW), cells); return null; } @@ -823,7 +823,7 @@ public Object run() throws Exception { verifyAllowed(new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preExists(TestAccessController.createAndPrepare(RCP_ENV), + ACCESS_CONTROLLER.preExists(ObserverContextImpl.createAndPrepare(RCP_ENV), new Get(TEST_ROW), true); return null; } @@ -833,7 +833,7 @@ public Object run() throws Exception { verifyAllowed(new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.prePut(TestAccessController.createAndPrepare(RCP_ENV), + ACCESS_CONTROLLER.prePut(ObserverContextImpl.createAndPrepare(RCP_ENV), new Put(TEST_ROW), new WALEdit(), Durability.USE_DEFAULT); return null; } @@ -843,7 +843,7 @@ public Object run() throws Exception { verifyAllowed(new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preDelete(TestAccessController.createAndPrepare(RCP_ENV), + ACCESS_CONTROLLER.preDelete(ObserverContextImpl.createAndPrepare(RCP_ENV), new Delete(TEST_ROW), new WALEdit(), Durability.USE_DEFAULT); return null; } @@ -853,7 +853,7 @@ public Object run() throws Exception { verifyAllowed(new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preBatchMutate(TestAccessController.createAndPrepare(RCP_ENV), + ACCESS_CONTROLLER.preBatchMutate(ObserverContextImpl.createAndPrepare(RCP_ENV), new MiniBatchOperationInProgress<>(null, null, null, 0, 0, 0)); return null; } @@ -863,7 +863,7 @@ public Object run() throws Exception { verifyAllowed(new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preCheckAndPut(TestAccessController.createAndPrepare(RCP_ENV), + ACCESS_CONTROLLER.preCheckAndPut(ObserverContextImpl.createAndPrepare(RCP_ENV), TEST_ROW, TEST_FAMILY, TEST_Q1, CompareOperator.EQUAL, new BinaryComparator("foo".getBytes()), new Put(TEST_ROW), true); return null; @@ -874,7 +874,7 @@ public Object run() throws Exception { verifyAllowed(new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preCheckAndDelete(TestAccessController.createAndPrepare(RCP_ENV), + ACCESS_CONTROLLER.preCheckAndDelete(ObserverContextImpl.createAndPrepare(RCP_ENV), TEST_ROW, TEST_FAMILY, TEST_Q1, CompareOperator.EQUAL, new BinaryComparator("foo".getBytes()), new Delete(TEST_ROW), true); return null; @@ -885,7 +885,7 @@ public Object run() throws Exception { verifyAllowed(new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preAppend(TestAccessController.createAndPrepare(RCP_ENV), + ACCESS_CONTROLLER.preAppend(ObserverContextImpl.createAndPrepare(RCP_ENV), new Append(TEST_ROW)); return null; } @@ -895,7 +895,7 @@ public Object run() throws Exception { verifyAllowed(new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preIncrement(TestAccessController.createAndPrepare(RCP_ENV), + ACCESS_CONTROLLER.preIncrement(ObserverContextImpl.createAndPrepare(RCP_ENV), new Increment(TEST_ROW)); return null; } @@ -905,7 +905,7 @@ public Object run() throws Exception { verifyAllowed(new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preScannerOpen(TestAccessController.createAndPrepare(RCP_ENV), + ACCESS_CONTROLLER.preScannerOpen(ObserverContextImpl.createAndPrepare(RCP_ENV), new Scan()); return null; } @@ -916,7 +916,7 @@ public Object run() throws Exception { @Override public Object run() throws Exception { List> paths = Lists.newArrayList(); - ACCESS_CONTROLLER.preBulkLoadHFile(TestAccessController.createAndPrepare(RCP_ENV), + ACCESS_CONTROLLER.preBulkLoadHFile(ObserverContextImpl.createAndPrepare(RCP_ENV), paths); return null; } diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestSortedList.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestSortedList.java similarity index 100% rename from hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestSortedList.java rename to hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestSortedList.java diff --git a/pom.xml b/pom.xml index 465cdb2535e2..92cb517d872a 100755 --- a/pom.xml +++ b/pom.xml @@ -92,7 +92,6 @@ hbase-hbtop hbase-asyncfs hbase-logging - hbase-coprocessor scm:git:git://gitbox.apache.org/repos/asf/hbase.git @@ -1628,18 +1627,6 @@ test-jar test - - org.apache.hbase - hbase-coprocessor - ${project.version} - - - org.apache.hbase - hbase-coprocessor - ${project.version} - test-jar - test - org.apache.hbase hbase-protocol-shaded