corda / net.corda.node.services.transactions / DistributedImmutableMap

DistributedImmutableMap

class DistributedImmutableMap<K : Any, V : Any> : StateMachine, Snapshottable

A distributed map state machine that doesn't allow overriding values. The state machine is replicated across a Copycat Raft cluster.

The map contents are backed by a JDBC table. State re-synchronisation is achieved by periodically persisting snapshots to disk, and sharing them across the cluster. A new node joining the cluster will have to obtain and install a snapshot containing the entire JDBC table contents.

Types

Commands object Commands

Constructors

<init> DistributedImmutableMap(db: Database, tableName: String)

A distributed map state machine that doesn't allow overriding values. The state machine is replicated across a Copycat Raft cluster.

Properties

db val db: Database

Functions

get fun get(commit: Commit<Get<K, V>>): V?

Gets a value for the given Commands.Get.key

install fun install(reader: SnapshotReader): Unit

Reads entries from disk and adds them to map.

put fun put(commit: Commit<PutAll<K, V>>): Map<K, V>

Stores the given Commands.PutAll.entries if no entry key already exists.

size fun size(commit: Commit<Size>): Int
snapshot fun snapshot(writer: SnapshotWriter): Unit

Writes out all map entries to disk. Note that this operation does not load all entries into memory, as the SnapshotWriter is using a disk-backed buffer internally, and iterating map entries results in only a fixed number of recently accessed entries to ever be kept in memory.