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 () | |
Constructs a hazelcastClient with default configurations. | |
HazelcastClient (const 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 K , typename V > | |
boost::shared_ptr< ReplicatedMap< K, V > > | getReplicatedMap (const std::string &name) |
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... | |
FlakeIdGenerator | getFlakeIdGenerator (const std::string &name) |
Returns a generator that creates a cluster-wide unique IDs. More... | |
IAtomicLong | getIAtomicLong (const std::string &name) |
Creates cluster-wide atomic long. More... | |
boost::shared_ptr< crdt::pncounter::PNCounter > | getPNCounter (const std::string &name) |
Obtain a com.hazelcast.crdt.pncounter.PNCounter with the given name. 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... | |
boost::shared_ptr< IExecutorService > | getExecutorService (const std::string &name) |
Creates or returns the distributed executor service for the given name. 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... | |
Client | getLocalEndpoint () const |
Returns the local endpoint which this HazelcastInstance belongs to. 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 | ( | const 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. |
boost::shared_ptr< IExecutorService > hazelcast::client::HazelcastClient::getExecutorService | ( | const std::string & | name | ) |
Creates or returns the distributed executor service for the given name.
Executor service enables you to run your Runnable
s and Callable
s on the Hazelcast cluster.
Note: Note that it doesn't support
and doesn't have standard shutdown behavior
name | name of the executor service |
FlakeIdGenerator hazelcast::client::HazelcastClient::getFlakeIdGenerator | ( | const std::string & | name | ) |
Returns a generator that creates a cluster-wide unique IDs.
Generated IDs are
primitive values and are k-ordered (roughly ordered). IDs are in the range from
to
.
The IDs contain timestamp component and a node ID component, which is assigned when the member joins the cluster. This allows the IDs to be ordered and unique without any coordination between members, which makes the generator safe even in split-brain scenario (for caveats, see here).
For more details and caveats, see class documentation for FlakeIdGenerator.
Note: this implementation doesn't share namespace with getIdGenerator(String). That is,
is distinct from
.
name | name of the FlakeIdGenerator |
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 |
Client hazelcast::client::HazelcastClient::getLocalEndpoint | ( | ) | const |
Returns the local endpoint which this HazelcastInstance belongs to.
|
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.
boost::shared_ptr< crdt::pncounter::PNCounter > hazelcast::client::HazelcastClient::getPNCounter | ( | const std::string & | name | ) |
Obtain a com.hazelcast.crdt.pncounter.PNCounter with the given name.
The PN counter can be used as a counter with strong eventual consistency guarantees - if operations to the counters stop, the counter values of all replicas that can communicate with each other should eventually converge to the same value.
name | the name of the PN counter |
|
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.