net.corda.node.services.transactions

## Class DistributedImmutableMap<K,V>

- net.corda.node.services.transactions.DistributedImmutableMap<K,V>

-     public class DistributedImmutableMap<K,V>

  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.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `DistributedImmutableMap.Commands`
    `static class` | `DistributedImmutableMap.Companion`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static DistributedImmutableMap.Companion` | `Companion`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DistributedImmutableMap(org.jetbrains.exposed.sql.Database db, java.lang.String tableName)` A distributed map state machine that doesn't allow overriding values. The state machine is replicated across a Copycat Raft cluster.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `V` | `get(io.atomix.copycat.server.Commit<net.corda.node.services.transactions.DistributedImmutableMap.Commands.Get> commit)` Gets a value for the given Commands.Get.key
    `org.jetbrains.exposed.sql.Database` | `getDb()`
    `void` | `install(io.atomix.copycat.server.storage.snapshot.SnapshotReader reader)` Reads entries from disk and adds them to map.
    `java.util.Map<K,V>` | `put(io.atomix.copycat.server.Commit<net.corda.node.services.transactions.DistributedImmutableMap.Commands.PutAll> commit)` Stores the given Commands.PutAll.entries if no entry key already exists.
    `int` | `size(io.atomix.copycat.server.Commit<net.corda.node.services.transactions.DistributedImmutableMap.Commands.Size> commit)`
    `void` | `snapshot(io.atomix.copycat.server.storage.snapshot.SnapshotWriter writer)` 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.

- - ### Field Detail

    - #### Companion

          public static DistributedImmutableMap.Companion Companion

  - ### Constructor Detail

    - #### DistributedImmutableMap

          public DistributedImmutableMap(org.jetbrains.exposed.sql.Database db,
                                         java.lang.String tableName)

      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.

  - ### Method Detail

    - #### get

          public V get(io.atomix.copycat.server.Commit<net.corda.node.services.transactions.DistributedImmutableMap.Commands.Get> commit)

      Gets a value for the given Commands.Get.key

    - #### put

          public java.util.Map<K,V> put(io.atomix.copycat.server.Commit<net.corda.node.services.transactions.DistributedImmutableMap.Commands.PutAll> commit)

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

      Returns:
        map containing conflicting entries

    - #### size

          public int size(io.atomix.copycat.server.Commit<net.corda.node.services.transactions.DistributedImmutableMap.Commands.Size> commit)

    - #### snapshot

          public void snapshot(io.atomix.copycat.server.storage.snapshot.SnapshotWriter writer)

      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.

    - #### install

          public void install(io.atomix.copycat.server.storage.snapshot.SnapshotReader reader)

      Reads entries from disk and adds them to map.

    - #### getDb

          public org.jetbrains.exposed.sql.Database getDb()