use of org.apache.flink.util.CloseableIterable in project flink by apache.
the class StreamTaskStateInitializerImpl method rawOperatorStateInputs.
protected CloseableIterable<StatePartitionStreamProvider> rawOperatorStateInputs(Iterator<StateObjectCollection<OperatorStateHandle>> restoreStateAlternatives) {
if (restoreStateAlternatives.hasNext()) {
Collection<OperatorStateHandle> rawOperatorState = restoreStateAlternatives.next();
// TODO currently this does not support local state recovery, so we expect there is only
// one handle.
Preconditions.checkState(!restoreStateAlternatives.hasNext(), "Local recovery is currently not implemented for raw operator state, but found state alternative.");
if (rawOperatorState != null) {
return new CloseableIterable<StatePartitionStreamProvider>() {
final CloseableRegistry closeableRegistry = new CloseableRegistry();
@Override
public void close() throws IOException {
closeableRegistry.close();
}
@Nonnull
@Override
public Iterator<StatePartitionStreamProvider> iterator() {
return new OperatorStateStreamIterator(DefaultOperatorStateBackend.DEFAULT_OPERATOR_STATE_NAME, rawOperatorState.iterator(), closeableRegistry);
}
};
}
}
return CloseableIterable.empty();
}
use of org.apache.flink.util.CloseableIterable in project flink by apache.
the class StreamTaskStateInitializerImpl method rawKeyedStateInputs.
protected CloseableIterable<KeyGroupStatePartitionStreamProvider> rawKeyedStateInputs(Iterator<StateObjectCollection<KeyedStateHandle>> restoreStateAlternatives) {
if (restoreStateAlternatives.hasNext()) {
Collection<KeyedStateHandle> rawKeyedState = restoreStateAlternatives.next();
// TODO currently this does not support local state recovery, so we expect there is only
// one handle.
Preconditions.checkState(!restoreStateAlternatives.hasNext(), "Local recovery is currently not implemented for raw keyed state, but found state alternative.");
if (rawKeyedState != null) {
Collection<KeyGroupsStateHandle> keyGroupsStateHandles = transform(rawKeyedState);
final CloseableRegistry closeableRegistry = new CloseableRegistry();
return new CloseableIterable<KeyGroupStatePartitionStreamProvider>() {
@Override
public void close() throws IOException {
closeableRegistry.close();
}
@Override
public Iterator<KeyGroupStatePartitionStreamProvider> iterator() {
return new KeyGroupStreamIterator(keyGroupsStateHandles.iterator(), closeableRegistry);
}
};
}
}
return CloseableIterable.empty();
}
Aggregations