K
- key typeV
- value typepublic class ReplicatedMapProxy<K,V> extends AbstractDistributedObject<ReplicatedMapService> implements ReplicatedMap<K,V>, InitializingObject
ReplicatedMap
interface.PARTITIONING_STRATEGY
Modifier and Type | Method and Description |
---|---|
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 wipes data out of the replicated maps.
|
boolean |
containsKey(Object key) |
boolean |
containsValue(Object value) |
Set<Map.Entry<K,V>> |
entrySet()
Returns a lazy
Set view of the mappings contained in this map.A LazySet is optimized for querying speed (preventing eager deserialization and hashing on HashSet insertion) and does NOT provide all operations. |
V |
get(Object key) |
String |
getName()
Returns the unique name for this DistributedObject.
|
String |
getPartitionKey()
Returns the key of the partition that this DistributedObject is assigned to.
|
LocalReplicatedMapStats |
getReplicatedMapStats()
Returns LocalReplicatedMapStats for this replicated map.
|
String |
getServiceName()
Returns the service name for this object.
|
int |
hashCode() |
void |
initialize() |
boolean |
isEmpty() |
Set<K> |
keySet()
Returns a lazy
Set view of the key contained in this map.A LazySet is optimized for querying speed (preventing eager deserialization and hashing on HashSet insertion) and does NOT provide all operations. |
protected boolean |
preDestroy() |
V |
put(K key,
V value) |
V |
put(K key,
V value,
long ttl,
TimeUnit timeUnit)
Associates a given value to the specified key and replicates it to the
cluster.
|
void |
putAll(Map<? extends K,? extends V> entries) |
V |
remove(Object key) |
boolean |
removeEntryListener(String id)
Removes the specified entry listener.
|
int |
size() |
String |
toString() |
Collection<V> |
values()
Returns a lazy
Collection view of the values contained in this map.A LazyCollection is optimized for querying speed (preventing eager deserialization and hashing on HashSet insertion) and does NOT provide all operations. |
Collection<V> |
values(Comparator<V> comparator)
Returns an eagerly populated
Collection view of the values contained in this map. |
destroy, equals, getDistributedObjectName, getNameAsPartitionAwareData, getNodeEngine, getOperationService, getPartitionId, getService, invalidate, invokeOnPartition, isClusterVersionEqualTo, isClusterVersionGreaterOrEqual, isClusterVersionGreaterThan, isClusterVersionLessOrEqual, isClusterVersionLessThan, isClusterVersionUnknown, isClusterVersionUnknownOrGreaterOrEqual, isClusterVersionUnknownOrGreaterThan, isClusterVersionUnknownOrLessOrEqual, isClusterVersionUnknownOrLessThan, postDestroy, throwNotActiveException, toData
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
destroy
public void initialize()
initialize
in interface InitializingObject
protected boolean preDestroy()
preDestroy
in class AbstractDistributedObject<ReplicatedMapService>
public String getName()
DistributedObject
DistributedObjectUtil.getName(DistributedObject)
because this might be also a PrefixedDistributedObject
.getName
in interface DistributedObject
public String getPartitionKey()
DistributedObject
IAtomicLong
. For a partitioned data structure like an IMap
,
the returned value will not be null, but otherwise undefined.getPartitionKey
in interface DistributedObject
getPartitionKey
in class AbstractDistributedObject<ReplicatedMapService>
public String getServiceName()
DistributedObject
getServiceName
in interface DistributedObject
getServiceName
in class AbstractDistributedObject<ReplicatedMapService>
public boolean containsKey(Object key)
containsKey
in interface Map<K,V>
public boolean containsValue(Object value)
containsValue
in interface Map<K,V>
public V put(K key, V value, long ttl, TimeUnit timeUnit)
ReplicatedMap
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.
put
in interface ReplicatedMap<K,V>
key
- key with which the specified value is to be associated.value
- value to be associated with the specified key.ttl
- ttl to be associated with the specified key-value pair.timeUnit
- TimeUnit to be used for the ttl value.public void clear()
ReplicatedMap
The clear operation wipes data out of the replicated maps.
If some node fails on executing the operation, it is retried for at most 5 times (on the failing nodes only).
public boolean removeEntryListener(String id)
ReplicatedMap
removeEntryListener
in interface ReplicatedMap<K,V>
id
- ID of the registered entry listener.public String addEntryListener(EntryListener<K,V> listener)
ReplicatedMap
addEntryListener
in interface ReplicatedMap<K,V>
listener
- entry listenerpublic String addEntryListener(EntryListener<K,V> listener, K key)
ReplicatedMap
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.addEntryListener
in interface ReplicatedMap<K,V>
listener
- the entry listener to addkey
- the key to listen topublic String addEntryListener(EntryListener<K,V> listener, Predicate<K,V> predicate)
ReplicatedMap
addEntryListener
in interface ReplicatedMap<K,V>
listener
- the entry listener to addpredicate
- the predicate for filtering entriespublic String addEntryListener(EntryListener<K,V> listener, Predicate<K,V> predicate, K key)
ReplicatedMap
addEntryListener
in interface ReplicatedMap<K,V>
listener
- the entry listenerpredicate
- the predicate for filtering entrieskey
- the key to listen topublic Set<K> keySet()
ReplicatedMap
Set
view of the key contained in this map.UnsupportedOperationException
. Same is true for operations
like Set.contains(Object)
and
Set.containsAll(java.util.Collection)
which would result in
very poor performance if called repeatedly (for example, in a loop). If the use
case is different from querying the data, please copy the resulting set into a
new HashSet
.
ReplicatedMap<K, V> repMap = ...; // Returns a LazySet Set<K> keySet = repMap.keySet(); Set<K> copy = new HashSet<K>(keySet); for (K key : possibleKeys) { if (!copy.contains(key)) return false; }Due to the lazy nature of the returned set, changes to the map (addition, removal, update) might be reflected on the set.
public Collection<V> values()
ReplicatedMap
Collection
view of the values contained in this map.UnsupportedOperationException
. Same is true for operations
like Collection.contains(Object)
and
Collection.containsAll(java.util.Collection)
, which would result in
very poor performance if called repeatedly (for example, in a loop). If the use
case is different from querying the data, please copy the resulting set into a
new List
or similar data structure.
ReplicatedMap<K, V> repMap = ...; // Returns a LazyCollection Collection<V> values = repMap.values(); List<V> copy = new ArrayList<V>(values); if (copy.containsAll(possibleValues)) { // ... }Due to the lazy nature of the returned set, changes to the map (addition, removal, update) might be reflected on the collection.
ReplicatedMap.values(java.util.Comparator)
to force reordering of the
elements before returning.public Collection<V> values(Comparator<V> comparator)
ReplicatedMap
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 on the collection, and vice-versa.Comparator
before returning the elements.values
in interface ReplicatedMap<K,V>
comparator
- the Comparator to sort the returned elements.Collection
view of the values contained in this map.public Set<Map.Entry<K,V>> entrySet()
ReplicatedMap
Set
view of the mappings contained in this map.UnsupportedOperationException
. Same is true for operations
like Set.contains(Object)
and
Set.containsAll(java.util.Collection)
which would result in
very poor performance if called repeatedly (for example, in a loop). If the use
case is different from querying the data, please copy the resulting set into a
new HashSet
.
ReplicatedMap<K, V> repMap = ...; // Returns a LazySet Set<Map.Entry<K, V>> entrySet = repMap.entrySet(); Set<Map.Entry<K, V>> copy = new HashSet<Map.Entry<K, V>>(entrySet);Due to the lazy nature of the returned set, changes to the map (addition, removal, update) might be reflected on the set.
public int hashCode()
hashCode
in interface Map<K,V>
hashCode
in class AbstractDistributedObject<ReplicatedMapService>
public String toString()
toString
in class AbstractDistributedObject<ReplicatedMapService>
public LocalReplicatedMapStats getReplicatedMapStats()
ReplicatedMap
getReplicatedMapStats
in interface ReplicatedMap<K,V>
Copyright © 2022 Hazelcast, Inc.. All Rights Reserved.