Skip to content

Commit 2e9d63c

Browse files
ReiddddddthangTang
authored andcommitted
HBASE-24112 [RSGroup] Support renaming rsgroup (apache#1435)
Signed-off-by: Duo Zhang <zhangduo@apache.org>
1 parent e468e7b commit 2e9d63c

18 files changed

Lines changed: 241 additions & 4 deletions

File tree

hbase-client/src/main/java/org/apache/hadoop/hbase/client/Admin.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2396,4 +2396,13 @@ Pair<List<String>, List<TableName>> getConfiguredNamespacesAndTablesInRSGroup(St
23962396
* @throws IOException if a remote or network exception occurs
23972397
*/
23982398
boolean balanceRSGroup(String groupName) throws IOException;
2399+
2400+
/**
2401+
* Rename rsgroup
2402+
* @param oldName old rsgroup name
2403+
* @param newName new rsgroup name
2404+
* @throws IOException if a remote or network exception occurs
2405+
*/
2406+
void renameRSGroup(String oldName, String newName) throws IOException;
2407+
23992408
}

hbase-client/src/main/java/org/apache/hadoop/hbase/client/AdminOverAsyncAdmin.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,4 +1036,9 @@ public RSGroupInfo getRSGroup(TableName tableName) throws IOException {
10361036
public void setRSGroup(Set<TableName> tables, String groupName) throws IOException {
10371037
get(admin.setRSGroup(tables, groupName));
10381038
}
1039+
1040+
@Override
1041+
public void renameRSGroup(String oldName, String newName) throws IOException {
1042+
get(admin.renameRSGroup(oldName, newName));
1043+
}
10391044
}

hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncAdmin.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1631,4 +1631,12 @@ CompletableFuture<List<OnlineLogRecord>> getSlowLogResponses(final Set<ServerNam
16311631
* @throws IOException if a remote or network exception occurs
16321632
*/
16331633
CompletableFuture<Boolean> balanceRSGroup(String groupName);
1634+
1635+
/**
1636+
* Rename rsgroup
1637+
* @param oldName old rsgroup name
1638+
* @param newName new rsgroup name
1639+
* @throws IOException if a remote or network exception occurs
1640+
*/
1641+
CompletableFuture<Void> renameRSGroup(String oldName, String newName);
16341642
}

hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncHBaseAdmin.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,4 +913,9 @@ public CompletableFuture<RSGroupInfo> getRSGroup(TableName tableName) {
913913
public CompletableFuture<Void> setRSGroup(Set<TableName> tables, String groupName) {
914914
return wrap(rawAdmin.setRSGroup(tables, groupName));
915915
}
916+
917+
@Override
918+
public CompletableFuture<Void> renameRSGroup(String oldName, String newName) {
919+
return wrap(rawAdmin.renameRSGroup(oldName, newName));
920+
}
916921
}

hbase-client/src/main/java/org/apache/hadoop/hbase/client/RawAsyncHBaseAdmin.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,8 @@
309309
import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.RemoveRSGroupResponse;
310310
import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.RemoveServersRequest;
311311
import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.RemoveServersResponse;
312+
import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.RenameRSGroupRequest;
313+
import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.RenameRSGroupResponse;
312314
import org.apache.hadoop.hbase.shaded.protobuf.generated.ReplicationProtos.AddReplicationPeerRequest;
313315
import org.apache.hadoop.hbase.shaded.protobuf.generated.ReplicationProtos.AddReplicationPeerResponse;
314316
import org.apache.hadoop.hbase.shaded.protobuf.generated.ReplicationProtos.DisableReplicationPeerRequest;
@@ -4146,4 +4148,21 @@ public CompletableFuture<RSGroupInfo> getRSGroup(String groupName) {
41464148
resp -> resp.hasRSGroupInfo() ? ProtobufUtil.toGroupInfo(resp.getRSGroupInfo()) : null)))
41474149
.call();
41484150
}
4151+
4152+
@Override
4153+
public CompletableFuture<Void> renameRSGroup(String oldName, String newName) {
4154+
return this.<Void> newMasterCaller()
4155+
.action(
4156+
(
4157+
(controller, stub) -> this.<RenameRSGroupRequest, RenameRSGroupResponse, Void> call(
4158+
controller,
4159+
stub,
4160+
RenameRSGroupRequest.newBuilder().setOldRsgroupName(oldName).setNewRsgroupName(newName)
4161+
.build(),
4162+
(s, c, req, done) -> s.renameRSGroup(c, req, done),
4163+
resp -> null
4164+
)
4165+
)
4166+
).call();
4167+
}
41494168
}

hbase-common/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfo.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public class RSGroupInfo {
3838
// Keep servers in a sorted set so has an expected ordering when displayed.
3939
private final SortedSet<Address> servers;
4040
// Keep tables sorted too.
41+
4142
/**
4243
* @deprecated Since 3.0.0, will be removed in 4.0.0. The rsgroup information will be stored in
4344
* the configuration of a table so this will be removed.

hbase-protocol-shaded/src/main/protobuf/server/master/Master.proto

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,6 +1119,9 @@ service MasterService {
11191119

11201120
rpc GetConfiguredNamespacesAndTablesInRSGroup(GetConfiguredNamespacesAndTablesInRSGroupRequest)
11211121
returns (GetConfiguredNamespacesAndTablesInRSGroupResponse);
1122+
1123+
rpc RenameRSGroup(RenameRSGroupRequest)
1124+
returns (RenameRSGroupResponse);
11221125
}
11231126

11241127
// HBCK Service definitions.

hbase-protocol-shaded/src/main/protobuf/server/rsgroup/RSGroupAdmin.proto

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,14 @@ message GetConfiguredNamespacesAndTablesInRSGroupResponse {
139139
repeated TableName table_name = 2;
140140
}
141141

142+
message RenameRSGroupRequest {
143+
required string old_rsgroup_name = 1;
144+
required string new_rsgroup_name = 2;
145+
}
146+
147+
message RenameRSGroupResponse {
148+
}
149+
142150
service RSGroupAdminService {
143151
rpc GetRSGroupInfo(GetRSGroupInfoRequest)
144152
returns (GetRSGroupInfoResponse);
@@ -172,4 +180,7 @@ service RSGroupAdminService {
172180

173181
rpc RemoveServers(RemoveServersRequest)
174182
returns (RemoveServersResponse);
183+
184+
rpc RenameRSGroup(RenameRSGroupRequest)
185+
returns (RenameRSGroupResponse);
175186
}

hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/MasterObserver.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,6 +1340,24 @@ default void preListTablesInRSGroup(final ObserverContext<MasterCoprocessorEnvir
13401340
default void postListTablesInRSGroup(final ObserverContext<MasterCoprocessorEnvironment> ctx,
13411341
final String groupName) throws IOException {}
13421342

1343+
/**
1344+
* Called before rename rsgroup.
1345+
* @param ctx the environment to interact with the framework and master
1346+
* @param oldName old rsgroup name
1347+
* @param newName new rsgroup name
1348+
*/
1349+
default void preRenameRSGroup(final ObserverContext<MasterCoprocessorEnvironment> ctx,
1350+
final String oldName, final String newName) throws IOException {}
1351+
1352+
/**
1353+
* Called after rename rsgroup.
1354+
* @param ctx the environment to interact with the framework and master
1355+
* @param oldName old rsgroup name
1356+
* @param newName new rsgroup name
1357+
*/
1358+
default void postRenameRSGroup(final ObserverContext<MasterCoprocessorEnvironment> ctx,
1359+
final String oldName, final String newName) throws IOException {}
1360+
13431361
/**
13441362
* Called before getting the configured namespaces and tables in the region server group.
13451363
* @param ctx the environment to interact with the framework and master

hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterCoprocessorHost.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,6 +1542,26 @@ protected void call(MasterObserver observer) throws IOException {
15421542
});
15431543
}
15441544

1545+
public void preRenameRSGroup(final String oldName, final String newName) throws IOException {
1546+
execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1547+
1548+
@Override
1549+
protected void call(MasterObserver observer) throws IOException {
1550+
observer.preRenameRSGroup(this, oldName, newName);
1551+
}
1552+
});
1553+
}
1554+
1555+
public void postRenameRSGroup(final String oldName, final String newName) throws IOException {
1556+
execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1557+
1558+
@Override
1559+
protected void call(MasterObserver observer) throws IOException {
1560+
observer.postRenameRSGroup(this, oldName, newName);
1561+
}
1562+
});
1563+
}
1564+
15451565
public void preGetConfiguredNamespacesAndTablesInRSGroup(final String groupName)
15461566
throws IOException {
15471567
execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {

0 commit comments

Comments
 (0)