HBASE-17260 Procedure v2 - Add setOwner() overload taking a User instance

This commit is contained in:
Matteo Bertozzi 2016-12-06 10:32:43 -08:00
parent f112427425
commit 1eb24e4e8e
5 changed files with 12 additions and 6 deletions

View File

@ -30,6 +30,7 @@ import org.apache.hadoop.hbase.classification.InterfaceStability;
import org.apache.hadoop.hbase.exceptions.TimeoutIOException;
import org.apache.hadoop.hbase.procedure2.util.StringUtils;
import org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos.ProcedureState;
import org.apache.hadoop.hbase.security.User;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.hbase.util.NonceKey;
@ -392,6 +393,11 @@ public abstract class Procedure<TEnvironment> implements Comparable<Procedure> {
this.owner = StringUtils.isEmpty(owner) ? null : owner;
}
public void setOwner(final User owner) {
assert owner != null : "expected owner to be not null";
setOwner(owner.getShortName());
}
/**
* Called on store load to initialize the Procedure internals after
* the creation/deserialization.

View File

@ -36,7 +36,7 @@ public abstract class AbstractStateMachineNamespaceProcedure<TState>
}
protected AbstractStateMachineNamespaceProcedure(final MasterProcedureEnv env) {
this.setOwner(env.getRequestUser().getShortName());
this.setOwner(env.getRequestUser());
}
protected abstract String getNamespaceName();

View File

@ -53,7 +53,7 @@ public abstract class AbstractStateMachineTableProcedure<TState>
protected AbstractStateMachineTableProcedure(final MasterProcedureEnv env,
final ProcedurePrepareLatch latch) {
this.user = env.getRequestUser();
this.setOwner(user.getShortName());
this.setOwner(user);
// used for compatibility with clients without procedures
// they need a sync TableExistsException, TableNotFoundException, TableNotDisabledException, ...

View File

@ -153,7 +153,7 @@ implements ServerProcedureInterface {
this.serverName = serverName;
this.shouldSplitWal = shouldSplitWal;
this.carryingMeta = carryingMeta;
this.setOwner(env.getRequestUser().getShortName());
this.setOwner(env.getRequestUser());
}
/**

View File

@ -548,7 +548,7 @@ public class TestAccessController extends SecureTestUtil {
throws IOException {
this.tableName = tableName;
this.setTimeout(180000); // Timeout in 3 minutes
this.setOwner(env.getRequestUser().getUGI().getShortUserName());
this.setOwner(env.getRequestUser());
}
@Override
@ -600,7 +600,7 @@ public class TestAccessController extends SecureTestUtil {
final ProcedureExecutor<MasterProcedureEnv> procExec =
TEST_UTIL.getHBaseCluster().getMaster().getMasterProcedureExecutor();
Procedure proc = new TestTableDDLProcedure(procExec.getEnvironment(), tableName);
proc.setOwner(USER_OWNER.getShortName());
proc.setOwner(USER_OWNER);
final long procId = procExec.submitProcedure(proc);
AccessTestAction abortProcedureAction = new AccessTestAction() {
@ -624,7 +624,7 @@ public class TestAccessController extends SecureTestUtil {
final ProcedureExecutor<MasterProcedureEnv> procExec =
TEST_UTIL.getHBaseCluster().getMaster().getMasterProcedureExecutor();
Procedure proc = new TestTableDDLProcedure(procExec.getEnvironment(), tableName);
proc.setOwner(USER_OWNER.getShortName());
proc.setOwner(USER_OWNER);
final long procId = procExec.submitProcedure(proc);
final List<ProcedureInfo> procInfoList = procExec.listProcedures();