use of com.alibaba.otter.shared.common.model.autokeeper.AutoKeeperServerStat in project otter by alibaba.
the class AutoKeeperCollector method collectorServerStat.
public void collectorServerStat(String address) {
List<String> netAddress = splitAddress(address);
if (netAddress.isEmpty()) {
return;
}
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);
}
use of com.alibaba.otter.shared.common.model.autokeeper.AutoKeeperServerStat in project otter by alibaba.
the class AutoKeeperClientPath method execute.
public void execute(@Param("clusterId") String clusterId, @Param("address") String address, Context context) throws Exception {
AutoKeeperCluster autoKeeperCluster = autoKeeperClusterService.findAutoKeeperClusterById(Long.valueOf(clusterId));
Set<AutoKeeperConnectionStat> autoKeeperConnectionStats = new HashSet<AutoKeeperConnectionStat>();
for (String ipAddress : autoKeeperCluster.getServerList()) {
if (ipAddress.equalsIgnoreCase(address)) {
AutoKeeperServerStat autoKeeperServerStat = autoKeeperStatService.findServerStat(ipAddress);
if (autoKeeperServerStat != null) {
autoKeeperConnectionStats = autoKeeperServerStat.getConnectionStats();
} else {
autoKeeperConnectionStats = new HashSet<AutoKeeperConnectionStat>();
}
}
}
context.put("autoKeeperConnectionStats", autoKeeperConnectionStats);
}
use of com.alibaba.otter.shared.common.model.autokeeper.AutoKeeperServerStat in project otter by alibaba.
the class AutoKeeperCollectorTest method testCollectorServerStat.
@Test
public void testCollectorServerStat() {
autoKeeperCollector.collectorServerStat(ADDRESS);
autoKeeperCollector.collectorConnectionStat(ADDRESS);
autoKeeperCollector.collectorWatchStat(ADDRESS);
autoKeeperCollector.collectorEphemeralStat(ADDRESS);
AutoKeeperServerStat stat = autoKeeperStatService.findServerStat(ADDRESS);
Set<AutoKeeperConnectionStat> conns = stat.getConnectionStats();
for (AutoKeeperConnectionStat autoKeeperConnectionStat : conns) {
autoKeeperStatService.findConnectionBySessionId(autoKeeperConnectionStat.getSessionId());
autoKeeperStatService.findServerStatBySessionId(autoKeeperConnectionStat.getSessionId());
String path = autoKeeperConnectionStat.getClientAddress();
System.out.println(path);
}
}
use of com.alibaba.otter.shared.common.model.autokeeper.AutoKeeperServerStat in project otter by alibaba.
the class AutoKeeperClustersDetail method execute.
public void execute(@Param("clusterId") String clusterId, Context context) throws Exception {
Map<String, AutoKeeperServerStat> statMap = new HashMap<String, AutoKeeperServerStat>();
AutoKeeperCluster autoKeeperCluster = autoKeeperClusterService.findAutoKeeperClusterById(Long.valueOf(clusterId));
for (String address : autoKeeperCluster.getServerList()) {
AutoKeeperServerStat autoKeeperServerStat = autoKeeperStatService.findServerStat(address);
statMap.put(address, autoKeeperServerStat);
}
context.put("clusterId", clusterId);
context.put("statMap", statMap);
}
Aggregations