HBASE-16522 Procedure v2 - Cache system user and avoid IOException
This commit is contained in:
parent
c66bb48ce8
commit
af33f94513
|
@ -42,6 +42,7 @@ public final class Superusers {
|
||||||
|
|
||||||
private static List<String> superUsers;
|
private static List<String> superUsers;
|
||||||
private static List<String> superGroups;
|
private static List<String> superGroups;
|
||||||
|
private static User systemUser;
|
||||||
|
|
||||||
private Superusers(){}
|
private Superusers(){}
|
||||||
|
|
||||||
|
@ -55,17 +56,17 @@ public final class Superusers {
|
||||||
public static void initialize(Configuration conf) throws IOException {
|
public static void initialize(Configuration conf) throws IOException {
|
||||||
superUsers = new ArrayList<>();
|
superUsers = new ArrayList<>();
|
||||||
superGroups = new ArrayList<>();
|
superGroups = new ArrayList<>();
|
||||||
User user = User.getCurrent();
|
systemUser = User.getCurrent();
|
||||||
|
|
||||||
if (user == null) {
|
if (systemUser == null) {
|
||||||
throw new IllegalStateException("Unable to obtain the current user, "
|
throw new IllegalStateException("Unable to obtain the current user, "
|
||||||
+ "authorization checks for internal operations will not work correctly!");
|
+ "authorization checks for internal operations will not work correctly!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LOG.isTraceEnabled()) {
|
if (LOG.isTraceEnabled()) {
|
||||||
LOG.trace("Current user name is " + user.getShortName());
|
LOG.trace("Current user name is " + systemUser.getShortName());
|
||||||
}
|
}
|
||||||
String currentUser = user.getShortName();
|
String currentUser = systemUser.getShortName();
|
||||||
String[] superUserList = conf.getStrings(SUPERUSER_CONF_KEY, new String[0]);
|
String[] superUserList = conf.getStrings(SUPERUSER_CONF_KEY, new String[0]);
|
||||||
for (String name : superUserList) {
|
for (String name : superUserList) {
|
||||||
if (AuthUtil.isGroupPrincipal(name)) {
|
if (AuthUtil.isGroupPrincipal(name)) {
|
||||||
|
@ -104,4 +105,8 @@ public final class Superusers {
|
||||||
public static List<String> getSuperUsers() {
|
public static List<String> getSuperUsers() {
|
||||||
return superUsers;
|
return superUsers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static User getSystemUser() {
|
||||||
|
return systemUser;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -75,7 +75,7 @@ public class AddColumnFamilyProcedure
|
||||||
}
|
}
|
||||||
|
|
||||||
public AddColumnFamilyProcedure(final MasterProcedureEnv env, final TableName tableName,
|
public AddColumnFamilyProcedure(final MasterProcedureEnv env, final TableName tableName,
|
||||||
final HColumnDescriptor cfDescriptor, final ProcedurePrepareLatch latch) throws IOException {
|
final HColumnDescriptor cfDescriptor, final ProcedurePrepareLatch latch) {
|
||||||
this.tableName = tableName;
|
this.tableName = tableName;
|
||||||
this.cfDescriptor = cfDescriptor;
|
this.cfDescriptor = cfDescriptor;
|
||||||
this.user = env.getRequestUser();
|
this.user = env.getRequestUser();
|
||||||
|
|
|
@ -97,13 +97,9 @@ public class CloneSnapshotProcedure
|
||||||
* @param env MasterProcedureEnv
|
* @param env MasterProcedureEnv
|
||||||
* @param hTableDescriptor the table to operate on
|
* @param hTableDescriptor the table to operate on
|
||||||
* @param snapshot snapshot to clone from
|
* @param snapshot snapshot to clone from
|
||||||
* @throws IOException
|
|
||||||
*/
|
*/
|
||||||
public CloneSnapshotProcedure(
|
public CloneSnapshotProcedure(final MasterProcedureEnv env,
|
||||||
final MasterProcedureEnv env,
|
final HTableDescriptor hTableDescriptor, final SnapshotDescription snapshot) {
|
||||||
final HTableDescriptor hTableDescriptor,
|
|
||||||
final SnapshotDescription snapshot)
|
|
||||||
throws IOException {
|
|
||||||
this.hTableDescriptor = hTableDescriptor;
|
this.hTableDescriptor = hTableDescriptor;
|
||||||
this.snapshot = snapshot;
|
this.snapshot = snapshot;
|
||||||
this.user = env.getRequestUser();
|
this.user = env.getRequestUser();
|
||||||
|
|
|
@ -55,9 +55,8 @@ public class CreateNamespaceProcedure
|
||||||
this.traceEnabled = null;
|
this.traceEnabled = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CreateNamespaceProcedure(
|
public CreateNamespaceProcedure(final MasterProcedureEnv env,
|
||||||
final MasterProcedureEnv env,
|
final NamespaceDescriptor nsDescriptor) {
|
||||||
final NamespaceDescriptor nsDescriptor) throws IOException {
|
|
||||||
this.nsDescriptor = nsDescriptor;
|
this.nsDescriptor = nsDescriptor;
|
||||||
this.traceEnabled = null;
|
this.traceEnabled = null;
|
||||||
this.setOwner(env.getRequestUser().getUGI().getShortUserName());
|
this.setOwner(env.getRequestUser().getUGI().getShortUserName());
|
||||||
|
|
|
@ -76,15 +76,13 @@ public class CreateTableProcedure
|
||||||
}
|
}
|
||||||
|
|
||||||
public CreateTableProcedure(final MasterProcedureEnv env,
|
public CreateTableProcedure(final MasterProcedureEnv env,
|
||||||
final HTableDescriptor hTableDescriptor, final HRegionInfo[] newRegions)
|
final HTableDescriptor hTableDescriptor, final HRegionInfo[] newRegions) {
|
||||||
throws IOException {
|
|
||||||
this(env, hTableDescriptor, newRegions, null);
|
this(env, hTableDescriptor, newRegions, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CreateTableProcedure(final MasterProcedureEnv env,
|
public CreateTableProcedure(final MasterProcedureEnv env,
|
||||||
final HTableDescriptor hTableDescriptor, final HRegionInfo[] newRegions,
|
final HTableDescriptor hTableDescriptor, final HRegionInfo[] newRegions,
|
||||||
final ProcedurePrepareLatch syncLatch)
|
final ProcedurePrepareLatch syncLatch) {
|
||||||
throws IOException {
|
|
||||||
this.hTableDescriptor = hTableDescriptor;
|
this.hTableDescriptor = hTableDescriptor;
|
||||||
this.newRegions = newRegions != null ? Lists.newArrayList(newRegions) : null;
|
this.newRegions = newRegions != null ? Lists.newArrayList(newRegions) : null;
|
||||||
this.user = env.getRequestUser();
|
this.user = env.getRequestUser();
|
||||||
|
|
|
@ -73,12 +73,12 @@ public class DeleteColumnFamilyProcedure
|
||||||
}
|
}
|
||||||
|
|
||||||
public DeleteColumnFamilyProcedure(final MasterProcedureEnv env, final TableName tableName,
|
public DeleteColumnFamilyProcedure(final MasterProcedureEnv env, final TableName tableName,
|
||||||
final byte[] familyName) throws IOException {
|
final byte[] familyName) {
|
||||||
this(env, tableName, familyName, null);
|
this(env, tableName, familyName, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DeleteColumnFamilyProcedure(final MasterProcedureEnv env, final TableName tableName,
|
public DeleteColumnFamilyProcedure(final MasterProcedureEnv env, final TableName tableName,
|
||||||
final byte[] familyName, final ProcedurePrepareLatch latch) throws IOException {
|
final byte[] familyName, final ProcedurePrepareLatch latch) {
|
||||||
this.tableName = tableName;
|
this.tableName = tableName;
|
||||||
this.familyName = familyName;
|
this.familyName = familyName;
|
||||||
this.user = env.getRequestUser();
|
this.user = env.getRequestUser();
|
||||||
|
|
|
@ -63,9 +63,7 @@ public class DeleteNamespaceProcedure
|
||||||
this.traceEnabled = null;
|
this.traceEnabled = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DeleteNamespaceProcedure(
|
public DeleteNamespaceProcedure(final MasterProcedureEnv env, final String namespaceName) {
|
||||||
final MasterProcedureEnv env,
|
|
||||||
final String namespaceName) throws IOException {
|
|
||||||
this.namespaceName = namespaceName;
|
this.namespaceName = namespaceName;
|
||||||
this.nsDescriptor = null;
|
this.nsDescriptor = null;
|
||||||
this.traceEnabled = null;
|
this.traceEnabled = null;
|
||||||
|
|
|
@ -76,13 +76,12 @@ public class DeleteTableProcedure
|
||||||
syncLatch = null;
|
syncLatch = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DeleteTableProcedure(final MasterProcedureEnv env, final TableName tableName)
|
public DeleteTableProcedure(final MasterProcedureEnv env, final TableName tableName) {
|
||||||
throws IOException {
|
|
||||||
this(env, tableName, null);
|
this(env, tableName, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DeleteTableProcedure(final MasterProcedureEnv env, final TableName tableName,
|
public DeleteTableProcedure(final MasterProcedureEnv env, final TableName tableName,
|
||||||
final ProcedurePrepareLatch syncLatch) throws IOException {
|
final ProcedurePrepareLatch syncLatch) {
|
||||||
this.tableName = tableName;
|
this.tableName = tableName;
|
||||||
this.user = env.getRequestUser();
|
this.user = env.getRequestUser();
|
||||||
this.setOwner(this.user.getShortName());
|
this.setOwner(this.user.getShortName());
|
||||||
|
|
|
@ -83,12 +83,9 @@ public class DisableTableProcedure
|
||||||
* @param env MasterProcedureEnv
|
* @param env MasterProcedureEnv
|
||||||
* @param tableName the table to operate on
|
* @param tableName the table to operate on
|
||||||
* @param skipTableStateCheck whether to check table state
|
* @param skipTableStateCheck whether to check table state
|
||||||
* @throws IOException
|
|
||||||
*/
|
*/
|
||||||
public DisableTableProcedure(
|
public DisableTableProcedure(final MasterProcedureEnv env, final TableName tableName,
|
||||||
final MasterProcedureEnv env,
|
final boolean skipTableStateCheck) {
|
||||||
final TableName tableName,
|
|
||||||
final boolean skipTableStateCheck) throws IOException {
|
|
||||||
this(env, tableName, skipTableStateCheck, null);
|
this(env, tableName, skipTableStateCheck, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,13 +94,9 @@ public class DisableTableProcedure
|
||||||
* @param env MasterProcedureEnv
|
* @param env MasterProcedureEnv
|
||||||
* @param tableName the table to operate on
|
* @param tableName the table to operate on
|
||||||
* @param skipTableStateCheck whether to check table state
|
* @param skipTableStateCheck whether to check table state
|
||||||
* @throws IOException
|
|
||||||
*/
|
*/
|
||||||
public DisableTableProcedure(
|
public DisableTableProcedure(final MasterProcedureEnv env, final TableName tableName,
|
||||||
final MasterProcedureEnv env,
|
final boolean skipTableStateCheck, final ProcedurePrepareLatch syncLatch) {
|
||||||
final TableName tableName,
|
|
||||||
final boolean skipTableStateCheck,
|
|
||||||
final ProcedurePrepareLatch syncLatch) throws IOException {
|
|
||||||
this.tableName = tableName;
|
this.tableName = tableName;
|
||||||
this.skipTableStateCheck = skipTableStateCheck;
|
this.skipTableStateCheck = skipTableStateCheck;
|
||||||
this.user = env.getRequestUser();
|
this.user = env.getRequestUser();
|
||||||
|
|
|
@ -84,7 +84,7 @@ implements TableProcedureInterface {
|
||||||
final MasterProcedureEnv env,
|
final MasterProcedureEnv env,
|
||||||
final TableName tableName,
|
final TableName tableName,
|
||||||
final HRegionInfo [] regionsToMerge,
|
final HRegionInfo [] regionsToMerge,
|
||||||
final boolean forcible) throws IOException {
|
final boolean forcible) {
|
||||||
this.traceEnabled = isTraceEnabled();
|
this.traceEnabled = isTraceEnabled();
|
||||||
this.assignmentManager = getAssignmentManager(env);
|
this.assignmentManager = getAssignmentManager(env);
|
||||||
this.tableName = tableName;
|
this.tableName = tableName;
|
||||||
|
|
|
@ -80,12 +80,9 @@ public class EnableTableProcedure
|
||||||
* @param env MasterProcedureEnv
|
* @param env MasterProcedureEnv
|
||||||
* @param tableName the table to operate on
|
* @param tableName the table to operate on
|
||||||
* @param skipTableStateCheck whether to check table state
|
* @param skipTableStateCheck whether to check table state
|
||||||
* @throws IOException
|
|
||||||
*/
|
*/
|
||||||
public EnableTableProcedure(
|
public EnableTableProcedure(final MasterProcedureEnv env, final TableName tableName,
|
||||||
final MasterProcedureEnv env,
|
final boolean skipTableStateCheck) {
|
||||||
final TableName tableName,
|
|
||||||
final boolean skipTableStateCheck) throws IOException {
|
|
||||||
this(env, tableName, skipTableStateCheck, null);
|
this(env, tableName, skipTableStateCheck, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,13 +91,9 @@ public class EnableTableProcedure
|
||||||
* @param env MasterProcedureEnv
|
* @param env MasterProcedureEnv
|
||||||
* @param tableName the table to operate on
|
* @param tableName the table to operate on
|
||||||
* @param skipTableStateCheck whether to check table state
|
* @param skipTableStateCheck whether to check table state
|
||||||
* @throws IOException
|
|
||||||
*/
|
*/
|
||||||
public EnableTableProcedure(
|
public EnableTableProcedure(final MasterProcedureEnv env, final TableName tableName,
|
||||||
final MasterProcedureEnv env,
|
final boolean skipTableStateCheck, final ProcedurePrepareLatch syncLatch) {
|
||||||
final TableName tableName,
|
|
||||||
final boolean skipTableStateCheck,
|
|
||||||
final ProcedurePrepareLatch syncLatch) throws IOException {
|
|
||||||
this.tableName = tableName;
|
this.tableName = tableName;
|
||||||
this.skipTableStateCheck = skipTableStateCheck;
|
this.skipTableStateCheck = skipTableStateCheck;
|
||||||
this.user = env.getRequestUser();
|
this.user = env.getRequestUser();
|
||||||
|
|
|
@ -36,7 +36,7 @@ import org.apache.hadoop.hbase.procedure2.Procedure;
|
||||||
import org.apache.hadoop.hbase.procedure2.store.ProcedureStore;
|
import org.apache.hadoop.hbase.procedure2.store.ProcedureStore;
|
||||||
import org.apache.hadoop.hbase.procedure2.store.wal.WALProcedureStore;
|
import org.apache.hadoop.hbase.procedure2.store.wal.WALProcedureStore;
|
||||||
import org.apache.hadoop.hbase.security.User;
|
import org.apache.hadoop.hbase.security.User;
|
||||||
import org.apache.hadoop.hbase.security.UserProvider;
|
import org.apache.hadoop.hbase.security.Superusers;
|
||||||
import org.apache.hadoop.hbase.util.CancelableProgressable;
|
import org.apache.hadoop.hbase.util.CancelableProgressable;
|
||||||
import org.apache.hadoop.hbase.util.FSUtils;
|
import org.apache.hadoop.hbase.util.FSUtils;
|
||||||
|
|
||||||
|
@ -96,10 +96,10 @@ public class MasterProcedureEnv {
|
||||||
master.getTableLockManager());
|
master.getTableLockManager());
|
||||||
}
|
}
|
||||||
|
|
||||||
public User getRequestUser() throws IOException {
|
public User getRequestUser() {
|
||||||
User user = RpcServer.getRequestUser();
|
User user = RpcServer.getRequestUser();
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
user = UserProvider.instantiate(getMasterConfiguration()).getCurrent();
|
user = Superusers.getSystemUser();
|
||||||
}
|
}
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,12 +69,12 @@ public class ModifyColumnFamilyProcedure
|
||||||
}
|
}
|
||||||
|
|
||||||
public ModifyColumnFamilyProcedure(final MasterProcedureEnv env, final TableName tableName,
|
public ModifyColumnFamilyProcedure(final MasterProcedureEnv env, final TableName tableName,
|
||||||
final HColumnDescriptor cfDescriptor) throws IOException {
|
final HColumnDescriptor cfDescriptor) {
|
||||||
this(env, tableName, cfDescriptor, null);
|
this(env, tableName, cfDescriptor, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ModifyColumnFamilyProcedure(final MasterProcedureEnv env, final TableName tableName,
|
public ModifyColumnFamilyProcedure(final MasterProcedureEnv env, final TableName tableName,
|
||||||
final HColumnDescriptor cfDescriptor, final ProcedurePrepareLatch latch) throws IOException {
|
final HColumnDescriptor cfDescriptor, final ProcedurePrepareLatch latch) {
|
||||||
this.tableName = tableName;
|
this.tableName = tableName;
|
||||||
this.cfDescriptor = cfDescriptor;
|
this.cfDescriptor = cfDescriptor;
|
||||||
this.user = env.getRequestUser();
|
this.user = env.getRequestUser();
|
||||||
|
|
|
@ -55,9 +55,8 @@ public class ModifyNamespaceProcedure
|
||||||
this.traceEnabled = null;
|
this.traceEnabled = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ModifyNamespaceProcedure(
|
public ModifyNamespaceProcedure(final MasterProcedureEnv env,
|
||||||
final MasterProcedureEnv env,
|
final NamespaceDescriptor newNsDescriptor) {
|
||||||
final NamespaceDescriptor newNsDescriptor) throws IOException {
|
|
||||||
this.oldNsDescriptor = null;
|
this.oldNsDescriptor = null;
|
||||||
this.newNsDescriptor = newNsDescriptor;
|
this.newNsDescriptor = newNsDescriptor;
|
||||||
this.traceEnabled = null;
|
this.traceEnabled = null;
|
||||||
|
|
|
@ -76,13 +76,12 @@ public class ModifyTableProcedure
|
||||||
this.syncLatch = null;
|
this.syncLatch = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ModifyTableProcedure(final MasterProcedureEnv env, final HTableDescriptor htd)
|
public ModifyTableProcedure(final MasterProcedureEnv env, final HTableDescriptor htd) {
|
||||||
throws IOException {
|
|
||||||
this(env, htd, null);
|
this(env, htd, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ModifyTableProcedure(final MasterProcedureEnv env, final HTableDescriptor htd,
|
public ModifyTableProcedure(final MasterProcedureEnv env, final HTableDescriptor htd,
|
||||||
final ProcedurePrepareLatch latch) throws IOException {
|
final ProcedurePrepareLatch latch) {
|
||||||
initilize();
|
initilize();
|
||||||
this.modifiedHTableDescriptor = htd;
|
this.modifiedHTableDescriptor = htd;
|
||||||
this.user = env.getRequestUser();
|
this.user = env.getRequestUser();
|
||||||
|
|
|
@ -99,8 +99,7 @@ public class RestoreSnapshotProcedure
|
||||||
public RestoreSnapshotProcedure(
|
public RestoreSnapshotProcedure(
|
||||||
final MasterProcedureEnv env,
|
final MasterProcedureEnv env,
|
||||||
final HTableDescriptor hTableDescriptor,
|
final HTableDescriptor hTableDescriptor,
|
||||||
final SnapshotDescription snapshot)
|
final SnapshotDescription snapshot) {
|
||||||
throws IOException {
|
|
||||||
// This is the new schema we are going to write out as this modification.
|
// This is the new schema we are going to write out as this modification.
|
||||||
this.modifiedHTableDescriptor = hTableDescriptor;
|
this.modifiedHTableDescriptor = hTableDescriptor;
|
||||||
// Snapshot information
|
// Snapshot information
|
||||||
|
|
|
@ -65,12 +65,12 @@ public class TruncateTableProcedure
|
||||||
}
|
}
|
||||||
|
|
||||||
public TruncateTableProcedure(final MasterProcedureEnv env, final TableName tableName,
|
public TruncateTableProcedure(final MasterProcedureEnv env, final TableName tableName,
|
||||||
boolean preserveSplits) throws IOException {
|
boolean preserveSplits) {
|
||||||
this(env, tableName, preserveSplits, null);
|
this(env, tableName, preserveSplits, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TruncateTableProcedure(final MasterProcedureEnv env, final TableName tableName,
|
public TruncateTableProcedure(final MasterProcedureEnv env, final TableName tableName,
|
||||||
boolean preserveSplits, ProcedurePrepareLatch latch) throws IOException {
|
boolean preserveSplits, ProcedurePrepareLatch latch) {
|
||||||
this.tableName = tableName;
|
this.tableName = tableName;
|
||||||
this.preserveSplits = preserveSplits;
|
this.preserveSplits = preserveSplits;
|
||||||
this.user = env.getRequestUser();
|
this.user = env.getRequestUser();
|
||||||
|
|
Loading…
Reference in New Issue