HBASE-25718 Backport "HBASE-25705 Convert proto to RSGroupInfo is costly" (#3109)

Signed-off-by: Pankaj Kumar <pankajkumar@apache.org>
This commit is contained in:
mokai 2021-05-28 19:23:25 +08:00 committed by GitHub
parent 1e01c94ba3
commit b4e8b91414
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 8 deletions

View File

@ -35,10 +35,12 @@ import java.lang.reflect.Method;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.NavigableSet;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.Cell.Type;
@ -1777,14 +1779,17 @@ public final class ProtobufUtil {
}
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(TableProtos.TableName pTableName: proto.getTablesList()) {
RSGroupInfo.addTable(ProtobufUtil.toTableName(pTableName));
}
return RSGroupInfo;
RSGroupInfo rsGroupInfo = new RSGroupInfo(proto.getName());
Collection<Address> addresses = proto.getServersList().parallelStream()
.map(serverName -> Address.fromParts(serverName.getHostName(), serverName.getPort()))
.collect(Collectors.toList());
rsGroupInfo.addAllServers(addresses);
Collection<TableName> tables = proto.getTablesList().parallelStream()
.map(ProtobufUtil::toTableName).collect(Collectors.toList());
rsGroupInfo.addAllTables(tables);
return rsGroupInfo;
}
public static HBaseProtos.TimeRange toTimeRange(TimeRange timeRange) {