Package com.dianping.cat.home.dependency.config.entity

Examples of com.dianping.cat.home.dependency.config.entity.EdgeConfig


  public Pair<Integer, String> buildEdgeState(String domain, Dependency dependency) {
    String type = formatType(dependency.getType());
    String from = domain;
    String to = dependency.getTarget();
    EdgeConfig config = queryEdgeConfig(type, from, to);
    long error = dependency.getErrorCount();
    StringBuilder sb = new StringBuilder();
    int errorCode = OK;

    if (config != null) {
      double avg = dependency.getAvg();
      sb.append(buildDes(type, TOTAL_STR, String.valueOf(dependency.getTotalCount()))).append(GraphConstrant.ENTER);

      if (avg >= config.getErrorResponseTime()) {
        errorCode = ERROR;
        sb.append(buildErrorDes(type, AVG_STR, m_df.format(avg), MILLISECOND)).append(GraphConstrant.ENTER);
      } else if (avg >= config.getWarningResponseTime()) {
        errorCode = WARN;
        sb.append(buildWarningDes(type, AVG_STR, m_df.format(avg), MILLISECOND)).append(GraphConstrant.ENTER);
      } else {
        sb.append(buildDes(type, AVG_STR, m_df.format(avg), MILLISECOND)).append(GraphConstrant.ENTER);
      }
      if (error >= config.getErrorThreshold()) {
        errorCode = ERROR;
        sb.append(buildErrorDes(type, ERROR_STR, String.valueOf(error))).append(GraphConstrant.ENTER);
      } else if (error >= config.getWarningThreshold()) {
        errorCode = WARN;
        sb.append(buildWarningDes(type, ERROR_STR, String.valueOf(error))).append(GraphConstrant.ENTER);
      } else if (error > 0) {
        sb.append(buildDes(type, ERROR_STR, String.valueOf(error))).append(GraphConstrant.ENTER);
      }
View Full Code Here


    sb.append(content).append("</span>");
    return sb.toString();
  }

  private EdgeConfig convertNodeConfig(DomainConfig config) {
    EdgeConfig edgeConfig = new EdgeConfig();

    edgeConfig.setWarningResponseTime(config.getWarningResponseTime());
    edgeConfig.setErrorResponseTime(config.getErrorResponseTime());
    edgeConfig.setWarningThreshold(config.getWarningThreshold());
    edgeConfig.setErrorThreshold(config.getErrorThreshold());
    return edgeConfig;
  }
View Full Code Here

    m_config.addEdgeConfig(config);
    return storeConfig();
  }

  public EdgeConfig queryEdgeConfig(String type, String from, String to) {
    EdgeConfig edgeConfig = m_config.findEdgeConfig(type + ":" + from + ":" + to);

    if (edgeConfig == null) {
      DomainConfig domainConfig = null;
      if ("PigeonCall".equalsIgnoreCase(type)) {
        domainConfig = queryNodeConfig("PigeonService", to);
View Full Code Here

  private void graphEdgeConfigAdd(Payload payload, Model model) {
    String type = payload.getType();
    String from = payload.getFrom();
    String to = payload.getTo();
    EdgeConfig config = m_topologyConfigManager.queryEdgeConfig(type, from, to);

    model.setEdgeConfig(config);
  }
View Full Code Here

    model.setEdgeConfig(config);
  }


  private boolean graphEdgeConfigAddOrUpdateSubmit(Payload payload, Model model) {
    EdgeConfig config = payload.getEdgeConfig();

    if (!StringUtil.isEmpty(config.getType())) {
      model.setEdgeConfig(config);
      payload.setType(config.getType());
      return m_topologyConfigManager.insertEdgeConfig(config);
    } else {
      return false;
    }
  }
View Full Code Here

  @Test
  public void testAddModifyDeleteEdge() throws IOException {
    String type = "PigeonCall";
    String from = "TuanGouWeb";
    String to = "TuanGouService";
    EdgeConfig config = new EdgeConfig(type + ":" + from + ":" + to);

    config.setType(type);
    config.setFrom(from);
    config.setTo(to);
    config.setErrorResponseTime(1.1);
    config.setErrorThreshold(1);
    config.setWarningResponseTime(2.2);
    config.setWarningThreshold(2);

    m_manager.insertEdgeConfig(config);

    String addContent = Files.forIO().readFrom(GraphConfigManagerTest.class.getResourceAsStream("AddEdgeConfig.xml"),
          "utf-8");
    Assert.assertEquals(addContent.replaceAll("\r", ""), m_manager.getConfig().toString().replaceAll("\r", ""));

    config = new EdgeConfig(from);
    config.setType(type);
    config.setFrom(from);
    config.setTo(to);
    config.setErrorResponseTime(11.1);
    config.setErrorThreshold(11);
    config.setWarningResponseTime(22.2);
    config.setWarningThreshold(22);
    m_manager.insertEdgeConfig(config);

    String updateContent = Files.forIO().readFrom(
          GraphConfigManagerTest.class.getResourceAsStream("UpdateEdgeConfig.xml"), "utf-8");
    Assert.assertEquals(updateContent.replaceAll("\r", ""), m_manager.getConfig().toString().replaceAll("\r", ""));
View Full Code Here

TOP

Related Classes of com.dianping.cat.home.dependency.config.entity.EdgeConfig

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.