HBASE-20652 Remove internal uses of some deprecated MasterObserver hooks
Remove internal uses of these hooks: preModifyNamespace postModifyNamespace preModifyTable postModifyTable preModifyTableAction postCompletedModifyTableAction Signed-off-by: tedyu <yuzhihong@gmail.com>
This commit is contained in:
parent
81228f72d0
commit
05f57f4c03
|
@ -490,8 +490,8 @@ public class RSGroupAdminEndpoint implements MasterCoprocessor, MasterObserver {
|
|||
|
||||
@Override
|
||||
public void preModifyNamespace(ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
NamespaceDescriptor ns) throws IOException {
|
||||
preCreateNamespace(ctx, ns);
|
||||
NamespaceDescriptor currentNsDesc, NamespaceDescriptor newNsDesc) throws IOException {
|
||||
preCreateNamespace(ctx, newNsDesc);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -229,7 +229,6 @@ public interface MasterObserver {
|
|||
throws IOException {
|
||||
preModifyTable(ctx, tableName, newDescriptor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called after the modifyTable operation has been requested. Called as part
|
||||
* of modify table RPC call.
|
||||
|
|
|
@ -969,24 +969,24 @@ public class AccessController implements MasterCoprocessor, RegionCoprocessor,
|
|||
|
||||
@Override
|
||||
public void preModifyTable(ObserverContext<MasterCoprocessorEnvironment> c, TableName tableName,
|
||||
TableDescriptor htd) throws IOException {
|
||||
TableDescriptor currentDesc, TableDescriptor newDesc) throws IOException {
|
||||
// TODO: potentially check if this is a add/modify/delete column operation
|
||||
requirePermission(c, "modifyTable",
|
||||
tableName, null, null, Action.ADMIN, Action.CREATE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postModifyTable(ObserverContext<MasterCoprocessorEnvironment> c,
|
||||
TableName tableName, final TableDescriptor htd) throws IOException {
|
||||
public void postModifyTable(ObserverContext<MasterCoprocessorEnvironment> c, TableName tableName,
|
||||
TableDescriptor oldDesc, TableDescriptor currentDesc) throws IOException {
|
||||
final Configuration conf = c.getEnvironment().getConfiguration();
|
||||
// default the table owner to current user, if not specified.
|
||||
final String owner = (htd.getOwnerString() != null) ? htd.getOwnerString() :
|
||||
final String owner = (currentDesc.getOwnerString() != null) ? currentDesc.getOwnerString() :
|
||||
getActiveUser(c).getShortName();
|
||||
User.runAsLoginUser(new PrivilegedExceptionAction<Void>() {
|
||||
@Override
|
||||
public Void run() throws Exception {
|
||||
UserPermission userperm = new UserPermission(Bytes.toBytes(owner),
|
||||
htd.getTableName(), null, Action.values());
|
||||
currentDesc.getTableName(), null, Action.values());
|
||||
try (Table table = c.getEnvironment().getConnection().
|
||||
getTable(AccessControlLists.ACL_TABLE_NAME)) {
|
||||
AccessControlLists.addUserPermission(conf, userperm, table);
|
||||
|
@ -1233,18 +1233,16 @@ public class AccessController implements MasterCoprocessor, RegionCoprocessor,
|
|||
|
||||
@Override
|
||||
public void preModifyNamespace(ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
NamespaceDescriptor ns) throws IOException {
|
||||
NamespaceDescriptor currentNsDesc, NamespaceDescriptor newNsDesc) throws IOException {
|
||||
// We require only global permission so that
|
||||
// a user with NS admin cannot altering namespace configurations. i.e. namespace quota
|
||||
requireGlobalPermission(ctx, "modifyNamespace",
|
||||
Action.ADMIN, ns.getName());
|
||||
requireGlobalPermission(ctx, "modifyNamespace", Action.ADMIN, newNsDesc.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preGetNamespaceDescriptor(ObserverContext<MasterCoprocessorEnvironment> ctx, String namespace)
|
||||
throws IOException {
|
||||
requireNamespacePermission(ctx, "getNamespaceDescriptor",
|
||||
namespace, Action.ADMIN);
|
||||
public void preGetNamespaceDescriptor(ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
String namespace) throws IOException {
|
||||
requireNamespacePermission(ctx, "getNamespaceDescriptor", namespace, Action.ADMIN);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -55,8 +55,9 @@ public class CoprocessorWhitelistMasterObserver implements MasterCoprocessor, Ma
|
|||
|
||||
@Override
|
||||
public void preModifyTable(ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
TableName tableName, TableDescriptor htd) throws IOException {
|
||||
verifyCoprocessors(ctx, htd);
|
||||
TableName tableName, TableDescriptor currentDesc, TableDescriptor newDesc)
|
||||
throws IOException {
|
||||
verifyCoprocessors(ctx, newDesc);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -226,8 +226,8 @@ public class VisibilityController implements MasterCoprocessor, RegionCoprocesso
|
|||
}
|
||||
|
||||
@Override
|
||||
public void preModifyTable(ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
TableName tableName, TableDescriptor htd) throws IOException {
|
||||
public void preModifyTable(ObserverContext<MasterCoprocessorEnvironment> ctx, TableName tableName,
|
||||
TableDescriptor currentDescriptor, TableDescriptor newDescriptor) throws IOException {
|
||||
if (!authorizationEnabled) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -364,13 +364,15 @@ public class TestMasterObserver {
|
|||
|
||||
@Override
|
||||
public void preModifyTable(ObserverContext<MasterCoprocessorEnvironment> env,
|
||||
TableName tableName, TableDescriptor htd) throws IOException {
|
||||
TableName tableName, final TableDescriptor currentDescriptor,
|
||||
final TableDescriptor newDescriptor) throws IOException {
|
||||
preModifyTableCalled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postModifyTable(ObserverContext<MasterCoprocessorEnvironment> env,
|
||||
TableName tableName, TableDescriptor htd) throws IOException {
|
||||
TableName tableName, final TableDescriptor oldDescriptor,
|
||||
final TableDescriptor currentDescriptor) throws IOException {
|
||||
postModifyTableCalled = true;
|
||||
}
|
||||
|
||||
|
@ -424,13 +426,13 @@ public class TestMasterObserver {
|
|||
|
||||
@Override
|
||||
public void preModifyNamespace(ObserverContext<MasterCoprocessorEnvironment> env,
|
||||
NamespaceDescriptor ns) throws IOException {
|
||||
NamespaceDescriptor currentNsDesc, NamespaceDescriptor newNsDesc) throws IOException {
|
||||
preModifyNamespaceCalled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postModifyNamespace(ObserverContext<MasterCoprocessorEnvironment> env,
|
||||
NamespaceDescriptor ns) throws IOException {
|
||||
NamespaceDescriptor oldNsDesc, NamespaceDescriptor currentNsDesc) throws IOException {
|
||||
postModifyNamespaceCalled = true;
|
||||
}
|
||||
|
||||
|
@ -917,7 +919,8 @@ public class TestMasterObserver {
|
|||
public void preModifyTableAction(
|
||||
final ObserverContext<MasterCoprocessorEnvironment> env,
|
||||
final TableName tableName,
|
||||
final TableDescriptor htd) throws IOException {
|
||||
final TableDescriptor currentDescriptor,
|
||||
final TableDescriptor newDescriptor) throws IOException {
|
||||
preModifyTableActionCalled = true;
|
||||
}
|
||||
|
||||
|
@ -925,7 +928,8 @@ public class TestMasterObserver {
|
|||
public void postCompletedModifyTableAction(
|
||||
final ObserverContext<MasterCoprocessorEnvironment> env,
|
||||
final TableName tableName,
|
||||
final TableDescriptor htd) throws IOException {
|
||||
final TableDescriptor oldDescriptor,
|
||||
final TableDescriptor currentDescriptor) throws IOException {
|
||||
postCompletedModifyTableActionCalled = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -106,7 +106,8 @@ public class TestMasterObserverPostCalls {
|
|||
|
||||
@Override
|
||||
public void postModifyNamespace(
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx, NamespaceDescriptor desc) {
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx, NamespaceDescriptor oldNsDesc,
|
||||
NamespaceDescriptor currentNsDesc) {
|
||||
postHookCalls.incrementAndGet();
|
||||
}
|
||||
|
||||
|
@ -125,7 +126,8 @@ public class TestMasterObserverPostCalls {
|
|||
|
||||
@Override
|
||||
public void postModifyTable(
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx, TableName tn, TableDescriptor td) {
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx, TableName tn,
|
||||
TableDescriptor oldDescriptor, TableDescriptor currentDescriptor) {
|
||||
postHookCalls.incrementAndGet();
|
||||
}
|
||||
|
||||
|
|
|
@ -406,7 +406,9 @@ public class TestAccessController extends SecureTestUtil {
|
|||
htd.addFamily(new HColumnDescriptor(TEST_FAMILY));
|
||||
htd.addFamily(new HColumnDescriptor("fam_" + User.getCurrent().getShortName()));
|
||||
ACCESS_CONTROLLER.preModifyTable(ObserverContextImpl.createAndPrepare(CP_ENV),
|
||||
TEST_TABLE, htd);
|
||||
TEST_TABLE,
|
||||
null, // not needed by AccessController
|
||||
htd);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -250,6 +250,7 @@ public class TestNamespaceCommands extends SecureTestUtil {
|
|||
@Override
|
||||
public Object run() throws Exception {
|
||||
ACCESS_CONTROLLER.preModifyNamespace(ObserverContextImpl.createAndPrepare(CP_ENV),
|
||||
null, // not needed by AccessController
|
||||
NamespaceDescriptor.create(TEST_NAMESPACE).addConfiguration("abc", "156").build());
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -493,7 +493,9 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
|
|||
htd.addFamily(new HColumnDescriptor(TEST_FAMILY));
|
||||
htd.addFamily(new HColumnDescriptor(TEST_FAMILY2));
|
||||
ACCESS_CONTROLLER.preModifyTable(ObserverContextImpl.createAndPrepare(CP_ENV),
|
||||
TEST_TABLE.getTableName(), htd);
|
||||
TEST_TABLE.getTableName(),
|
||||
null, // not needed by AccessController
|
||||
htd);
|
||||
return null;
|
||||
}
|
||||
}, SUPERUSER, USER_ADMIN, USER_RW, USER_RO, USER_OWNER, USER_CREATE, USER_QUAL, USER_NONE);
|
||||
|
@ -700,6 +702,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
|
|||
public Object run() throws Exception {
|
||||
NamespaceDescriptor ns = NamespaceDescriptor.create("test").build();
|
||||
ACCESS_CONTROLLER.preModifyNamespace(ObserverContextImpl.createAndPrepare(CP_ENV),
|
||||
null, // not needed by AccessController
|
||||
ns);
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue