예제 #1
0
  /** Modifies events in-place. */
  @Override
  public Event intercept(Event event) {
    Map<String, String> headers = event.getHeaders();

    if (preserveExisting && headers.containsKey(key)) {
      return event;
    }

    if (period >= 0) {
      if (period == 0 || System.currentTimeMillis() > this.nextheaderscan) {
        try {
          String tmpValue = readHeader(file);
          if (tmpValue != value) {
            logger.debug(String.format("New CSV Header for file %s = %s", file, value));
            value = tmpValue;
          }
        } catch (FlumeException e) {
          logger.error(String.format("Error reading new CSV Header, keeping old one = %s", value));
        }
        calcNextheaderscan();
      }
    }

    if (value != null) {
      headers.put(key, value);
    }
    return event;
  }
예제 #2
0
 private void calcNextheaderscan() {
   this.nextheaderscan = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(period);
 }