org.apache.flink.streaming.api.watermark.Watermark.getTimestamp()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(5.8k)|赞(0)|评价(0)|浏览(144)

本文整理了Java中org.apache.flink.streaming.api.watermark.Watermark.getTimestamp()方法的一些代码示例,展示了Watermark.getTimestamp()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Watermark.getTimestamp()方法的具体详情如下:
包路径:org.apache.flink.streaming.api.watermark.Watermark
类名称:Watermark
方法名:getTimestamp

Watermark.getTimestamp介绍

[英]Returns the timestamp associated with this Watermark in milliseconds.
[中]返回与此水印关联的时间戳(以毫秒为单位)。

代码示例

代码示例来源:origin: apache/flink

@Override
  public void processWatermark(Watermark mark) throws Exception {
    // if we receive a Long.MAX_VALUE watermark we forward it since it is used
    // to signal the end of input and to not block watermark progress downstream
    if (mark.getTimestamp() == Long.MAX_VALUE && mark.getTimestamp() > currentWatermark) {
      currentWatermark = Long.MAX_VALUE;
      output.emitWatermark(mark);
    }
  }
}

代码示例来源:origin: apache/flink

@Nullable
public Watermark checkAndGetNewWatermark(T record, long timestamp) {
  Watermark mark = timestampsAndWatermarks.checkAndGetNextWatermark(record, timestamp);
  if (mark != null && mark.getTimestamp() > partitionWatermark) {
    partitionWatermark = mark.getTimestamp();
    return mark;
  }
  else {
    return null;
  }
}

代码示例来源:origin: apache/flink

@Override
public void processWatermark(Watermark mark) throws Exception {
  super.processWatermark(mark);
  this.currentWatermark = mark.getTimestamp();
}

代码示例来源:origin: apache/flink

public long getCurrentWatermarkTimestamp() {
  Watermark wm = timestampsAndWatermarks.getCurrentWatermark();
  if (wm != null) {
    partitionWatermark = Math.max(partitionWatermark, wm.getTimestamp());
  }
  return partitionWatermark;
}

代码示例来源:origin: apache/flink

public void advanceWatermark(Watermark watermark) throws Exception {
  for (InternalTimerServiceImpl<?, ?> service : timerServices.values()) {
    service.advanceWatermark(watermark.getTimestamp());
  }
}

代码示例来源:origin: apache/flink

@Override
public void processWatermark(Watermark mark) throws Exception {
  super.processWatermark(mark);
  this.currentWatermark = mark.getTimestamp();
}

代码示例来源:origin: apache/flink

@Override
public void processWatermark(Watermark mark) throws Exception {
  super.processWatermark(mark);
  currentWatermark = mark.getTimestamp();
}

代码示例来源:origin: apache/flink

@Override
public void processWatermark(Watermark mark) throws Exception {
  super.processWatermark(mark);
  currentWatermark = mark.getTimestamp();
}

代码示例来源:origin: apache/flink

@Override
  public void close() throws Exception {
    super.close();

    // emit a final watermark
    Watermark newWatermark = userFunction.getCurrentWatermark();
    if (newWatermark != null && newWatermark.getTimestamp() > currentWatermark) {
      currentWatermark = newWatermark.getTimestamp();
      // emit watermark
      output.emitWatermark(newWatermark);
    }
  }
}

代码示例来源:origin: apache/flink

public void processWatermark2(Watermark mark) throws Exception {
  input2Watermark = mark.getTimestamp();
  long newMin = Math.min(input1Watermark, input2Watermark);
  if (newMin > combinedWatermark) {
    combinedWatermark = newMin;
    processWatermark(new Watermark(combinedWatermark));
  }
}

代码示例来源:origin: apache/flink

public void processWatermark1(Watermark mark) throws Exception {
  input1Watermark = mark.getTimestamp();
  long newMin = Math.min(input1Watermark, input2Watermark);
  if (newMin > combinedWatermark) {
    combinedWatermark = newMin;
    processWatermark(new Watermark(combinedWatermark));
  }
}

代码示例来源:origin: apache/flink

@Override
public void emitWatermark(Watermark mark) {
  watermarkGauge.setCurrentWatermark(mark.getTimestamp());
  for (Output<StreamRecord<OUT>> out : allOutputs) {
    out.emitWatermark(mark);
  }
}

代码示例来源:origin: apache/flink

@Override
public void emitWatermark(Watermark mark) {
  watermarkGauge.setCurrentWatermark(mark.getTimestamp());
  serializationDelegate.setInstance(mark);
  if (streamStatusProvider.getStreamStatus().isActive()) {
    try {
      recordWriter.broadcastEmit(serializationDelegate);
    } catch (Exception e) {
      throw new RuntimeException(e.getMessage(), e);
    }
  }
}

代码示例来源:origin: apache/flink

@Override
public void onProcessingTime(long timestamp) throws Exception {
  // register next timer
  Watermark newWatermark = userFunction.getCurrentWatermark();
  if (newWatermark != null && newWatermark.getTimestamp() > currentWatermark) {
    currentWatermark = newWatermark.getTimestamp();
    // emit watermark
    output.emitWatermark(newWatermark);
  }
  long now = getProcessingTimeService().getCurrentProcessingTime();
  getProcessingTimeService().registerTimer(now + watermarkInterval, this);
}

代码示例来源:origin: apache/flink

public OutputAsserter watermarkEquals(long timestamp) {
    Object record = output.poll();
    if (record instanceof Watermark) {
      Watermark watermark = (Watermark) record;
      assertThat(watermark.getTimestamp(), is(timestamp));
    } else {
      throw fail(record);
    }
    return this;
  }
}

代码示例来源:origin: apache/flink

@Override
public void emitWatermark(Watermark mark) {
  watermarkGauge.setCurrentWatermark(mark.getTimestamp());
  if (streamStatusProvider.getStreamStatus().isActive()) {
    for (Output<StreamRecord<T>> output : outputs) {
      output.emitWatermark(mark);
    }
  }
}

代码示例来源:origin: apache/flink

@Override
public void processWatermark(Watermark mark) throws Exception {
  super.processWatermark(mark);
  for (Watermark previousMark: watermarks) {
    assertTrue(previousMark.getTimestamp() < mark.getTimestamp());
  }
  watermarks.add(mark);
  latch.trigger();
  output.emitWatermark(mark);
}

代码示例来源:origin: apache/flink

@Override
public void emitWatermark(Watermark mark) {
  try {
    watermarkGauge.setCurrentWatermark(mark.getTimestamp());
    if (streamStatusProvider.getStreamStatus().isActive()) {
      operator.processWatermark(mark);
    }
  }
  catch (Exception e) {
    throw new ExceptionInChainedOperatorException(e);
  }
}

代码示例来源:origin: apache/flink

@Override
  public void processWatermark(Watermark mark) throws Exception {
    output.emitWatermark(new Watermark(mark.getTimestamp() * 2));
  }
}

代码示例来源:origin: apache/flink

@Test
public void testInitialAndFinalWatermark() {
  AscendingTimestampExtractor<Long> extractor = new LongExtractor();
  assertEquals(Long.MIN_VALUE, extractor.getCurrentWatermark().getTimestamp());
  extractor.extractTimestamp(Long.MIN_VALUE, -1L);
  extractor.extractTimestamp(Long.MAX_VALUE, -1L);
  assertEquals(Long.MAX_VALUE - 1, extractor.getCurrentWatermark().getTimestamp());
}

相关文章