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 96 of file replicated_map.h.

98  {
99  return proxy::ReplicatedMapImpl::add_entry_listener(
100  std::shared_ptr<impl::BaseEventHandler>(
101  new EntryEventHandler<
102  protocol::codec::replicatedmap_addentrylistener_handler>(
103  get_name(),
104  get_context().get_client_cluster_service(),
105  get_context().get_serialization_service(),
106  std::move(listener),
107  get_context().get_logger())));
108  }

◆ 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 125 of file replicated_map.h.

126  {
127  return proxy::ReplicatedMapImpl::add_entry_listener_to_key(
128  std::shared_ptr<impl::BaseEventHandler>(
129  new EntryEventHandler<
130  protocol::codec::replicatedmap_addentrylistenertokey_handler>(
131  get_name(),
132  get_context().get_client_cluster_service(),
133  get_context().get_serialization_service(),
134  std::move(listener),
135  get_context().get_logger())),
136  to_data(key));
137  }

◆ 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 150 of file replicated_map.h.

151  {
152  return proxy::ReplicatedMapImpl::add_entry_listener(
153  std::shared_ptr<impl::BaseEventHandler>(
154  new EntryEventHandler<
155  protocol::codec::
156  replicatedmap_addentrylistenerwithpredicate_handler>(
157  get_name(),
158  get_context().get_client_cluster_service(),
159  get_context().get_serialization_service(),
160  std::move(listener),
161  get_context().get_logger())),
162  to_data(predicate));
163  }

◆ 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 177 of file replicated_map.h.

180  {
181  return proxy::ReplicatedMapImpl::add_entry_listener(
182  std::shared_ptr<impl::BaseEventHandler>(
183  new EntryEventHandler<
184  protocol::codec::
185  replicatedmap_addentrylistenertokeywithpredicate_handler>(
186  get_name(),
187  get_context().get_client_cluster_service(),
188  get_context().get_serialization_service(),
189  std::move(listener),
190  get_context().get_logger())),
191  to_data(key),
192  to_data(predicate));
193  }

◆ 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 255 of file replicated_map.h.

256  {
257  return contains_key_data(to_data(key));
258  }

◆ 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 266 of file replicated_map.h.

267  {
268  return contains_value_data(to_data(value));
269  }

◆ 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 227 of file replicated_map.h.

228  {
229  return to_entry_object_vector<K, V>(entry_set_data());
230  }

◆ 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 277 of file replicated_map.h.

278  {
279  return to_object<V>(get_data(to_data(key)));
280  }

◆ 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 244 of file replicated_map.h.

245  {
246  return to_object_vector<K>(key_set_data());
247  }

◆ 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 290 of file replicated_map.h.

291  {
292  return put<K, V, R>(key, value, std::chrono::milliseconds(0));
293  }

◆ 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 67 of file replicated_map.h.

70  {
71  return to_object<R>(put_data(to_data(key), to_data(value), ttl));
72  }

◆ 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 85 of file replicated_map.h.

86  {
87  return put_all_data(to_data_entries(entries));
88  }

◆ 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 301 of file replicated_map.h.

302  {
303  return to_object<V>(remove_data(to_data(key)));
304  }

◆ 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 210 of file replicated_map.h.

211  {
212  return to_object_vector<V>(values_data());
213  }

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