Interface EventuallyConsistentMapBuilder<K,​V>

  • Type Parameters:
    K - type for map keys
    V - type for map values

    public interface EventuallyConsistentMapBuilder<K,​V>
    Builder for eventually consistent maps.
    • Method Detail

      • withName

        EventuallyConsistentMapBuilder<K,​V> withName​(String name)
        Sets the name of the map.

        Each map is identified by a string map name. EventuallyConsistentMapImpl objects in different JVMs that use the same map name will form a distributed map across JVMs (provided the cluster service is aware of both nodes).

        Note: This is a mandatory parameter.

        Parameters:
        name - name of the map
        Returns:
        this EventuallyConsistentMapBuilder
      • withSerializer

        EventuallyConsistentMapBuilder<K,​V> withSerializer​(KryoNamespace.Builder serializerBuilder)
        Sets a serializer builder that can be used to create a serializer that can serialize both the keys and values put into the map. The serializer builder should be pre-populated with any classes that will be put into the map.

        Note: This is a mandatory parameter.

        Parameters:
        serializerBuilder - serializer builder
        Returns:
        this EventuallyConsistentMapBuilder
      • withSerializer

        EventuallyConsistentMapBuilder<K,​V> withSerializer​(KryoNamespace serializer)
        Sets a serializer that can be used to create a serializer that can serialize both the keys and values put into the map. The serializer builder should be pre-populated with any classes that will be put into the map.

        Note: This is a mandatory parameter.

        Parameters:
        serializer - serializer
        Returns:
        this EventuallyConsistentMapBuilder
      • withTimestampProvider

        EventuallyConsistentMapBuilder<K,​V> withTimestampProvider​(BiFunction<K,​V,​Timestamp> timestampProvider)
        Sets the function to use for generating timestamps for map updates.

        The client must provide an BiFunction<K, V, Timestamp> which can generate timestamps for a given key. The function is free to generate timestamps however it wishes, however these timestamps will be used to serialize updates to the map so they must be strict enough to ensure updates are properly ordered for the use case (i.e. in some cases wallclock time will suffice, whereas in other cases logical time will be necessary).

        Note: This is a mandatory parameter.

        Parameters:
        timestampProvider - provides a new timestamp
        Returns:
        this EventuallyConsistentMapBuilder
      • withEventExecutor

        EventuallyConsistentMapBuilder<K,​V> withEventExecutor​(ExecutorService executor)
        Sets the executor to use for processing events coming in from peers.
        Parameters:
        executor - event executor
        Returns:
        this EventuallyConsistentMapBuilder
      • withCommunicationExecutor

        EventuallyConsistentMapBuilder<K,​V> withCommunicationExecutor​(ExecutorService executor)
        Sets the executor to use for sending events to peers.
        Parameters:
        executor - event executor
        Returns:
        this EventuallyConsistentMapBuilder
      • withPeerUpdateFunction

        EventuallyConsistentMapBuilder<K,​V> withPeerUpdateFunction​(BiFunction<K,​V,​Collection<NodeId>> peerUpdateFunction)
        Sets a function that can determine which peers to replicate updates to.

        The default function replicates to all nodes.

        Parameters:
        peerUpdateFunction - function that takes a K, V input and returns a collection of NodeIds to replicate the event to
        Returns:
        this EventuallyConsistentMapBuilder
      • withTombstonesDisabled

        EventuallyConsistentMapBuilder<K,​V> withTombstonesDisabled()
        Prevents this map from writing tombstones of items that have been removed. This may result in zombie items reappearing after they have been removed.

        The default behavior is tombstones are enabled.

        Returns:
        this EventuallyConsistentMapBuilder
      • withAntiEntropyPeriod

        EventuallyConsistentMapBuilder<K,​V> withAntiEntropyPeriod​(long period,
                                                                        TimeUnit unit)
        Configures how often to run the anti-entropy background task.

        The default anti-entropy period is 5 seconds.

        Parameters:
        period - anti-entropy period
        unit - time unit for the period
        Returns:
        this EventuallyConsistentMapBuilder
      • withFasterConvergence

        EventuallyConsistentMapBuilder<K,​V> withFasterConvergence()
        Configure anti-entropy to converge faster at the cost of doing more work for each anti-entropy cycle. Suited to maps with low update rate where convergence time is more important than throughput.

        The default behavior is to do less anti-entropy work at the cost of slower convergence.

        Returns:
        this EventuallyConsistentMapBuilder
      • withPersistence

        EventuallyConsistentMapBuilder<K,​V> withPersistence()
        Configure the map to persist data to disk.

        The default behavior is no persistence

        Returns:
        this EventuallyConsistentMapBuilder
      • build

        EventuallyConsistentMap<K,​V> build()
        Builds an eventually consistent map based on the configuration options supplied to this builder.
        Returns:
        new eventually consistent map
        Throws:
        RuntimeException - if a mandatory parameter is missing