Search in sources :

Example 1 with BatchExecutionInternalTimeServiceManager

use of org.apache.flink.streaming.api.operators.sorted.state.BatchExecutionInternalTimeServiceManager in project flink by apache.

the class AbstractPythonFunctionOperator method fireAllRegisteredTimers.

private void fireAllRegisteredTimers(Object newKey) throws Exception {
    Field keySelectionListenersField = BatchExecutionKeyedStateBackend.class.getDeclaredField("keySelectionListeners");
    keySelectionListenersField.setAccessible(true);
    List<KeyedStateBackend.KeySelectionListener<Object>> listeners = (List<KeyedStateBackend.KeySelectionListener<Object>>) keySelectionListenersField.get(getKeyedStateBackend());
    for (KeyedStateBackend.KeySelectionListener<Object> listener : listeners) {
        if (listener instanceof BatchExecutionInternalTimeServiceManager) {
            // fire the registered timers
            listener.keySelected(newKey);
            // set back the current key
            listener.keySelected(getCurrentKey());
        }
    }
}
Also used : KeyedStateBackend(org.apache.flink.runtime.state.KeyedStateBackend) BatchExecutionKeyedStateBackend(org.apache.flink.streaming.api.operators.sorted.state.BatchExecutionKeyedStateBackend) Field(java.lang.reflect.Field) List(java.util.List) BatchExecutionInternalTimeServiceManager(org.apache.flink.streaming.api.operators.sorted.state.BatchExecutionInternalTimeServiceManager)

Example 2 with BatchExecutionInternalTimeServiceManager

use of org.apache.flink.streaming.api.operators.sorted.state.BatchExecutionInternalTimeServiceManager in project flink by apache.

the class StreamGraphGenerator method setBatchStateBackendAndTimerService.

private void setBatchStateBackendAndTimerService(StreamGraph graph) {
    boolean useStateBackend = configuration.get(ExecutionOptions.USE_BATCH_STATE_BACKEND);
    boolean sortInputs = configuration.get(ExecutionOptions.SORT_INPUTS);
    checkState(!useStateBackend || sortInputs, "Batch state backend requires the sorted inputs to be enabled!");
    if (useStateBackend) {
        LOG.debug("Using BATCH execution state backend and timer service.");
        graph.setStateBackend(new BatchExecutionStateBackend());
        graph.setChangelogStateBackendEnabled(TernaryBoolean.FALSE);
        graph.setCheckpointStorage(new BatchExecutionCheckpointStorage());
        graph.setTimerServiceProvider(BatchExecutionInternalTimeServiceManager::create);
    } else {
        graph.setStateBackend(stateBackend);
        graph.setChangelogStateBackendEnabled(changelogStateBackendEnabled);
    }
}
Also used : BatchExecutionCheckpointStorage(org.apache.flink.streaming.api.operators.sorted.state.BatchExecutionCheckpointStorage) BatchExecutionStateBackend(org.apache.flink.streaming.api.operators.sorted.state.BatchExecutionStateBackend) BatchExecutionInternalTimeServiceManager(org.apache.flink.streaming.api.operators.sorted.state.BatchExecutionInternalTimeServiceManager)

Aggregations

BatchExecutionInternalTimeServiceManager (org.apache.flink.streaming.api.operators.sorted.state.BatchExecutionInternalTimeServiceManager)2 Field (java.lang.reflect.Field)1 List (java.util.List)1 KeyedStateBackend (org.apache.flink.runtime.state.KeyedStateBackend)1 BatchExecutionCheckpointStorage (org.apache.flink.streaming.api.operators.sorted.state.BatchExecutionCheckpointStorage)1 BatchExecutionKeyedStateBackend (org.apache.flink.streaming.api.operators.sorted.state.BatchExecutionKeyedStateBackend)1 BatchExecutionStateBackend (org.apache.flink.streaming.api.operators.sorted.state.BatchExecutionStateBackend)1