Package com.dianping.cat.report.task.spi

Examples of com.dianping.cat.report.task.spi.GraphLine


          long[] failCount = getFailsCount(ranges);
          detailBuilder.append(arrayToString(failCount));
          detailBuilder.append('\n');

          String key = eventType.getId() + "\t" + eventName.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, failCount);

          typeCounts = arrayAdd(typeCounts, totalCount);
          typeFails = arrayAdd(typeFails, failCount);
        }

        String summaryKey = eventType.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);

        summaryBuilder.append(eventType.getId());
        summaryBuilder.append('\t');
        summaryBuilder.append(arrayToString(typeCounts));
        summaryBuilder.append('\t');
        summaryBuilder.append(arrayToString(typeFails));
        summaryBuilder.append('\n');
      }
      graph.setDetailContent(detailBuilder.toString());
      graph.setSummaryContent(summaryBuilder.toString());
      graphs.add(graph);
    }

    Graph allGraph = new Graph();
    allGraph.setIp("all");
    allGraph.setDomain(domainName);
    allGraph.setName(reportName);
    allGraph.setPeriod(reportPeriod);
    allGraph.setType(3);
    allGraph.setCreationDate(creationDate);

    StringBuilder detailSb = new StringBuilder();
    for (Entry<String, GraphLine> entry : allDetailCache.entrySet()) {
      detailSb.append(entry.getKey());
      detailSb.append('\t');
      GraphLine value = entry.getValue();
      detailSb.append(arrayToString(value.totalCounts));
      detailSb.append('\t');
      detailSb.append(arrayToString(value.failCounts));
      detailSb.append('\t');
      detailSb.append('\n');
    }
    allGraph.setDetailContent(detailSb.toString());

    StringBuilder summarySb = new StringBuilder();
    for (Entry<String, GraphLine> entry : allSummaryCache.entrySet()) {
      summarySb.append(entry.getKey());
      summarySb.append('\t');
      GraphLine value = entry.getValue();
      summarySb.append(arrayToString(value.totalCounts));
      summarySb.append('\t');
      summarySb.append(arrayToString(value.failCounts));
      summarySb.append('\n');
    }
View Full Code Here


            Segment segment = segmentEntry.getValue();
            int minute = segment.getId();
            int count = segment.getMessages().size();
            String summaryKey = type;

            GraphLine summaryLine = summaryCache.get(summaryKey);
            if (summaryLine == null) {
              summaryLine = new GraphLine();
              summaryLine.minuteCounts = new int[60];
              summaryCache.put(summaryKey, summaryLine);
            }
            summaryLine.totalCount = summaryLine.totalCount + count;
            summaryLine.minuteCounts[minute] = summaryLine.minuteCounts[minute] + count;

            GraphLine allSummaryLine = allSummaryCache.get(summaryKey);
            if (allSummaryLine == null) {
              allSummaryLine = new GraphLine();
              allSummaryLine.minuteCounts = new int[60];
              allSummaryCache.put(summaryKey, allSummaryLine);
            }
            allSummaryLine.totalCount = allSummaryLine.totalCount + count;
            allSummaryLine.minuteCounts[minute] = allSummaryLine.minuteCounts[minute] + count;

            String detailKey = type + "\t" + status;
            GraphLine detailLine = detailCache.get(detailKey);
            if (detailLine == null) {
              detailLine = new GraphLine();
              detailLine.minuteCounts = new int[60];
              detailCache.put(detailKey, detailLine);
            }
            detailLine.totalCount = detailLine.totalCount + count;
            detailLine.minuteCounts[minute] = detailLine.minuteCounts[minute] + count;

            GraphLine allDetailLine = allDetailCache.get(detailKey);
            if (allDetailLine == null) {
              allDetailLine = new GraphLine();
              allDetailLine.minuteCounts = new int[60];
              allDetailCache.put(detailKey, allDetailLine);
            }
            allDetailLine.totalCount = allDetailLine.totalCount + count;
            allDetailLine.minuteCounts[minute] = allDetailLine.minuteCounts[minute] + count;
          }
        }
      }

      StringBuilder summaryBuilder = new StringBuilder();
      for (Entry<String, GraphLine> summaryEntry : summaryCache.entrySet()) {
        GraphLine summaryLine = summaryEntry.getValue();
        summaryBuilder.append(summaryEntry.getKey());
        summaryBuilder.append("\t");
        summaryBuilder.append(summaryLine.totalCount);
        summaryBuilder.append("\t");
        summaryBuilder.append(TaskHelper.join(summaryLine.minuteCounts, ','));
        summaryBuilder.append("\n");
      }
      graph.setSummaryContent(summaryBuilder.toString());

      StringBuilder detailBuilder = new StringBuilder();
      for (Entry<String, GraphLine> detailEntry : detailCache.entrySet()) {
        GraphLine detailLine = detailEntry.getValue();
        detailBuilder.append(detailEntry.getKey());
        detailBuilder.append("\t");
        detailBuilder.append(detailLine.totalCount);
        detailBuilder.append("\t");
        detailBuilder.append(TaskHelper.join(detailLine.minuteCounts, ','));
        detailBuilder.append("\n");
      }
      graph.setDetailContent(detailBuilder.toString());

      graph.setCreationDate(new Date());
      graphs.add(graph);
    }

    Graph allGraph = new Graph();
    allGraph.setIp("all");
    allGraph.setDomain(reportDomain);
    allGraph.setName(reportName);
    allGraph.setPeriod(reportPeriod);
    allGraph.setType(3);

    StringBuilder summaryBuilder = new StringBuilder();
    for (Entry<String, GraphLine> summaryEntry : allSummaryCache.entrySet()) {
      GraphLine summaryLine = summaryEntry.getValue();
      summaryBuilder.append(summaryEntry.getKey());
      summaryBuilder.append("\t");
      summaryBuilder.append(summaryLine.totalCount);
      summaryBuilder.append("\t");
      summaryBuilder.append(TaskHelper.join(summaryLine.minuteCounts, ','));
      summaryBuilder.append("\n");
    }
    allGraph.setSummaryContent(summaryBuilder.toString());

    StringBuilder detailBuilder = new StringBuilder();
    for (Entry<String, GraphLine> detailEntry : allDetailCache.entrySet()) {
      GraphLine detailLine = detailEntry.getValue();
      detailBuilder.append(detailEntry.getKey());
      detailBuilder.append("\t");
      detailBuilder.append(detailLine.totalCount);
      detailBuilder.append("\t");
      detailBuilder.append(TaskHelper.join(detailLine.minuteCounts, ','));
View Full Code Here

          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);
    }

    Graph allGraph = new Graph();
    allGraph.setIp("all");
    allGraph.setDomain(reportDomain);
    allGraph.setName(reportName);
    allGraph.setPeriod(reportPeriod);
    allGraph.setType(3);
    allGraph.setCreationDate(creationDate);

    StringBuilder detailSb = new StringBuilder();
    for (Entry<String, GraphLine> entry : allDetailCache.entrySet()) {
      detailSb.append(entry.getKey());
      detailSb.append('\t');
      GraphLine value = entry.getValue();
      detailSb.append(arrayToString(value.totalCounts));
      detailSb.append('\t');
      detailSb.append(arrayToString(value.failCounts));
      detailSb.append('\t');
      detailSb.append(value.min);
      detailSb.append('\t');
      detailSb.append(value.max);
      detailSb.append('\t');
      detailSb.append(arrayToString(value.sums));
      detailSb.append('\t');
      detailSb.append(value.sum2);
      detailSb.append('\n');
    }
    allGraph.setDetailContent(detailSb.toString());

    StringBuilder summarySb = new StringBuilder();
    for (Entry<String, GraphLine> entry : allSummaryCache.entrySet()) {
      summarySb.append(entry.getKey());
      summarySb.append('\t');
      GraphLine value = entry.getValue();
      summarySb.append(arrayToString(value.totalCounts));
      summarySb.append('\t');
      summarySb.append(arrayToString(value.failCounts));
      summarySb.append('\t');
      summarySb.append(value.min);
View Full Code Here

import com.dianping.cat.report.task.spi.GraphLine;

public class HeartbeatGraphCreator  {

  private void cacheHeartbeatColumn(Map<String, GraphLine> detailCache, int minute, Number value, String key) {
    GraphLine detailLine = detailCache.get(key);
    if (detailLine == null) {
      detailLine = new GraphLine();
      detailLine.minuteNumbers = new double[60];
      detailCache.put(key, detailLine);
    }
    detailLine.minuteNumbers[minute] = value.doubleValue();
  }
View Full Code Here

          }
        }
      }

      for (Entry<String, GraphLine> entry : detailCache.entrySet()) {
        GraphLine line = entry.getValue();
        double[] numbers = line.minuteNumbers;
        double minValue = numbers[0];
        double maxValue = minValue;
        double sum = minValue;
        double sum2 = sum * sum;

        for (int i = 1; i < numbers.length; i++) {
          double n = numbers[i];
          if (n > maxValue) {
            maxValue = n;
          }
          if (n < minValue) {
            minValue = n;
          }
          sum += n;
          sum2 += n * n;
        }

        line.min = minValue;
        line.max = maxValue;
        line.sum = sum;
        line.sum2 = sum2;
      }

      StringBuilder sb = new StringBuilder(64 * detailCache.size());
      for (Entry<String, GraphLine> entry : detailCache.entrySet()) {
        GraphLine value = entry.getValue();
        sb.append(entry.getKey());
        sb.append('\t');
        sb.append(value.min);
        sb.append('\t');
        sb.append(value.max);
View Full Code Here

TOP

Related Classes of com.dianping.cat.report.task.spi.GraphLine

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.