[22/23] hbase git commit: HBASE-17758 [RSGROUP] Add shell command to move servers and tables at the same time (Guangxu Cheng)
http://git-wip-us.apache.org/repos/asf/hbase/blob/56baade3/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminEndpoint.java -- 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 e71470e..ee30e15 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 @@ -68,6 +68,8 @@ import org.apache.hadoop.hbase.protobuf.generated.RSGroupAdminProtos.GetRSGroupI import org.apache.hadoop.hbase.protobuf.generated.RSGroupAdminProtos.GetRSGroupInfoResponse; import org.apache.hadoop.hbase.protobuf.generated.RSGroupAdminProtos.ListRSGroupInfosRequest; import org.apache.hadoop.hbase.protobuf.generated.RSGroupAdminProtos.ListRSGroupInfosResponse; +import org.apache.hadoop.hbase.protobuf.generated.RSGroupAdminProtos.MoveServersAndTablesRequest; +import org.apache.hadoop.hbase.protobuf.generated.RSGroupAdminProtos.MoveServersAndTablesResponse; import org.apache.hadoop.hbase.protobuf.generated.RSGroupAdminProtos.MoveServersRequest; import org.apache.hadoop.hbase.protobuf.generated.RSGroupAdminProtos.MoveServersResponse; import org.apache.hadoop.hbase.protobuf.generated.RSGroupAdminProtos.MoveTablesRequest; @@ -206,6 +208,26 @@ public class RSGroupAdminEndpoint extends RSGroupAdminService } @Override + public void moveServersAndTables(RpcController controller, MoveServersAndTablesRequest request, + RpcCallback done) { +MoveServersAndTablesResponse.Builder builder = MoveServersAndTablesResponse.newBuilder(); +try { + Set hostPorts = Sets.newHashSet(); + for (HBaseProtos.ServerName el : request.getServersList()) { +hostPorts.add(HostAndPort.fromParts(el.getHostName(), el.getPort())); + } + Set tables = new HashSet<>(request.getTableNameList().size()); + for (HBaseProtos.TableName tableName : request.getTableNameList()) { +tables.add(ProtobufUtil.toTableName(tableName)); + } + groupAdminServer.moveServersAndTables(hostPorts, tables, request.getTargetGroup()); +} catch (IOException e) { + ResponseConverter.setControllerException(controller, e); +} +done.run(builder.build()); + } + + @Override public void addRSGroup(RpcController controller, AddRSGroupRequest request, RpcCallback done) { @@ -953,6 +975,16 @@ public class RSGroupAdminEndpoint extends RSGroupAdminService } @Override + public void preMoveServersAndTables(ObserverContext ctx, + Set servers, Set tables, String targetGroup) throws IOException { + } + + @Override + public void postMoveServersAndTables(ObserverContext ctx, + Set servers, Set tables, String targetGroup) throws IOException { + } + + @Override public void preAddRSGroup(ObserverContext ctx, String name) throws IOException { http://git-wip-us.apache.org/repos/asf/hbase/blob/56baade3/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminServer.java -- diff --git a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminServer.java b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminServer.java index 1069ac0..863b71e 100644 --- a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminServer.java +++ b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminServer.java @@ -501,6 +501,19 @@ public class RSGroupAdminServer extends RSGroupAdmin { } @Override + public void moveServersAndTables(Set servers, Set tables, + String targetGroup) throws IOException { +if (servers == null || servers.isEmpty() ) { + throw new ConstraintException("The list of servers to move cannot be null or empty."); +} +if (tables == null || tables.isEmpty()) { + throw new ConstraintException("The list of tables to move cannot be null or empty."); +} +moveServers(servers, targetGroup); +moveTables(tables, targetGroup); + } + + @Override public void close() throws IOException { } } http://git-wip-us.apache.org/repos/asf/hbase/blob/56baade3/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfoManager.java -- diff --git a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfoManager.java b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfoManager.java index 5b5563e..e11cb57 100644 --- a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfoManager.java +++ b/hbase-rsgroup/src/main/java/org/apache/hadoop
[22/23] hbase git commit: HBASE-17758 [RSGROUP] Add shell command to move servers and tables at the same time (Guangxu Cheng)
http://git-wip-us.apache.org/repos/asf/hbase/blob/a1cf043a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminEndpoint.java -- 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 e71470e..ee30e15 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 @@ -68,6 +68,8 @@ import org.apache.hadoop.hbase.protobuf.generated.RSGroupAdminProtos.GetRSGroupI import org.apache.hadoop.hbase.protobuf.generated.RSGroupAdminProtos.GetRSGroupInfoResponse; import org.apache.hadoop.hbase.protobuf.generated.RSGroupAdminProtos.ListRSGroupInfosRequest; import org.apache.hadoop.hbase.protobuf.generated.RSGroupAdminProtos.ListRSGroupInfosResponse; +import org.apache.hadoop.hbase.protobuf.generated.RSGroupAdminProtos.MoveServersAndTablesRequest; +import org.apache.hadoop.hbase.protobuf.generated.RSGroupAdminProtos.MoveServersAndTablesResponse; import org.apache.hadoop.hbase.protobuf.generated.RSGroupAdminProtos.MoveServersRequest; import org.apache.hadoop.hbase.protobuf.generated.RSGroupAdminProtos.MoveServersResponse; import org.apache.hadoop.hbase.protobuf.generated.RSGroupAdminProtos.MoveTablesRequest; @@ -206,6 +208,26 @@ public class RSGroupAdminEndpoint extends RSGroupAdminService } @Override + public void moveServersAndTables(RpcController controller, MoveServersAndTablesRequest request, + RpcCallback done) { +MoveServersAndTablesResponse.Builder builder = MoveServersAndTablesResponse.newBuilder(); +try { + Set hostPorts = Sets.newHashSet(); + for (HBaseProtos.ServerName el : request.getServersList()) { +hostPorts.add(HostAndPort.fromParts(el.getHostName(), el.getPort())); + } + Set tables = new HashSet<>(request.getTableNameList().size()); + for (HBaseProtos.TableName tableName : request.getTableNameList()) { +tables.add(ProtobufUtil.toTableName(tableName)); + } + groupAdminServer.moveServersAndTables(hostPorts, tables, request.getTargetGroup()); +} catch (IOException e) { + ResponseConverter.setControllerException(controller, e); +} +done.run(builder.build()); + } + + @Override public void addRSGroup(RpcController controller, AddRSGroupRequest request, RpcCallback done) { @@ -953,6 +975,16 @@ public class RSGroupAdminEndpoint extends RSGroupAdminService } @Override + public void preMoveServersAndTables(ObserverContext ctx, + Set servers, Set tables, String targetGroup) throws IOException { + } + + @Override + public void postMoveServersAndTables(ObserverContext ctx, + Set servers, Set tables, String targetGroup) throws IOException { + } + + @Override public void preAddRSGroup(ObserverContext ctx, String name) throws IOException { http://git-wip-us.apache.org/repos/asf/hbase/blob/a1cf043a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminServer.java -- diff --git a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminServer.java b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminServer.java index 1069ac0..863b71e 100644 --- a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminServer.java +++ b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminServer.java @@ -501,6 +501,19 @@ public class RSGroupAdminServer extends RSGroupAdmin { } @Override + public void moveServersAndTables(Set servers, Set tables, + String targetGroup) throws IOException { +if (servers == null || servers.isEmpty() ) { + throw new ConstraintException("The list of servers to move cannot be null or empty."); +} +if (tables == null || tables.isEmpty()) { + throw new ConstraintException("The list of tables to move cannot be null or empty."); +} +moveServers(servers, targetGroup); +moveTables(tables, targetGroup); + } + + @Override public void close() throws IOException { } } http://git-wip-us.apache.org/repos/asf/hbase/blob/a1cf043a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfoManager.java -- diff --git a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfoManager.java b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfoManager.java index 5b5563e..e11cb57 100644 --- a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfoManager.java +++ b/hbase-rsgroup/src/main/java/org/apache/hadoop