com.hazelcast.client.proxy

## Class ClientReplicatedMapProxy<K,V>

- java.lang.Object
- - com.hazelcast.client.spi.ClientProxy
  - - com.hazelcast.client.proxy.ClientReplicatedMapProxy<K,V>

- Type Parameters:
    `K` - key type
    `V` - value type
  All Implemented Interfaces:
    DistributedObject, ReplicatedMap<K,V>, Map<K,V>

      public class ClientReplicatedMapProxy<K,V>
      extends ClientProxy
      implements ReplicatedMap<K,V>

  The replicated map client side proxy implementation proxying all requests to a member node

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface java.util.Map

      `Map.Entry<K,V>`

  - ### Field Summary

    - ### Fields inherited from class com.hazelcast.client.spi.ClientProxy

      `name`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ClientReplicatedMapProxy(String serviceName, String objectName, ClientContext context)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    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.
    `String` | `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(String 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.

    - ### Methods inherited from class com.hazelcast.client.spi.ClientProxy

      `deregisterListener, destroy, destroyLocally, destroyRemotely, equals, getClient, getConnectedServerVersion, getContext, getDistributedObjectName, getId, getName, getPartitionKey, getSerializationService, getServiceName, hashCode, invoke, invoke, invokeOnAddress, invokeOnPartition, invokeOnPartitionInterruptibly, onDestroy, onShutdown, preDestroy, registerListener, setContext, toData, toObject`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface java.util.Map

      `compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll`

    - ### Methods inherited from interface com.hazelcast.core.DistributedObject

      `destroy, getName, getPartitionKey, getServiceName`

- - ### Constructor Detail

    - #### ClientReplicatedMapProxy

          public ClientReplicatedMapProxy(String serviceName,
                                          String objectName,
                                          ClientContext context)

  - ### Method Detail

    - #### onInitialize

          protected void onInitialize()

      Description copied from class: `ClientProxy`
      Called when proxy is created. Overriding implementations can add initialization specific logic into this method like registering a listener, creating a cleanup task etc.
      Overrides:
        `onInitialize` in class `ClientProxy`

    - #### postDestroy

          protected void postDestroy()

      Description copied from class: `ClientProxy`
      Called after proxy is destroyed.
      Overrides:
        `postDestroy` in class `ClientProxy`

    - #### put

          public V put(K key,
                       V value,
                       long ttl,
                       TimeUnit timeUnit)

      Description copied from interface: `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.

      Specified by:
        `put` in interface `ReplicatedMap<K,V>`
      Parameters:
        `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.

    - #### size

          public int size()

      Specified by:
        `size` in interface `Map<K,V>`

    - #### isEmpty

          public boolean isEmpty()

      Specified by:
        `isEmpty` in interface `Map<K,V>`

    - #### containsKey

          public boolean containsKey(Object key)

      Specified by:
        `containsKey` in interface `Map<K,V>`

    - #### containsValue

          public boolean containsValue(Object value)

      Specified by:
        `containsValue` in interface `Map<K,V>`

    - #### get

          public V get(Object userKey)

      Specified by:
        `get` in interface `Map<K,V>`

    - #### put

          public V put(K key,
                       V value)

      Specified by:
        `put` in interface `Map<K,V>`

    - #### remove

          public V remove(Object userKey)

      Specified by:
        `remove` in interface `Map<K,V>`

    - #### putAll

          public void putAll(Map<? extends K,? extends V> map)

      Specified by:
        `putAll` in interface `Map<K,V>`

    - #### clear

          public void clear()

      Description copied from interface: `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).

      Specified by:
        `clear` in interface `ReplicatedMap<K,V>`
      Specified by:
        `clear` in interface `Map<K,V>`

    - #### removeEntryListener

          public boolean removeEntryListener(String registrationId)

      Description copied from interface: `ReplicatedMap`
      Removes the specified entry listener. Returns silently if there was no such listener added before.
      Specified by:
        `removeEntryListener` in interface `ReplicatedMap<K,V>`
      Parameters:
        `registrationId` - ID of the registered entry listener.
      Returns:
        true if registration is removed, false otherwise.

    - #### addEntryListener

          public String addEntryListener(EntryListener<K,V> listener)

      Description copied from interface: `ReplicatedMap`
      Adds an entry listener for this map. The listener will be notified for all map add/remove/update/evict events.
      Specified by:
        `addEntryListener` in interface `ReplicatedMap<K,V>`
      Parameters:
        `listener` - entry listener

    - #### addEntryListener

          public String addEntryListener(EntryListener<K,V> listener,
                                         K key)

      Description copied from interface: `ReplicatedMap`
      Adds the specified entry listener for the specified key. The listener will be notified for all add/remove/update/evict events of the specified key only.

      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.
      Specified by:
        `addEntryListener` in interface `ReplicatedMap<K,V>`
      Parameters:
        `listener` - the entry listener to add
        `key` - the key to listen to

    - #### addEntryListener

          public String addEntryListener(EntryListener<K,V> listener,
                                         Predicate<K,V> predicate)

      Description copied from interface: `ReplicatedMap`
      Adds an continuous entry listener for this map. The listener will be notified for map add/remove/update/evict events filtered by the given predicate.
      Specified by:
        `addEntryListener` in interface `ReplicatedMap<K,V>`
      Parameters:
        `listener` - the entry listener to add
        `predicate` - the predicate for filtering entries

    - #### addEntryListener

          public String addEntryListener(EntryListener<K,V> listener,
                                         Predicate<K,V> predicate,
                                         K key)

      Description copied from interface: `ReplicatedMap`
      Adds an continuous entry listener for this map. The listener will be notified for map add/remove/update/evict events filtered by the given predicate.
      Specified by:
        `addEntryListener` in interface `ReplicatedMap<K,V>`
      Parameters:
        `listener` - the entry listener
        `predicate` - the predicate for filtering entries
        `key` - the key to listen to

    - #### keySet

          public Set<K> keySet()

      Description copied from interface: `ReplicatedMap`
      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. Any kind of mutating function will throw an `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.
      Specified by:
        `keySet` in interface `ReplicatedMap<K,V>`
      Specified by:
        `keySet` in interface `Map<K,V>`
      Returns:
        A lazy `Set` view of the keys contained in this map.

    - #### getReplicatedMapStats

          public LocalReplicatedMapStats getReplicatedMapStats()

      Description copied from interface: `ReplicatedMap`
      Returns LocalReplicatedMapStats for this replicated map. LocalReplicatedMapStats is the statistics for the local replicated map and contains information such as getCount putCount, hits, lastUpdateTime etc.

      Specified by:
        `getReplicatedMapStats` in interface `ReplicatedMap<K,V>`
      Returns:
        this replicated map's statistics.

    - #### values

          public Collection<V> values()

      Description copied from interface: `ReplicatedMap`
      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. Any kind of mutating function will throw an `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.
      Changes on the map are NOT reflected on the collection on the CLIENT or vice versa. The order of the elements is not guaranteed due to the internal asynchronous replication behavior. If a specific order is needed, use `ReplicatedMap.values(java.util.Comparator)` to force reordering of the elements before returning.
      Changes to any returned object are NOT replicated back to other members.
      Specified by:
        `values` in interface `ReplicatedMap<K,V>`
      Specified by:
        `values` in interface `Map<K,V>`
      Returns:
        A collection view of the values contained in this map.

    - #### values

          public Collection<V> values(Comparator<V> comparator)

      Description copied from interface: `ReplicatedMap`
      Returns an eagerly populated `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.
      The order of the elements is guaranteed by executing the given `Comparator` before returning the elements.
      Changes to any returned object are NOT replicated back to other members.
      Specified by:
        `values` in interface `ReplicatedMap<K,V>`
      Parameters:
        `comparator` - the Comparator to sort the returned elements.
      Returns:
        An eagerly populated `Collection` view of the values contained in this map.

    - #### entrySet

          public Set<Map.Entry<K,V>> entrySet()

      Description copied from interface: `ReplicatedMap`
      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. Any kind of mutating function will throw an `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.
      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.
      Specified by:
        `entrySet` in interface `ReplicatedMap<K,V>`
      Specified by:
        `entrySet` in interface `Map<K,V>`
      Returns:
        A lazy set view of the mappings contained in this map.

    - #### addNearCacheInvalidationListener

          public String addNearCacheInvalidationListener(EventHandler handler)

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2018. All rights reserved.