K - key typeV - value typepublic class ClientReplicatedMapProxy<K,V> extends ClientProxy implements ReplicatedMap<K,V>
name| Constructor and Description |
|---|
ClientReplicatedMapProxy(String serviceName,
String objectName,
ClientContext context) |
| Modifier and Type | Method and Description |
|---|---|
UUID |
addEntryListener(EntryListener<K,V> listener)
Adds an entry listener for this map.
|
UUID |
addEntryListener(EntryListener<K,V> listener,
K key)
Adds the specified entry listener for the specified key.
|
UUID |
addEntryListener(EntryListener<K,V> listener,
Predicate<K,V> predicate)
Adds an continuous entry listener for this map.
|
UUID |
addEntryListener(EntryListener<K,V> listener,
Predicate<K,V> predicate,
K key)
Adds an continuous entry listener for this map.
|
UUID |
addNearCacheInvalidationListener(EventHandler handler) |
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 userKey) |
LocalReplicatedMapStats |
getReplicatedMapStats()
Returns LocalReplicatedMapStats for this replicated map.
|
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 void |
onInitialize()
Called when proxy is created.
|
protected void |
postDestroy()
Called after proxy is destroyed.
|
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> map) |
V |
remove(Object userKey) |
boolean |
removeEntryListener(UUID registrationId)
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. |
deregisterListener, destroy, destroyLocally, destroyRemotely, equals, getClient, getContext, getDistributedObjectName, getId, getName, getPartitionKey, getSerializationService, getServiceName, hashCode, invoke, invoke, invokeOnAddress, invokeOnPartition, invokeOnPartitionInterruptibly, onDestroy, onShutdown, preDestroy, registerListener, toData, toObjectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitcompute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAlldestroy, getName, getPartitionKey, getServiceNamepublic ClientReplicatedMapProxy(String serviceName, String objectName, ClientContext context)
protected void onInitialize()
ClientProxyonInitialize in class ClientProxyprotected void postDestroy()
ClientProxypostDestroy in class ClientProxypublic V put(@Nonnull K key, @Nonnull V value, long ttl, @Nonnull TimeUnit timeUnit)
ReplicatedMapAssociates 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 boolean containsKey(@Nonnull Object key)
containsKey in interface Map<K,V>public boolean containsValue(@Nonnull Object value)
containsValue in interface Map<K,V>public void clear()
ReplicatedMapThe 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(@Nonnull UUID registrationId)
ReplicatedMapremoveEntryListener in interface ReplicatedMap<K,V>registrationId - ID of the registered entry listener.@Nonnull public UUID addEntryListener(@Nonnull EntryListener<K,V> listener)
ReplicatedMapaddEntryListener in interface ReplicatedMap<K,V>listener - entry listener@Nonnull public UUID addEntryListener(@Nonnull EntryListener<K,V> listener, @Nullable K key)
ReplicatedMapWarning:
This method useshashCode 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 to@Nonnull public UUID addEntryListener(@Nonnull EntryListener<K,V> listener, @Nonnull Predicate<K,V> predicate)
ReplicatedMapaddEntryListener in interface ReplicatedMap<K,V>listener - the entry listener to addpredicate - the predicate for filtering entries@Nonnull public UUID addEntryListener(@Nonnull EntryListener<K,V> listener, @Nonnull Predicate<K,V> predicate, @Nullable K key)
ReplicatedMapaddEntryListener in interface ReplicatedMap<K,V>listener - the entry listenerpredicate - the predicate for filtering entrieskey - the key to listen to@Nonnull public Set<K> keySet()
ReplicatedMapSet 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.
Changes on the map are NOT reflected on the set on the CLIENT or vice versa.
The order of the elements is not guaranteed due to the internal
asynchronous replication behavior.
Changes to any returned object are NOT replicated back to other
members.
@Nonnull public LocalReplicatedMapStats getReplicatedMapStats()
ReplicatedMapgetReplicatedMapStats in interface ReplicatedMap<K,V>@Nonnull public Collection<V> values()
ReplicatedMapCollection 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.@Nonnull public Collection<V> values(@Nullable Comparator<V> comparator)
ReplicatedMapCollection 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.@Nonnull public Set<Map.Entry<K,V>> entrySet()
ReplicatedMapSet 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 UUID addNearCacheInvalidationListener(EventHandler handler)
Copyright © 2019 Hazelcast, Inc.. All rights reserved.