You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ni...@apache.org on 2024/09/23 16:51:21 UTC
(hbase) branch branch-2 updated: HBASE-28867 Backport "HBASE-20653 Add missing observer hooks for region server group to MasterObserver" to branch-2 (#6276)
This is an automated email from the ASF dual-hosted git repository.
nihaljain pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2 by this push:
new 9382dfac2c5 HBASE-28867 Backport "HBASE-20653 Add missing observer hooks for region server group to MasterObserver" to branch-2 (#6276)
9382dfac2c5 is described below
commit 9382dfac2c58731bb53e2055957d94896162c7c6
Author: Nihal Jain <ni...@apache.org>
AuthorDate: Mon Sep 23 22:21:16 2024 +0530
HBASE-28867 Backport "HBASE-20653 Add missing observer hooks for region server group to MasterObserver" to branch-2 (#6276)
Signed-off-by: Nick Dimiduk <nd...@apache.org>
---
.../hadoop/hbase/rsgroup/RSGroupAdminEndpoint.java | 24 ++++++++
.../hadoop/hbase/rsgroup/TestRSGroupsBase.java | 64 +++++++++++++++++++
.../hadoop/hbase/rsgroup/TestRSGroupsWithACL.java | 44 +++++--------
.../hadoop/hbase/coprocessor/MasterObserver.java | 70 +++++++++++++++++++++
.../hadoop/hbase/master/MasterCoprocessorHost.java | 72 ++++++++++++++++++++++
5 files changed, 244 insertions(+), 30 deletions(-)
diff --git a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminEndpoint.java b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminEndpoint.java
index 0d5188ce735..98ab2d4d285 100644
--- a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminEndpoint.java
+++ b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminEndpoint.java
@@ -167,11 +167,17 @@ public class RSGroupAdminEndpoint implements MasterCoprocessor, MasterObserver {
LOG.info(
master.getClientIdAuditPrefix() + " initiates rsgroup info retrieval, group=" + groupName);
try {
+ if (master.getMasterCoprocessorHost() != null) {
+ master.getMasterCoprocessorHost().preGetRSGroupInfo(groupName);
+ }
checkPermission("getRSGroupInfo");
RSGroupInfo rsGroupInfo = groupAdminServer.getRSGroupInfo(groupName);
if (rsGroupInfo != null) {
builder.setRSGroupInfo(RSGroupProtobufUtil.toProtoGroupInfo(rsGroupInfo));
}
+ if (master.getMasterCoprocessorHost() != null) {
+ master.getMasterCoprocessorHost().postGetRSGroupInfo(groupName);
+ }
} catch (IOException e) {
CoprocessorRpcUtils.setControllerException(controller, e);
}
@@ -186,11 +192,17 @@ public class RSGroupAdminEndpoint implements MasterCoprocessor, MasterObserver {
LOG.info(
master.getClientIdAuditPrefix() + " initiates rsgroup info retrieval, table=" + tableName);
try {
+ if (master.getMasterCoprocessorHost() != null) {
+ master.getMasterCoprocessorHost().preGetRSGroupInfoOfTable(tableName);
+ }
checkPermission("getRSGroupInfoOfTable");
RSGroupInfo RSGroupInfo = groupAdminServer.getRSGroupInfoOfTable(tableName);
if (RSGroupInfo != null) {
builder.setRSGroupInfo(RSGroupProtobufUtil.toProtoGroupInfo(RSGroupInfo));
}
+ if (master.getMasterCoprocessorHost() != null) {
+ master.getMasterCoprocessorHost().postGetRSGroupInfoOfTable(tableName);
+ }
} catch (IOException e) {
CoprocessorRpcUtils.setControllerException(controller, e);
}
@@ -325,10 +337,16 @@ public class RSGroupAdminEndpoint implements MasterCoprocessor, MasterObserver {
ListRSGroupInfosResponse.Builder builder = ListRSGroupInfosResponse.newBuilder();
LOG.info(master.getClientIdAuditPrefix() + " list rsgroup");
try {
+ if (master.getMasterCoprocessorHost() != null) {
+ master.getMasterCoprocessorHost().preListRSGroups();
+ }
checkPermission("listRSGroup");
for (RSGroupInfo RSGroupInfo : groupAdminServer.listRSGroups()) {
builder.addRSGroupInfo(RSGroupProtobufUtil.toProtoGroupInfo(RSGroupInfo));
}
+ if (master.getMasterCoprocessorHost() != null) {
+ master.getMasterCoprocessorHost().postListRSGroups();
+ }
} catch (IOException e) {
CoprocessorRpcUtils.setControllerException(controller, e);
}
@@ -343,11 +361,17 @@ public class RSGroupAdminEndpoint implements MasterCoprocessor, MasterObserver {
Address.fromParts(request.getServer().getHostName(), request.getServer().getPort());
LOG.info(master.getClientIdAuditPrefix() + " initiates rsgroup info retrieval, server=" + hp);
try {
+ if (master.getMasterCoprocessorHost() != null) {
+ master.getMasterCoprocessorHost().preGetRSGroupInfoOfServer(hp);
+ }
checkPermission("getRSGroupInfoOfServer");
RSGroupInfo info = groupAdminServer.getRSGroupOfServer(hp);
if (info != null) {
builder.setRSGroupInfo(RSGroupProtobufUtil.toProtoGroupInfo(info));
}
+ if (master.getMasterCoprocessorHost() != null) {
+ master.getMasterCoprocessorHost().postGetRSGroupInfoOfServer(hp);
+ }
} catch (IOException e) {
CoprocessorRpcUtils.setControllerException(controller, e);
}
diff --git a/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsBase.java b/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsBase.java
index 445f17a2b48..ee8d30448af 100644
--- a/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsBase.java
+++ b/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsBase.java
@@ -302,6 +302,14 @@ public abstract class TestRSGroupsBase extends AbstractTestUpdateConfiguration {
boolean postMoveServersAndTables = false;
boolean preRenameRSGroupCalled = false;
boolean postRenameRSGroupCalled = false;
+ boolean preGetRSGroupInfoCalled = false;
+ boolean postGetRSGroupInfoCalled = false;
+ boolean preGetRSGroupInfoOfTableCalled = false;
+ boolean postGetRSGroupInfoOfTableCalled = false;
+ boolean preListRSGroupsCalled = false;
+ boolean postListRSGroupsCalled = false;
+ boolean preGetRSGroupInfoOfServerCalled = false;
+ boolean postGetRSGroupInfoOfServerCalled = false;
public void resetFlags() {
preBalanceRSGroupCalled = false;
@@ -320,6 +328,14 @@ public abstract class TestRSGroupsBase extends AbstractTestUpdateConfiguration {
postMoveServersAndTables = false;
preRenameRSGroupCalled = false;
postRenameRSGroupCalled = false;
+ preGetRSGroupInfoCalled = false;
+ postGetRSGroupInfoCalled = false;
+ preGetRSGroupInfoOfTableCalled = false;
+ postGetRSGroupInfoOfTableCalled = false;
+ preListRSGroupsCalled = false;
+ postListRSGroupsCalled = false;
+ preGetRSGroupInfoOfServerCalled = false;
+ postGetRSGroupInfoOfServerCalled = false;
}
@Override
@@ -422,6 +438,54 @@ public abstract class TestRSGroupsBase extends AbstractTestUpdateConfiguration {
String newName) throws IOException {
postRenameRSGroupCalled = true;
}
+
+ @Override
+ public void preGetRSGroupInfo(final ObserverContext<MasterCoprocessorEnvironment> ctx,
+ final String groupName) throws IOException {
+ preGetRSGroupInfoCalled = true;
+ }
+
+ @Override
+ public void postGetRSGroupInfo(final ObserverContext<MasterCoprocessorEnvironment> ctx,
+ final String groupName) throws IOException {
+ postGetRSGroupInfoCalled = true;
+ }
+
+ @Override
+ public void preGetRSGroupInfoOfTable(final ObserverContext<MasterCoprocessorEnvironment> ctx,
+ final TableName tableName) throws IOException {
+ preGetRSGroupInfoOfTableCalled = true;
+ }
+
+ @Override
+ public void postGetRSGroupInfoOfTable(final ObserverContext<MasterCoprocessorEnvironment> ctx,
+ final TableName tableName) throws IOException {
+ postGetRSGroupInfoOfTableCalled = true;
+ }
+
+ @Override
+ public void preListRSGroups(final ObserverContext<MasterCoprocessorEnvironment> ctx)
+ throws IOException {
+ preListRSGroupsCalled = true;
+ }
+
+ @Override
+ public void postListRSGroups(final ObserverContext<MasterCoprocessorEnvironment> ctx)
+ throws IOException {
+ postListRSGroupsCalled = true;
+ }
+
+ @Override
+ public void preGetRSGroupInfoOfServer(final ObserverContext<MasterCoprocessorEnvironment> ctx,
+ final Address server) throws IOException {
+ preGetRSGroupInfoOfServerCalled = true;
+ }
+
+ @Override
+ public void postGetRSGroupInfoOfServer(final ObserverContext<MasterCoprocessorEnvironment> ctx,
+ final Address server) throws IOException {
+ postGetRSGroupInfoOfServerCalled = true;
+ }
}
}
diff --git a/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsWithACL.java b/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsWithACL.java
index a930b71a6e4..700d03c3cbf 100644
--- a/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsWithACL.java
+++ b/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsWithACL.java
@@ -217,9 +217,7 @@ public class TestRSGroupsWithACL extends SecureTestUtil {
return null;
};
- verifyAllowed(action, SUPERUSER, USER_ADMIN, USER_GROUP_ADMIN);
- verifyDenied(action, USER_CREATE, USER_OWNER, USER_RW, USER_RO, USER_NONE, USER_GROUP_READ,
- USER_GROUP_WRITE, USER_GROUP_CREATE);
+ validateAdminPermissions(action);
}
@Test
@@ -229,9 +227,7 @@ public class TestRSGroupsWithACL extends SecureTestUtil {
return null;
};
- verifyAllowed(action, SUPERUSER, USER_ADMIN, USER_GROUP_ADMIN);
- verifyDenied(action, USER_CREATE, USER_OWNER, USER_RW, USER_RO, USER_NONE, USER_GROUP_READ,
- USER_GROUP_WRITE, USER_GROUP_CREATE);
+ validateAdminPermissions(action);
}
@Test
@@ -241,9 +237,7 @@ public class TestRSGroupsWithACL extends SecureTestUtil {
return null;
};
- verifyAllowed(action, SUPERUSER, USER_ADMIN, USER_GROUP_ADMIN);
- verifyDenied(action, USER_CREATE, USER_OWNER, USER_RW, USER_RO, USER_NONE, USER_GROUP_READ,
- USER_GROUP_WRITE, USER_GROUP_CREATE);
+ validateAdminPermissions(action);
}
@Test
@@ -253,9 +247,7 @@ public class TestRSGroupsWithACL extends SecureTestUtil {
return null;
};
- verifyAllowed(action, SUPERUSER, USER_ADMIN, USER_GROUP_ADMIN);
- verifyDenied(action, USER_CREATE, USER_OWNER, USER_RW, USER_RO, USER_NONE, USER_GROUP_READ,
- USER_GROUP_WRITE, USER_GROUP_CREATE);
+ validateAdminPermissions(action);
}
@Test
@@ -265,9 +257,7 @@ public class TestRSGroupsWithACL extends SecureTestUtil {
return null;
};
- verifyAllowed(action, SUPERUSER, USER_ADMIN, USER_GROUP_ADMIN);
- verifyDenied(action, USER_CREATE, USER_OWNER, USER_RW, USER_RO, USER_NONE, USER_GROUP_READ,
- USER_GROUP_WRITE, USER_GROUP_CREATE);
+ validateAdminPermissions(action);
}
@Test
@@ -277,9 +267,7 @@ public class TestRSGroupsWithACL extends SecureTestUtil {
return null;
};
- verifyAllowed(action, SUPERUSER, USER_ADMIN, USER_GROUP_ADMIN);
- verifyDenied(action, USER_CREATE, USER_OWNER, USER_RW, USER_RO, USER_NONE, USER_GROUP_READ,
- USER_GROUP_WRITE, USER_GROUP_CREATE);
+ validateAdminPermissions(action);
}
@Test
@@ -289,9 +277,7 @@ public class TestRSGroupsWithACL extends SecureTestUtil {
return null;
};
- verifyAllowed(action, SUPERUSER, USER_ADMIN, USER_GROUP_ADMIN);
- verifyDenied(action, USER_CREATE, USER_OWNER, USER_RW, USER_RO, USER_NONE, USER_GROUP_READ,
- USER_GROUP_WRITE, USER_GROUP_CREATE);
+ validateAdminPermissions(action);
}
@Test
@@ -301,9 +287,7 @@ public class TestRSGroupsWithACL extends SecureTestUtil {
return null;
};
- verifyAllowed(action, SUPERUSER, USER_ADMIN, USER_GROUP_ADMIN);
- verifyDenied(action, USER_CREATE, USER_OWNER, USER_RW, USER_RO, USER_NONE, USER_GROUP_READ,
- USER_GROUP_WRITE, USER_GROUP_CREATE);
+ validateAdminPermissions(action);
}
@Test
@@ -313,9 +297,7 @@ public class TestRSGroupsWithACL extends SecureTestUtil {
return null;
};
- verifyAllowed(action, SUPERUSER, USER_ADMIN, USER_GROUP_ADMIN);
- verifyDenied(action, USER_CREATE, USER_OWNER, USER_RW, USER_RO, USER_NONE, USER_GROUP_READ,
- USER_GROUP_WRITE, USER_GROUP_CREATE);
+ validateAdminPermissions(action);
}
@Test
@@ -325,9 +307,7 @@ public class TestRSGroupsWithACL extends SecureTestUtil {
return null;
};
- verifyAllowed(action, SUPERUSER, USER_ADMIN, USER_GROUP_ADMIN);
- verifyDenied(action, USER_CREATE, USER_OWNER, USER_RW, USER_RO, USER_NONE, USER_GROUP_READ,
- USER_GROUP_WRITE, USER_GROUP_CREATE);
+ validateAdminPermissions(action);
}
@Test
@@ -337,6 +317,10 @@ public class TestRSGroupsWithACL extends SecureTestUtil {
return null;
};
+ validateAdminPermissions(action);
+ }
+
+ private void validateAdminPermissions(AccessTestAction action) throws Exception {
verifyAllowed(action, SUPERUSER, USER_ADMIN, USER_GROUP_ADMIN);
verifyDenied(action, USER_CREATE, USER_OWNER, USER_RW, USER_RO, USER_NONE, USER_GROUP_READ,
USER_GROUP_WRITE, USER_GROUP_CREATE);
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/MasterObserver.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/MasterObserver.java
index 4186511acdf..85ab42b9a55 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/MasterObserver.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/MasterObserver.java
@@ -1441,6 +1441,76 @@ public interface MasterObserver {
Set<Address> servers) throws IOException {
}
+ /**
+ * Called before getting region server group info of the passed groupName.
+ * @param ctx the environment to interact with the framework and master
+ * @param groupName name of the group to get RSGroupInfo for
+ */
+ default void preGetRSGroupInfo(final ObserverContext<MasterCoprocessorEnvironment> ctx,
+ final String groupName) throws IOException {
+ }
+
+ /**
+ * Called after getting region server group info of the passed groupName.
+ * @param ctx the environment to interact with the framework and master
+ * @param groupName name of the group to get RSGroupInfo for
+ */
+ default void postGetRSGroupInfo(final ObserverContext<MasterCoprocessorEnvironment> ctx,
+ final String groupName) throws IOException {
+ }
+
+ /**
+ * Called before getting region server group info of the passed tableName.
+ * @param ctx the environment to interact with the framework and master
+ * @param tableName name of the table to get RSGroupInfo for
+ */
+ default void preGetRSGroupInfoOfTable(final ObserverContext<MasterCoprocessorEnvironment> ctx,
+ final TableName tableName) throws IOException {
+ }
+
+ /**
+ * Called after getting region server group info of the passed tableName.
+ * @param ctx the environment to interact with the framework and master
+ * @param tableName name of the table to get RSGroupInfo for
+ */
+ default void postGetRSGroupInfoOfTable(final ObserverContext<MasterCoprocessorEnvironment> ctx,
+ final TableName tableName) throws IOException {
+ }
+
+ /**
+ * Called before listing region server group information.
+ * @param ctx the environment to interact with the framework and master
+ */
+ default void preListRSGroups(final ObserverContext<MasterCoprocessorEnvironment> ctx)
+ throws IOException {
+ }
+
+ /**
+ * Called after listing region server group information.
+ * @param ctx the environment to interact with the framework and master
+ */
+ default void postListRSGroups(final ObserverContext<MasterCoprocessorEnvironment> ctx)
+ throws IOException {
+ }
+
+ /**
+ * Called before getting region server group info of the passed server.
+ * @param ctx the environment to interact with the framework and master
+ * @param server server to get RSGroupInfo for
+ */
+ default void preGetRSGroupInfoOfServer(final ObserverContext<MasterCoprocessorEnvironment> ctx,
+ final Address server) throws IOException {
+ }
+
+ /**
+ * Called after getting region server group info of the passed server.
+ * @param ctx the environment to interact with the framework and master
+ * @param server server to get RSGroupInfo for
+ */
+ default void postGetRSGroupInfoOfServer(final ObserverContext<MasterCoprocessorEnvironment> ctx,
+ final Address server) throws IOException {
+ }
+
/**
* Called before add a replication peer
* @param ctx the environment to interact with the framework and master
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterCoprocessorHost.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterCoprocessorHost.java
index 89c0b8b1349..026eee7c69d 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterCoprocessorHost.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterCoprocessorHost.java
@@ -1568,6 +1568,78 @@ public class MasterCoprocessorHost
});
}
+ public void preGetRSGroupInfo(final String groupName) throws IOException {
+ execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
+ @Override
+ public void call(MasterObserver observer) throws IOException {
+ observer.preGetRSGroupInfo(this, groupName);
+ }
+ });
+ }
+
+ public void postGetRSGroupInfo(final String groupName) throws IOException {
+ execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
+ @Override
+ public void call(MasterObserver observer) throws IOException {
+ observer.postGetRSGroupInfo(this, groupName);
+ }
+ });
+ }
+
+ public void preGetRSGroupInfoOfTable(final TableName tableName) throws IOException {
+ execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
+ @Override
+ public void call(MasterObserver observer) throws IOException {
+ observer.preGetRSGroupInfoOfTable(this, tableName);
+ }
+ });
+ }
+
+ public void postGetRSGroupInfoOfTable(final TableName tableName) throws IOException {
+ execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
+ @Override
+ public void call(MasterObserver observer) throws IOException {
+ observer.postGetRSGroupInfoOfTable(this, tableName);
+ }
+ });
+ }
+
+ public void preListRSGroups() throws IOException {
+ execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
+ @Override
+ public void call(MasterObserver observer) throws IOException {
+ observer.preListRSGroups(this);
+ }
+ });
+ }
+
+ public void postListRSGroups() throws IOException {
+ execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
+ @Override
+ public void call(MasterObserver observer) throws IOException {
+ observer.postListRSGroups(this);
+ }
+ });
+ }
+
+ public void preGetRSGroupInfoOfServer(final Address server) throws IOException {
+ execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
+ @Override
+ public void call(MasterObserver observer) throws IOException {
+ observer.preGetRSGroupInfoOfServer(this, server);
+ }
+ });
+ }
+
+ public void postGetRSGroupInfoOfServer(final Address server) throws IOException {
+ execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
+ @Override
+ public void call(MasterObserver observer) throws IOException {
+ observer.postGetRSGroupInfoOfServer(this, server);
+ }
+ });
+ }
+
public void preUpdateRSGroupConfig(final String groupName,
final Map<String, String> configuration) throws IOException {
execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {