|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
K
- the type of keys maintained by this mapV
- the type of mapped values@Beta public interface ReplicatedMap<K,V>
A ReplicatedMap is a map-like data structure with non-strong consistency (so-called eventually consistent) and values locally stored on every node of the cluster. When accessing values, due to the eventually consistency, it is possible to read stale data since replication is not handled in a synchronous way.
Whenever a value is written asynchronously, the new value will be internally distributed to all existing cluster members, and eventually every node will have the new value and the cluster again is in a consistent state.
When a new node joins the cluster, the new node initially will request existing values from older nodes and replicate them locally.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface java.util.Map |
---|
Map.Entry<K,V> |
Method Summary | |
---|---|
String |
addEntryListener(EntryListener<K,V> listener)
Adds an entry listener for this map. |
String |
addEntryListener(EntryListener<K,V> listener,
K key)
Adds the specified entry listener for the specified key. |
String |
addEntryListener(EntryListener<K,V> listener,
Predicate<K,V> predicate)
Adds an continuous entry listener for this map. |
String |
addEntryListener(EntryListener<K,V> listener,
Predicate<K,V> predicate,
K key)
Adds an continuous entry listener for this map. |
void |
clear()
The clear operation is used for wiping data out of the replicated maps. |
Set<Map.Entry<K,V>> |
entrySet()
Returns a Set view of the mappings contained in this map. |
V |
put(K key,
V value,
long ttl,
TimeUnit timeUnit)
Associates a given value to the specified key and replicates it to the cluster. |
boolean |
removeEntryListener(String id)
Removes the specified entry listener. |
Collection<V> |
values()
Returns a Collection view of the values contained in this map. |
Collection<V> |
values(Comparator<V> comparator)
Returns a Collection view of the values contained in this map. |
Methods inherited from interface java.util.Map |
---|
containsKey, containsValue, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size |
Methods inherited from interface com.hazelcast.core.DistributedObject |
---|
destroy, getId, getName, getPartitionKey, getServiceName |
Method Detail |
---|
V put(K key, V value, long ttl, TimeUnit timeUnit)
Associates a given value to the specified key and replicates it to the cluster. If there is an old value, it will be replaced by the specified one and returned from the call.
In addition, you have to specify a ttl and its TimeUnit
to define when the value is outdated and thus should be removed from the
replicated map.
key
- key with which the specified value is to be associatedvalue
- value to be associated with the specified keyttl
- ttl to be associated with the specified key-value pairtimeUnit
- TimeUnit to be used for the ttl valuevoid clear()
The clear operation is used for wiping data out of the replicated maps. It is the only synchronous remote operation in this implementation, so be aware that this might be a slow operation.
If some node fails on executing the operation, it is retried for at most
3 times (on the failing nodes only). If not working after the third time, this
method throws a OperationTimeoutException
back
to the caller.
clear
in interface Map<K,V>
OperationTimeoutException
- thrown if clear could not
executed on remote nodesboolean removeEntryListener(String id)
id
- id of the registered listener
String addEntryListener(EntryListener<K,V> listener)
listener
- entry listenerString addEntryListener(EntryListener<K,V> listener, K key)
Warning:
This method uses hashCode and equals of the binary form of the key, not the actual implementations of hashCode and equals defined in the key's class.
listener
- the entry listenerkey
- the key to listen to
NullPointerException
- if the specified key is nullString addEntryListener(EntryListener<K,V> listener, Predicate<K,V> predicate)
listener
- the entry listenerpredicate
- the predicate for filtering entriesString addEntryListener(EntryListener<K,V> listener, Predicate<K,V> predicate, K key)
listener
- the entry listenerpredicate
- the predicate for filtering entrieskey
- the key to listen toCollection<V> values()
Collection
view of the values contained in this map.
The collection is NOT backed by the map, so changes to the map are
NOT reflected in the collection, and vice-versa.values(java.util.Comparator)
to force reordering of the
elements before returning.
values
in interface Map<K,V>
Collection<V> values(Comparator<V> comparator)
Collection
view of the values contained in this map.
The collection is NOT backed by the map, so changes to the map are
NOT reflected in the collection, and vice-versa.Comparator
before returning the elements.
comparator
- the Comparator to sort the returned elements
Set<Map.Entry<K,V>> entrySet()
Set
view of the mappings contained in this map.
The set is NOT backed by the map, so changes to the map are
NOT reflected in the set, and vice-versa.
entrySet
in interface Map<K,V>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |