Machine machine = report.findOrCreateMachine(ip);
Map<String, TransactionType> types = machine.getTypes();
StringBuilder detailBuilder = new StringBuilder();
StringBuilder summaryBuilder = new StringBuilder();
for (Entry<String, TransactionType> transactionEntry : types.entrySet()) {
TransactionType transactionType = transactionEntry.getValue();
long[] typeCounts = new long[60];
long[] typeFails = new long[60];
double[] typeSums = new double[60];
Map<String, TransactionName> names = transactionType.getNames();
for (Entry<String, TransactionName> nameEntry : names.entrySet()) {
TransactionName transactionName = nameEntry.getValue();
List<Range> ranges = new ArrayList<Range>(transactionName.getRanges().values());
detailBuilder.append(transactionType.getId());
detailBuilder.append('\t');
detailBuilder.append(transactionName.getId());
detailBuilder.append('\t');
long[] totalCount = getTotalCount(ranges);
detailBuilder.append(arrayToString(totalCount));
detailBuilder.append('\t');
long[] failsCount = getFailsCount(ranges);
detailBuilder.append(arrayToString(failsCount));
detailBuilder.append('\t');
detailBuilder.append(transactionName.getMin());
detailBuilder.append('\t');
detailBuilder.append(transactionName.getMax());
detailBuilder.append('\t');
double[] sumCount = getSumCount(ranges);
detailBuilder.append(arrayToString(sumCount));
detailBuilder.append('\t');
detailBuilder.append(transactionName.getSum2());
detailBuilder.append('\n');
String key = transactionType.getId() + "\t" + transactionName.getId();
GraphLine detailLine = allDetailCache.get(key);
if (detailLine == null) {
detailLine = new GraphLine();
allDetailCache.put(key, detailLine);
}
detailLine.totalCounts = arrayAdd(detailLine.totalCounts, totalCount);
detailLine.failCounts = arrayAdd(detailLine.failCounts, failsCount);
detailLine.min += transactionName.getMin();
detailLine.max += transactionName.getMax();
detailLine.sums = arrayAdd(detailLine.sums, sumCount);
detailLine.sum2 += transactionName.getSum2();
typeCounts = arrayAdd(typeCounts, totalCount);
typeFails = arrayAdd(typeFails, failsCount);
typeSums = arrayAdd(typeSums, sumCount);
}
summaryBuilder.append(transactionType.getId());
summaryBuilder.append('\t');
summaryBuilder.append(arrayToString(typeCounts));
summaryBuilder.append('\t');
summaryBuilder.append(arrayToString(typeFails));
summaryBuilder.append('\t');
summaryBuilder.append(transactionType.getMin());
summaryBuilder.append('\t');
summaryBuilder.append(transactionType.getMax());
summaryBuilder.append('\t');
summaryBuilder.append(arrayToString(typeSums));
summaryBuilder.append('\t');
summaryBuilder.append(transactionType.getSum2());
summaryBuilder.append('\n');
String summaryKey = transactionType.getId();
GraphLine summaryLine = allSummaryCache.get(summaryKey);
if (summaryLine == null) {
summaryLine = new GraphLine();
allSummaryCache.put(summaryKey, summaryLine);
}
summaryLine.totalCounts = arrayAdd(summaryLine.totalCounts, typeCounts);
summaryLine.failCounts = arrayAdd(summaryLine.failCounts, typeFails);
summaryLine.min += transactionType.getMin();
summaryLine.max += transactionType.getMax();
summaryLine.sums = arrayAdd(summaryLine.sums, typeSums);
summaryLine.sum2 += transactionType.getSum2();
}
graph.setDetailContent(detailBuilder.toString());
graph.setSummaryContent(summaryBuilder.toString());
graphs.add(graph);
}