Esempio n. 1
0
  /**
   * Takes a FlumeConfigData and attempts load/config the node.
   *
   * <p>True if successful, false if failed
   */
  public synchronized boolean checkConfig(FlumeConfigData data) {

    if (data == null) {
      return false;
    }

    // check if config is too old or the same as current
    if (lastGoodCfg != null) {
      if (data.getSourceVersion() <= lastGoodCfg.getSourceVersion()) {
        if (data.getSourceVersion() < lastGoodCfg.getSourceVersion()) {
          // retrieved configuration is older!?
          LOG.warn("reject because config older than the current. ");
          return false;
        }

        LOG.debug(
            "do nothing: retrieved config ("
                + new Date(data.getSourceVersion())
                + ") same as current ("
                + new Date(lastGoodCfg.getSourceVersion())
                + "). ");
        return false;
      }
    }

    try {
      loadConfig(data);
    } catch (Exception e) {
      // Catch the exception to prevent backoff
      LOG.warn("Configuration " + data + " failed to load!", e);
      return false;
    }
    return true;
  }
Esempio n. 2
0
 public long getConfigVersion() {
   if (lastGoodCfg == null) return 0;
   return lastGoodCfg.getTimestamp();
 }