/** * Convert a protobuf ClusterStatus to a ClusterStatus * * @param proto the protobuf ClusterStatus * @return the converted ClusterStatus */ public static ClusterStatus convert(ClusterStatusProtos.ClusterStatus proto) { Map<ServerName, ServerLoad> servers = new HashMap<ServerName, ServerLoad>(); for (LiveServerInfo lsi : proto.getLiveServersList()) { servers.put(ProtobufUtil.toServerName(lsi.getServer()), new ServerLoad(lsi.getServerLoad())); } Collection<ServerName> deadServers = new LinkedList<ServerName>(); for (HBaseProtos.ServerName sn : proto.getDeadServersList()) { deadServers.add(ProtobufUtil.toServerName(sn)); } Collection<ServerName> backupMasters = new LinkedList<ServerName>(); for (HBaseProtos.ServerName sn : proto.getBackupMastersList()) { backupMasters.add(ProtobufUtil.toServerName(sn)); } final Map<String, RegionState> rit = new HashMap<String, RegionState>(); for (RegionInTransition region : proto.getRegionsInTransitionList()) { String key = new String(region.getSpec().getValue().toByteArray()); RegionState value = RegionState.convert(region.getRegionState()); rit.put(key, value); } final int numMasterCoprocessors = proto.getMasterCoprocessorsCount(); final String[] masterCoprocessors = new String[numMasterCoprocessors]; for (int i = 0; i < numMasterCoprocessors; i++) { masterCoprocessors[i] = proto.getMasterCoprocessors(i).getName(); } return new ClusterStatus( proto.getHbaseVersion().getVersion(), ClusterId.convert(proto.getClusterId()).toString(), servers, deadServers, ProtobufUtil.toServerName(proto.getMaster()), backupMasters, rit, masterCoprocessors, proto.getBalancerOn()); }