Exemple #1
0
  /**
   * If readRange is outside runRecord's range, then the readRange is adjusted to fall within
   * runRecords range.
   */
  private ReadRange adjustReadRange(ReadRange readRange, @Nullable RunRecord runRecord) {
    if (runRecord == null) {
      return readRange;
    }

    long fromTimeMillis = readRange.getFromMillis();
    long toTimeMillis = readRange.getToMillis();

    long runStartMillis = TimeUnit.SECONDS.toMillis(runRecord.getStartTs());
    if (fromTimeMillis < runStartMillis) {
      fromTimeMillis = runStartMillis;
    }
    if (runRecord.getStopTs() != null) {
      long runStopMillis = TimeUnit.SECONDS.toMillis(runRecord.getStopTs());
      if (toTimeMillis > runStopMillis) {
        toTimeMillis = runStopMillis;
      }
    }
    return new ReadRange(fromTimeMillis, toTimeMillis, readRange.getKafkaOffset());
  }