Hazelcast C++ Client
Public Member Functions | List of all members
hazelcast::client::ReplicatedMap< K, V > Class Template Referenceabstract

#include <ReplicatedMap.h>

+ Inheritance diagram for hazelcast::client::ReplicatedMap< K, V >:

Public Member Functions

virtual boost::shared_ptr< V > put (const K &key, const V &value, int64_t ttl)=0
 
virtual void putAll (const std::map< K, V > &entries)=0
 Copies all of the mappings from the specified map to this map (optional operation). More...
 
virtual void clear ()=0
 
virtual bool removeEntryListener (const std::string &registrationId)=0
 Removes the specified entry listener. More...
 
virtual std::string addEntryListener (const boost::shared_ptr< EntryListener< K, V > > &listener)=0
 Adds an entry listener for this map. More...
 
virtual std::string addEntryListener (const boost::shared_ptr< EntryListener< K, V > > &listener, const K &key)=0
 Adds the specified entry listener for the specified key. More...
 
virtual const std::string addEntryListener (const boost::shared_ptr< EntryListener< K, V > > &listener, const query::Predicate &predicate)=0
 Adds an continuous entry listener for this map. More...
 
virtual std::string addEntryListener (const boost::shared_ptr< EntryListener< K, V > > &listener, const query::Predicate &predicate, const K &key)=0
 Adds an continuous entry listener for this map. More...
 
virtual boost::shared_ptr< DataArray< V > > values ()=0
 Due to the lazy nature of the returned array, changes to the map (addition, removal, update) might be reflected on the collection. More...
 
virtual boost::shared_ptr< LazyEntryArray< K, V > > entrySet ()=0
 Returns a lazy LazyEntryArray view of the mappings contained in this map. More...
 
virtual boost::shared_ptr< DataArray< K > > keySet ()=0
 Returns a lazy DataArray view of the key contained in this map. More...
 
virtual int32_t size ()=0
 
virtual bool isEmpty ()=0
 
virtual bool containsKey (const K &key)=0
 
virtual bool containsValue (const V &value)=0
 
virtual boost::shared_ptr< V > get (const K &key)=0
 
virtual boost::shared_ptr< V > put (const K &key, const V &value)=0
 
virtual boost::shared_ptr< V > remove (const K &key)=0
 
- Public Member Functions inherited from hazelcast::client::DistributedObject
virtual const std::string & getServiceName () const =0
 Returns the service name for this object.
 
virtual const std::string & getName () const =0
 Returns the unique name for this DistributedObject. More...
 
virtual void destroy ()=0
 Destroys this object cluster-wide. More...
 
virtual ~DistributedObject ()
 Destructor.
 

Detailed Description

template<typename K, typename V>
class hazelcast::client::ReplicatedMap< K, V >

A ReplicatedMap is a map-like data structure with weak consistency and values locally stored on every node of the cluster.

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.

When a new node joins the cluster, the new node initially will request existing values from older nodes and replicate them locally.

Parameters
<K>the type of keys maintained by this map
<V>the type of mapped values

Member Function Documentation

◆ addEntryListener() [1/4]

template<typename K , typename V >
virtual std::string hazelcast::client::ReplicatedMap< K, V >::addEntryListener ( const boost::shared_ptr< EntryListener< K, V > > &  listener)
pure virtual

Adds an entry listener for this map.

The listener will be notified for all map add/remove/update/evict events.

Parameters
listenerentry listener

◆ addEntryListener() [2/4]

template<typename K , typename V >
virtual std::string hazelcast::client::ReplicatedMap< K, V >::addEntryListener ( const boost::shared_ptr< EntryListener< K, V > > &  listener,
const K &  key 
)
pure virtual

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.

Parameters
listenerthe entry listener to add
keythe key to listen to

◆ addEntryListener() [3/4]

template<typename K , typename V >
virtual const std::string hazelcast::client::ReplicatedMap< K, V >::addEntryListener ( const boost::shared_ptr< EntryListener< K, V > > &  listener,
const query::Predicate predicate 
)
pure virtual

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.

Parameters
listenerthe entry listener to add
predicatethe predicate for filtering entries

◆ addEntryListener() [4/4]

template<typename K , typename V >
virtual std::string hazelcast::client::ReplicatedMap< K, V >::addEntryListener ( const boost::shared_ptr< EntryListener< K, V > > &  listener,
const query::Predicate predicate,
const K &  key 
)
pure virtual

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.

Parameters
listenerthe entry listener
predicatethe predicate for filtering entries
keythe key to listen to

◆ clear()

template<typename K , typename V >
virtual void hazelcast::client::ReplicatedMap< K, V >::clear ( )
pure virtual

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).

◆ containsKey()

template<typename K , typename V >
virtual bool hazelcast::client::ReplicatedMap< K, V >::containsKey ( const K &  key)
pure virtual
Parameters
keyThe key to be checked for existence
Returns
true if the entry with the key exist in the replicated map.

◆ containsValue()

template<typename K , typename V >
virtual bool hazelcast::client::ReplicatedMap< K, V >::containsValue ( const V &  value)
pure virtual
Parameters
valueThe value to check in the replicated map for existence.
Returns
true if the value exist in the replicated map.

◆ entrySet()

template<typename K , typename V >
virtual boost::shared_ptr<LazyEntryArray<K, V> > hazelcast::client::ReplicatedMap< K, V >::entrySet ( )
pure virtual

Returns a lazy LazyEntryArray view of the mappings contained in this map.


Due to the lazy nature of the returned array, changes to the map (addition, removal, update) might be reflected on the array.
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.

Returns
A lazy set view of the mappings contained in this map.

◆ get()

template<typename K , typename V >
virtual boost::shared_ptr<V> hazelcast::client::ReplicatedMap< K, V >::get ( const K &  key)
pure virtual
Parameters
keyThe key to be used to query from replicated map.
Returns
The value of the key if the key exist, null pointer otherwise.

◆ isEmpty()

template<typename K , typename V >
virtual bool hazelcast::client::ReplicatedMap< K, V >::isEmpty ( )
pure virtual
Returns
true if the replicated map is empty, false otherwise

◆ keySet()

template<typename K , typename V >
virtual boost::shared_ptr<DataArray<K> > hazelcast::client::ReplicatedMap< K, V >::keySet ( )
pure virtual

Returns a lazy DataArray view of the key contained in this map.


Due to the lazy nature of the returned array, changes to the map (addition, removal, update) might be reflected on the array.
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.

Returns
A lazy Set view of the keys contained in this map.

◆ put() [1/2]

template<typename K , typename V >
virtual boost::shared_ptr<V> hazelcast::client::ReplicatedMap< K, V >::put ( const K &  key,
const V &  value,
int64_t  ttl 
)
pure virtual

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 in milliseconds to define when the value is outdated and thus should be removed from the replicated map.

Parameters
keykey with which the specified value is to be associated.
valuevalue to be associated with the specified key.
ttlttl in milliseconds to be associated with the specified key-value pair.

◆ put() [2/2]

template<typename K , typename V >
virtual boost::shared_ptr<V> hazelcast::client::ReplicatedMap< K, V >::put ( const K &  key,
const V &  value 
)
pure virtual
Parameters
keyThe key to be put into the replicated map.
valueThe value of the key
Returns
The previous value if the key existed in the map or null pointer otherwise.

◆ putAll()

template<typename K , typename V >
virtual void hazelcast::client::ReplicatedMap< K, V >::putAll ( const std::map< K, V > &  entries)
pure virtual

Copies all of the mappings from the specified map to this map (optional operation).

The effect of this call is equivalent to that of calling put(k, v) on this map once for each mapping from key k to value v in the specified map. The behavior of this operation is undefined if the specified map is modified while the operation is in progress.

Parameters
entriesmappings to be stored in this map

◆ remove()

template<typename K , typename V >
virtual boost::shared_ptr<V> hazelcast::client::ReplicatedMap< K, V >::remove ( const K &  key)
pure virtual
Parameters
keyThe key of the entry to be removed.
Returns
The value associated with the removed key.

◆ removeEntryListener()

template<typename K , typename V >
virtual bool hazelcast::client::ReplicatedMap< K, V >::removeEntryListener ( const std::string &  registrationId)
pure virtual

Removes the specified entry listener.

Returns silently if there was no such listener added before.

Parameters
registrationIdID of the registered entry listener.
Returns
true if registration is removed, false otherwise.

◆ size()

template<typename K , typename V >
virtual int32_t hazelcast::client::ReplicatedMap< K, V >::size ( )
pure virtual
Returns
The number of the replicated map entries in the cluster.

◆ values()

template<typename K , typename V >
virtual boost::shared_ptr<DataArray<V> > hazelcast::client::ReplicatedMap< K, V >::values ( )
pure virtual

Due to the lazy nature of the returned array, 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 values(Comparator) to force reordering of the elements before returning.
Changes to any returned object are NOT replicated back to other members.

Returns
A collection view of the values contained in this map.

The documentation for this class was generated from the following file: