Skip to content

Commit

Permalink
Revert "HBASE-22664 Move protobuf stuff in hbase-rsgroup to hbase-pro…
Browse files Browse the repository at this point in the history
…tocol-shaded (#362)"

This reverts commit d364364.
  • Loading branch information
Apache9 committed Sep 10, 2019
1 parent c2c9984 commit 4ca760f
Show file tree
Hide file tree
Showing 11 changed files with 108 additions and 254 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1768,36 +1768,23 @@ 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()) {
for(HBaseProtos.ServerName el: proto.getServersList()) {
RSGroupInfo.addServer(Address.fromParts(el.getHostName(), el.getPort()));
}
for (HBaseProtos.TableName pTableName : proto.getTablesList()) {
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());
public static HBaseProtos.TimeRange toTimeRange(TimeRange timeRange) {
if (timeRange == null) {
timeRange = TimeRange.allTime();
}
return RSGroupProtos.RSGroupInfo.newBuilder().setName(pojo.getName()).addAllServers(hostports)
.addAllTables(tables).build();
return HBaseProtos.TimeRange.newBuilder().setFrom(timeRange.getMin())
.setTo(timeRange.getMax())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@
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 @@ -100,7 +99,6 @@
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 @@ -177,7 +175,6 @@
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 @@ -3290,29 +3287,4 @@ public static Set<String> toCompactedStoreFiles(byte[] bytes) throws IOException
}
return Collections.emptySet();
}

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();
}
}
33 changes: 0 additions & 33 deletions hbase-protocol-shaded/src/main/protobuf/RSGroup.proto

This file was deleted.

158 changes: 0 additions & 158 deletions hbase-protocol-shaded/src/main/protobuf/RSGroupAdmin.proto

This file was deleted.

18 changes: 18 additions & 0 deletions hbase-rsgroup/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,24 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<executions>
<execution>
<id>compile-protoc</id>
<phase>generate-sources</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<additionalProtoPathElements>
<additionalProtoPathElement>${basedir}/../hbase-protocol/src/main/protobuf</additionalProtoPathElement>
</additionalProtoPathElements>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
package org.apache.hadoop.hbase.rsgroup;

import com.google.protobuf.ServiceException;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.TableNotFoundException;
import org.apache.hadoop.hbase.client.Admin;
Expand Down Expand Up @@ -68,7 +70,7 @@ public RSGroupInfo getRSGroupInfo(String groupName) throws IOException {
GetRSGroupInfoResponse resp = stub.getRSGroupInfo(null,
GetRSGroupInfoRequest.newBuilder().setRSGroupName(groupName).build());
if(resp.hasRSGroupInfo()) {
return ProtobufUtil.toGroupInfo(resp.getRSGroupInfo());
return RSGroupProtobufUtil.toGroupInfo(resp.getRSGroupInfo());
}
return null;
} catch (ServiceException e) {
Expand All @@ -83,7 +85,7 @@ public RSGroupInfo getRSGroupInfoOfTable(TableName tableName) throws IOException
try {
GetRSGroupInfoOfTableResponse resp = stub.getRSGroupInfoOfTable(null, request);
if (resp.hasRSGroupInfo()) {
return ProtobufUtil.toGroupInfo(resp.getRSGroupInfo());
return RSGroupProtobufUtil.toGroupInfo(resp.getRSGroupInfo());
}
return null;
} catch (ServiceException e) {
Expand Down Expand Up @@ -165,7 +167,7 @@ public List<RSGroupInfo> listRSGroups() throws IOException {
ListRSGroupInfosRequest.getDefaultInstance()).getRSGroupInfoList();
List<RSGroupInfo> result = new ArrayList<>(resp.size());
for(RSGroupProtos.RSGroupInfo entry : resp) {
result.add(ProtobufUtil.toGroupInfo(entry));
result.add(RSGroupProtobufUtil.toGroupInfo(entry));
}
return result;
} catch (ServiceException e) {
Expand All @@ -184,7 +186,7 @@ public RSGroupInfo getRSGroupOfServer(Address hostPort) throws IOException {
try {
GetRSGroupInfoOfServerResponse resp = stub.getRSGroupInfoOfServer(null, request);
if (resp.hasRSGroupInfo()) {
return ProtobufUtil.toGroupInfo(resp.getRSGroupInfo());
return RSGroupProtobufUtil.toGroupInfo(resp.getRSGroupInfo());
}
return null;
} catch (ServiceException e) {
Expand Down
Loading

0 comments on commit 4ca760f

Please sign in to comment.