Package com.dianping.cat.home.router.entity

Examples of com.dianping.cat.home.router.entity.RouterConfig


    Model model = new Model(ctx);
    Payload payload = ctx.getPayload();
    Action action = payload.getAction();
    Date start = payload.getDate();
    Date end = new Date(start.getTime() + TimeHelper.ONE_DAY);
    RouterConfig report = m_reportService.queryRouterConfigReport(Constants.CAT, start, end);

    switch (action) {
    case API:
      Domain domainConfig = m_configManager.getRouterConfig().findDomain(payload.getDomain());

      if (domainConfig == null) {
        if (report != null) {
          Domain domain = report.findDomain(payload.getDomain());
          String str = null;

          if (domain == null) {
            m_configManager.getRouterConfig().getDefaultServers();

            List<Server> servers = m_configManager.queryServersByDomain(payload.getDomain());

            str = buildServerStr(servers);
          } else {
            List<Server> servers = domain.getServers();

            str = buildServerStr(servers);
          }
          model.setContent(str);
        } else {
          List<Server> servers = m_configManager.queryServersByDomain(payload.getDomain());

          model.setContent(buildServerStr(servers));
        }
      } else {
        model.setContent(buildServerStr(domainConfig.getServers()));
      }
      break;
    case MODEL:
      if (report != null) {
        model.setContent(report.toString());
      }
    }

    ctx.getHttpServletResponse().getWriter().write(model.getContent());
  }
View Full Code Here


  @Override
  public boolean buildDailyTask(String name, String domain, Date period) {
    Date end = new Date(period.getTime() + TimeHelper.ONE_DAY);
    StateReport report = m_reportService.queryStateReport(Constants.CAT, period, end);
    RouterConfig routerConfig = new RouterConfig(Constants.CAT);
    StateReportVisitor visitor = new StateReportVisitor();

    visitor.visitStateReport(report);

    Map<String, Long> numbers = visitor.getNumbers();
    Comparator<Entry<String, Long>> compator = new Comparator<Map.Entry<String, Long>>() {

      @Override
      public int compare(Entry<String, Long> o1, Entry<String, Long> o2) {
        return (int) (o2.getValue() - o1.getValue());
      }
    };
    numbers = SortHelper.sortMap(numbers, compator);
    Map<Server, Long> servers = findAvaliableServers();

    processMainServer(servers, routerConfig, numbers);
    processBackServer(servers, routerConfig, numbers);

    routerConfig.setStartTime(end);
    routerConfig.setEndTime(new Date(end.getTime() + TimeHelper.ONE_DAY));

    DailyReport dailyReport = new DailyReport();

    dailyReport.setContent("");
    dailyReport.setCreationDate(new Date());
View Full Code Here

  }

  @Override
  public RouterConfig queryDailyReport(String domain, Date start, Date end) {
    long time = start.getTime();
    RouterConfig config = m_configs.get(time);

    if (config == null) {
      String name = Constants.REPORT_ROUTER;

      try {
View Full Code Here

  @Test
  public void test1() throws Exception {
    ReportServiceManager service = lookup(ReportServiceManager.class);
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    RouterConfig report1 = service.queryRouterConfigReport(Constants.CAT, sdf.parse(day3), sdf.parse(day4));

    RouterConfig report2 = service.queryRouterConfigReport(Constants.CAT, sdf.parse(day3), sdf.parse(day4));

    Assert.assertEquals(report1.toString(), report2.toString());
  }
View Full Code Here

      }
    } catch (Exception e) {
      Cat.logError(e);
    }
    if (m_routerConfig == null) {
      m_routerConfig = new RouterConfig();
    }
  }
View Full Code Here

    long modifyTime = config.getModifyDate().getTime();

    synchronized (this) {
      if (modifyTime > m_modifyTime) {
        String content = config.getContent();
        RouterConfig routerConfig = DefaultSaxParser.parse(content);

        m_routerConfig = routerConfig;
        m_modifyTime = modifyTime;
      }
    }
View Full Code Here

TOP

Related Classes of com.dianping.cat.home.router.entity.RouterConfig

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.