HBASE-25713 Make an hbase-wal module

First extract an hbase-coprocessor module used by hbase-client, hbase-server.
This is prerequisite to extracting an hbase-wal module.

M hbase-common/src/main/java/org/apache/hadoop/hbase/Abortable.java
M hbase-common/src/main/java/org/apache/hadoop/hbase/DoNotRetryIOException.java
M hbase-common/src/main/java/org/apache/hadoop/hbase/util/SortedList.java
 Move to hbase-common. Its a generic Interface. Need by

M hbase-coprocessor/src/main/java/org/apache/hadoop/hbase/Coprocessor.java
M hbase-coprocessor/src/main/java/org/apache/hadoop/hbase/CoprocessorEnvironment.java
M hbase-coprocessor/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseEnvironment.java
M hbase-coprocessor/src/main/java/org/apache/hadoop/hbase/coprocessor/CoprocessorHost.java
M hbase-coprocessor/src/main/java/org/apache/hadoop/hbase/coprocessor/CoreCoprocessor.java
M hbase-coprocessor/src/main/java/org/apache/hadoop/hbase/coprocessor/ObserverContext.java
M hbase-coprocessor/src/main/java/org/apache/hadoop/hbase/coprocessor/ObserverContextImpl.java
M hbase-coprocessor/src/main/java/org/apache/hadoop/hbase/coprocessor/ReadOnlyConfiguration.java
 Move to hbase-coprocessor.

M hbase-endpoint/src/main/java/org/apache/hadoop/hbase/client/coprocessor/BigDecimalColumnInterpreter.java
M hbase-client/src/main/java/org/apache/hadoop/hbase/client/coprocessor/DoubleColumnInterpreter.java
M hbase-endpoint/src/main/java/org/apache/hadoop/hbase/client/coprocessor/LongColumnInterpreter.java
M hbase-endpoint/src/main/java/org/apache/hadoop/hbase/coprocessor/ColumnInterpreter.java
 Moved to hbase-endpoint where they are used.
M hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionCoprocessorHost.java
 Include region name when toString'd.
M hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALCoprocessorHost.java
 Include WAL name when toString'd.
M hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java
 Add utility used in testing here from CoprocessorHost.
This commit is contained in:
stack 2021-03-29 21:11:29 -07:00
parent 1d3ea38f1e
commit e58f1b24a6
29 changed files with 328 additions and 244 deletions

View File

@ -72,6 +72,10 @@
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-coprocessor</artifactId>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-common</artifactId>

View File

@ -1,6 +1,5 @@
/**
*
* 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
@ -23,10 +22,8 @@ import org.apache.yetus.audience.InterfaceAudience;
/**
* Interface to support the aborting of a given server or client.
* <p>
* This is used primarily for ZooKeeper usage when we could get an unexpected
* and fatal exception, requiring an abort.
* <p>
* Implemented by the Master, RegionServer, and TableServers (client).
* This is used primarily when we could get an unexpected and fatal exception; abort is called to
* exit the hosting process.
*/
@InterfaceAudience.Private
public interface Abortable {

View File

@ -1,5 +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
@ -21,8 +20,7 @@ package org.apache.hadoop.hbase;
import org.apache.yetus.audience.InterfaceAudience;
/**
* Subclass if exception is not meant to be retried: e.g.
* {@link org.apache.hadoop.hbase.UnknownScannerException}
* Subclass if exception is not meant to be retried.
*/
@InterfaceAudience.Public
public class DoNotRetryIOException extends HBaseIOException {

102
hbase-coprocessor/pom.xml Normal file
View File

@ -0,0 +1,102 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<!--
/**
* 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
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>hbase-build-configuration</artifactId>
<groupId>org.apache.hbase</groupId>
<version>2.5.0-SNAPSHOT</version>
<relativePath>../hbase-build-configuration</relativePath>
</parent>
<artifactId>hbase-coprocessor</artifactId>
<name>Apache HBase - Coprocessor</name>
<description>Base Coprocessor Types</description>
<build>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<includes>
<include>log4j.properties</include>
</includes>
</testResource>
</testResources>
<plugins>
<plugin>
<!--Make it so assembly:single does nothing in here -->
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<skipAssembly>true</skipAssembly>
</configuration>
</plugin>
<!-- Make a jar and put the sources in the jar -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<plugin>
<groupId>net.revelc.code</groupId>
<artifactId>warbucks-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-annotations</artifactId>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-common</artifactId>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-common</artifactId>
<type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -18,11 +18,9 @@
*/
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;
@ -97,8 +95,8 @@ public interface Coprocessor {
/**
* Coprocessor endpoints providing protobuf services should override this method.
* @return Iterable of {@link Service}s or empty collection. Implementations should never
* return null.
* @return Iterable of {@link Service}s or empty collection; implementations should not return
* null.
*/
default Iterable<Service> getServices() {
return Collections.EMPTY_SET;

View File

@ -1,5 +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
@ -19,6 +18,7 @@
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,8 +27,6 @@ import org.apache.yetus.audience.InterfaceAudience;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
/**
* Encapsulation of the environment of each coprocessor
*/
@ -37,21 +35,21 @@ public class BaseEnvironment<C extends Coprocessor> implements CoprocessorEnviro
private static final Logger LOG = LoggerFactory.getLogger(BaseEnvironment.class);
/** The coprocessor */
public C impl;
protected final C impl;
/** Chaining priority */
protected int priority = Coprocessor.PRIORITY_USER;
/** Current coprocessor state */
Coprocessor.State state = Coprocessor.State.UNINSTALLED;
private int seq;
private Configuration conf;
private ClassLoader classLoader;
private final int seq;
private final Configuration conf;
private final ClassLoader classLoader;
/**
* Constructor
* @param impl the coprocessor instance
* @param priority chaining priority
*/
public BaseEnvironment(final C impl, final int priority, final int seq, final Configuration conf) {
public BaseEnvironment(C impl, final int priority, int seq, Configuration conf) {
this.impl = impl;
this.classLoader = impl.getClass().getClassLoader();
this.priority = priority;

View File

@ -31,10 +31,6 @@ import java.util.UUID;
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;
@ -42,17 +38,18 @@ import org.apache.hadoop.hbase.Coprocessor;
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 <C> type of specific coprocessor this host will handle
* @param <E> type of specific coprocessor environment this host requires.
* provides
*/
@InterfaceAudience.Private
public abstract class CoprocessorHost<C extends Coprocessor, E extends CoprocessorEnvironment<C>> {
@ -100,8 +97,7 @@ public abstract class CoprocessorHost<C extends Coprocessor, E extends Coprocess
* the intention is to preserve a history of all loaded coprocessors for
* diagnosis in case of server crash (HBASE-4014).
*/
private static Set<String> coprocessorNames =
Collections.synchronizedSet(new HashSet<String>());
private static final Set<String> coprocessorNames = Collections.synchronizedSet(new HashSet<>());
public static Set<String> getLoadedCoprocessors() {
synchronized (coprocessorNames) {
@ -139,8 +135,9 @@ public abstract class CoprocessorHost<C extends Coprocessor, E extends Coprocess
// 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) {
@ -454,15 +451,8 @@ public abstract class CoprocessorHost<C extends Coprocessor, E extends Coprocess
// server is configured to abort.
abortServer(env, e);
} else {
// 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);
}
// env will print the Region toString if a RegionCoprocessorEnvironment which includes table.
LOG.error("Removing coprocessor '" + env.toString() + "' from " + "environment", e);
coprocEnvironments.remove(env);
try {
shutdown(env);
@ -480,16 +470,13 @@ public abstract class CoprocessorHost<C extends Coprocessor, E extends Coprocess
* Used to limit legacy handling to once per Coprocessor class per classloader.
*/
private static final Set<Class<? extends Coprocessor>> legacyWarning =
new ConcurrentSkipListSet<>(
new Comparator<Class<? extends Coprocessor>>() {
@Override
public int compare(Class<? extends Coprocessor> c1, Class<? extends Coprocessor> c2) {
if (c1.equals(c2)) {
return 0;
}
return c1.getName().compareTo(c2.getName());
}
});
new ConcurrentSkipListSet<>(new Comparator<Class<? extends Coprocessor>>() {
@Override
public int compare(Class<? extends Coprocessor> c1, Class<? extends Coprocessor> c2) {
return c1.equals(c2) ? 0 : c1.getName().compareTo(c2.getName());
}
}
);
/**
* Implementations defined function to get an observer of type {@code O} from a coprocessor of
@ -518,7 +505,8 @@ public abstract class CoprocessorHost<C extends Coprocessor, E extends Coprocess
}
ObserverOperation(ObserverGetter<C, O> observerGetter, User user, boolean bypassable) {
super(user != null? user: RpcServer.getRequestUser().orElse(null), bypassable);
// Used to get user from RpcServer if null -- removed.
super(user, bypassable);
this.observerGetter = observerGetter;
}
@ -546,7 +534,7 @@ public abstract class CoprocessorHost<C extends Coprocessor, E extends Coprocess
}
/**
* In case of coprocessors which have many kinds of observers (for eg, {@link RegionCoprocessor}
* In case of coprocessors which have many kinds of observers (e.g. 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.
@ -614,7 +602,7 @@ public abstract class CoprocessorHost<C extends Coprocessor, E extends Coprocess
/**
* @return True if we are to bypass (Can only be <code>true</code> if
* ObserverOperation#isBypassable().
* ObserverOperation#isBypassable()).
*/
protected <O> boolean execOperation(final ObserverOperation<O> observerOperation)
throws IOException {
@ -657,11 +645,12 @@ public abstract class CoprocessorHost<C extends Coprocessor, E extends Coprocess
* master/regionserver stop or cluster shutdown. (Refer:
* <a href="https://issues.apache.org/jira/browse/HBASE-16663">HBASE-16663</a>
* @return true if bypaas coprocessor execution, false if not.
* @throws IOException
*/
protected <O> boolean execShutdown(final ObserverOperation<O> observerOperation)
throws IOException {
if (observerOperation == null) return false;
if (observerOperation == null) {
return false;
}
boolean bypass = false;
List<E> envs = coprocEnvironments.get();
// Iterate the coprocessors and execute ObserverOperation's call()

View File

@ -1,5 +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
@ -19,7 +18,6 @@
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;

View File

@ -17,20 +17,18 @@
*/
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
* ({@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
* <code>CoprocessorEnvironment</code> reference set appropriately for each Coprocessor type:
* 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 <code>CoprocessorEnvironment</code> reference set appropriately for each
* Coprocessor type:
* e.g. the RegionCoprocessorEnvironment is passed to RegionCoprocessors, and so on.
* @param <E> The {@link CoprocessorEnvironment} subclass applicable to the
* revelant Observer interface.
@ -69,7 +67,6 @@ public interface ObserverContext<E extends CoprocessorEnvironment> {
*/
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

View File

@ -19,7 +19,6 @@ package org.apache.hadoop.hbase.coprocessor;
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;
@ -42,6 +41,9 @@ public class ObserverContextImpl<E extends CoprocessorEnvironment> implements Ob
}
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;
}
@ -87,19 +89,5 @@ public class ObserverContextImpl<E extends CoprocessorEnvironment> implements Ob
return Optional.ofNullable(caller);
}
/**
* Instantiates a new ObserverContext instance if the passed reference is <code>null</code> and
* sets the environment in the new or existing instance. This allows deferring the instantiation
* of a ObserverContext until it is actually needed.
* @param <E> The environment type for the context
* @param env The coprocessor environment to set
* @return An instance of <code>ObserverContext</code> with the environment set
*/
@Deprecated
// TODO: Remove this method, ObserverContext should not depend on RpcServer
public static <E extends CoprocessorEnvironment> ObserverContext<E> createAndPrepare(E env) {
ObserverContextImpl<E> ctx = new ObserverContextImpl<>(RpcServer.getRequestUser().orElse(null));
ctx.prepare(env);
return ctx;
}
}

View File

@ -34,7 +34,6 @@ import java.util.Map;
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;

View File

@ -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,25 +22,20 @@ import org.apache.hadoop.hbase.HBaseClassTestRule;
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
@Test (expected = UnsupportedOperationException.class)
public void testAddDefaultResource() {
Configuration configuration = new Configuration();
Configuration readOnlyConf = new ReadOnlyConfiguration(configuration);
configuration.addDefaultResource("abc.xml");
readOnlyConf.addDefaultResource("abc.xml");
readOnlyConf.setInt("any.old.config", 1);
}
}

View File

@ -256,6 +256,10 @@
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-common</artifactId>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-coprocessor</artifactId>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-http</artifactId>

View File

@ -1,5 +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
@ -26,8 +25,6 @@ import org.apache.yetus.audience.InterfaceAudience;
*/
@InterfaceAudience.Public
public class CoprocessorException extends DoNotRetryIOException {
private static final long serialVersionUID = 4357922136679804887L;
/** Default Constructor */
public CoprocessorException() {
super();
@ -35,19 +32,15 @@ public class CoprocessorException extends DoNotRetryIOException {
/**
* 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);
}
}

View File

@ -21,7 +21,6 @@ package org.apache.hadoop.hbase.coprocessor;
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;

View File

@ -1689,4 +1689,9 @@ public class RegionCoprocessorHost
}
});
}
@Override
public String toString() {
return "RegionCoprocessorHost{region=" + region + "} " + super.toString();
}
}

View File

@ -90,6 +90,10 @@ public class WALCoprocessorHost
super.shutdown();
MetricsCoprocessor.removeRegistry(this.metricRegistry);
}
@Override public String toString() {
return "WALEnvironment{wal=" + wal + '}';
}
}
private final WAL wal;

View File

@ -24,7 +24,6 @@ import static org.junit.Assert.assertFalse;
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;
@ -39,7 +38,6 @@ import java.util.Collections;
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;
@ -81,9 +79,9 @@ import org.apache.hadoop.hbase.client.SnapshotDescription;
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;
@ -104,6 +102,7 @@ import org.apache.hadoop.hbase.io.hfile.CacheConfig;
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;
@ -445,7 +444,7 @@ public class TestAccessController extends SecureTestUtil {
public Object run() throws Exception {
HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(name.getMethodName()));
htd.addFamily(new HColumnDescriptor(TEST_FAMILY));
ACCESS_CONTROLLER.preCreateTable(ObserverContextImpl.createAndPrepare(CP_ENV), htd, null);
ACCESS_CONTROLLER.preCreateTable(createAndPrepare(CP_ENV), htd, null);
return null;
}
};
@ -466,8 +465,7 @@ public class TestAccessController extends SecureTestUtil {
HTableDescriptor htd = new HTableDescriptor(TEST_TABLE);
htd.addFamily(new HColumnDescriptor(TEST_FAMILY));
htd.addFamily(new HColumnDescriptor("fam_" + User.getCurrent().getShortName()));
ACCESS_CONTROLLER.preModifyTable(ObserverContextImpl.createAndPrepare(CP_ENV), TEST_TABLE,
null, htd);
ACCESS_CONTROLLER.preModifyTable(createAndPrepare(CP_ENV), TEST_TABLE, null, htd);
return null;
}
};
@ -483,7 +481,7 @@ public class TestAccessController extends SecureTestUtil {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER
.preDeleteTable(ObserverContextImpl.createAndPrepare(CP_ENV), TEST_TABLE);
.preDeleteTable(createAndPrepare(CP_ENV), TEST_TABLE);
return null;
}
};
@ -498,9 +496,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction truncateTable = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER
.preTruncateTable(ObserverContextImpl.createAndPrepare(CP_ENV),
TEST_TABLE);
ACCESS_CONTROLLER.preTruncateTable(createAndPrepare(CP_ENV), TEST_TABLE);
return null;
}
};
@ -515,8 +511,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction disableTable = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preDisableTable(ObserverContextImpl.createAndPrepare(CP_ENV),
TEST_TABLE);
ACCESS_CONTROLLER.preDisableTable(createAndPrepare(CP_ENV), TEST_TABLE);
return null;
}
};
@ -524,7 +519,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction disableAclTable = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preDisableTable(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preDisableTable(createAndPrepare(CP_ENV),
PermissionStorage.ACL_TABLE_NAME);
return null;
}
@ -544,8 +539,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction enableTable = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER
.preEnableTable(ObserverContextImpl.createAndPrepare(CP_ENV), TEST_TABLE);
ACCESS_CONTROLLER.preEnableTable(createAndPrepare(CP_ENV), TEST_TABLE);
return null;
}
};
@ -620,8 +614,8 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction abortProcedureAction = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preAbortProcedure(ObserverContextImpl.createAndPrepare(CP_ENV), procId);
return null;
ACCESS_CONTROLLER.preAbortProcedure(createAndPrepare(CP_ENV), procId);
return null;
}
};
@ -641,8 +635,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction getProceduresAction = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER
.postGetProcedures(ObserverContextImpl.createAndPrepare(CP_ENV));
ACCESS_CONTROLLER.postGetProcedures(createAndPrepare(CP_ENV));
return null;
}
};
@ -658,7 +651,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preGetLocks(ObserverContextImpl.createAndPrepare(CP_ENV));
ACCESS_CONTROLLER.preGetLocks(createAndPrepare(CP_ENV));
return null;
}
};
@ -680,8 +673,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preMove(ObserverContextImpl.createAndPrepare(CP_ENV),
hri, server, server);
ACCESS_CONTROLLER.preMove(createAndPrepare(CP_ENV), hri, server, server);
return null;
}
};
@ -702,7 +694,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preAssign(ObserverContextImpl.createAndPrepare(CP_ENV), hri);
ACCESS_CONTROLLER.preAssign(createAndPrepare(CP_ENV), hri);
return null;
}
};
@ -723,7 +715,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preUnassign(ObserverContextImpl.createAndPrepare(CP_ENV), hri);
ACCESS_CONTROLLER.preUnassign(createAndPrepare(CP_ENV), hri);
return null;
}
};
@ -744,7 +736,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preRegionOffline(ObserverContextImpl.createAndPrepare(CP_ENV), hri);
ACCESS_CONTROLLER.preRegionOffline(createAndPrepare(CP_ENV), hri);
return null;
}
};
@ -759,7 +751,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preSetSplitOrMergeEnabled(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preSetSplitOrMergeEnabled(createAndPrepare(CP_ENV),
true, MasterSwitchType.MERGE);
return null;
}
@ -775,7 +767,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preBalance(ObserverContextImpl.createAndPrepare(CP_ENV));
ACCESS_CONTROLLER.preBalance(createAndPrepare(CP_ENV));
return null;
}
};
@ -790,7 +782,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preBalanceSwitch(ObserverContextImpl.createAndPrepare(CP_ENV), true);
ACCESS_CONTROLLER.preBalanceSwitch(createAndPrepare(CP_ENV), true);
return null;
}
};
@ -805,7 +797,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preShutdown(ObserverContextImpl.createAndPrepare(CP_ENV));
ACCESS_CONTROLLER.preShutdown(createAndPrepare(CP_ENV));
return null;
}
};
@ -820,7 +812,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preStopMaster(ObserverContextImpl.createAndPrepare(CP_ENV));
ACCESS_CONTROLLER.preStopMaster(createAndPrepare(CP_ENV));
return null;
}
};
@ -843,10 +835,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preSplitRegion(
ObserverContextImpl.createAndPrepare(CP_ENV),
tableName,
TEST_ROW);
ACCESS_CONTROLLER.preSplitRegion(createAndPrepare(CP_ENV), tableName, TEST_ROW);
return null;
}
};
@ -861,8 +850,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preFlush(ObserverContextImpl.createAndPrepare(RCP_ENV),
FlushLifeCycleTracker.DUMMY);
ACCESS_CONTROLLER.preFlush(createAndPrepare(RCP_ENV), FlushLifeCycleTracker.DUMMY);
return null;
}
};
@ -877,7 +865,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preCompact(ObserverContextImpl.createAndPrepare(RCP_ENV), null, null,
ACCESS_CONTROLLER.preCompact(createAndPrepare(RCP_ENV), null, null,
ScanType.COMPACT_RETAIN_DELETES, null, null);
return null;
}
@ -919,7 +907,7 @@ public class TestAccessController extends SecureTestUtil {
// action for scanning
AccessTestAction scanAction = new AccessTestAction() {
@Override
@SuppressWarnings("checkstyle:EmptyStatement") @Override
public Object run() throws Exception {
Scan s = new Scan();
s.addFamily(TEST_FAMILY);
@ -928,7 +916,7 @@ public class TestAccessController extends SecureTestUtil {
ResultScanner scanner = table.getScanner(s);
try {
for (Result r = scanner.next(); r != null; r = scanner.next()) {
// do nothing
; // do nothing
}
} finally {
scanner.close();
@ -1261,7 +1249,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction preGrantAction = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preGrant(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preGrant(createAndPrepare(CP_ENV),
new UserPermission(USER_RO.getShortName(), Permission.newBuilder(TEST_TABLE)
.withFamily(TEST_FAMILY).withActions(Action.READ).build()),
false);
@ -1272,7 +1260,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction preRevokeAction = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preRevoke(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preRevoke(createAndPrepare(CP_ENV),
new UserPermission(USER_RO.getShortName(), Permission.newBuilder(TEST_TABLE)
.withFamily(TEST_FAMILY).withActions(Action.READ).build()));
return null;
@ -1593,11 +1581,12 @@ public class TestAccessController extends SecureTestUtil {
}
private boolean hasFoundUserPermission(List<UserPermission> userPermissions,
List<UserPermission> perms) {
List<UserPermission> perms) {
return perms.containsAll(userPermissions);
}
private boolean hasFoundUserPermission(UserPermission userPermission, List<UserPermission> perms) {
private boolean hasFoundUserPermission(UserPermission userPermission,
List<UserPermission> perms) {
return perms.contains(userPermission);
}
@ -1991,7 +1980,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preStopRegionServer(ObserverContextImpl.createAndPrepare(RSCP_ENV));
ACCESS_CONTROLLER.preStopRegionServer(createAndPrepare(RSCP_ENV));
return null;
}
};
@ -2006,7 +1995,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preRollWALWriterRequest(ObserverContextImpl.createAndPrepare(RSCP_ENV));
ACCESS_CONTROLLER.preRollWALWriterRequest(createAndPrepare(RSCP_ENV));
return null;
}
};
@ -2021,7 +2010,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preOpen(ObserverContextImpl.createAndPrepare(RCP_ENV));
ACCESS_CONTROLLER.preOpen(createAndPrepare(RCP_ENV));
return null;
}
};
@ -2036,7 +2025,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preClose(ObserverContextImpl.createAndPrepare(RCP_ENV), false);
ACCESS_CONTROLLER.preClose(createAndPrepare(RCP_ENV), false);
return null;
}
};
@ -2055,7 +2044,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction snapshotAction = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preSnapshot(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preSnapshot(createAndPrepare(CP_ENV),
snapshot, htd);
return null;
}
@ -2064,7 +2053,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction deleteAction = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preDeleteSnapshot(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preDeleteSnapshot(createAndPrepare(CP_ENV),
snapshot);
return null;
}
@ -2073,7 +2062,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction restoreAction = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preRestoreSnapshot(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preRestoreSnapshot(createAndPrepare(CP_ENV),
snapshot, htd);
return null;
}
@ -2082,7 +2071,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction cloneAction = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preCloneSnapshot(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preCloneSnapshot(createAndPrepare(CP_ENV),
snapshot, null);
return null;
}
@ -2115,7 +2104,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction snapshotAction = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preSnapshot(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preSnapshot(createAndPrepare(CP_ENV),
snapshot, htd);
return null;
}
@ -2127,7 +2116,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction deleteAction = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preDeleteSnapshot(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preDeleteSnapshot(createAndPrepare(CP_ENV),
snapshot);
return null;
}
@ -2139,7 +2128,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction restoreAction = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preRestoreSnapshot(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preRestoreSnapshot(createAndPrepare(CP_ENV),
snapshot, htd);
return null;
}
@ -2151,7 +2140,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction cloneAction = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preCloneSnapshot(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preCloneSnapshot(createAndPrepare(CP_ENV),
snapshot, htd);
return null;
}
@ -2296,7 +2285,8 @@ public class TestAccessController extends SecureTestUtil {
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
@ -2524,8 +2514,8 @@ public class TestAccessController extends SecureTestUtil {
// 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);
}
@ -2710,7 +2700,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction setUserQuotaAction = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preSetUserQuota(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preSetUserQuota(createAndPrepare(CP_ENV),
null, null);
return null;
}
@ -2719,7 +2709,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction setUserTableQuotaAction = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preSetUserQuota(ObserverContextImpl.createAndPrepare(CP_ENV), null,
ACCESS_CONTROLLER.preSetUserQuota(createAndPrepare(CP_ENV), null,
TEST_TABLE, null);
return null;
}
@ -2728,7 +2718,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction setUserNamespaceQuotaAction = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preSetUserQuota(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preSetUserQuota(createAndPrepare(CP_ENV),
null, (String)null, null);
return null;
}
@ -2737,7 +2727,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction setTableQuotaAction = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preSetTableQuota(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preSetTableQuota(createAndPrepare(CP_ENV),
TEST_TABLE, null);
return null;
}
@ -2746,7 +2736,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction setNamespaceQuotaAction = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preSetNamespaceQuota(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preSetNamespaceQuota(createAndPrepare(CP_ENV),
null, null);
return null;
}
@ -2755,7 +2745,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction setRegionServerQuotaAction = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preSetRegionServerQuota(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preSetRegionServerQuota(createAndPrepare(CP_ENV),
null, null);
return null;
}
@ -2807,7 +2797,8 @@ public class TestAccessController extends SecureTestUtil {
/**
* 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
@ -2944,14 +2935,14 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction prepareBulkLoadAction = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.prePrepareBulkLoad(ObserverContextImpl.createAndPrepare(RCP_ENV));
ACCESS_CONTROLLER.prePrepareBulkLoad(createAndPrepare(RCP_ENV));
return null;
}
};
AccessTestAction cleanupBulkLoadAction = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preCleanupBulkLoad(ObserverContextImpl.createAndPrepare(RCP_ENV));
ACCESS_CONTROLLER.preCleanupBulkLoad(createAndPrepare(RCP_ENV));
return null;
}
};
@ -2964,8 +2955,8 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction replicateLogEntriesAction = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preReplicateLogEntries(ObserverContextImpl.createAndPrepare(RSCP_ENV));
ACCESS_CONTROLLER.postReplicateLogEntries(ObserverContextImpl.createAndPrepare(RSCP_ENV));
ACCESS_CONTROLLER.preReplicateLogEntries(createAndPrepare(RSCP_ENV));
ACCESS_CONTROLLER.postReplicateLogEntries(createAndPrepare(RSCP_ENV));
return null;
}
};
@ -2980,7 +2971,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preAddReplicationPeer(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preAddReplicationPeer(createAndPrepare(CP_ENV),
"test", null);
return null;
}
@ -2995,7 +2986,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preRemoveReplicationPeer(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preRemoveReplicationPeer(createAndPrepare(CP_ENV),
"test");
return null;
}
@ -3010,7 +3001,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preEnableReplicationPeer(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preEnableReplicationPeer(createAndPrepare(CP_ENV),
"test");
return null;
}
@ -3025,7 +3016,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preDisableReplicationPeer(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preDisableReplicationPeer(createAndPrepare(CP_ENV),
"test");
return null;
}
@ -3041,7 +3032,7 @@ public class TestAccessController extends SecureTestUtil {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preGetReplicationPeerConfig(
ObserverContextImpl.createAndPrepare(CP_ENV), "test");
createAndPrepare(CP_ENV), "test");
return null;
}
};
@ -3056,7 +3047,7 @@ public class TestAccessController extends SecureTestUtil {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preUpdateReplicationPeerConfig(
ObserverContextImpl.createAndPrepare(CP_ENV), "test", new ReplicationPeerConfig());
createAndPrepare(CP_ENV), "test", new ReplicationPeerConfig());
return null;
}
};
@ -3070,7 +3061,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preListReplicationPeers(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preListReplicationPeers(createAndPrepare(CP_ENV),
"test");
return null;
}
@ -3101,7 +3092,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction namespaceLockAction = new AccessTestAction() {
@Override public Object run() throws Exception {
ACCESS_CONTROLLER.preRequestLock(ObserverContextImpl.createAndPrepare(CP_ENV), namespace,
ACCESS_CONTROLLER.preRequestLock(createAndPrepare(CP_ENV), namespace,
null, null, null);
return null;
}
@ -3115,7 +3106,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction tableLockAction = new AccessTestAction() {
@Override public Object run() throws Exception {
ACCESS_CONTROLLER.preRequestLock(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preRequestLock(createAndPrepare(CP_ENV),
null, tableName, null, null);
return null;
}
@ -3137,7 +3128,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction regionsLockAction = new AccessTestAction() {
@Override public Object run() throws Exception {
ACCESS_CONTROLLER.preRequestLock(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preRequestLock(createAndPrepare(CP_ENV),
null, null, regionInfos, null);
return null;
}
@ -3151,7 +3142,7 @@ public class TestAccessController extends SecureTestUtil {
LockProcedure proc = new LockProcedure(conf, tableName, LockType.EXCLUSIVE, "test", null);
AccessTestAction regionLockHeartbeatAction = new AccessTestAction() {
@Override public Object run() throws Exception {
ACCESS_CONTROLLER.preLockHeartbeat(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preLockHeartbeat(createAndPrepare(CP_ENV),
proc.getTableName(), proc.getDescription());
return null;
}
@ -3201,7 +3192,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preGetClusterMetrics(ObserverContextImpl.createAndPrepare(CP_ENV));
ACCESS_CONTROLLER.preGetClusterMetrics(createAndPrepare(CP_ENV));
return null;
}
};
@ -3215,7 +3206,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preExecuteProcedures(ObserverContextImpl.createAndPrepare(RSCP_ENV));
ACCESS_CONTROLLER.preExecuteProcedures(createAndPrepare(RSCP_ENV));
return null;
}
};
@ -3496,7 +3487,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preSwitchRpcThrottle(ObserverContextImpl.createAndPrepare(CP_ENV), true);
ACCESS_CONTROLLER.preSwitchRpcThrottle(createAndPrepare(CP_ENV), true);
return null;
}
};
@ -3509,7 +3500,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preIsRpcThrottleEnabled(ObserverContextImpl.createAndPrepare(CP_ENV));
ACCESS_CONTROLLER.preIsRpcThrottleEnabled(createAndPrepare(CP_ENV));
return null;
}
};
@ -3522,8 +3513,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preSwitchExceedThrottleQuota(ObserverContextImpl.createAndPrepare(CP_ENV),
true);
ACCESS_CONTROLLER.preSwitchExceedThrottleQuota(createAndPrepare(CP_ENV), true);
return null;
}
};
@ -3743,4 +3733,18 @@ public class TestAccessController extends SecureTestUtil {
}
}
}
/**
* Instantiates a new ObserverContext instance if the passed reference is <code>null</code> and
* sets the environment in the new or existing instance. This allows deferring the instantiation
* of a ObserverContext until it is actually needed.
* @param <E> The environment type for the context
* @param env The coprocessor environment to set
* @return An instance of <code>ObserverContext</code> with the environment set
*/
static <E extends CoprocessorEnvironment> ObserverContext<E> createAndPrepare(E env) {
ObserverContextImpl<E> ctx = new ObserverContextImpl<>(RpcServer.getRequestUser().orElse(null));
ctx.prepare(env);
return ctx;
}
}

View File

@ -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,7 +32,6 @@ import org.apache.hadoop.hbase.TableNotFoundException;
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;
@ -44,7 +43,6 @@ import org.apache.hadoop.hbase.security.User;
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;
@ -111,7 +109,7 @@ public class TestAccessController3 extends SecureTestUtil {
// https://hbase.apache.org/book/appendix_acl_matrix.html
// creating all Scope x Permission combinations
private static byte[] TEST_FAMILY = Bytes.toBytes("f1");
private static final byte[] TEST_FAMILY = Bytes.toBytes("f1");
private static MasterCoprocessorEnvironment CP_ENV;
private static AccessController ACCESS_CONTROLLER;
@ -281,7 +279,8 @@ public class TestAccessController3 extends SecureTestUtil {
public Object run() throws Exception {
HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(name.getMethodName()));
htd.addFamily(new HColumnDescriptor(TEST_FAMILY));
ACCESS_CONTROLLER.preCreateTable(ObserverContextImpl.createAndPrepare(CP_ENV), htd, null);
ACCESS_CONTROLLER.preCreateTable(TestAccessController.
createAndPrepare(CP_ENV), htd, null);
return null;
}
};

View File

@ -248,7 +248,7 @@ public class TestNamespaceCommands extends SecureTestUtil {
AccessTestAction modifyNamespace = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preModifyNamespace(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preModifyNamespace(TestAccessController.createAndPrepare(CP_ENV),
NamespaceDescriptor.create(TEST_NAMESPACE).addConfiguration("abc", "156").build());
return null;
}
@ -266,7 +266,7 @@ public class TestNamespaceCommands extends SecureTestUtil {
AccessTestAction createNamespace = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preCreateNamespace(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preCreateNamespace(TestAccessController.createAndPrepare(CP_ENV),
NamespaceDescriptor.create(TEST_NAMESPACE2).build());
return null;
}
@ -275,7 +275,7 @@ public class TestNamespaceCommands extends SecureTestUtil {
AccessTestAction deleteNamespace = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preDeleteNamespace(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preDeleteNamespace(TestAccessController.createAndPrepare(CP_ENV),
TEST_NAMESPACE2);
return null;
}
@ -300,7 +300,7 @@ public class TestNamespaceCommands extends SecureTestUtil {
AccessTestAction getNamespaceAction = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preGetNamespaceDescriptor(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preGetNamespaceDescriptor(TestAccessController.createAndPrepare(CP_ENV),
TEST_NAMESPACE);
return null;
}
@ -422,7 +422,7 @@ public class TestNamespaceCommands extends SecureTestUtil {
AccessTestAction preGrantAction = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preGrant(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preGrant(TestAccessController.createAndPrepare(CP_ENV),
new UserPermission(testUser,
Permission.newBuilder(TEST_NAMESPACE).withActions(Action.WRITE).build()),
false);
@ -432,7 +432,7 @@ public class TestNamespaceCommands extends SecureTestUtil {
AccessTestAction preRevokeAction = new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preRevoke(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preRevoke(TestAccessController.createAndPrepare(CP_ENV),
new UserPermission(testUser,
Permission.newBuilder(TEST_NAMESPACE).withActions(Action.WRITE).build()));
return null;
@ -518,7 +518,7 @@ public class TestNamespaceCommands extends SecureTestUtil {
public Object run() throws Exception {
HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(TEST_TABLE));
htd.addFamily(new HColumnDescriptor(TEST_FAMILY));
ACCESS_CONTROLLER.preCreateTable(ObserverContextImpl.createAndPrepare(CP_ENV), htd, null);
ACCESS_CONTROLLER.preCreateTable(TestAccessController.createAndPrepare(CP_ENV), htd, null);
return null;
}
};

View File

@ -472,7 +472,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
public Object run() throws Exception {
HTableDescriptor htd = new HTableDescriptor(testTable.getTableName());
htd.addFamily(new HColumnDescriptor(TEST_FAMILY));
ACCESS_CONTROLLER.preCreateTable(ObserverContextImpl.createAndPrepare(CP_ENV), htd,
ACCESS_CONTROLLER.preCreateTable(TestAccessController.createAndPrepare(CP_ENV), htd,
null);
return null;
}
@ -485,7 +485,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
HTableDescriptor htd = new HTableDescriptor(testTable.getTableName());
htd.addFamily(new HColumnDescriptor(TEST_FAMILY));
htd.addFamily(new HColumnDescriptor(TEST_FAMILY2));
ACCESS_CONTROLLER.preModifyTable(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preModifyTable(TestAccessController.createAndPrepare(CP_ENV),
testTable.getTableName(), htd);
return null;
}
@ -495,7 +495,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preDeleteTable(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preDeleteTable(TestAccessController.createAndPrepare(CP_ENV),
testTable.getTableName());
return null;
}
@ -505,7 +505,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preTruncateTable(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preTruncateTable(TestAccessController.createAndPrepare(CP_ENV),
testTable.getTableName());
return null;
}
@ -515,7 +515,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preEnableTable(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preEnableTable(TestAccessController.createAndPrepare(CP_ENV),
testTable.getTableName());
return null;
}
@ -525,7 +525,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preDisableTable(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preDisableTable(TestAccessController.createAndPrepare(CP_ENV),
testTable.getTableName());
return null;
}
@ -538,7 +538,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
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(ObserverContextImpl.createAndPrepare(CP_ENV), region,
ACCESS_CONTROLLER.preMove(TestAccessController.createAndPrepare(CP_ENV), region,
srcServer, destServer);
return null;
}
@ -549,7 +549,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
@Override
public Object run() throws Exception {
HRegionInfo region = new HRegionInfo(testTable.getTableName());
ACCESS_CONTROLLER.preAssign(ObserverContextImpl.createAndPrepare(CP_ENV), region);
ACCESS_CONTROLLER.preAssign(TestAccessController.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 class TestWithDisabledAuthorization extends SecureTestUtil {
@Override
public Object run() throws Exception {
HRegionInfo region = new HRegionInfo(testTable.getTableName());
ACCESS_CONTROLLER.preUnassign(ObserverContextImpl.createAndPrepare(CP_ENV), region);
ACCESS_CONTROLLER.preUnassign(TestAccessController.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 class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preBalance(ObserverContextImpl.createAndPrepare(CP_ENV));
ACCESS_CONTROLLER.preBalance(TestAccessController.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 class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preBalanceSwitch(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preBalanceSwitch(TestAccessController.createAndPrepare(CP_ENV),
true);
return null;
}
@ -589,7 +589,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
public Object run() throws Exception {
SnapshotDescription snapshot = new SnapshotDescription("foo");
HTableDescriptor htd = new HTableDescriptor(testTable.getTableName());
ACCESS_CONTROLLER.preSnapshot(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preSnapshot(TestAccessController.createAndPrepare(CP_ENV),
snapshot, htd);
return null;
}
@ -600,7 +600,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
@Override
public Object run() throws Exception {
SnapshotDescription snapshot = new SnapshotDescription("foo");
ACCESS_CONTROLLER.preListSnapshot(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preListSnapshot(TestAccessController.createAndPrepare(CP_ENV),
snapshot);
return null;
}
@ -612,7 +612,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
public Object run() throws Exception {
SnapshotDescription snapshot = new SnapshotDescription("foo");
HTableDescriptor htd = new HTableDescriptor(testTable.getTableName());
ACCESS_CONTROLLER.preCloneSnapshot(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preCloneSnapshot(TestAccessController.createAndPrepare(CP_ENV),
snapshot, htd);
return null;
}
@ -624,7 +624,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
public Object run() throws Exception {
SnapshotDescription snapshot = new SnapshotDescription("foo");
HTableDescriptor htd = new HTableDescriptor(testTable.getTableName());
ACCESS_CONTROLLER.preRestoreSnapshot(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preRestoreSnapshot(TestAccessController.createAndPrepare(CP_ENV),
snapshot, htd);
return null;
}
@ -635,7 +635,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
@Override
public Object run() throws Exception {
SnapshotDescription snapshot = new SnapshotDescription("foo");
ACCESS_CONTROLLER.preDeleteSnapshot(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preDeleteSnapshot(TestAccessController.createAndPrepare(CP_ENV),
snapshot);
return null;
}
@ -648,7 +648,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
List<TableName> tableNamesList = Lists.newArrayList();
tableNamesList.add(testTable.getTableName());
List<TableDescriptor> descriptors = Lists.newArrayList();
ACCESS_CONTROLLER.preGetTableDescriptors(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preGetTableDescriptors(TestAccessController.createAndPrepare(CP_ENV),
tableNamesList, descriptors, ".+");
return null;
}
@ -659,7 +659,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
@Override
public Object run() throws Exception {
List<TableDescriptor> descriptors = Lists.newArrayList();
ACCESS_CONTROLLER.preGetTableNames(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preGetTableNames(TestAccessController.createAndPrepare(CP_ENV),
descriptors, ".+");
return null;
}
@ -670,7 +670,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
@Override
public Object run() throws Exception {
NamespaceDescriptor ns = NamespaceDescriptor.create("test").build();
ACCESS_CONTROLLER.preCreateNamespace(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preCreateNamespace(TestAccessController.createAndPrepare(CP_ENV),
ns);
return null;
}
@ -680,7 +680,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preDeleteNamespace(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preDeleteNamespace(TestAccessController.createAndPrepare(CP_ENV),
"test");
return null;
}
@ -691,7 +691,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
@Override
public Object run() throws Exception {
NamespaceDescriptor ns = NamespaceDescriptor.create("test").build();
ACCESS_CONTROLLER.preModifyNamespace(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preModifyNamespace(TestAccessController.createAndPrepare(CP_ENV),
ns);
return null;
}
@ -701,7 +701,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preGetNamespaceDescriptor(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preGetNamespaceDescriptor(TestAccessController.createAndPrepare(CP_ENV),
"test");
return null;
}
@ -712,7 +712,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
@Override
public Object run() throws Exception {
List<NamespaceDescriptor> descriptors = Lists.newArrayList();
ACCESS_CONTROLLER.preListNamespaceDescriptors(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preListNamespaceDescriptors(TestAccessController.createAndPrepare(CP_ENV),
descriptors);
return null;
}
@ -723,7 +723,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preSplitRegion(
ObserverContextImpl.createAndPrepare(CP_ENV),
TestAccessController.createAndPrepare(CP_ENV),
testTable.getTableName(),
Bytes.toBytes("ss"));
return null;
@ -734,7 +734,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preSetUserQuota(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preSetUserQuota(TestAccessController.createAndPrepare(CP_ENV),
"testuser", null);
return null;
}
@ -744,7 +744,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preSetTableQuota(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preSetTableQuota(TestAccessController.createAndPrepare(CP_ENV),
testTable.getTableName(), null);
return null;
}
@ -754,7 +754,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preSetNamespaceQuota(ObserverContextImpl.createAndPrepare(CP_ENV),
ACCESS_CONTROLLER.preSetNamespaceQuota(TestAccessController.createAndPrepare(CP_ENV),
"test", null);
return null;
}
@ -769,7 +769,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preStopRegionServer(ObserverContextImpl.createAndPrepare(RSCP_ENV));
ACCESS_CONTROLLER.preStopRegionServer(TestAccessController.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 class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preRollWALWriterRequest(ObserverContextImpl.createAndPrepare(RSCP_ENV));
ACCESS_CONTROLLER.preRollWALWriterRequest(TestAccessController.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 class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preOpen(ObserverContextImpl.createAndPrepare(RCP_ENV));
ACCESS_CONTROLLER.preOpen(TestAccessController.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 class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preFlush(ObserverContextImpl.createAndPrepare(RCP_ENV),
ACCESS_CONTROLLER.preFlush(TestAccessController.createAndPrepare(RCP_ENV),
FlushLifeCycleTracker.DUMMY);
return null;
}
@ -813,7 +813,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
@Override
public Object run() throws Exception {
List<Cell> cells = Lists.newArrayList();
ACCESS_CONTROLLER.preGetOp(ObserverContextImpl.createAndPrepare(RCP_ENV),
ACCESS_CONTROLLER.preGetOp(TestAccessController.createAndPrepare(RCP_ENV),
new Get(TEST_ROW), cells);
return null;
}
@ -823,7 +823,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preExists(ObserverContextImpl.createAndPrepare(RCP_ENV),
ACCESS_CONTROLLER.preExists(TestAccessController.createAndPrepare(RCP_ENV),
new Get(TEST_ROW), true);
return null;
}
@ -833,7 +833,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.prePut(ObserverContextImpl.createAndPrepare(RCP_ENV),
ACCESS_CONTROLLER.prePut(TestAccessController.createAndPrepare(RCP_ENV),
new Put(TEST_ROW), new WALEdit(), Durability.USE_DEFAULT);
return null;
}
@ -843,7 +843,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preDelete(ObserverContextImpl.createAndPrepare(RCP_ENV),
ACCESS_CONTROLLER.preDelete(TestAccessController.createAndPrepare(RCP_ENV),
new Delete(TEST_ROW), new WALEdit(), Durability.USE_DEFAULT);
return null;
}
@ -853,7 +853,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preBatchMutate(ObserverContextImpl.createAndPrepare(RCP_ENV),
ACCESS_CONTROLLER.preBatchMutate(TestAccessController.createAndPrepare(RCP_ENV),
new MiniBatchOperationInProgress<>(null, null, null, 0, 0, 0));
return null;
}
@ -863,7 +863,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preCheckAndPut(ObserverContextImpl.createAndPrepare(RCP_ENV),
ACCESS_CONTROLLER.preCheckAndPut(TestAccessController.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 class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preCheckAndDelete(ObserverContextImpl.createAndPrepare(RCP_ENV),
ACCESS_CONTROLLER.preCheckAndDelete(TestAccessController.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 class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preAppend(ObserverContextImpl.createAndPrepare(RCP_ENV),
ACCESS_CONTROLLER.preAppend(TestAccessController.createAndPrepare(RCP_ENV),
new Append(TEST_ROW));
return null;
}
@ -895,7 +895,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preIncrement(ObserverContextImpl.createAndPrepare(RCP_ENV),
ACCESS_CONTROLLER.preIncrement(TestAccessController.createAndPrepare(RCP_ENV),
new Increment(TEST_ROW));
return null;
}
@ -905,7 +905,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() {
@Override
public Object run() throws Exception {
ACCESS_CONTROLLER.preScannerOpen(ObserverContextImpl.createAndPrepare(RCP_ENV),
ACCESS_CONTROLLER.preScannerOpen(TestAccessController.createAndPrepare(RCP_ENV),
new Scan());
return null;
}
@ -916,7 +916,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
@Override
public Object run() throws Exception {
List<Pair<byte[], String>> paths = Lists.newArrayList();
ACCESS_CONTROLLER.preBulkLoadHFile(ObserverContextImpl.createAndPrepare(RCP_ENV),
ACCESS_CONTROLLER.preBulkLoadHFile(TestAccessController.createAndPrepare(RCP_ENV),
paths);
return null;
}

13
pom.xml
View File

@ -92,6 +92,7 @@
<module>hbase-hbtop</module>
<module>hbase-asyncfs</module>
<module>hbase-logging</module>
<module>hbase-coprocessor</module>
</modules>
<scm>
<connection>scm:git:git://gitbox.apache.org/repos/asf/hbase.git</connection>
@ -1627,6 +1628,18 @@
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-coprocessor</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-coprocessor</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-protocol-shaded</artifactId>