Hazelcast C++ Client
Hazelcast C++ Client Library
hazelcast::client::replicated_map Class Reference

#include <replicated_map.h>

+ Inheritance diagram for hazelcast::client::replicated_map:

Public Member Functions

template<typename K , typename V , typename R = V>
boost::future< boost::optional< R > > put (const K &key, const V &value, std::chrono::milliseconds ttl)
 
template<typename K , typename V >
boost::future< void > put_all (const std::unordered_map< K, V > &entries)
 Copies all of the mappings from the specified map to this map (optional operation). More...
 
boost::future< boost::uuids::uuid > add_entry_listener (entry_listener &&listener)
 Adds an entry listener for this map. More...
 
template<typename K >
std::enable_if<!std::is_base_of< query::predicate, K >::value, boost::future< boost::uuids::uuid > >::type add_entry_listener (entry_listener &&listener, const K &key)
 Adds the specified entry listener for the specified key. More...
 
template<typename P >
std::enable_if< std::is_base_of< query::predicate, P >::value, boost::future< boost::uuids::uuid > >::type add_entry_listener (entry_listener &&listener, const P &predicate)
 Adds an continuous entry listener for this map. More...
 
template<typename K , typename P >
std::enable_if< std::is_base_of< query::predicate, P >::value, boost::future< boost::uuids::uuid > >::type add_entry_listener (entry_listener &&listener, const P &predicate, const K &key)
 Adds an continuous entry listener for this map. More...
 
template<typename V >
boost::future< std::vector< V > > values ()
 Due to the lazy nature of the returned array, changes to the map (addition, removal, update) might be reflected on the collection. More...
 
template<typename K , typename V >
boost::future< std::vector< std::pair< K, V > > > entry_set ()
 Returns a view of the mappings contained in this map. More...
 
template<typename K >
boost::future< std::vector< K > > key_set ()
 Returns a view of the keys contained in this map. More...
 
template<typename K >
boost::future< bool > contains_key (const K &key)
 
template<typename V >
boost::future< bool > contains_value (const V &value)
 
template<typename K , typename V >
boost::future< boost::optional< V > > get (const K &key)
 
template<typename K , typename V , typename R = V>
boost::future< boost::optional< R > > put (const K &key, const V &value)
 
template<typename K , typename V >
boost::future< boost::optional< V > > remove (const K &key)
 

Static Public Attributes

static constexpr const char * SERVICE_NAME = "hz:impl:replicatedMapService"
 

Friends

class spi::ProxyManager
 

Detailed Description

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.

Definition at line 46 of file replicated_map.h.

Member Function Documentation

◆ add_entry_listener() [1/4]

boost::future<boost::uuids::uuid> hazelcast::client::replicated_map::add_entry_listener ( entry_listener &&  listener)
inline

Adds an entry listener for this map.

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

Parameters
listenerentry listener

Definition at line 90 of file replicated_map.h.

90  {
91  return proxy::ReplicatedMapImpl::add_entry_listener(
92  std::shared_ptr<impl::BaseEventHandler>(
93  new EntryEventHandler<protocol::codec::replicatedmap_addentrylistener_handler>(get_name(), get_context().get_client_cluster_service(),
94  get_context().get_serialization_service(), std::move(listener), get_context().get_logger())));
95  }

◆ add_entry_listener() [2/4]

template<typename K >
std::enable_if<!std::is_base_of<query::predicate, K>::value, boost::future<boost::uuids::uuid> >::type hazelcast::client::replicated_map::add_entry_listener ( entry_listener &&  listener,
const K &  key 
)
inline

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

Definition at line 111 of file replicated_map.h.

111  {
112  return proxy::ReplicatedMapImpl::add_entry_listener_to_key(
113  std::shared_ptr<impl::BaseEventHandler>(
114  new EntryEventHandler<protocol::codec::replicatedmap_addentrylistenertokey_handler>(get_name(), get_context().get_client_cluster_service(),
115  get_context().get_serialization_service(), std::move(listener),
116  get_context().get_logger())), to_data(key));
117  }

◆ add_entry_listener() [3/4]

template<typename P >
std::enable_if<std::is_base_of<query::predicate, P>::value, boost::future<boost::uuids::uuid> >::type hazelcast::client::replicated_map::add_entry_listener ( entry_listener &&  listener,
const P &  predicate 
)
inline

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

Definition at line 128 of file replicated_map.h.

128  {
129  return proxy::ReplicatedMapImpl::add_entry_listener(
130  std::shared_ptr<impl::BaseEventHandler>(
131  new EntryEventHandler<protocol::codec::replicatedmap_addentrylistenerwithpredicate_handler>(get_name(), get_context().get_client_cluster_service(),
132  get_context().get_serialization_service(), std::move(listener),
133  get_context().get_logger())), to_data(predicate));
134  }

◆ add_entry_listener() [4/4]

template<typename K , typename P >
std::enable_if<std::is_base_of<query::predicate, P>::value, boost::future<boost::uuids::uuid> >::type hazelcast::client::replicated_map::add_entry_listener ( entry_listener &&  listener,
const P &  predicate,
const K &  key 
)
inline

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

Definition at line 146 of file replicated_map.h.

146  {
147  return proxy::ReplicatedMapImpl::add_entry_listener(
148  std::shared_ptr<impl::BaseEventHandler>(
149  new EntryEventHandler<protocol::codec::replicatedmap_addentrylistenertokeywithpredicate_handler>(get_name(), get_context().get_client_cluster_service(),
150  get_context().get_serialization_service(), std::move(listener),
151  get_context().get_logger())), to_data(key), to_data(predicate));
152  }

◆ contains_key()

template<typename K >
boost::future<bool> hazelcast::client::replicated_map::contains_key ( const K &  key)
inline
Parameters
keyThe key to be checked for existence
Returns
true if the entry with the key exist in the replicated map.

Definition at line 212 of file replicated_map.h.

212  {
213  return contains_key_data(to_data(key));
214  }

◆ contains_value()

template<typename V >
boost::future<bool> hazelcast::client::replicated_map::contains_value ( const V &  value)
inline
Parameters
valueThe value to check in the replicated map for existence.
Returns
true if the value exist in the replicated map.

Definition at line 222 of file replicated_map.h.

222  {
223  return contains_value_data(to_data(value));
224  }

◆ entry_set()

template<typename K , typename V >
boost::future<std::vector<std::pair<K, V> > > hazelcast::client::replicated_map::entry_set ( )
inline

Returns a 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
view of the mappings contained in this map.

Definition at line 185 of file replicated_map.h.

185  {
186  return to_entry_object_vector<K,V>(entry_set_data());
187  }

◆ get()

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

Definition at line 232 of file replicated_map.h.

232  {
233  return to_object<V>(get_data(to_data(key)));
234  }

◆ key_set()

template<typename K >
boost::future<std::vector<K> > hazelcast::client::replicated_map::key_set ( )
inline

Returns a view of the keys 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
The keys contained in this map.

Definition at line 202 of file replicated_map.h.

202  {
203  return to_object_vector<K>(key_set_data());
204  }

◆ put() [1/2]

template<typename K , typename V , typename R = V>
boost::future<boost::optional<R> > hazelcast::client::replicated_map::put ( const K &  key,
const V &  value 
)
inline
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.

Definition at line 243 of file replicated_map.h.

243  {
244  return put<K, V, R>(key, value, std::chrono::milliseconds(0));
245  }

◆ put() [2/2]

template<typename K , typename V , typename R = V>
boost::future<boost::optional<R> > hazelcast::client::replicated_map::put ( const K &  key,
const V &  value,
std::chrono::milliseconds  ttl 
)
inline

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 to be associated with the specified key-value pair.
Returns
the previous value associated with key, or empty if there was no mapping for key.

Definition at line 65 of file replicated_map.h.

65  {
66  return to_object<R>(put_data(to_data(key), to_data(value), ttl));
67  }

◆ put_all()

template<typename K , typename V >
boost::future<void> hazelcast::client::replicated_map::put_all ( const std::unordered_map< K, V > &  entries)
inline

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

Definition at line 80 of file replicated_map.h.

80  {
81  return put_all_data(to_data_entries(entries));
82  }

◆ remove()

template<typename K , typename V >
boost::future<boost::optional<V> > hazelcast::client::replicated_map::remove ( const K &  key)
inline
Parameters
keyThe key of the entry to be removed.
Returns
The value associated with the removed key.

Definition at line 253 of file replicated_map.h.

253  {
254  return to_object<V>(remove_data(to_data(key)));
255  }

◆ values()

template<typename V >
boost::future<std::vector<V> > hazelcast::client::replicated_map::values ( )
inline

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.

Definition at line 168 of file replicated_map.h.

168  {
169  return to_object_vector<V>(values_data());
170  }

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