org.apache.flink.streaming.api.operators.InternalTimeServiceManager Java Examples
The following examples show how to use
org.apache.flink.streaming.api.operators.InternalTimeServiceManager.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KeyedCoProcessOperatorWithWatermarkDelay.java From flink with Apache License 2.0 | 5 votes |
@Override public void processWatermark(Watermark mark) throws Exception { Optional<InternalTimeServiceManager<?>> timeServiceManager = getTimeServiceManager(); if (timeServiceManager.isPresent()) { timeServiceManager.get().advanceWatermark(mark); } emitter.accept(mark); }
Example #2
Source File: StateReaderOperator.java From flink with Apache License 2.0 | 5 votes |
public final void setup( ExecutionConfig executionConfig, KeyedStateBackend<KEY> keyKeyedStateBackend, InternalTimeServiceManager<KEY> timerServiceManager, SavepointRuntimeContext ctx) { this.executionConfig = executionConfig; this.keyedStateBackend = keyKeyedStateBackend; this.timerServiceManager = timerServiceManager; this.keySerializer = keyType.createSerializer(executionConfig); FunctionUtils.setFunctionRuntimeContext(function, ctx); }
Example #3
Source File: KeyedStateInputFormat.java From flink with Apache License 2.0 | 5 votes |
@Override @SuppressWarnings("unchecked") public void open(KeyGroupRangeInputSplit split) throws IOException { registry = new CloseableRegistry(); final Environment environment = new SavepointEnvironment .Builder(getRuntimeContext(), split.getNumKeyGroups()) .setConfiguration(configuration) .setSubtaskIndex(split.getSplitNumber()) .setPrioritizedOperatorSubtaskState(split.getPrioritizedOperatorSubtaskState()) .build(); final StreamOperatorStateContext context = getStreamOperatorStateContext(environment); AbstractKeyedStateBackend<K> keyedStateBackend = (AbstractKeyedStateBackend<K>) context.keyedStateBackend(); final DefaultKeyedStateStore keyedStateStore = new DefaultKeyedStateStore(keyedStateBackend, getRuntimeContext().getExecutionConfig()); SavepointRuntimeContext ctx = new SavepointRuntimeContext(getRuntimeContext(), keyedStateStore); InternalTimeServiceManager<K> timeServiceManager = (InternalTimeServiceManager<K>) context.internalTimerServiceManager(); try { operator.setup(getRuntimeContext().getExecutionConfig(), keyedStateBackend, timeServiceManager, ctx); operator.open(); keysAndNamespaces = operator.getKeysAndNamespaces(ctx); } catch (Exception e) { throw new IOException("Failed to restore timer state", e); } }
Example #4
Source File: StreamTaskTest.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Override public StreamTaskStateInitializer createStreamTaskStateInitializer() { final StreamTaskStateInitializer streamTaskStateManager = super.createStreamTaskStateInitializer(); return (operatorID, operatorClassName, keyContext, keySerializer, closeableRegistry, metricGroup) -> { final StreamOperatorStateContext context = streamTaskStateManager.streamOperatorStateContext( operatorID, operatorClassName, keyContext, keySerializer, closeableRegistry, metricGroup); return new StreamOperatorStateContext() { @Override public boolean isRestored() { return context.isRestored(); } @Override public OperatorStateBackend operatorStateBackend() { return context.operatorStateBackend(); } @Override public AbstractKeyedStateBackend<?> keyedStateBackend() { return context.keyedStateBackend(); } @Override public InternalTimeServiceManager<?> internalTimerServiceManager() { InternalTimeServiceManager<?> timeServiceManager = context.internalTimerServiceManager(); return timeServiceManager != null ? spy(timeServiceManager) : null; } @Override public CloseableIterable<StatePartitionStreamProvider> rawOperatorStateInputs() { return replaceWithSpy(context.rawOperatorStateInputs()); } @Override public CloseableIterable<KeyGroupStatePartitionStreamProvider> rawKeyedStateInputs() { return replaceWithSpy(context.rawKeyedStateInputs()); } public <T extends Closeable> T replaceWithSpy(T closeable) { T spyCloseable = spy(closeable); if (closeableRegistry.unregisterCloseable(closeable)) { try { closeableRegistry.registerCloseable(spyCloseable); } catch (IOException e) { throw new RuntimeException(e); } } return spyCloseable; } }; }; }
Example #5
Source File: KeyedStateInputFormat.java From flink with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") private InternalTimerService<VoidNamespace> restoreTimerService(StreamOperatorStateContext context) { InternalTimeServiceManager<K> timeServiceManager = (InternalTimeServiceManager<K>) context.internalTimerServiceManager(); TimerSerializer<K, VoidNamespace> timerSerializer = new TimerSerializer<>(keySerializer, VoidNamespaceSerializer.INSTANCE); return timeServiceManager.getInternalTimerService(USER_TIMERS_NAME, timerSerializer, VoidTriggerable.instance()); }
Example #6
Source File: StreamTaskTest.java From flink with Apache License 2.0 | 4 votes |
@Override public StreamTaskStateInitializer createStreamTaskStateInitializer() { final StreamTaskStateInitializer streamTaskStateManager = super.createStreamTaskStateInitializer(); return (operatorID, operatorClassName, keyContext, keySerializer, closeableRegistry, metricGroup) -> { final StreamOperatorStateContext context = streamTaskStateManager.streamOperatorStateContext( operatorID, operatorClassName, keyContext, keySerializer, closeableRegistry, metricGroup); return new StreamOperatorStateContext() { @Override public boolean isRestored() { return context.isRestored(); } @Override public OperatorStateBackend operatorStateBackend() { return context.operatorStateBackend(); } @Override public AbstractKeyedStateBackend<?> keyedStateBackend() { return context.keyedStateBackend(); } @Override public InternalTimeServiceManager<?> internalTimerServiceManager() { InternalTimeServiceManager<?> timeServiceManager = context.internalTimerServiceManager(); return timeServiceManager != null ? spy(timeServiceManager) : null; } @Override public CloseableIterable<StatePartitionStreamProvider> rawOperatorStateInputs() { return replaceWithSpy(context.rawOperatorStateInputs()); } @Override public CloseableIterable<KeyGroupStatePartitionStreamProvider> rawKeyedStateInputs() { return replaceWithSpy(context.rawKeyedStateInputs()); } public <T extends Closeable> T replaceWithSpy(T closeable) { T spyCloseable = spy(closeable); if (closeableRegistry.unregisterCloseable(closeable)) { try { closeableRegistry.registerCloseable(spyCloseable); } catch (IOException e) { throw new RuntimeException(e); } } return spyCloseable; } }; }; }
Example #7
Source File: FlinkTimerServiceFactory.java From stateful-functions with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") FlinkTimerServiceFactory(InternalTimeServiceManager<?> timeServiceManager) { this.timeServiceManager = (InternalTimeServiceManager<String>) Objects.requireNonNull(timeServiceManager); }
Example #8
Source File: FlinkTimerServiceFactory.java From flink-statefun with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") FlinkTimerServiceFactory(InternalTimeServiceManager<?> timeServiceManager) { this.timeServiceManager = (InternalTimeServiceManager<String>) Objects.requireNonNull(timeServiceManager); }
Example #9
Source File: StreamTaskTest.java From flink with Apache License 2.0 | 4 votes |
@Override public StreamTaskStateInitializer createStreamTaskStateInitializer() { final StreamTaskStateInitializer streamTaskStateManager = super.createStreamTaskStateInitializer(); return (operatorID, operatorClassName, processingTimeService, keyContext, keySerializer, closeableRegistry, metricGroup) -> { final StreamOperatorStateContext controller = streamTaskStateManager.streamOperatorStateContext( operatorID, operatorClassName, processingTimeService, keyContext, keySerializer, closeableRegistry, metricGroup); return new StreamOperatorStateContext() { @Override public boolean isRestored() { return controller.isRestored(); } @Override public OperatorStateBackend operatorStateBackend() { return controller.operatorStateBackend(); } @Override public AbstractKeyedStateBackend<?> keyedStateBackend() { return controller.keyedStateBackend(); } @Override public InternalTimeServiceManager<?> internalTimerServiceManager() { InternalTimeServiceManager<?> timeServiceManager = controller.internalTimerServiceManager(); return timeServiceManager != null ? spy(timeServiceManager) : null; } @Override public CloseableIterable<StatePartitionStreamProvider> rawOperatorStateInputs() { return replaceWithSpy(controller.rawOperatorStateInputs()); } @Override public CloseableIterable<KeyGroupStatePartitionStreamProvider> rawKeyedStateInputs() { return replaceWithSpy(controller.rawKeyedStateInputs()); } public <T extends Closeable> T replaceWithSpy(T closeable) { T spyCloseable = spy(closeable); if (closeableRegistry.unregisterCloseable(closeable)) { try { closeableRegistry.registerCloseable(spyCloseable); } catch (IOException e) { throw new RuntimeException(e); } } return spyCloseable; } }; }; }