Hazelcast C++ Client
Hazelcast C++ Client Library
Loading...
Searching...
No Matches
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).
boost::future< boost::uuids::uuid > add_entry_listener (entry_listener &&listener)
 Adds an entry listener for this map.
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.
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.
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.
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.
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.
template<typename K>
boost::future< std::vector< K > > key_set ()
 Returns a view of the keys contained in this map.
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 47 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 97 of file replicated_map.h.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

292 {
293 return put<K, V, R>(key, value, std::chrono::milliseconds(0));
294 }
boost::future< boost::optional< R > > put(const K &key, const V &value, std::chrono::milliseconds ttl)

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

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

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

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

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

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

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

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

◆ spi::ProxyManager

friend class spi::ProxyManager
friend

Definition at line 49 of file replicated_map.h.

Member Data Documentation

◆ SERVICE_NAME

const char* hazelcast::client::replicated_map::SERVICE_NAME = "hz:impl:replicatedMapService"
staticconstexpr

Definition at line 52 of file replicated_map.h.


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