关注 spark技术分享,
撸spark源码 玩spark最佳实践

HDFSBackedStateStore — State Store on HDFS-Compatible File System

HDFSBackedStateStore — State Store on HDFS-Compatible File System

HDFSBackedStateStore is a concrete StateStore that uses a HDFS-compatible file system for versioned state persistence.

HDFSBackedStateStore is created exclusively when HDFSBackedStateStoreProvider is requested for a state store for a given version (when StateStore helper object is requested to retrieve the StateStore for a given ID and version).

HDFSBackedStateStore can be in the following states:

  • UPDATING

  • COMMITTED

  • ABORTED

HDFSBackedStateStore uses the StateStoreId of the HDFSBackedStateStoreProvider.

When requested for the textual representation, HDFSBackedStateStore gives HDFSStateStore[id=(op=[operatorId],part=[partitionId]),dir=[baseDir]].

HDFSBackedStateStore takes the following to be created:

Table 1. HDFSBackedStateStore’s Internal Registries
Name Description

compressedStream

The compressed java.io.DataOutputStream for the deltaFileStream

deltaFileStream

finalDeltaFile

The Hadoop Path of the deltaFile for the version

newVersion

Used exclusively when HDFSBackedStateStore is requested for the finalDeltaFile, to commit and abort

state

Tip

HDFSBackedStateStore is an internal class of HDFSBackedStateStoreProvider and uses its logger.

writeUpdateToDeltaFile Internal Method

Caution
FIXME

put Method

Note
put is a part of StateStore Contract to…​FIXME

put stores the copies of the key and value in mapToUpdate internal registry followed by writing them to a delta file (using tempDeltaFileStream).

Note

put can only be used when HDFSBackedStateStore is in UPDATING state and reports a IllegalStateException otherwise.

Committing State Changes — commit Method

Note
commit is part of the StateStore Contract to commit state changes.

commit firstly commitUpdates (with the newVersion, the mapToUpdate and the compressed stream).

commit sets the state to COMMITTED.

commit prints out the following INFO message to the logs:

commit returns a newVersion.

commit throws a IllegalStateException when executed in any state but UPDATING state:

commit throws a IllegalStateException for any NonFatal exception:

Aborting State Changes — abort Method

Note
abort is part of the StateStore Contract to abort the state changes.

abort…​FIXME

commitUpdates Internal Method

commitUpdates…​FIXME

Note
commitUpdates is used exclusively when HDFSBackedStateStore is requested to commit state changes.

metrics Method

Note
metrics is part of the StateStore Contract to get the StateStoreMetrics.

metrics…​FIXME

赞(0) 打赏
未经允许不得转载:spark技术分享 » HDFSBackedStateStore — State Store on HDFS-Compatible File System
分享到: 更多 (0)

关注公众号:spark技术分享

联系我们联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏