HBASE-25705 Convert proto to RSGroupInfo is costly (#3102)

Signed-off-by: stack <stack@apache.org>
This commit is contained in:
mokai 2021-03-30 02:59:04 +08:00 committed by GitHub
parent 05dddafc37
commit 60dde9a433
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 6 deletions

View File

@ -29,6 +29,7 @@ import java.nio.ByteBuffer;
import java.security.AccessController; import java.security.AccessController;
import java.security.PrivilegedAction; import java.security.PrivilegedAction;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -3611,12 +3612,16 @@ public final class ProtobufUtil {
public static RSGroupInfo toGroupInfo(RSGroupProtos.RSGroupInfo proto) { public static RSGroupInfo toGroupInfo(RSGroupProtos.RSGroupInfo proto) {
RSGroupInfo rsGroupInfo = new RSGroupInfo(proto.getName()); RSGroupInfo rsGroupInfo = new RSGroupInfo(proto.getName());
for (HBaseProtos.ServerName el : proto.getServersList()) {
rsGroupInfo.addServer(Address.fromParts(el.getHostName(), el.getPort())); Collection<Address> addresses = proto.getServersList().parallelStream()
} .map(serverName -> Address.fromParts(serverName.getHostName(), serverName.getPort()))
for (HBaseProtos.TableName pTableName : proto.getTablesList()) { .collect(Collectors.toList());
rsGroupInfo.addTable(ProtobufUtil.toTableName(pTableName)); rsGroupInfo.addAllServers(addresses);
}
Collection<TableName> tables = proto.getTablesList().parallelStream()
.map(ProtobufUtil::toTableName).collect(Collectors.toList());
rsGroupInfo.addAllTables(tables);
proto.getConfigurationList().forEach(pair -> proto.getConfigurationList().forEach(pair ->
rsGroupInfo.setConfiguration(pair.getName(), pair.getValue())); rsGroupInfo.setConfiguration(pair.getName(), pair.getValue()));
return rsGroupInfo; return rsGroupInfo;