Search in sources :

Example 1 with SavepointKeyedStateHandle

use of org.apache.flink.runtime.state.SavepointKeyedStateHandle in project flink by apache.

the class HeapKeyedStateBackendBuilder method restoreState.

private void restoreState(Map<String, StateTable<K, ?, ?>> registeredKVStates, Map<String, HeapPriorityQueueSnapshotRestoreWrapper<?>> registeredPQStates, InternalKeyContext<K> keyContext, StateTableFactory<K> stateTableFactory) throws BackendBuildingException {
    final RestoreOperation<Void> restoreOperation;
    final KeyedStateHandle firstHandle;
    if (restoreStateHandles.isEmpty()) {
        firstHandle = null;
    } else {
        firstHandle = restoreStateHandles.iterator().next();
    }
    if (firstHandle instanceof SavepointKeyedStateHandle) {
        restoreOperation = new HeapSavepointRestoreOperation<>(restoreStateHandles, keySerializerProvider, userCodeClassLoader, registeredKVStates, registeredPQStates, priorityQueueSetFactory, keyGroupRange, numberOfKeyGroups, stateTableFactory, keyContext);
    } else {
        restoreOperation = new HeapRestoreOperation<>(restoreStateHandles, keySerializerProvider, userCodeClassLoader, registeredKVStates, registeredPQStates, cancelStreamRegistry, priorityQueueSetFactory, keyGroupRange, numberOfKeyGroups, stateTableFactory, keyContext);
    }
    try {
        restoreOperation.restore();
        logger.info("Finished to build heap keyed state-backend.");
    } catch (Exception e) {
        throw new BackendBuildingException("Failed when trying to restore heap backend", e);
    }
}
Also used : BackendBuildingException(org.apache.flink.runtime.state.BackendBuildingException) SavepointKeyedStateHandle(org.apache.flink.runtime.state.SavepointKeyedStateHandle) KeyedStateHandle(org.apache.flink.runtime.state.KeyedStateHandle) SavepointKeyedStateHandle(org.apache.flink.runtime.state.SavepointKeyedStateHandle) BackendBuildingException(org.apache.flink.runtime.state.BackendBuildingException)

Aggregations

BackendBuildingException (org.apache.flink.runtime.state.BackendBuildingException)1 KeyedStateHandle (org.apache.flink.runtime.state.KeyedStateHandle)1 SavepointKeyedStateHandle (org.apache.flink.runtime.state.SavepointKeyedStateHandle)1