use of org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.FavoredNodes in project hbase by apache.
the class FavoredNodeAssignmentHelper method getFavoredNodesList.
/**
* @param favoredNodes The PB'ed bytes of favored nodes
* @return the array of {@link ServerName} for the byte array of favored nodes.
* @throws IOException
*/
public static ServerName[] getFavoredNodesList(byte[] favoredNodes) throws IOException {
FavoredNodes f = FavoredNodes.parseFrom(favoredNodes);
List<HBaseProtos.ServerName> protoNodes = f.getFavoredNodeList();
ServerName[] servers = new ServerName[protoNodes.size()];
int i = 0;
for (HBaseProtos.ServerName node : protoNodes) {
servers[i++] = ProtobufUtil.toServerName(node);
}
return servers;
}
use of org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.FavoredNodes in project hbase by apache.
the class FavoredNodeAssignmentHelper method getFavoredNodes.
/**
* @param serverAddrList
* @return PB'ed bytes of {@link FavoredNodes} generated by the server list.
*/
public static byte[] getFavoredNodes(List<ServerName> serverAddrList) {
FavoredNodes.Builder f = FavoredNodes.newBuilder();
for (ServerName s : serverAddrList) {
HBaseProtos.ServerName.Builder b = HBaseProtos.ServerName.newBuilder();
b.setHostName(s.getHostname());
b.setPort(s.getPort());
b.setStartCode(ServerName.NON_STARTCODE);
f.addFavoredNode(b.build());
}
return f.build().toByteArray();
}
Aggregations