String ip = netAddress.get(0);
String port = netAddress.get(1);
String[] cmd = { "/bin/bash", "-c", String.format(CMD_STAT, ip, port) };
String cmdresult = collector(cmd);
String[] result = cmdresult.split(WRAP);
AutoKeeperServerStat summary = new AutoKeeperServerStat();
summary.setOriginalContent(cmdresult);
for (String line : result) {
if (line.contains(MODE_FOLLOWER)) {
summary.setQuorumType(AutoKeeperQuorumType.FOLLOWER);
} else if (line.contains(MODE_LEADERER)) {
summary.setQuorumType(AutoKeeperQuorumType.LEADER);
} else if (line.contains(MODE_STANDALONE)) {
summary.setQuorumType(AutoKeeperQuorumType.STANDALONE);
} else if (line.contains(MODE_OBSERVER)) {
summary.setQuorumType(AutoKeeperQuorumType.OBSERVER);
} else if (line.contains(STRING_LATENCY)) {
List<String> latency = Arrays.asList(StringUtils.trimToEmpty(line.replace(STRING_LATENCY,
StringUtils.EMPTY)).split("/"));
summary.setMinLatency(Long.parseLong(latency.get(0)));
summary.setAvgLatency(Long.parseLong(latency.get(1)));
summary.setMaxLatency(Long.parseLong(latency.get(2)));
} else if (line.contains(STRING_OUTSTANDING)) {
summary.setQueued(Long.parseLong(StringUtils.trimToEmpty(line.replace(STRING_OUTSTANDING,
StringUtils.EMPTY))));
} else if (line.contains(NODE_COUNT)) {
summary.setNodeCount(Long.parseLong(StringUtils.trimToEmpty(line.replace(NODE_COUNT, StringUtils.EMPTY))));
} else if (line.contains(STRING_SENT)) {
summary.setSent(Long.parseLong(StringUtils.trimToEmpty(line.replace(STRING_SENT, StringUtils.EMPTY))));
} else if (line.contains(STRING_RECEIVED)) {
summary.setRecved(Long.parseLong(StringUtils.trimToEmpty(line.replace(STRING_RECEIVED,
StringUtils.EMPTY))));
}
}
autoKeeperData.joinServer(address, summary);