Hazelcast C++ Client
 All Classes Functions Variables Enumerations Pages
Public Member Functions | Friends | List of all members
hazelcast::client::HazelcastClient Class Reference

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 &)
 Constructs a hazelcastClient with given ClientConfig. More...
 
 ~HazelcastClient ()
 Destructor.
 
template<typename 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...
 
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...
 
ISemaphore getISemaphore (const std::string &name)
 Creates cluster-wide semaphore. More...
 
ClientConfiggetClientConfig ()
 
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...
 
ClustergetCluster ()
 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.
 

Friends

class spi::ClientContext
 

Detailed Description

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.

Constructor & Destructor Documentation

hazelcast::client::HazelcastClient::HazelcastClient ( ClientConfig config)

Constructs a hazelcastClient with given ClientConfig.

Note: ClientConfig will be copied.

Member Function Documentation

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.

Parameters
lifecycleListenerListener object
ClientConfig & hazelcast::client::HazelcastClient::getClientConfig ( )
Returns
configuration of this Hazelcast client.
Cluster & hazelcast::client::HazelcastClient::getCluster ( )

Returns the Cluster that connected Hazelcast instance is a part of.

Cluster interface allows you to add listener for membership events and learn more about the cluster.

Returns
cluster
template<typename T >
T hazelcast::client::HazelcastClient::getDistributedObject ( const std::string &  name)
inline
Template Parameters
Ttype of the distributed object
Parameters
namename of the distributed object.
Returns
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.

Parameters
namename of the IAtomicLong proxy
Returns
IAtomicLong proxy for the given name
ICountDownLatch hazelcast::client::HazelcastClient::getICountDownLatch ( const std::string &  name)

Creates cluster-wide CountDownLatch.

Hazelcast ICountDownLatch is distributed implementation of java.util.concurrent.CountDownLatch.

Parameters
namename of the ICountDownLatch proxy
Returns
ICountDownLatch proxy for the given name
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.

Parameters
namename of the IdGenerator
Returns
IdGenerator for the given name
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();
 }
Parameters
namename of the lock instance
Returns
distributed lock instance for the specified name.
ISemaphore hazelcast::client::HazelcastClient::getISemaphore ( const std::string &  name)

Creates cluster-wide semaphore.

Hazelcast ISemaphore is distributed implementation of java.util.concurrent.Semaphore.

Parameters
namename of the ISemaphore proxy
Returns
ISemaphore proxy for the given name
template<typename E >
IList<E> hazelcast::client::HazelcastClient::getList ( const std::string &  name)
inline

Returns the distributed list instance with the specified name.

List is ordered set of entries. similar to std::vector

Parameters
namename of the distributed list
Returns
distributed list instance with the specified name
template<typename K , typename V >
IMap<K, V> hazelcast::client::HazelcastClient::getMap ( const std::string &  name)
inline

Returns the distributed map instance with the specified name.

Template Parameters
Kkey type
Vvalue type
Parameters
namename of the distributed map
Returns
distributed map instance with the specified name
template<typename K , typename V >
MultiMap<K, V> hazelcast::client::HazelcastClient::getMultiMap ( const std::string &  name)
inline

Returns the distributed multimap instance with the specified name.

Parameters
namename of the distributed multimap
Returns
distributed multimap instance with the specified name
template<typename E >
IQueue<E> hazelcast::client::HazelcastClient::getQueue ( const std::string &  name)
inline

Returns the distributed queue instance with the specified name and entry type E.

Parameters
namename of the distributed queue
Returns
distributed queue instance with the specified name
template<typename E >
ISet<E> hazelcast::client::HazelcastClient::getSet ( const std::string &  name)
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

Parameters
namename of the distributed set
Returns
distributed set instance with the specified name
template<typename E >
ITopic<E> hazelcast::client::HazelcastClient::getTopic ( const std::string &  name)
inline

Returns the distributed topic instance with the specified name and entry type E.

Parameters
namename of the distributed topic
Returns
distributed topic instance with the specified name
TransactionContext hazelcast::client::HazelcastClient::newTransactionContext ( )

Creates a new TransactionContext associated with the current thread using default options.

Returns
new TransactionContext
TransactionContext hazelcast::client::HazelcastClient::newTransactionContext ( const TransactionOptions options)

Creates a new TransactionContext associated with the current thread with given options.

Parameters
optionsoptions for this transaction
Returns
new TransactionContext
bool hazelcast::client::HazelcastClient::removeLifecycleListener ( LifecycleListener lifecycleListener)

Remove lifecycle listener.

Parameters
lifecycleListener
Returns
true if removed successfully

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