Package com.dianping.cat.consumer.matrix.model.entity

Examples of com.dianping.cat.consumer.matrix.model.entity.Ratio


        long duration = ((Transaction) message).getDurationInMicros();
        matrix.incCount();
        matrix.setTotalTime(matrix.getTotalTime() + duration);

        Map<String, Ratio> ratios = new HashMap<String, Ratio>();
        ratios.put("Call", new Ratio());
        ratios.put("SQL", new Ratio());
        ratios.put("Cache", new Ratio());

        processTransaction(tree, (Transaction) message, ratios);

        for (Entry<String, Ratio> entry : ratios.entrySet()) {
          String type = entry.getKey();
          Ratio ratio = entry.getValue();
          int count = ratio.getTotalCount();
          long time = ratio.getTotalTime();

          Ratio real = matrix.findOrCreateRatio(type);
          if (real.getMin() > count || real.getMin() == 0) {
            real.setMin(count);
          }
          if (real.getMax() < count) {
            real.setMax(count);
            real.setUrl(tree.getMessageId());
          }
          real.setTotalCount(real.getTotalCount() + count);
          real.setTotalTime(real.getTotalTime() + time);
        }
        if (matrix.getUrl() == null) {
          matrix.setUrl(tree.getMessageId());
        }
      }
View Full Code Here


  }

  private void processTransaction(MessageTree tree, Transaction t, Map<String, Ratio> ratios) {
    List<Message> children = t.getChildren();
    String type = t.getType();
    Ratio ratio = null;

    if (type.equals("Call") || type.equals("PigeonCall")) {
      ratio = ratios.get("Call");
    } else if (type.equals("SQL")) {
      ratio = ratios.get("SQL");
    } else if (type.startsWith("Cache.")) {
      ratio = ratios.get("Cache");
    }
    if (ratio != null) {
      ratio.incTotalCount();
      ratio.setTotalTime(ratio.getTotalTime() + t.getDurationInMicros());
    }

    for (Message child : children) {
      if (child instanceof Transaction) {
        processTransaction(tree, (Transaction) child, ratios);
View Full Code Here

      }
      m_url = matrix.getUrl();
    }

    public void setCacheInfo(Matrix matrix) {
      Ratio ratio = matrix.getRatios().get("Cache");
      if (ratio == null) {
        return;
      }

      m_cacheMin = ratio.getMin();
      m_cacheMax = ratio.getMax();
      m_cacheUrl = ratio.getUrl();
      if (matrix.getCount() > 0) {
        m_cacheAvg = (double) ratio.getTotalCount() / (double) matrix.getCount();
      }
      if (m_cacheAvg > 0) {
        m_cacheTime = (int) ((double) ratio.getTotalTime() / 1000 / m_cacheAvg / m_count);
      }
      if (matrix.getTotalTime() > 0) {
        m_cacheTimePercent = (double) ratio.getTotalTime() / (double) (matrix.getTotalTime());
      }
    }
View Full Code Here

        m_cacheTimePercent = (double) ratio.getTotalTime() / (double) (matrix.getTotalTime());
      }
    }

    public void setCallInfo(Matrix matrix) {
      Ratio ratio = matrix.getRatios().get("Call");
      if (ratio == null) {
        return;
      }

      m_callMin = ratio.getMin();
      m_callMax = ratio.getMax();
      m_callUrl = ratio.getUrl();
      if (matrix.getCount() > 0) {
        m_callAvg = (double) ratio.getTotalCount() / (double) matrix.getCount();
      }
      if (m_callAvg > 0) {
        m_callTime = (int) ((double) ratio.getTotalTime() / 1000 / m_callAvg / m_count);
      }
      if (matrix.getTotalTime() > 0) {
        m_callTimePercent = (double) ratio.getTotalTime() / (double) (matrix.getTotalTime());
      }
    }
View Full Code Here

        m_callTimePercent = (double) ratio.getTotalTime() / (double) (matrix.getTotalTime());
      }
    }

    public void setSQLInfo(Matrix matrix) {
      Ratio ratio = matrix.getRatios().get("SQL");
      if (ratio == null) {
        return;
      }

      m_sqlMin = ratio.getMin();
      m_sqlMax = ratio.getMax();
      m_sqlUrl = ratio.getUrl();
      if (matrix.getCount() > 0) {
        m_sqlAvg = (double) ratio.getTotalCount() / (double) matrix.getCount();
      }
      if (m_sqlAvg > 0) {
        m_sqlTime = (int) ((double) ratio.getTotalTime() / 1000 / m_sqlAvg / m_count);
      }
      if (matrix.getTotalTime() > 0) {
        m_sqlTimePercent = (double) ratio.getTotalTime() / (double) (matrix.getTotalTime());
      }
    }
View Full Code Here

TOP

Related Classes of com.dianping.cat.consumer.matrix.model.entity.Ratio

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.