Search in sources :

Example 11 with VoidNamespace

use of org.apache.flink.runtime.state.VoidNamespace in project flink by apache.

the class BaseTwoInputStreamOperatorWithStateRetention method initializeTimerService.

private void initializeTimerService() {
    InternalTimerService<VoidNamespace> internalTimerService = getInternalTimerService(TIMERS_STATE_NAME, VoidNamespaceSerializer.INSTANCE, this);
    timerService = new SimpleTimerService(internalTimerService);
}
Also used : SimpleTimerService(org.apache.flink.streaming.api.SimpleTimerService) VoidNamespace(org.apache.flink.runtime.state.VoidNamespace)

Example 12 with VoidNamespace

use of org.apache.flink.runtime.state.VoidNamespace in project flink by apache.

the class LatencyTrackingReducingStateTest method testLatencyTrackingReducingState.

@Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void testLatencyTrackingReducingState() throws Exception {
    AbstractKeyedStateBackend<Integer> keyedBackend = createKeyedBackend(getKeySerializer());
    try {
        LatencyTrackingReducingState<Integer, VoidNamespace, Long> latencyTrackingState = (LatencyTrackingReducingState) createLatencyTrackingState(keyedBackend, getStateDescriptor());
        latencyTrackingState.setCurrentNamespace(VoidNamespace.INSTANCE);
        LatencyTrackingReducingState.ReducingStateLatencyMetrics latencyTrackingStateMetric = latencyTrackingState.getLatencyTrackingStateMetric();
        assertEquals(0, latencyTrackingStateMetric.getAddCount());
        assertEquals(0, latencyTrackingStateMetric.getGetCount());
        assertEquals(0, latencyTrackingStateMetric.getMergeNamespaceCount());
        setCurrentKey(keyedBackend);
        ThreadLocalRandom random = ThreadLocalRandom.current();
        for (int index = 1; index <= SAMPLE_INTERVAL; index++) {
            int expectedResult = index == SAMPLE_INTERVAL ? 0 : index;
            latencyTrackingState.add(random.nextLong());
            assertEquals(expectedResult, latencyTrackingStateMetric.getAddCount());
            latencyTrackingState.get();
            assertEquals(expectedResult, latencyTrackingStateMetric.getGetCount());
            latencyTrackingState.mergeNamespaces(VoidNamespace.INSTANCE, Collections.emptyList());
            assertEquals(expectedResult, latencyTrackingStateMetric.getMergeNamespaceCount());
        }
    } finally {
        if (keyedBackend != null) {
            keyedBackend.close();
            keyedBackend.dispose();
        }
    }
}
Also used : ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) VoidNamespace(org.apache.flink.runtime.state.VoidNamespace) Test(org.junit.Test)

Example 13 with VoidNamespace

use of org.apache.flink.runtime.state.VoidNamespace in project flink by apache.

the class KeyedProcessOperator method open.

@Override
public void open() throws Exception {
    super.open();
    collector = new TimestampedCollector<>(output);
    InternalTimerService<VoidNamespace> internalTimerService = getInternalTimerService("user-timers", VoidNamespaceSerializer.INSTANCE, this);
    TimerService timerService = new SimpleTimerService(internalTimerService);
    context = new ContextImpl(userFunction, timerService);
    onTimerContext = new OnTimerContextImpl(userFunction, timerService);
}
Also used : SimpleTimerService(org.apache.flink.streaming.api.SimpleTimerService) VoidNamespace(org.apache.flink.runtime.state.VoidNamespace) TimerService(org.apache.flink.streaming.api.TimerService) SimpleTimerService(org.apache.flink.streaming.api.SimpleTimerService)

Example 14 with VoidNamespace

use of org.apache.flink.runtime.state.VoidNamespace in project flink by apache.

the class LegacyKeyedProcessOperator method open.

@Override
public void open() throws Exception {
    super.open();
    collector = new TimestampedCollector<>(output);
    InternalTimerService<VoidNamespace> internalTimerService = getInternalTimerService("user-timers", VoidNamespaceSerializer.INSTANCE, this);
    TimerService timerService = new SimpleTimerService(internalTimerService);
    context = new ContextImpl(userFunction, timerService);
    onTimerContext = new OnTimerContextImpl(userFunction, timerService);
}
Also used : SimpleTimerService(org.apache.flink.streaming.api.SimpleTimerService) VoidNamespace(org.apache.flink.runtime.state.VoidNamespace) TimerService(org.apache.flink.streaming.api.TimerService) SimpleTimerService(org.apache.flink.streaming.api.SimpleTimerService)

Example 15 with VoidNamespace

use of org.apache.flink.runtime.state.VoidNamespace in project flink by apache.

the class BaseTemporalSortOperator method open.

@Override
public void open() throws Exception {
    InternalTimerService<VoidNamespace> internalTimerService = getInternalTimerService("user-timers", VoidNamespaceSerializer.INSTANCE, this);
    timerService = new SimpleTimerService(internalTimerService);
    collector = new TimestampedCollector<>(output);
}
Also used : SimpleTimerService(org.apache.flink.streaming.api.SimpleTimerService) VoidNamespace(org.apache.flink.runtime.state.VoidNamespace)

Aggregations

VoidNamespace (org.apache.flink.runtime.state.VoidNamespace)31 Test (org.junit.Test)21 KeyGroupRange (org.apache.flink.runtime.state.KeyGroupRange)11 ExecutionConfig (org.apache.flink.api.common.ExecutionConfig)10 ArrayList (java.util.ArrayList)9 SimpleTimerService (org.apache.flink.streaming.api.SimpleTimerService)8 JobID (org.apache.flink.api.common.JobID)6 VoidNamespaceSerializer (org.apache.flink.runtime.state.VoidNamespaceSerializer)6 InternalTimerService (org.apache.flink.streaming.api.operators.InternalTimerService)6 TestProcessingTimeService (org.apache.flink.streaming.runtime.tasks.TestProcessingTimeService)6 List (java.util.List)5 MemoryStateBackend (org.apache.flink.runtime.state.memory.MemoryStateBackend)5 TimerService (org.apache.flink.streaming.api.TimerService)5 Arrays (java.util.Arrays)4 TaskKvStateRegistry (org.apache.flink.runtime.query.TaskKvStateRegistry)4 Watermark (org.apache.flink.streaming.api.watermark.Watermark)4 Assert (org.junit.Assert)4 Collections (java.util.Collections)3 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)3 BiConsumer (java.util.function.BiConsumer)3