public class EventuallyConsistentMapBuilderImpl<K,V> extends Object implements EventuallyConsistentMapBuilder<K,V>
| Constructor and Description |
|---|
EventuallyConsistentMapBuilderImpl(ClusterService clusterService,
ClusterCommunicationService clusterCommunicator,
PersistenceService persistenceService)
Creates a new eventually consistent map builder.
|
| 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,
TimeUnit unit)
Configures how often to run the anti-entropy background task.
|
EventuallyConsistentMapBuilder<K,V> |
withBackgroundExecutor(ScheduledExecutorService executor)
Sets the executor to use for background anti-entropy tasks.
|
EventuallyConsistentMapBuilder<K,V> |
withCommunicationExecutor(ExecutorService executor)
Sets the executor to use for sending events to peers.
|
EventuallyConsistentMapBuilder<K,V> |
withEventExecutor(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(String name)
Sets the name of the map.
|
EventuallyConsistentMapBuilder<K,V> |
withPeerUpdateFunction(BiFunction<K,V,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(org.onlab.util.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(org.onlab.util.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(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.
|
public EventuallyConsistentMapBuilderImpl(ClusterService clusterService, ClusterCommunicationService clusterCommunicator, PersistenceService persistenceService)
clusterService - cluster serviceclusterCommunicator - cluster communication servicepersistenceService - persistence servicepublic EventuallyConsistentMapBuilder<K,V> withName(String name)
EventuallyConsistentMapBuilderEach 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.
withName in interface EventuallyConsistentMapBuilder<K,V>name - name of the mappublic EventuallyConsistentMapBuilder<K,V> withSerializer(org.onlab.util.KryoNamespace.Builder serializerBuilder)
EventuallyConsistentMapBuilderNote: This is a mandatory parameter.
withSerializer in interface EventuallyConsistentMapBuilder<K,V>serializerBuilder - serializer builderpublic EventuallyConsistentMapBuilder<K,V> withSerializer(org.onlab.util.KryoNamespace serializer)
EventuallyConsistentMapBuilderNote: This is a mandatory parameter.
withSerializer in interface EventuallyConsistentMapBuilder<K,V>serializer - serializerpublic EventuallyConsistentMapBuilder<K,V> withTimestampProvider(BiFunction<K,V,Timestamp> timestampProvider)
EventuallyConsistentMapBuilder
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.
withTimestampProvider in interface EventuallyConsistentMapBuilder<K,V>timestampProvider - provides a new timestamppublic EventuallyConsistentMapBuilder<K,V> withEventExecutor(ExecutorService executor)
EventuallyConsistentMapBuilderwithEventExecutor in interface EventuallyConsistentMapBuilder<K,V>executor - event executorpublic EventuallyConsistentMapBuilder<K,V> withCommunicationExecutor(ExecutorService executor)
EventuallyConsistentMapBuilderwithCommunicationExecutor in interface EventuallyConsistentMapBuilder<K,V>executor - event executorpublic EventuallyConsistentMapBuilder<K,V> withBackgroundExecutor(ScheduledExecutorService executor)
EventuallyConsistentMapBuilderwithBackgroundExecutor in interface EventuallyConsistentMapBuilder<K,V>executor - event executorpublic EventuallyConsistentMapBuilder<K,V> withPeerUpdateFunction(BiFunction<K,V,Collection<NodeId>> peerUpdateFunction)
EventuallyConsistentMapBuilderThe default function replicates to all nodes.
withPeerUpdateFunction in interface EventuallyConsistentMapBuilder<K,V>peerUpdateFunction - function that takes a K, V input and returns
a collection of NodeIds to replicate the event
topublic EventuallyConsistentMapBuilder<K,V> withTombstonesDisabled()
EventuallyConsistentMapBuilderThe default behavior is tombstones are enabled.
withTombstonesDisabled in interface EventuallyConsistentMapBuilder<K,V>public EventuallyConsistentMapBuilder<K,V> withAntiEntropyPeriod(long period, TimeUnit unit)
EventuallyConsistentMapBuilderThe default anti-entropy period is 5 seconds.
withAntiEntropyPeriod in interface EventuallyConsistentMapBuilder<K,V>period - anti-entropy periodunit - time unit for the periodpublic EventuallyConsistentMapBuilder<K,V> withFasterConvergence()
EventuallyConsistentMapBuilderThe default behavior is to do less anti-entropy work at the cost of slower convergence.
withFasterConvergence in interface EventuallyConsistentMapBuilder<K,V>public EventuallyConsistentMapBuilder<K,V> withPersistence()
EventuallyConsistentMapBuilderThe default behavior is no persistence
withPersistence in interface EventuallyConsistentMapBuilder<K,V>public EventuallyConsistentMap<K,V> build()
EventuallyConsistentMapBuilderbuild in interface EventuallyConsistentMapBuilder<K,V>