Search in sources :

Example 11 with TimerUpdate

use of org.apache.beam.runners.direct.WatermarkManager.TimerUpdate in project beam by apache.

the class WatermarkManagerTest method timerUpdateBuilderBuildAddsAllAddedTimers.

@Test
public void timerUpdateBuilderBuildAddsAllAddedTimers() {
    TimerData set = TimerData.of(StateNamespaces.global(), new Instant(10L), new Instant(10L), TimeDomain.EVENT_TIME);
    TimerData deleted = TimerData.of(StateNamespaces.global(), new Instant(24L), new Instant(24L), TimeDomain.PROCESSING_TIME);
    TimerData completedOne = TimerData.of(StateNamespaces.global(), new Instant(1024L), new Instant(1024L), TimeDomain.SYNCHRONIZED_PROCESSING_TIME);
    TimerData completedTwo = TimerData.of(StateNamespaces.global(), new Instant(2048L), new Instant(2048L), TimeDomain.EVENT_TIME);
    TimerUpdate update = TimerUpdate.builder(StructuralKey.of("foo", StringUtf8Coder.of())).withCompletedTimers(ImmutableList.of(completedOne, completedTwo)).setTimer(set).deletedTimer(deleted).build();
    assertThat(update.getCompletedTimers(), containsInAnyOrder(completedOne, completedTwo));
    assertThat(update.getSetTimers(), contains(set));
    assertThat(update.getDeletedTimers(), contains(deleted));
}
Also used : TimerUpdate(org.apache.beam.runners.direct.WatermarkManager.TimerUpdate) Instant(org.joda.time.Instant) TimerData(org.apache.beam.runners.core.TimerInternals.TimerData) Test(org.junit.Test)

Example 12 with TimerUpdate

use of org.apache.beam.runners.direct.WatermarkManager.TimerUpdate in project beam by apache.

the class WatermarkManagerTest method timerUpdateBuilderWithDeleteThenSetHasOnlySet.

@Test
public void timerUpdateBuilderWithDeleteThenSetHasOnlySet() {
    TimerUpdateBuilder builder = TimerUpdate.builder(null);
    Instant now = Instant.now();
    TimerData timer = TimerData.of(StateNamespaces.global(), now, now, TimeDomain.EVENT_TIME);
    TimerUpdate built = builder.deletedTimer(timer).setTimer(timer).build();
    assertThat(built.getSetTimers(), contains(timer));
    assertThat(built.getDeletedTimers(), emptyIterable());
}
Also used : TimerUpdate(org.apache.beam.runners.direct.WatermarkManager.TimerUpdate) Instant(org.joda.time.Instant) TimerData(org.apache.beam.runners.core.TimerInternals.TimerData) TimerUpdateBuilder(org.apache.beam.runners.direct.WatermarkManager.TimerUpdate.TimerUpdateBuilder) Test(org.junit.Test)

Example 13 with TimerUpdate

use of org.apache.beam.runners.direct.WatermarkManager.TimerUpdate in project beam by apache.

the class WatermarkManagerTest method timerUpdateBuilderWithDeleteAfterBuildNotAddedToBuilt.

@Test
public void timerUpdateBuilderWithDeleteAfterBuildNotAddedToBuilt() {
    TimerUpdateBuilder builder = TimerUpdate.builder(null);
    Instant now = Instant.now();
    TimerData timer = TimerData.of(StateNamespaces.global(), now, now, TimeDomain.EVENT_TIME);
    TimerUpdate built = builder.build();
    builder.deletedTimer(timer);
    assertThat(built.getDeletedTimers(), emptyIterable());
    builder.build();
    assertThat(built.getDeletedTimers(), emptyIterable());
}
Also used : TimerUpdate(org.apache.beam.runners.direct.WatermarkManager.TimerUpdate) Instant(org.joda.time.Instant) TimerData(org.apache.beam.runners.core.TimerInternals.TimerData) TimerUpdateBuilder(org.apache.beam.runners.direct.WatermarkManager.TimerUpdate.TimerUpdateBuilder) Test(org.junit.Test)

Aggregations

TimerData (org.apache.beam.runners.core.TimerInternals.TimerData)13 TimerUpdate (org.apache.beam.runners.direct.WatermarkManager.TimerUpdate)13 Instant (org.joda.time.Instant)13 Test (org.junit.Test)13 FiredTimers (org.apache.beam.runners.direct.WatermarkManager.FiredTimers)6 TimerUpdateBuilder (org.apache.beam.runners.direct.WatermarkManager.TimerUpdate.TimerUpdateBuilder)6 AppliedPTransform (org.apache.beam.sdk.runners.AppliedPTransform)5 TransformWatermarks (org.apache.beam.runners.direct.WatermarkManager.TransformWatermarks)1