protected <K> InternalTimeServiceManager<K> internalTimeServiceManager( AbstractKeyedStateBackend<K> keyedStatedBackend, KeyContext keyContext, //the operator Iterable<KeyGroupStatePartitionStreamProvider> rawKeyedStates) throws Exception { if (keyedStatedBackend == null) { return null; } final KeyGroupRange keyGroupRange = keyedStatedBackend.getKeyGroupRange(); final InternalTimeServiceManager<K> timeServiceManager = new InternalTimeServiceManager<>( keyGroupRange, keyContext, keyedStatedBackend, processingTimeService, keyedStatedBackend.requiresLegacySynchronousTimerSnapshots()); // and then initialize the timer services for (KeyGroupStatePartitionStreamProvider streamProvider : rawKeyedStates) { int keyGroupIdx = streamProvider.getKeyGroupId(); Preconditions.checkArgument(keyGroupRange.contains(keyGroupIdx), "Key Group " + keyGroupIdx + " does not belong to the local range."); timeServiceManager.restoreStateForKeyGroup( streamProvider.getStream(), keyGroupIdx, environment.getUserClassLoader()); } return timeServiceManager; }
protected <K> InternalTimeServiceManager<K> internalTimeServiceManager( AbstractKeyedStateBackend<K> keyedStatedBackend, KeyContext keyContext, //the operator Iterable<KeyGroupStatePartitionStreamProvider> rawKeyedStates) throws Exception { if (keyedStatedBackend == null) { return null; } final KeyGroupRange keyGroupRange = keyedStatedBackend.getKeyGroupRange(); final InternalTimeServiceManager<K> timeServiceManager = new InternalTimeServiceManager<>( keyGroupRange, keyContext, keyedStatedBackend, processingTimeService, keyedStatedBackend.requiresLegacySynchronousTimerSnapshots()); // and then initialize the timer services for (KeyGroupStatePartitionStreamProvider streamProvider : rawKeyedStates) { int keyGroupIdx = streamProvider.getKeyGroupId(); Preconditions.checkArgument(keyGroupRange.contains(keyGroupIdx), "Key Group " + keyGroupIdx + " does not belong to the local range."); timeServiceManager.restoreStateForKeyGroup( streamProvider.getStream(), keyGroupIdx, environment.getUserClassLoader()); } return timeServiceManager; }
protected <K> InternalTimeServiceManager<K> internalTimeServiceManager( AbstractKeyedStateBackend<K> keyedStatedBackend, KeyContext keyContext, //the operator Iterable<KeyGroupStatePartitionStreamProvider> rawKeyedStates) throws Exception { if (keyedStatedBackend == null) { return null; } final KeyGroupRange keyGroupRange = keyedStatedBackend.getKeyGroupRange(); final InternalTimeServiceManager<K> timeServiceManager = new InternalTimeServiceManager<>( keyGroupRange, keyContext, keyedStatedBackend, processingTimeService, keyedStatedBackend.requiresLegacySynchronousTimerSnapshots()); // and then initialize the timer services for (KeyGroupStatePartitionStreamProvider streamProvider : rawKeyedStates) { int keyGroupIdx = streamProvider.getKeyGroupId(); Preconditions.checkArgument(keyGroupRange.contains(keyGroupIdx), "Key Group " + keyGroupIdx + " does not belong to the local range."); timeServiceManager.restoreStateForKeyGroup( streamProvider.getStream(), keyGroupIdx, environment.getUserClassLoader()); } return timeServiceManager; }
/** * Stream operators with state which can be restored need to override this hook method. * * @param context context that allows to register different states. */ public void initializeState(StateInitializationContext context) throws Exception { if (getKeyedStateBackend() != null) { KeyGroupsList localKeyGroupRange = getKeyedStateBackend().getKeyGroupRange(); // and then initialize the timer services for (KeyGroupStatePartitionStreamProvider streamProvider : context.getRawKeyedStateInputs()) { int keyGroupIdx = streamProvider.getKeyGroupId(); checkArgument(localKeyGroupRange.contains(keyGroupIdx), "Key Group " + keyGroupIdx + " does not belong to the local range."); timeServiceManager.restoreStateForKeyGroup( new DataInputViewStreamWrapper(streamProvider.getStream()), keyGroupIdx, getUserCodeClassloader()); } } }