Package com.dianping.cat.core.config

Examples of com.dianping.cat.core.config.Config


  }

  @Override
  public void initialize() throws InitializationException {
    try {
      Config config = m_configDao.findByName(CONFIG_NAME, ConfigEntity.READSET_FULL);
      String content = config.getContent();

      m_configId = config.getId();
      m_routerConfig = DefaultSaxParser.parse(content);
      m_modifyTime = config.getModifyDate().getTime();
    } catch (DalNotFoundException e) {
      try {
        String content = Files.forIO().readFrom(
              this.getClass().getResourceAsStream("/config/default-router-config.xml"), "utf-8");
        Config config = m_configDao.createLocal();
        Date now = new Date();

        config.setName(CONFIG_NAME);
        config.setContent(content);
        config.setModifyDate(now);
        m_configDao.insert(config);

        m_configId = config.getId();
        m_routerConfig = DefaultSaxParser.parse(content);
        m_modifyTime = now.getTime();
      } catch (Exception ex) {
        Cat.logError(ex);
      }
View Full Code Here


    }
    return result;
  }

  public void refreshRouterConfig() throws DalException, SAXException, IOException {
    Config config = m_configDao.findByName(CONFIG_NAME, ConfigEntity.READSET_FULL);
    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

  }

  private boolean storeConfig() {
    synchronized (this) {
      try {
        Config config = m_configDao.createLocal();

        config.setId(m_configId);
        config.setKeyId(m_configId);
        config.setName(CONFIG_NAME);
        config.setContent(m_routerConfig.toString());
        m_configDao.updateByPK(config, ConfigEntity.UPDATESET_FULL);
      } catch (Exception e) {
        Cat.logError(e);
        return false;
      }
View Full Code Here

  }

  @Override
  public void initialize() throws InitializationException {
    try {
      Config config = m_configDao.findByName(CONFIG_NAME, ConfigEntity.READSET_FULL);
      String content = config.getContent();

      m_configId = config.getId();
      m_exceptionConfig = DefaultSaxParser.parse(content);
    } catch (DalNotFoundException e) {
      try {
        String content = Files.forIO().readFrom(
              this.getClass().getResourceAsStream("/config/default-exception-config.xml"), "utf-8");
        Config config = m_configDao.createLocal();

        config.setName(CONFIG_NAME);
        config.setContent(content);
        m_configDao.insert(config);

        m_configId = config.getId();
        m_exceptionConfig = DefaultSaxParser.parse(content);
      } catch (Exception ex) {
        Cat.logError(ex);
      }
    } catch (Exception e) {
View Full Code Here

  }

  private boolean storeConfig() {
    synchronized (this) {
      try {
        Config config = m_configDao.createLocal();

        config.setId(m_configId);
        config.setKeyId(m_configId);
        config.setName(CONFIG_NAME);
        config.setContent(m_exceptionConfig.toString());
        m_configDao.updateByPK(config, ConfigEntity.UPDATESET_FULL);
      } catch (Exception e) {
        Cat.logError(e);
        return false;
      }
View Full Code Here

  }

  @Override
  public void initialize() {
    try {
      Config config = m_configDao.findByName(CONFIG_NAME, ConfigEntity.READSET_FULL);
      String content = config.getContent();

      m_configId = config.getId();
      m_UrlPattern = DefaultSaxParser.parse(content);
      m_modifyTime = config.getModifyDate().getTime();
    } catch (DalNotFoundException e) {
      try {
        String content = Files.forIO().readFrom(
              this.getClass().getResourceAsStream("/config/default-url-pattern-config.xml"), "utf-8");
        Config config = m_configDao.createLocal();

        config.setName(CONFIG_NAME);
        config.setContent(content);
        m_configDao.insert(config);
        m_configId = config.getId();
        m_UrlPattern = DefaultSaxParser.parse(content);
      } catch (Exception ex) {
        Cat.logError(ex);
      }
    } catch (Exception e) {
View Full Code Here

  public Collection<PatternItem> queryUrlPatternRules() {
    return m_UrlPattern.getPatternItems().values();
  }

  public void refreshUrlPatternConfig() throws DalException, SAXException, IOException {
    Config config = m_configDao.findByName(CONFIG_NAME, ConfigEntity.READSET_FULL);
    long modifyTime = config.getModifyDate().getTime();

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

        m_UrlPattern = pattern;
        m_handler.register(new ArrayList<PatternItem>(m_UrlPattern.getPatternItems().values()));
        m_modifyTime = modifyTime;
View Full Code Here

    }
  }

  private boolean storeConfig() {
    try {
      Config config = m_configDao.createLocal();

      config.setId(m_configId);
      config.setKeyId(m_configId);
      config.setName(CONFIG_NAME);
      config.setContent(m_UrlPattern.toString());
      m_configDao.updateByPK(config, ConfigEntity.UPDATESET_FULL);
    } catch (Exception e) {
      Cat.logError(e);
      return false;
    }
View Full Code Here

  }

  @Override
  public void initialize() throws InitializationException {
    try {
      Config config = m_configDao.findByName(CONFIG_NAME, ConfigEntity.READSET_FULL);
      String content = config.getContent();
      m_configId = config.getId();
      m_config = DefaultSaxParser.parse(content);
    } catch (DalNotFoundException e) {
      try {
        String content = Files.forIO().readFrom(
              this.getClass().getResourceAsStream("/config/default-app-comparison-config.xml"), "utf-8");
        Config config = m_configDao.createLocal();

        config.setName(CONFIG_NAME);
        config.setContent(content);
        m_configDao.insert(config);

        m_configId = config.getId();
        m_config = DefaultSaxParser.parse(content);
      } catch (Exception ex) {
        Cat.logError(ex);
      }
    } catch (Exception e) {
View Full Code Here

  }

  @Override
  public void initialize() throws InitializationException {
    try {
      Config config = m_configDao.findByName(CONFIG_NAME, ConfigEntity.READSET_FULL);
      String content = config.getContent();

      m_configId = config.getId();
      m_config = DefaultSaxParser.parse(content);
    } catch (DalNotFoundException e) {
      try {
        String content = Files.forIO().readFrom(
              this.getClass().getResourceAsStream("/config/default-business-metric-rule-config.xml"), "utf-8");
        Config config = m_configDao.createLocal();

        config.setName(CONFIG_NAME);
        config.setContent(content);
        m_configDao.insert(config);

        m_configId = config.getId();
        m_config = DefaultSaxParser.parse(content);
      } catch (Exception ex) {
        Cat.logError(ex);
      }
    } catch (Exception e) {
View Full Code Here

TOP

Related Classes of com.dianping.cat.core.config.Config

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.