Search in sources :

Example 1 with FavoredNodes

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;
}
Also used : FavoredNodes(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.FavoredNodes) ServerName(org.apache.hadoop.hbase.ServerName) HBaseProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos)

Example 2 with FavoredNodes

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();
}
Also used : FavoredNodes(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.FavoredNodes) ServerName(org.apache.hadoop.hbase.ServerName)

Aggregations

ServerName (org.apache.hadoop.hbase.ServerName)2 FavoredNodes (org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.FavoredNodes)2 HBaseProtos (org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos)1