Skip to content

Commit

Permalink
HBASE-22664 Move protobuf stuff in hbase-rsgroup to hbase-protocol-sh…
Browse files Browse the repository at this point in the history
…aded (apache#362)

Signed-off-by: Guanghao Zhang <[email protected]>

(cherry picked from commit d364364)
  • Loading branch information
孙鑫 authored and 张洸豪 committed Jun 10, 2020
1 parent c18cb4b commit aaf6823
Show file tree
Hide file tree
Showing 45 changed files with 909 additions and 1,210 deletions.
16 changes: 0 additions & 16 deletions hbase-assembly/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -333,20 +333,4 @@
<type>pom</type>
</dependency>
</dependencies>
<profiles>
<profile>
<id>rsgroup</id>
<activation>
<property>
<name>!skip-rsgroup</name>
</property>
</activation>
<dependencies>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-rsgroup</artifactId>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
8 changes: 0 additions & 8 deletions hbase-assembly/src/main/assembly/components.xml
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,6 @@
</includes>
<fileMode>0644</fileMode>
</fileSet>
<fileSet>
<directory>${project.basedir}/../hbase-rsgroup/target/</directory>
<outputDirectory>lib</outputDirectory>
<includes>
<include>${rsgroup.test.jar}</include>
</includes>
<fileMode>0644</fileMode>
</fileSet>
<fileSet>
<directory>${project.basedir}/../hbase-mapreduce/target/</directory>
<outputDirectory>lib</outputDirectory>
Expand Down
1 change: 0 additions & 1 deletion hbase-assembly/src/main/assembly/hadoop-two-compat.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
<include>org.apache.hbase:hbase-protocol-shaded</include>
<include>org.apache.hbase:hbase-replication</include>
<include>org.apache.hbase:hbase-rest</include>
<include>org.apache.hbase:hbase-rsgroup</include>
<include>org.apache.hbase:hbase-server</include>
<include>org.apache.hbase:hbase-shell</include>
<include>org.apache.hbase:hbase-testing-util</include>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
import org.apache.hadoop.hbase.protobuf.generated.MapReduceProtos;
import org.apache.hadoop.hbase.protobuf.generated.TableProtos;
import org.apache.hadoop.hbase.protobuf.generated.RSGroupProtos;
import org.apache.hadoop.hbase.protobuf.generated.TableProtos;
import org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos;
import org.apache.hadoop.hbase.rsgroup.RSGroupInfo;
import org.apache.hadoop.hbase.util.Addressing;
Expand Down Expand Up @@ -1775,6 +1776,14 @@ public static ServerName toServerName(final byte [] data) throws Deserialization
return ServerName.valueOf(hostname, port, -1L);
}

public static HBaseProtos.TimeRange toTimeRange(TimeRange timeRange) {
if (timeRange == null) {
timeRange = TimeRange.allTime();
}
return HBaseProtos.TimeRange.newBuilder().setFrom(timeRange.getMin()).setTo(timeRange.getMax())
.build();
}

public static RSGroupInfo toGroupInfo(RSGroupProtos.RSGroupInfo proto) {
RSGroupInfo RSGroupInfo = new RSGroupInfo(proto.getName());
for(HBaseProtos.ServerName el: proto.getServersList()) {
Expand All @@ -1786,13 +1795,18 @@ public static RSGroupInfo toGroupInfo(RSGroupProtos.RSGroupInfo proto) {
return RSGroupInfo;
}

public static HBaseProtos.TimeRange toTimeRange(TimeRange timeRange) {
if (timeRange == null) {
timeRange = TimeRange.allTime();
public static RSGroupProtos.RSGroupInfo toProtoGroupInfo(RSGroupInfo pojo) {
List<TableProtos.TableName> tables = new ArrayList<>(pojo.getTables().size());
for (TableName arg : pojo.getTables()) {
tables.add(ProtobufUtil.toProtoTableName(arg));
}
List<HBaseProtos.ServerName> hostports = new ArrayList<>(pojo.getServers().size());
for (Address el : pojo.getServers()) {
hostports.add(HBaseProtos.ServerName.newBuilder().setHostName(el.getHostname())
.setPort(el.getPort()).build());
}
return HBaseProtos.TimeRange.newBuilder().setFrom(timeRange.getMin())
.setTo(timeRange.getMax())
.build();
return RSGroupProtos.RSGroupInfo.newBuilder().setName(pojo.getName()).addAllServers(hostports)
.addAllTables(tables).build();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import java.util.regex.Pattern;
import java.util.stream.Collectors;

import org.apache.commons.io.input.BoundedInputStream;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.ByteBufferExtendedCell;
Expand Down Expand Up @@ -94,6 +93,7 @@
import org.apache.hadoop.hbase.filter.ByteArrayComparable;
import org.apache.hadoop.hbase.filter.Filter;
import org.apache.hadoop.hbase.io.TimeRange;
import org.apache.hadoop.hbase.net.Address;
import org.apache.hadoop.hbase.protobuf.ProtobufMagic;
import org.apache.hadoop.hbase.protobuf.ProtobufMessageConverter;
import org.apache.hadoop.hbase.quotas.QuotaScope;
Expand All @@ -102,6 +102,7 @@
import org.apache.hadoop.hbase.quotas.ThrottleType;
import org.apache.hadoop.hbase.replication.ReplicationLoadSink;
import org.apache.hadoop.hbase.replication.ReplicationLoadSource;
import org.apache.hadoop.hbase.rsgroup.RSGroupInfo;
import org.apache.hadoop.hbase.security.visibility.Authorizations;
import org.apache.hadoop.hbase.security.visibility.CellVisibility;
import org.apache.hadoop.hbase.util.Addressing;
Expand Down Expand Up @@ -178,6 +179,7 @@
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.MajorCompactionTimestampResponse;
import org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos;
import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos;
import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupProtos;
import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionServerReportRequest;
import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionServerStartupRequest;
import org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos;
Expand Down Expand Up @@ -3392,4 +3394,29 @@ public static RegionStatesCount toTableRegionStatesCount(
.build();
}


public static RSGroupInfo toGroupInfo(RSGroupProtos.RSGroupInfo proto) {
RSGroupInfo RSGroupInfo = new RSGroupInfo(proto.getName());
for (HBaseProtos.ServerName el : proto.getServersList()) {
RSGroupInfo.addServer(Address.fromParts(el.getHostName(), el.getPort()));
}
for (HBaseProtos.TableName pTableName : proto.getTablesList()) {
RSGroupInfo.addTable(ProtobufUtil.toTableName(pTableName));
}
return RSGroupInfo;
}

public static RSGroupProtos.RSGroupInfo toProtoGroupInfo(RSGroupInfo pojo) {
List<HBaseProtos.TableName> tables = new ArrayList<>(pojo.getTables().size());
for (TableName arg : pojo.getTables()) {
tables.add(ProtobufUtil.toProtoTableName(arg));
}
List<HBaseProtos.ServerName> hostports = new ArrayList<>(pojo.getServers().size());
for (Address el : pojo.getServers()) {
hostports.add(HBaseProtos.ServerName.newBuilder().setHostName(el.getHostname())
.setPort(el.getPort()).build());
}
return RSGroupProtos.RSGroupInfo.newBuilder().setName(pojo.getName()).addAllServers(hostports)
.addAllTables(tables).build();
}
}
10 changes: 0 additions & 10 deletions hbase-it/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -181,16 +181,6 @@
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-rsgroup</artifactId>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-rsgroup</artifactId>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-server</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
/**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
Expand All @@ -19,14 +15,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<configuration>
<property>
<name>hbase.defaults.for.version.skip</name>
<value>true</value>
</property>
<property>
<name>hbase.hconnection.threads.keepalivetime</name>
<value>3</value>
</property>
</configuration>

package hbase.pb;

option java_package = "org.apache.hadoop.hbase.shaded.protobuf.generated";
option java_outer_classname = "RSGroupProtos";
option java_generic_services = true;
option java_generate_equals_and_hash = true;
option optimize_for = SPEED;

import "HBase.proto";

message RSGroupInfo {
required string name = 1;
repeated ServerName servers = 4;
repeated TableName tables = 3;
}
158 changes: 158 additions & 0 deletions hbase-protocol-shaded/src/main/protobuf/RSGroupAdmin.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package hbase.pb;

option java_package = "org.apache.hadoop.hbase.shaded.protobuf.generated";
option java_outer_classname = "RSGroupAdminProtos";
option java_generic_services = true;
option java_generate_equals_and_hash = true;
option optimize_for = SPEED;

import "HBase.proto";
import "RSGroup.proto";

/** Group level protobufs */

message ListTablesOfRSGroupRequest {
required string r_s_group_name = 1;
}

message ListTablesOfRSGroupResponse {
repeated TableName table_name = 1;
}

message GetRSGroupInfoRequest {
required string r_s_group_name = 1;
}

message GetRSGroupInfoResponse {
optional RSGroupInfo r_s_group_info = 1;
}

message GetRSGroupInfoOfTableRequest {
required TableName table_name = 1;
}

message GetRSGroupInfoOfTableResponse {
optional RSGroupInfo r_s_group_info = 1;
}

message MoveServersRequest {
required string target_group = 1;
repeated ServerName servers = 3;
}

message MoveServersResponse {
}

message MoveTablesRequest {
required string target_group = 1;
repeated TableName table_name = 2;
}

message MoveTablesResponse {
}

message AddRSGroupRequest {
required string r_s_group_name = 1;
}

message AddRSGroupResponse {
}

message RemoveRSGroupRequest {
required string r_s_group_name = 1;
}

message RemoveRSGroupResponse {
}

message BalanceRSGroupRequest {
required string r_s_group_name = 1;
}

message BalanceRSGroupResponse {
required bool balanceRan = 1;
}

message ListRSGroupInfosRequest {
}

message ListRSGroupInfosResponse {
repeated RSGroupInfo r_s_group_info = 1;
}

message GetRSGroupInfoOfServerRequest {
required ServerName server = 2;
}

message GetRSGroupInfoOfServerResponse {
optional RSGroupInfo r_s_group_info = 1;
}

message MoveServersAndTablesRequest {
required string target_group = 1;
repeated ServerName servers = 2;
repeated TableName table_name = 3;
}

message MoveServersAndTablesResponse {
}

message RemoveServersRequest {
repeated ServerName servers = 1;
}

message RemoveServersResponse {
}

service RSGroupAdminService {
rpc GetRSGroupInfo(GetRSGroupInfoRequest)
returns (GetRSGroupInfoResponse);

rpc GetRSGroupInfoOfTable(GetRSGroupInfoOfTableRequest)
returns (GetRSGroupInfoOfTableResponse);

rpc GetRSGroupInfoOfServer(GetRSGroupInfoOfServerRequest)
returns (GetRSGroupInfoOfServerResponse);

rpc MoveServers(MoveServersRequest)
returns (MoveServersResponse);

rpc MoveTables(MoveTablesRequest)
returns (MoveTablesResponse);

rpc AddRSGroup(AddRSGroupRequest)
returns (AddRSGroupResponse);

rpc RemoveRSGroup(RemoveRSGroupRequest)
returns (RemoveRSGroupResponse);

rpc BalanceRSGroup(BalanceRSGroupRequest)
returns (BalanceRSGroupResponse);

rpc ListRSGroupInfos(ListRSGroupInfosRequest)
returns (ListRSGroupInfosResponse);

rpc MoveServersAndTables(MoveServersAndTablesRequest)
returns (MoveServersAndTablesResponse);

rpc RemoveServers(RemoveServersRequest)
returns (RemoveServersResponse);
}
13 changes: 0 additions & 13 deletions hbase-rsgroup/README.txt

This file was deleted.

Loading

0 comments on commit aaf6823

Please sign in to comment.