@Override public void initializeState(StateInitializationContext context) throws Exception { keyedStateBackend = (AbstractKeyedStateBackend<?>) getKeyedStateBackend(); operatorStateBackend = getOperatorStateBackend(); rawOperatorStateInputs = (CloseableIterable<StatePartitionStreamProvider>) context.getRawOperatorStateInputs(); rawKeyedStateInputs = (CloseableIterable<KeyGroupStatePartitionStreamProvider>) context.getRawKeyedStateInputs(); super.initializeState(context); } }
for (KeyGroupStatePartitionStreamProvider streamProvider : context.getRawKeyedStateInputs()) { try (InputStream in = streamProvider.getStream()) { DataInputView div = new DataInputViewStreamWrapper(in);
@Override public void initializeState(StateInitializationContext context) throws Exception { if (getKeyedStateBackend() != null) { KeyGroupsList localKeyGroupRange = getKeyedStateBackend().getKeyGroupRange(); for (KeyGroupStatePartitionStreamProvider streamProvider : context.getRawKeyedStateInputs()) { DataInputViewStreamWrapper div = new DataInputViewStreamWrapper(streamProvider.getStream()); int keyGroupIdx = streamProvider.getKeyGroupId(); checkArgument(localKeyGroupRange.contains(keyGroupIdx), "Key Group " + keyGroupIdx + " does not belong to the local range."); // if (this instanceof KeyGroupRestoringOperator) restoreKeyGroupState(keyGroupIdx, div); } } }
/** * 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()); } } }
@Override public void initializeState(StateInitializationContext context) throws Exception { if (getKeyedStateBackend() != null) { int totalKeyGroups = getKeyedStateBackend().getNumberOfKeyGroups(); KeyGroupsList localKeyGroupRange = getKeyedStateBackend().getKeyGroupRange(); for (KeyGroupStatePartitionStreamProvider streamProvider : context.getRawKeyedStateInputs()) { DataInputViewStreamWrapper div = new DataInputViewStreamWrapper(streamProvider.getStream()); int keyGroupIdx = streamProvider.getKeyGroupId(); checkArgument(localKeyGroupRange.contains(keyGroupIdx), "Key Group " + keyGroupIdx + " does not belong to the local range."); // if (this instanceof KeyGroupRestoringOperator) restoreKeyGroupState(keyGroupIdx, div); // We just initialize our timerService if (keyCoder != null) { if (timerService == null) { timerService = new HeapInternalTimerService<>( totalKeyGroups, localKeyGroupRange, this, getRuntimeContext().getProcessingTimeService()); } timerService.restoreTimersForKeyGroup(div, keyGroupIdx, getUserCodeClassloader()); } } } }