Hazelcast C++ Client
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 &config)
 Constructs a hazelcastClient with given ClientConfig. More...
 
const std::string & getName () const
 Returns the name of this Hazelcast instance. More...
 
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...
 
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...
 
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.
 
mixedtype::HazelcastClienttoMixedType () 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
 

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

◆ HazelcastClient()

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

Constructs a hazelcastClient with given ClientConfig.

Note: ClientConfig will be copied.

Parameters
configclient configuration to start the client with

Member Function Documentation

◆ addLifecycleListener()

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

◆ getClientConfig()

ClientConfig & hazelcast::client::HazelcastClient::getClientConfig ( )
Returns
configuration of this Hazelcast client.

◆ getCluster()

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

◆ getDistributedObject()

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

◆ getIAtomicLong()

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

◆ getICountDownLatch()

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

◆ getIdGenerator()

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

◆ getILock()

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.

◆ getISemaphore()

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

◆ getLifecycleService()

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.

Returns
the lifecycle service for this instance

◆ getList()

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

◆ getMap()

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

◆ getMultiMap()

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

◆ getName()

const std::string & hazelcast::client::HazelcastClient::getName ( ) const

Returns the name of this Hazelcast instance.

Returns
name of this Hazelcast instance

◆ getQueue()

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

◆ getReliableTopic()

template<typename E >
boost::shared_ptr<ReliableTopic<E> > hazelcast::client::HazelcastClient::getReliableTopic ( 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

◆ getRingbuffer()

template<typename E >
boost::shared_ptr<Ringbuffer<E> > hazelcast::client::HazelcastClient::getRingbuffer ( const std::string &  name)
inline

Returns the distributed Ringbuffer instance with the specified name.

Parameters
namename of the distributed Ringbuffer
Returns
distributed RingBuffer instance with the specified name

◆ getSet()

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

◆ getTopic()

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

◆ newTransactionContext() [1/2]

TransactionContext hazelcast::client::HazelcastClient::newTransactionContext ( )

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

Returns
new TransactionContext

◆ newTransactionContext() [2/2]

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

◆ removeLifecycleListener()

bool hazelcast::client::HazelcastClient::removeLifecycleListener ( LifecycleListener lifecycleListener)

Remove lifecycle listener.

Parameters
lifecycleListener
Returns
true if removed successfully

◆ toMixedType()

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.

Returns
The mixed type supporting HazelcastClient.

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