if (demo) {
GaugesUtils gaugesUtils = new GaugesUtils();
StringBuilder result = new StringBuilder();
int[] maxOps = {8, 2, 4, 5, 1, 6};
String formatString = "<level%d name=\"%s\" meta1=\"%s\" meta2=\"%s\" meta3=\"%s\" meta4=\"%s\" meta5=\"%s\" meta6=\"%s\"";
Data data = gaugesUtils.generateRandomData(1000);
result.append(String.format(formatString, 0, "http://127.0.0.1:RND", data.getReqCount(), data
.getResCount(), data.getFaultCount(), data.getAvgTime(), data.getMinTime(), data.getMaxTime()));
result.append(">\n");
for (int i = 0; i < 6; i++) {
data = gaugesUtils.generateRandomData(250);
result.append(String.format(formatString, 1, String.format("Service %d", i), data
.getReqCount(), data.getResCount(), data.getFaultCount(), data.getAvgTime(), data
.getMinTime(), data.getMaxTime()));
result.append(">\n");
for (int j = 0; j < maxOps[i]; j++) {
data = gaugesUtils.generateRandomData(50);
result.append(String.format(formatString, 2, String.format("Operation %d", j),
(j % 2 == 0) ? "0" : data.getReqCount(), data.getResCount(),
data.getFaultCount(), data.getAvgTime(), data.getMinTime(), data.getMaxTime()));
result
.append(String.format(" count=\"%s\"/>\n", (j % 2 == 0) ? "0" : data
.getReqCount()));
}
result.append("</level1>\n");
}
result.append("</level0>\n");
return result.toString();
}
StringBuilder result = new StringBuilder();
String serverURL = "";
if (bamListAdminClient != null) {
MonitoredServerDTO[] serverList;
try {
serverList = bamListAdminClient.getServerList();
} catch (BAMException e) {
return "";
}
for (MonitoredServerDTO monitoredServerDTO : serverList) {
if (monitoredServerDTO.getServerId() == serverID) {
serverURL = monitoredServerDTO.getServerURL();
}
}
}
if (bamDSClient != null) {
Data serverData = null;
try {
serverData = bamDSClient.getLatestDataForServer(serverID);
} catch (BAMException e) {
throw new BAMException("Unable to get data for server with id" + serverID, e);
}
if (serverData != null) {
result.append("<level0 name=\"").append(serverURL).append("\"");
result.append(" meta1=\"").append(serverData.getReqCount()).append("\"");
result.append(" meta2=\"").append(serverData.getResCount()).append("\"");
result.append(" meta3=\"").append(serverData.getFaultCount()).append("\"");
result.append(" meta4=\"").append(serverData.getAvgTime()).append("\"");
result.append(" meta5=\"").append(serverData.getMinTime()).append("\"");
result.append(" meta6=\"").append(serverData.getMaxTime()).append("\"");
result.append(">\n");
}
}
if (bamListAdminClient != null) {
ServiceDO[] servicesList = new ServiceDO[0];
try {
servicesList = bamListAdminClient.getServicesList(serverID);
} catch (BAMException e) {
return "";
}
if (servicesList != null) {
for (ServiceDO service : servicesList) {
result.append("<level1 name=\"").append(service.getName()).append("\"");
Data serviceData = null;
try {
serviceData = bamDSClient.getLatestDataForService(service.getId());
} catch (BAMException e) {
throw new BAMException("Unable to get data for server with id" + serverID, e);
}
if (serviceData != null) {
result.append(" meta1=\"").append(serviceData.getReqCount()).append("\"");
result.append(" meta2=\"").append(serviceData.getResCount()).append("\"");
result.append(" meta3=\"").append(serviceData.getFaultCount()).append("\"");
result.append(" meta4=\"").append(serviceData.getAvgTime()).append("\"");
result.append(" meta5=\"").append(serviceData.getMinTime()).append("\"");
result.append(" meta6=\"").append(serviceData.getMaxTime()).append("\"");
}
result.append(">\n");
Operation[] operationsList;
try {
operationsList = bamDSClient.getOperations(service.getId());
} catch (BAMException e) {
throw new BAMException("Unable to get operation list for service" + service.getName(), e);
}
for (Operation operation : operationsList) {
result.append(" <level2 name=\"").append(operation.getName()).append("\"");
Data operationData = null;
try {
operationData = bamDSClient.getLatestDataForOperation(Integer.parseInt(operation
.getId()));
} catch (BAMException e) {
throw new BAMException("Unable to get operation data for operation with ID: " + operation.getId(), e);
}
if (operationData != null) {
result.append(" count=\"").append(operationData.getReqCount()).append("\"");
result.append(" meta1=\"").append(operationData.getReqCount()).append("\"");
result.append(" meta2=\"").append(operationData.getResCount()).append("\"");
result.append(" meta3=\"").append(operationData.getFaultCount()).append("\"");
result.append(" meta4=\"").append(operationData.getAvgTime()).append("\"");
result.append(" meta5=\"").append(operationData.getMinTime()).append("\"");
result.append(" meta6=\"").append(operationData.getMaxTime()).append("\"");
}
result.append("/>\n");
}
result.append("</level1>\n");