log.debug(ZorkaLogger.ZAG_DEBUG, "### traceRecordToData");
ArrayList<ActiveCheckResult> list = new ArrayList<ActiveCheckResult>();
ActiveCheckResult result;
String keySuffix = null;
TraceRecord traceRecord = (TraceRecord) rec;
long clock = traceRecord.getClock() / 1000l;
/* Finding Record's key */
if (traceRecord.getAttrs() != null) {
for (Map.Entry<Integer, Object> entry : traceRecord.getAttrs().entrySet()) {
String attrName = symbolRegistry.symbolName(entry.getKey());
if (attrName.equals("URI")) {
keySuffix = "frontends." + String.valueOf(entry.getValue());
}
}
}
if (keySuffix == null) {
String className = symbolRegistry.symbolName(traceRecord.getClassId()).replace(".", "_");
String methodName = symbolRegistry.symbolName(traceRecord.getMethodId()).replace(".", "_");
keySuffix = className + "_" + methodName;
}
String key;
if (prefix == null || prefix.length() == 0) {
key = keySuffix;
} else {
key = prefix + "." + keySuffix;
}
log.debug(ZorkaLogger.ZAG_DEBUG, "### traceRecordToData: key=" + key);
/* Time */
result = new ActiveCheckResult();
result.setHost(hostname);
result.setKey(key + ".time");
/* nanoseconds -> milliseconds */
result.setValue(String.valueOf(traceRecord.getTime() / 1000000l));
result.setLastlogsize(0);
result.setClock(clock);
list.add(result);
log.debug(ZorkaLogger.ZAG_DEBUG, "### traceRecordToData: data=" + result.toString());
/* Calls */
result = new ActiveCheckResult();
result.setHost(hostname);
result.setKey(key + ".calls");
/* contar a chamada atual como 1 */
result.setValue("1");
result.setLastlogsize(0);
result.setClock(clock);
list.add(result);
log.debug(ZorkaLogger.ZAG_DEBUG, "### traceRecordToData: data=" + result.toString());
/* Errors */
result = new ActiveCheckResult();
result.setHost(hostname);
result.setKey(key + ".errors");
result.setValue(String.valueOf(traceRecord.getErrors()));
result.setLastlogsize(0);
result.setClock(clock);
list.add(result);
log.debug(ZorkaLogger.ZAG_DEBUG, "### traceRecordToData: data=" + result.toString());
/* Recursive check children */
if ((level <= 1) && (traceRecord.getChildren() != null)) {
log.debug(ZorkaLogger.ZAG_DEBUG, "### traceRecordToData: children.size()=" + traceRecord.getChildren().size());
for (TraceRecord child : traceRecord.getChildren()) {
log.debug(ZorkaLogger.ZAG_DEBUG, "### traceRecordToData: child=" + child.toString());
list.addAll(traceRecordToData(child, key + ".backends", level+1));
}
}