public AClusterStatus getClusterStatus() throws AIOError { try { return AvroUtil.csToACS(admin.getClusterStatus()); } catch (IOException e) { AIOError ioe = new AIOError(); ioe.message = new Utf8(e.getMessage()); throw ioe; } }
static public AClusterStatus csToACS(ClusterStatus cs) throws IOException { AClusterStatus acs = new AClusterStatus(); acs.averageLoad = cs.getAverageLoad(); Collection<ServerName> deadServerNames = cs.getDeadServerNames(); Schema stringArraySchema = Schema.createArray(Schema.create(Schema.Type.STRING)); GenericData.Array<CharSequence> adeadServerNames = null; if (deadServerNames != null) { adeadServerNames = new GenericData.Array<CharSequence>(deadServerNames.size(), stringArraySchema); for (ServerName deadServerName : deadServerNames) { adeadServerNames.add(new Utf8(deadServerName.toString())); } } else { adeadServerNames = new GenericData.Array<CharSequence>(0, stringArraySchema); } acs.deadServerNames = adeadServerNames; acs.deadServers = cs.getDeadServers(); acs.hbaseVersion = new Utf8(cs.getHBaseVersion()); acs.regionsCount = cs.getRegionsCount(); acs.requestsCount = cs.getRequestsCount(); Collection<ServerName> hserverInfos = cs.getServers(); Schema s = Schema.createArray(AServerInfo.SCHEMA$); GenericData.Array<AServerInfo> aserverInfos = null; if (hserverInfos != null) { aserverInfos = new GenericData.Array<AServerInfo>(hserverInfos.size(), s); for (ServerName hsi : hserverInfos) { aserverInfos.add(hsiToASI(hsi, cs.getLoad(hsi))); } } else { aserverInfos = new GenericData.Array<AServerInfo>(0, s); } acs.serverInfos = aserverInfos; acs.servers = cs.getServers().size(); return acs; }