public interface EventuallyConsistentMap<K,V>
This map does not offer read after writes consistency. Operations are serialized via the timestamps issued by the clock service. If two updates are in conflict, the update with the more recent timestamp will endure.
The interface is mostly similar to Map with some minor
semantic changes and the addition of a listener framework (because the map
can be mutated by clients on other instances, not only through the local Java
API).
Clients are expected to register an
EventuallyConsistentMapListener if they
are interested in receiving notifications of update to the map.
Null values are not allowed in this map.
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(EventuallyConsistentMapListener<K,V> listener)
Adds the specified listener to the map which will be notified whenever
the mappings in the map are changed.
|
void |
clear()
Removes all mappings from this map.
|
boolean |
containsKey(K key)
Returns true if the map contains a mapping for the specified key.
|
boolean |
containsValue(V value)
Returns true if the map contains a mapping from any key to the specified
value.
|
void |
destroy()
Shuts down the map and breaks communication between different instances.
|
Set<Map.Entry<K,V>> |
entrySet()
Returns a set of mappings contained in this map.
|
V |
get(K key)
Returns the value mapped to the specified key.
|
boolean |
isEmpty()
Returns true if this map is empty.
|
Set<K> |
keySet()
Returns a set of the keys in this map.
|
void |
put(K key,
V value)
Associates the specified value to the specified key in this map.
|
void |
putAll(Map<? extends K,? extends V> m)
Adds mappings for all key-value pairs in the specified map to this map.
|
void |
remove(K key)
Removes the mapping associated with the specified key from the map.
|
void |
remove(K key,
V value)
Removes the given key-value mapping from the map, if it exists.
|
void |
removeListener(EventuallyConsistentMapListener<K,V> listener)
Removes the specified listener from the map such that it will no longer
receive change notifications.
|
int |
size()
Returns the number of key-value mappings in this map.
|
Collection<V> |
values()
Returns a collections of values in this map.
|
int size()
boolean isEmpty()
boolean containsKey(K key)
key - the key to check if this map containsboolean containsValue(V value)
value - the value to check if this map has a mapping forV get(K key)
key - the key to look up in this mapvoid put(K key, V value)
Note: this differs from the specification of Map
because it does not return the previous value associated with the key.
Clients are expected to register an
EventuallyConsistentMapListener if
they are interested in receiving notification of updates to the map.
Null values are not allowed in the map.
key - the key to add a mapping for in this mapvalue - the value to associate with the key in this mapvoid remove(K key)
Note: this differs from the specification of Map
because it does not return the previous value associated with the key.
Clients are expected to register an
EventuallyConsistentMapListener if
they are interested in receiving notification of updates to the map.
key - the key to remove the mapping forvoid remove(K key, V value)
This actually means remove any values up to and including the timestamp
given by ClockService.getTimestamp(Object, Object).
Any mappings that produce an earlier timestamp than this given key-value
pair will be removed, and any mappings that produce a later timestamp
will supersede this remove.
Note: this differs from the specification of Map
because it does not return a boolean indication whether a value was removed.
Clients are expected to register an
EventuallyConsistentMapListener if
they are interested in receiving notification of updates to the map.
key - the key to remove the mapping forvalue - the value mapped to the keyvoid putAll(Map<? extends K,? extends V> m)
This will be more efficient in communication than calling individual put operations.
m - a map of values to add to this mapvoid clear()
Set<K> keySet()
Collection<V> values()
Set<Map.Entry<K,V>> entrySet()
void addListener(EventuallyConsistentMapListener<K,V> listener)
listener - listener to register for eventsvoid removeListener(EventuallyConsistentMapListener<K,V> listener)
listener - listener to deregister for eventsvoid destroy()
RuntimeException.Copyright © 2015. All rights reserved.