use of org.apache.beam.runners.core.TimerInternals.TimerData in project beam by apache.
the class ApexTimerInternalsTest method testDeleteTimer.
@Test
public void testDeleteTimer() {
TimerDataCoder timerDataCoder = TimerDataCoder.of(GlobalWindow.Coder.INSTANCE);
String key1 = "key1";
Instant instant0 = new Instant(0);
Instant instant1 = new Instant(1);
ApexTimerInternals<String> timerInternals = new ApexTimerInternals<>(timerDataCoder);
timerInternals.setContext(key1, StringUtf8Coder.of(), Instant.now(), null);
TimerData timerData0 = TimerData.of("timerData0", StateNamespaces.global(), instant0, TimeDomain.EVENT_TIME);
timerInternals.setTimer(timerData0);
TimerData timerData1 = TimerData.of("timerData1", StateNamespaces.global(), instant1, TimeDomain.EVENT_TIME);
timerInternals.setTimer(timerData1);
Map<?, Set<Slice>> timerMap = timerInternals.getTimerSet(TimeDomain.EVENT_TIME).getMap();
assertEquals(1, timerMap.size());
assertEquals(2, timerMap.values().iterator().next().size());
timerInternals.deleteTimer(timerData0.getNamespace(), timerData0.getTimerId());
assertEquals(1, timerMap.size());
assertEquals(1, timerMap.values().iterator().next().size());
timerInternals.deleteTimer(timerData1.getNamespace(), timerData1.getTimerId(), TimeDomain.PROCESSING_TIME);
assertEquals(1, timerMap.size());
assertEquals(1, timerMap.values().iterator().next().size());
timerInternals.deleteTimer(timerData1.getNamespace(), timerData1.getTimerId(), TimeDomain.EVENT_TIME);
assertEquals(0, timerMap.size());
}
Aggregations