org.apache.ignite.internal.processors.metastorage

## Interface ReadableDistributedMetaStorage

All Known Subinterfaces:
  DistributedMetaStorage

All Known Implementing Classes:
  DistributedMetaStorageImpl

    public interface ReadableDistributedMetaStorage

API for distributed data storage. Gives the ability to store configuration data (or any other data) consistently and cluster-wide. It is guaranteed that every read value is the same on every node in the cluster all the time.

### Method Summary

All Methods Static Methods Instance Methods Abstract Methods Default Methods
`long` `getUpdatesCount()` Get the total number of updates (write/remove) that metastorage ever had.
`static boolean` `isSupported(GridKernalContext ctx)`
`void` `iterate(@NotNull String keyPrefix, @NotNull BiConsumer<String,? super Serializable> cb)` Iterate over all values corresponding to the keys with given prefix.
`void` `listen(@NotNull Predicate<String> keyPred, DistributedMetaStorageListener<?> lsnr)` Add listener on data updates.
`<T extends Serializable> T` `read(@NotNull String key)` Get value by the key.

### Method Detail

#### isSupported

    static boolean isSupported(GridKernalContext ctx)

Returns:
  `True` if all nodes in the cluster support discributed metastorage feature.
See Also:
  `IgniteFeatures.DISTRIBUTED_METASTORAGE`

#### getUpdatesCount

    long getUpdatesCount()

Get the total number of updates (write/remove) that metastorage ever had.

#### read

    @Nullable
    <T extends Serializable> T read(@NotNull
                                              @NotNull String key)
                                       throws IgniteCheckedException

Get value by the key. Should be consistent for all nodes.

Parameters:
  `key` - The key.
Returns:
  Value associated with the key.
Throws:
  `IgniteCheckedException` - If reading or unmarshalling failed.

#### iterate

    void iterate(@NotNull
                 @NotNull String keyPrefix,
                 @NotNull
                 @NotNull BiConsumer<String,? super Serializable> cb)
          throws IgniteCheckedException

Iterate over all values corresponding to the keys with given prefix. It is guaranteed that iteration will be executed in ascending keys order.

Parameters:
  `keyPrefix` - Prefix for the keys that will be iterated.
  `cb` - Callback that will be applied to all `<key, value>` pairs.
Throws:
  `IgniteCheckedException` - If reading or unmarshalling failed.

#### listen

    void listen(@NotNull
                @NotNull Predicate<String> keyPred,
                DistributedMetaStorageListener<?> lsnr)

Add listener on data updates. Updates happens it two cases:

- Some node invoked write or remove. Listeners are invoked after update update operation is already completed.
- Node is just started and not ready for write yet. In this case listeners are invoked for every key with new value (retrieved from the clueter) or already existing value if there was no updates for given key. This guarantees that all listeners are invoked for all updates in case of failover.

Parameters:
  `keyPred` - Predicate to check whether this listener should be invoked on given key update or not.
  `lsnr` - Listener object.
See Also:
  `DistributedMetaStorageListener`

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.13.0
Release Date | : April 20 2022