Class ChronicleMapStateRepository<V>

java.lang.Object
de.otto.synapse.state.ConcurrentMapStateRepository<V>
de.otto.synapse.state.ChronicleMapStateRepository<V>
Type Parameters:
V - The type of the event-sourced entities stored in the StateRepository
All Implemented Interfaces:
StateRepository<V>, java.lang.AutoCloseable

public class ChronicleMapStateRepository<V>
extends ConcurrentMapStateRepository<V>
A StateRepository that is using a ChronicleMap to store the event-sourced entities off the heap.

Suitable for larger amounts of data, without problems because of garbage-collection issues because of the usage of off-heap memory.

In order to be able to access the ConcurrentMapStateRepository.keySet() of the stored entities, this implementation is storing a copy of the keys in a separate ConcurrentSkipListSet

  • Nested Class Summary

    Nested Classes 
    Modifier and Type Class Description
    static class  ChronicleMapStateRepository.Builder<V>  
  • Method Summary

    Modifier and Type Method Description
    static <V> ChronicleMapStateRepository.Builder<V> builder​(java.lang.Class<V> clazz)  
    java.util.Optional<V> get​(java.lang.String key)
    Returns the optional value to which the specified key is mapped, or Optional.empty() if this repository contains no mapping for the key.
    java.util.Optional<V> put​(java.lang.String key, V value)
    Associates the specified value with the specified key in this repository.
    long size()
    Returns the number of key-value mappings in this repository.

    Methods inherited from class de.otto.synapse.state.ConcurrentMapStateRepository

    clear, close, compute, consumeAll, getName, keySet, remove

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • put

      public java.util.Optional<V> put​(java.lang.String key, V value)
      Description copied from interface: StateRepository
      Associates the specified value with the specified key in this repository. If the repository previously contained a mapping for the key, the old value is replaced by the specified value. (A repository m is said to contain a mapping for a key k if and only if m.get(k) would return a non-empty value.)
      Specified by:
      put in interface StateRepository<V>
      Overrides:
      put in class ConcurrentMapStateRepository<V>
      Parameters:
      key - key with which the specified value is to be associated
      value - value to be associated with the specified key
      Returns:
      the previous value associated with 'key', or 'Optional.empty()' if there was no mapping for 'key'
    • get

      public java.util.Optional<V> get​(java.lang.String key)
      Description copied from interface: StateRepository
      Returns the optional value to which the specified key is mapped, or Optional.empty() if this repository contains no mapping for the key.

      More formally, if this repository contains a mapping from a key k to a value v such that (key==null ? k==null : key.equals(k)), then this method returns Optional.of(v); otherwise it returns Optional.empty(). (There can be at most one such mapping.)

      Specified by:
      get in interface StateRepository<V>
      Overrides:
      get in class ConcurrentMapStateRepository<V>
      Parameters:
      key - the key whose associated value is to be returned
      Returns:
      the Optional containing the value to which the specified key is mapped, or Optional.empty() if this repository contains no mapping for the key
    • size

      public long size()
      Description copied from interface: StateRepository
      Returns the number of key-value mappings in this repository. If the repository contains more than 'Integer.MAX_VALUE' elements, returns 'Integer.MAX_VALUE'.
      Specified by:
      size in interface StateRepository<V>
      Overrides:
      size in class ConcurrentMapStateRepository<V>
      Returns:
      the number of key-value mappings in this repository
    • builder

      public static <V> ChronicleMapStateRepository.Builder<V> builder​(java.lang.Class<V> clazz)