object StateStore extends Logging
Companion object to StateStore that provides helper methods to create and retrieve stores by their unique ids. In addition, when a SparkContext is active (i.e. SparkEnv.get is not null), it also runs a periodic background task to do maintenance on the loaded stores. For each store, it uses the StateStoreCoordinator to ensure whether the current loaded instance of the store is the active instance. Accordingly, it either keeps it loaded and performs maintenance, or unloads the store.
- Alphabetic
- By Inheritance
- StateStore
- Logging
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- implicit class LogStringContext extends AnyRef
- Definition Classes
- Logging
- class MaintenanceTask extends AnyRef
Runs the
taskperiodically and bubbles any exceptions that it encounters.Runs the
taskperiodically and bubbles any exceptions that it encounters.Note: exceptions in the maintenance thread pool are caught and logged; the associated StateStoreProvider is also unloaded. Any exception that happens in the MaintenanceTask is indeed exceptional and thus we let it propagate.
- class MaintenanceThreadPool extends AnyRef
Thread Pool that runs maintenance on partitions that are scheduled by MaintenanceTask periodically
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- val DEFAULT_COL_FAMILY_NAME: String
- def MDC(key: LogKey, value: Any): MDC
- Attributes
- protected
- Definition Classes
- Logging
- val PARTITION_ID_TO_CHECK_SCHEMA: Int
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @IntrinsicCandidate() @native()
- def doMaintenanceAndUnload(storeProviderId: StateStoreProviderId): Unit
Runs maintenance and then unload a state store provider
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def get(storeProviderId: StateStoreProviderId, keySchema: StructType, valueSchema: StructType, keyStateEncoderSpec: KeyStateEncoderSpec, version: Long, stateStoreCkptId: Option[String], stateSchemaBroadcast: Option[StateSchemaBroadcast], useColumnFamilies: Boolean, storeConf: StateStoreConf, hadoopConf: Configuration, useMultipleValuesPerKey: Boolean = false): StateStore
Get or create a store associated with the id.
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @IntrinsicCandidate() @native()
- def getReadOnly(storeProviderId: StateStoreProviderId, keySchema: StructType, valueSchema: StructType, keyStateEncoderSpec: KeyStateEncoderSpec, version: Long, stateStoreCkptId: Option[String], stateSchemaBroadcast: Option[StateSchemaBroadcast], useColumnFamilies: Boolean, storeConf: StateStoreConf, hadoopConf: Configuration, useMultipleValuesPerKey: Boolean = false): ReadStateStore
Get or create a read-only store associated with the id.
- def getWriteStore(readStore: ReadStateStore, storeProviderId: StateStoreProviderId, keySchema: StructType, valueSchema: StructType, keyStateEncoderSpec: KeyStateEncoderSpec, version: Long, stateStoreCkptId: Option[String], stateSchemaBroadcast: Option[StateSchemaBroadcast], useColumnFamilies: Boolean, storeConf: StateStoreConf, hadoopConf: Configuration, useMultipleValuesPerKey: Boolean = false): StateStore
Converts an existing read-only state store to a writable state store.
Converts an existing read-only state store to a writable state store.
This method provides an optimization for stateful operations that need to both read and update state within the same task. Instead of opening separate read and write instances (which may cause resource contention or duplication), this method reuses the already loaded read store and transforms it into a writable store.
The optimization is particularly valuable for state stores with expensive initialization costs or limited concurrency capabilities (like RocksDB). It eliminates redundant loading of the same state data and reduces resource usage.
- readStore
The existing read-only state store to convert to a writable store
- storeProviderId
Unique identifier for the state store provider
- keySchema
Schema of the state store keys
- valueSchema
Schema of the state store values
- keyStateEncoderSpec
Specification for encoding the state keys
- version
The version of the state store (must match the read store's version)
- stateStoreCkptId
Optional checkpoint identifier for the state store
- stateSchemaBroadcast
Optional broadcast of the state schema
- useColumnFamilies
Whether to use column families in the state store
- storeConf
Configuration for the state store
- hadoopConf
Hadoop configuration
- useMultipleValuesPerKey
Whether the store supports multiple values per key
- returns
A writable StateStore instance that can be used to update and commit changes
- Exceptions thrown
SparkExceptionIf the store cannot be loaded or if there's insufficient memory
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @IntrinsicCandidate() @native()
- def initializeLogIfNecessary(isInterpreter: Boolean, silent: Boolean): Boolean
- Attributes
- protected
- Definition Classes
- Logging
- def initializeLogIfNecessary(isInterpreter: Boolean): Unit
- Attributes
- protected
- Definition Classes
- Logging
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def isLoaded(storeProviderId: StateStoreProviderId): Boolean
Whether a state store provider is loaded or not
- def isMaintenanceRunning: Boolean
Check if maintenance thread is running and scheduled future is not done
- def isTraceEnabled(): Boolean
- Attributes
- protected
- Definition Classes
- Logging
- def log: Logger
- Attributes
- protected
- Definition Classes
- Logging
- def logBasedOnLevel(level: Level)(f: => MessageWithContext): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def logDebug(msg: => String, throwable: Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def logDebug(entry: LogEntry, throwable: Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def logDebug(entry: LogEntry): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def logDebug(msg: => String): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def logError(msg: => String, throwable: Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def logError(entry: LogEntry, throwable: Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def logError(entry: LogEntry): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def logError(msg: => String): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def logInfo(msg: => String, throwable: Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def logInfo(entry: LogEntry, throwable: Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def logInfo(entry: LogEntry): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def logInfo(msg: => String): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def logName: String
- Attributes
- protected
- Definition Classes
- Logging
- def logTrace(msg: => String, throwable: Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def logTrace(entry: LogEntry, throwable: Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def logTrace(entry: LogEntry): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def logTrace(msg: => String): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def logWarning(msg: => String, throwable: Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def logWarning(entry: LogEntry, throwable: Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def logWarning(entry: LogEntry): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def logWarning(msg: => String): Unit
- Attributes
- protected
- Definition Classes
- Logging
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @IntrinsicCandidate() @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @IntrinsicCandidate() @native()
- def removeFromLoadedProvidersAndClose(storeProviderId: StateStoreProviderId, alreadyRemovedProvider: Option[StateStoreProvider] = None): Unit
Unload a state store provider.
Unload a state store provider. If alreadyRemovedFromLoadedProviders is None, provider will be removed from loadedProviders and closed. If alreadyRemovedFromLoadedProviders is Some, provider will be closed using passed in provider. WARNING: CAN ONLY BE CALLED FROM MAINTENANCE THREAD!
- def reportCommitToCoordinator(version: Long, stateStoreId: StateStoreId, hadoopConf: Configuration): Unit
Reports to the coordinator that a StateStore has committed
- def stop(): Unit
Unload and stop all state store providers
- def stopMaintenanceTask(): Unit
Stop maintenance thread and reset the maintenance task
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- def withLogContext(context: Map[String, String])(body: => Unit): Unit
- Attributes
- protected
- Definition Classes
- Logging
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated
(Since version 9)