K
- type for map keysV
- type for map valuespublic interface EventuallyConsistentMapBuilder<K,V>
Modifier and Type | Method and Description |
---|---|
EventuallyConsistentMap<K,V> |
build()
Builds an eventually consistent map based on the configuration options
supplied to this builder.
|
EventuallyConsistentMapBuilder<K,V> |
withAntiEntropyPeriod(long period,
java.util.concurrent.TimeUnit unit)
Configures how often to run the anti-entropy background task.
|
EventuallyConsistentMapBuilder<K,V> |
withBackgroundExecutor(java.util.concurrent.ScheduledExecutorService executor)
Sets the executor to use for background anti-entropy tasks.
|
EventuallyConsistentMapBuilder<K,V> |
withCommunicationExecutor(java.util.concurrent.ExecutorService executor)
Sets the executor to use for sending events to peers.
|
EventuallyConsistentMapBuilder<K,V> |
withEventExecutor(java.util.concurrent.ExecutorService executor)
Sets the executor to use for processing events coming in from peers.
|
EventuallyConsistentMapBuilder<K,V> |
withFasterConvergence()
Configure anti-entropy to converge faster at the cost of doing more work
for each anti-entropy cycle.
|
EventuallyConsistentMapBuilder<K,V> |
withName(java.lang.String name)
Sets the name of the map.
|
EventuallyConsistentMapBuilder<K,V> |
withPeerUpdateFunction(java.util.function.BiFunction<K,V,java.util.Collection<NodeId>> peerUpdateFunction)
Sets a function that can determine which peers to replicate updates to.
|
EventuallyConsistentMapBuilder<K,V> |
withPersistence()
Configure the map to persist data to disk.
|
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.
|
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.
|
EventuallyConsistentMapBuilder<K,V> |
withTimestampProvider(java.util.function.BiFunction<K,V,Timestamp> timestampProvider)
Sets the function to use for generating timestamps for map updates.
|
EventuallyConsistentMapBuilder<K,V> |
withTombstonesDisabled()
Prevents this map from writing tombstones of items that have been
removed.
|
EventuallyConsistentMapBuilder<K,V> withName(java.lang.String name)
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.
name
- name of the mapEventuallyConsistentMapBuilder<K,V> withSerializer(KryoNamespace.Builder serializerBuilder)
Note: This is a mandatory parameter.
serializerBuilder
- serializer builderEventuallyConsistentMapBuilder<K,V> withSerializer(KryoNamespace serializer)
Note: This is a mandatory parameter.
serializer
- serializerEventuallyConsistentMapBuilder<K,V> withTimestampProvider(java.util.function.BiFunction<K,V,Timestamp> timestampProvider)
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.
timestampProvider
- provides a new timestampEventuallyConsistentMapBuilder<K,V> withEventExecutor(java.util.concurrent.ExecutorService executor)
executor
- event executorEventuallyConsistentMapBuilder<K,V> withCommunicationExecutor(java.util.concurrent.ExecutorService executor)
executor
- event executorEventuallyConsistentMapBuilder<K,V> withBackgroundExecutor(java.util.concurrent.ScheduledExecutorService executor)
executor
- event executorEventuallyConsistentMapBuilder<K,V> withPeerUpdateFunction(java.util.function.BiFunction<K,V,java.util.Collection<NodeId>> peerUpdateFunction)
The default function replicates to all nodes.
peerUpdateFunction
- function that takes a K, V input and returns
a collection of NodeIds to replicate the event
toEventuallyConsistentMapBuilder<K,V> withTombstonesDisabled()
The default behavior is tombstones are enabled.
EventuallyConsistentMapBuilder<K,V> withAntiEntropyPeriod(long period, java.util.concurrent.TimeUnit unit)
The default anti-entropy period is 5 seconds.
period
- anti-entropy periodunit
- time unit for the periodEventuallyConsistentMapBuilder<K,V> withFasterConvergence()
The default behavior is to do less anti-entropy work at the cost of slower convergence.
EventuallyConsistentMapBuilder<K,V> withPersistence()
The default behavior is no persistence
EventuallyConsistentMap<K,V> build()
java.lang.RuntimeException
- if a mandatory parameter is missing