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

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


    }
  }

  private boolean graphNodeConfigAddOrUpdateSubmit(Payload payload, Model model) {
    String type = payload.getType();
    DomainConfig config = payload.getDomainConfig();
    String domain = config.getId();
    model.setDomainConfig(config);

    if (domain.equalsIgnoreCase(Constants.ALL)) {
      return m_topologyConfigManager.insertDomainDefaultConfig(type, config);
    } else {
View Full Code Here


  }

  public Pair<Integer, String> buildNodeState(String domain, Index index) {
    String type = index.getName();
    String realType = formatType(type);
    DomainConfig config = queryNodeConfig(realType, domain);
    int errorCode = OK;
    StringBuilder sb = new StringBuilder();

    if (config != null) {
      double avg = index.getAvg();
      long error = index.getErrorCount();

      sb.append(type).append(GraphConstrant.DELIMITER);

      if (index.getTotalCount() > 0 && !type.equalsIgnoreCase("Exception")) {
        sb.append(buildDes(TOTAL_STR, String.valueOf(index.getTotalCount())));
      }

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

  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);
      } else if ("PigeonServer".equalsIgnoreCase(type)) {
        domainConfig = queryNodeConfig("PigeonService", from);
      } else {
View Full Code Here

  public DomainConfig queryNodeConfig(String type, String domain) {
    NodeConfig typesConfig = m_config.findNodeConfig(type);

    if (typesConfig != null) {
      DomainConfig config = typesConfig.findDomainConfig(domain);
      if (config == null) {
        config = new DomainConfig();

        config.setId(domain);
        config.setErrorResponseTime(typesConfig.getDefaultErrorResponseTime());
        config.setErrorThreshold(typesConfig.getDefaultErrorThreshold());
        config.setWarningResponseTime(typesConfig.getDefaultWarningResponseTime());
        config.setWarningThreshold(typesConfig.getDefaultWarningThreshold());
      }
      return config;
    }
    return null;
  }
View Full Code Here

  @Test
  public void testAddModifyDeleteNode() throws IOException {
    String type = "URL";
    String domain = "cat";
    DomainConfig config = new DomainConfig(domain);
    config.setErrorResponseTime(1.1);
    config.setErrorThreshold(1);
    config.setWarningResponseTime(2.2);
    config.setWarningThreshold(2);
    m_manager.insertDomainConfig(type, config);

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

    config = new DomainConfig(domain);
    config.setErrorResponseTime(11.1);
    config.setErrorThreshold(11);
    config.setWarningResponseTime(22.2);
    config.setWarningThreshold(22);
    m_manager.insertDomainConfig(type, config);

    String updateContent = Files.forIO().readFrom(
          GraphConfigManagerTest.class.getResourceAsStream("UpdateDomainConfig.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.DomainConfig

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.