use of org.apache.flink.migration.state.MigrationKeyGroupStateHandle in project flink by apache.
the class SavepointV0Serializer method convertKeyedBackendState.
/**
* This is public so that we can use it when restoring a legacy snapshot
* in {@code AbstractStreamOperatorTestHarness}.
*/
public static KeyGroupsStateHandle convertKeyedBackendState(HashMap<String, KvStateSnapshot<?, ?, ?, ?>> oldKeyedState, int parallelInstanceIdx, long checkpointID) throws Exception {
if (null != oldKeyedState) {
CheckpointStreamFactory checkpointStreamFactory = new MemCheckpointStreamFactory(MAX_SIZE);
CheckpointStreamFactory.CheckpointStateOutputStream keyedStateOut = checkpointStreamFactory.createCheckpointStateOutputStream(checkpointID, 0L);
try {
final long offset = keyedStateOut.getPos();
InstantiationUtil.serializeObject(keyedStateOut, oldKeyedState);
StreamStateHandle streamStateHandle = keyedStateOut.closeAndGetHandle();
// makes IOUtils.closeQuietly(...) ignore this
keyedStateOut = null;
if (null != streamStateHandle) {
KeyGroupRangeOffsets keyGroupRangeOffsets = new KeyGroupRangeOffsets(parallelInstanceIdx, parallelInstanceIdx, new long[] { offset });
return new MigrationKeyGroupStateHandle(keyGroupRangeOffsets, streamStateHandle);
}
} finally {
IOUtils.closeQuietly(keyedStateOut);
}
}
return null;
}
Aggregations