Package org.apache.flink.runtime.state
Class StateBackendLoader
- java.lang.Object
-
- org.apache.flink.runtime.state.StateBackendLoader
-
public class StateBackendLoader extends Object
This class contains utility methods to load state backends from configurations.
-
-
Field Summary
Fields Modifier and Type Field Description static StringFORST_STATE_BACKEND_NAMEstatic StringHASHMAP_STATE_BACKEND_NAMEThe shortcut configuration name of the HashMap state backend.static StringROCKSDB_STATE_BACKEND_NAMEThe shortcut configuration name for the RocksDB State Backend.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StateBackendfromApplicationOrConfigOrDefault(StateBackend fromApplication, org.apache.flink.configuration.Configuration jobConfig, org.apache.flink.configuration.Configuration clusterConfig, ClassLoader classLoader, org.slf4j.Logger logger)This is the state backend loader that loads aDelegatingStateBackendwrapping the state backend loaded fromloadFromApplicationOrConfigOrDefaultInternal(org.apache.flink.runtime.state.StateBackend, org.apache.flink.configuration.Configuration, org.apache.flink.configuration.Configuration, java.lang.ClassLoader, org.slf4j.Logger)when delegation is enabled.static booleanisChangelogStateBackend(StateBackend backend)static StateBackendloadStateBackendFromConfig(org.apache.flink.configuration.ReadableConfig config, ClassLoader classLoader, org.slf4j.Logger logger)Loads the unwrapped state backend from the configuration, from the parameter 'state.backend', as defined inStateBackendOptions.STATE_BACKEND.static StateBackendloadStateBackendFromKeyedStateHandles(StateBackend originalStateBackend, ClassLoader classLoader, Collection<KeyedStateHandle> keyedStateHandles)Load state backend which may wrap the original state backend for recovery.static booleanstateBackendFromApplicationOrConfigOrDefaultUseManagedMemory(org.apache.flink.configuration.Configuration config, Optional<Boolean> stateBackendFromApplicationUsesManagedMemory, ClassLoader classLoader)Checks whether state backend uses managed memory, without having to deserialize or load the state backend.
-
-
-
Field Detail
-
HASHMAP_STATE_BACKEND_NAME
public static final String HASHMAP_STATE_BACKEND_NAME
The shortcut configuration name of the HashMap state backend.- See Also:
- Constant Field Values
-
ROCKSDB_STATE_BACKEND_NAME
public static final String ROCKSDB_STATE_BACKEND_NAME
The shortcut configuration name for the RocksDB State Backend.- See Also:
- Constant Field Values
-
FORST_STATE_BACKEND_NAME
public static final String FORST_STATE_BACKEND_NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
loadStateBackendFromConfig
@Nonnull public static StateBackend loadStateBackendFromConfig(org.apache.flink.configuration.ReadableConfig config, ClassLoader classLoader, @Nullable org.slf4j.Logger logger) throws org.apache.flink.configuration.IllegalConfigurationException, org.apache.flink.util.DynamicCodeLoadingException, IOException
Loads the unwrapped state backend from the configuration, from the parameter 'state.backend', as defined inStateBackendOptions.STATE_BACKEND.The state backends can be specified either via their shortcut name, or via the class name of a
StateBackendFactory. If a StateBackendFactory class name is specified, the factory is instantiated (via its zero-argument constructor) and itsStateBackendFactory.createFromConfig(ReadableConfig, ClassLoader)method is called.- Parameters:
config- The configuration to load the state backend fromclassLoader- The class loader that should be used to load the state backendlogger- Optionally, a logger to log actions to (may be null)- Returns:
- The instantiated state backend.
- Throws:
org.apache.flink.util.DynamicCodeLoadingException- Thrown if a state backend factory is configured and the factory class was not found or the factory could not be instantiatedorg.apache.flink.configuration.IllegalConfigurationException- May be thrown by the StateBackendFactory when creating / configuring the state backend in the factoryIOException- May be thrown by the StateBackendFactory when instantiating the state backend
-
fromApplicationOrConfigOrDefault
public static StateBackend fromApplicationOrConfigOrDefault(@Nullable StateBackend fromApplication, org.apache.flink.configuration.Configuration jobConfig, org.apache.flink.configuration.Configuration clusterConfig, ClassLoader classLoader, @Nullable org.slf4j.Logger logger) throws org.apache.flink.configuration.IllegalConfigurationException, org.apache.flink.util.DynamicCodeLoadingException, IOException
This is the state backend loader that loads aDelegatingStateBackendwrapping the state backend loaded fromloadFromApplicationOrConfigOrDefaultInternal(org.apache.flink.runtime.state.StateBackend, org.apache.flink.configuration.Configuration, org.apache.flink.configuration.Configuration, java.lang.ClassLoader, org.slf4j.Logger)when delegation is enabled. If delegation is not enabled, the underlying wrapped state backend is returned instead.- Parameters:
fromApplication- StateBackend defined from applicationjobConfig- The job level configuration to load the state backend fromclusterConfig- The cluster level configuration to load the state backend fromclassLoader- The class loader that should be used to load the state backendlogger- Optionally, a logger to log actions to (may be null)- Returns:
- The instantiated state backend.
- Throws:
org.apache.flink.util.DynamicCodeLoadingException- Thrown if a state backend (factory) is configured and the (factory) class was not found or could not be instantiatedorg.apache.flink.configuration.IllegalConfigurationException- May be thrown by the StateBackendFactory when creating / configuring the state backend in the factoryIOException- May be thrown by the StateBackendFactory when instantiating the state backend
-
stateBackendFromApplicationOrConfigOrDefaultUseManagedMemory
public static boolean stateBackendFromApplicationOrConfigOrDefaultUseManagedMemory(org.apache.flink.configuration.Configuration config, Optional<Boolean> stateBackendFromApplicationUsesManagedMemory, ClassLoader classLoader)Checks whether state backend uses managed memory, without having to deserialize or load the state backend.- Parameters:
config- configuration to load the state backend from.stateBackendFromApplicationUsesManagedMemory- Whether the application-defined backend uses Flink's managed memory. Empty if application has not defined a backend.classLoader- User code classloader.- Returns:
- Whether the state backend uses managed memory.
-
loadStateBackendFromKeyedStateHandles
public static StateBackend loadStateBackendFromKeyedStateHandles(StateBackend originalStateBackend, ClassLoader classLoader, Collection<KeyedStateHandle> keyedStateHandles) throws org.apache.flink.util.DynamicCodeLoadingException
Load state backend which may wrap the original state backend for recovery.- Parameters:
originalStateBackend- StateBackend loaded from application or config.classLoader- User code classloader.keyedStateHandles- The state handles for restore.- Returns:
- Wrapped state backend for recovery.
- Throws:
org.apache.flink.util.DynamicCodeLoadingException- Thrown if keyed state handles of wrapped state backend are found and the class was not found or could not be instantiated.
-
isChangelogStateBackend
public static boolean isChangelogStateBackend(StateBackend backend)
-
-