Hazelcast C++ Client
|
Hazelcast Client enables you to do all Hazelcast operations without being a member of the cluster. More...
#include <HazelcastClient.h>
Public Member Functions | |
HazelcastClient (ClientConfig &config) | |
Constructs a hazelcastClient with given ClientConfig. More... | |
const std::string & | getName () const |
Returns the name of this Hazelcast instance. More... | |
template<typename T > | |
T | getDistributedObject (const std::string &name) |
template<typename K , typename V > | |
IMap< K, V > | getMap (const std::string &name) |
Returns the distributed map instance with the specified name. More... | |
template<typename K , typename V > | |
MultiMap< K, V > | getMultiMap (const std::string &name) |
Returns the distributed multimap instance with the specified name. More... | |
template<typename E > | |
IQueue< E > | getQueue (const std::string &name) |
Returns the distributed queue instance with the specified name and entry type E. More... | |
template<typename E > | |
ISet< E > | getSet (const std::string &name) |
Returns the distributed set instance with the specified name and entry type E. More... | |
template<typename E > | |
IList< E > | getList (const std::string &name) |
Returns the distributed list instance with the specified name. More... | |
template<typename E > | |
ITopic< E > | getTopic (const std::string &name) |
Returns the distributed topic instance with the specified name and entry type E. More... | |
template<typename E > | |
boost::shared_ptr< ReliableTopic< E > > | getReliableTopic (const std::string &name) |
Returns the distributed topic instance with the specified name and entry type E. More... | |
IdGenerator | getIdGenerator (const std::string &name) |
Creates cluster-wide unique IDs. More... | |
IAtomicLong | getIAtomicLong (const std::string &name) |
Creates cluster-wide atomic long. More... | |
ICountDownLatch | getICountDownLatch (const std::string &name) |
Creates cluster-wide CountDownLatch. More... | |
ILock | getILock (const std::string &name) |
Returns the distributed lock instance for the specified key object. More... | |
template<typename E > | |
boost::shared_ptr< Ringbuffer< E > > | getRingbuffer (const std::string &name) |
Returns the distributed Ringbuffer instance with the specified name. More... | |
ISemaphore | getISemaphore (const std::string &name) |
Creates cluster-wide semaphore. More... | |
ClientConfig & | getClientConfig () |
TransactionContext | newTransactionContext () |
Creates a new TransactionContext associated with the current thread using default options. More... | |
TransactionContext | newTransactionContext (const TransactionOptions &options) |
Creates a new TransactionContext associated with the current thread with given options. More... | |
Cluster & | getCluster () |
Returns the Cluster that connected Hazelcast instance is a part of. More... | |
void | addLifecycleListener (LifecycleListener *lifecycleListener) |
Add listener to listen lifecycle events. More... | |
bool | removeLifecycleListener (LifecycleListener *lifecycleListener) |
Remove lifecycle listener. More... | |
void | shutdown () |
Shuts down this HazelcastClient. | |
mixedtype::HazelcastClient & | toMixedType () const |
Adopts the current map to the mixed type support interface. More... | |
spi::LifecycleService & | getLifecycleService () |
Returns the lifecycle service for this instance. More... | |
Friends | |
class | spi::ClientContext |
Hazelcast Client enables you to do all Hazelcast operations without being a member of the cluster.
It connects to one of the cluster members and delegates all cluster wide operations to it. When the connected cluster member dies, client will automatically switch to another live member.
hazelcast::client::HazelcastClient::HazelcastClient | ( | ClientConfig & | config | ) |
Constructs a hazelcastClient with given ClientConfig.
Note: ClientConfig will be copied.
config | client configuration to start the client with |
void hazelcast::client::HazelcastClient::addLifecycleListener | ( | LifecycleListener * | lifecycleListener | ) |
Add listener to listen lifecycle events.
Warning 1: If listener should do a time consuming operation, off-load the operation to another thread. otherwise it will slow down the system.
Warning 2: Do not make a call to hazelcast. It can cause deadlock.
lifecycleListener | Listener object |
ClientConfig & hazelcast::client::HazelcastClient::getClientConfig | ( | ) |
Cluster & hazelcast::client::HazelcastClient::getCluster | ( | ) |
|
inline |
T | type of the distributed object |
name | name of the distributed object. |
IAtomicLong hazelcast::client::HazelcastClient::getIAtomicLong | ( | const std::string & | name | ) |
Creates cluster-wide atomic long.
Hazelcast IAtomicLong is distributed implementation of java.util.concurrent.atomic.AtomicLong
.
name | name of the IAtomicLong proxy |
ICountDownLatch hazelcast::client::HazelcastClient::getICountDownLatch | ( | const std::string & | name | ) |
Creates cluster-wide CountDownLatch.
Hazelcast ICountDownLatch is distributed implementation of java.util.concurrent.CountDownLatch
.
name | name of the ICountDownLatch proxy |
IdGenerator hazelcast::client::HazelcastClient::getIdGenerator | ( | const std::string & | name | ) |
Creates cluster-wide unique IDs.
Generated IDs are long type primitive values between 0
and LONG_MAX
. Generated IDs are unique during the life cycle of the cluster. If the entire cluster is restarted, IDs start from 0
again.
name | name of the IdGenerator |
ILock hazelcast::client::HazelcastClient::getILock | ( | const std::string & | name | ) |
Returns the distributed lock instance for the specified key object.
The specified object is considered to be the key for this lock. So keys are considered equals cluster-wide as long as they are serialized to the same byte array such as String, long, Integer.
Locks are fail-safe. If a member holds a lock and some of the members go down, cluster will keep your locks safe and available. Moreover, when a member leaves the cluster, all the locks acquired by this dead member will be removed so that these locks can be available for live members immediately.
Lock lock = hazelcastInstance.getLock("PROCESS_LOCK"); lock.lock(); try { // process } finally { lock.unlock(); }
name | name of the lock instance |
ISemaphore hazelcast::client::HazelcastClient::getISemaphore | ( | const std::string & | name | ) |
Creates cluster-wide semaphore.
Hazelcast ISemaphore is distributed implementation of java.util.concurrent.Semaphore
.
name | name of the ISemaphore proxy |
spi::LifecycleService & hazelcast::client::HazelcastClient::getLifecycleService | ( | ) |
Returns the lifecycle service for this instance.
LifecycleService allows you to shutdown this HazelcastInstance and listen for the lifecycle events.
|
inline |
Returns the distributed list instance with the specified name.
List is ordered set of entries. similar to std::vector
name | name of the distributed list |
|
inline |
Returns the distributed map instance with the specified name.
K | key type |
V | value type |
name | name of the distributed map |
|
inline |
Returns the distributed multimap instance with the specified name.
name | name of the distributed multimap |
const std::string & hazelcast::client::HazelcastClient::getName | ( | ) | const |
Returns the name of this Hazelcast instance.
|
inline |
Returns the distributed queue instance with the specified name and entry type E.
name | name of the distributed queue |
|
inline |
Returns the distributed topic instance with the specified name and entry type E.
name | name of the distributed topic |
|
inline |
Returns the distributed Ringbuffer instance with the specified name.
name | name of the distributed Ringbuffer |
|
inline |
Returns the distributed set instance with the specified name and entry type E.
Set is ordered unique set of entries. similar to std::set
name | name of the distributed set |
|
inline |
Returns the distributed topic instance with the specified name and entry type E.
name | name of the distributed topic |
TransactionContext hazelcast::client::HazelcastClient::newTransactionContext | ( | ) |
Creates a new TransactionContext associated with the current thread using default options.
TransactionContext hazelcast::client::HazelcastClient::newTransactionContext | ( | const TransactionOptions & | options | ) |
Creates a new TransactionContext associated with the current thread with given options.
options | options for this transaction |
bool hazelcast::client::HazelcastClient::removeLifecycleListener | ( | LifecycleListener * | lifecycleListener | ) |
Remove lifecycle listener.
lifecycleListener |
mixedtype::HazelcastClient & hazelcast::client::HazelcastClient::toMixedType | ( | ) | const |
Adopts the current map to the mixed type support interface.
You can use the mixedtype::HazelcastClient interface to get data structures that support manipulating unrelated mixed data types.