Hazelcast C++ Client
 All Classes Functions Variables Enumerations Enumerator Pages
HazelcastClient.h
1 /*
2  * Copyright (c) 2008-2017, Hazelcast, Inc. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #ifndef HAZELCAST_CLIENT
17 #define HAZELCAST_CLIENT
18 
19 #include "hazelcast/client/map/impl/ClientMapProxyFactory.h"
20 #include "hazelcast/client/internal/nearcache/NearCacheManager.h"
21 #include "hazelcast/client/proxy/RingbufferImpl.h"
22 #include "hazelcast/client/IMap.h"
23 #include "hazelcast/client/MultiMap.h"
24 #include "hazelcast/client/IQueue.h"
25 #include "hazelcast/client/ISet.h"
26 #include "hazelcast/client/IList.h"
27 #include "hazelcast/client/ITopic.h"
28 #include "hazelcast/client/TransactionOptions.h"
29 #include "hazelcast/client/TransactionContext.h"
30 #include "hazelcast/client/Cluster.h"
31 #include "hazelcast/client/ClientConfig.h"
32 #include "hazelcast/client/ClientProperties.h"
33 #include "hazelcast/client/spi/InvocationService.h"
34 #include "hazelcast/client/spi/PartitionService.h"
35 #include "hazelcast/client/spi/ServerListenerService.h"
36 #include "hazelcast/client/spi/LifecycleService.h"
37 #include "hazelcast/client/spi/ProxyManager.h"
38 #include "hazelcast/client/connection/ConnectionManager.h"
39 #include "hazelcast/client/Ringbuffer.h"
40 #include "hazelcast/client/ReliableTopic.h"
41 
42 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
43 #pragma warning(push)
44 #pragma warning(disable: 4251) //for dll export
45 #endif
46 
47 namespace hazelcast {
48  namespace client {
407  namespace connection {
408  class ConnectionManager;
409  }
410 
411  namespace serialization {
412  namespace pimpl {
413  class SerializationService;
414  }
415  }
416  namespace spi {
417  class ClientContext;
418 
419  class InvocationService;
420 
421  class ClusterService;
422 
423  class PartitionService;
424 
425  class LifecycleService;
426 
427  class ServerListenerService;
428 
429  class ClientProxyFactory;
430 
431  }
432 
433  class ClientConfig;
434 
435  class IdGenerator;
436 
437  class IAtomicLong;
438 
439  class ICountDownLatch;
440 
441  class ISemaphore;
442 
443  class ILock;
444 
445  class TransactionContext;
446 
447  class TransactionOptions;
448 
449  class Cluster;
450 
458  class HAZELCAST_API HazelcastClient {
459  friend class spi::ClientContext;
460 
461  public:
468 
472  ~HazelcastClient();
473 
480  template<typename T>
481  T getDistributedObject(const std::string& name) {
482  T t(name, &(clientContext));
483  return t;
484  }
485 
496  template<typename K, typename V>
497  IMap<K, V> getMap(const std::string &name) {
498  map::impl::ClientMapProxyFactory<K, V> factory(&clientContext);
499  boost::shared_ptr<spi::ClientProxy> proxy =
500  getDistributedObjectForService(IMap<K, V>::SERVICE_NAME, name, factory);
501 
502  return IMap<K, V>(proxy);
503  }
504 
511  template<typename K, typename V>
512  MultiMap<K, V> getMultiMap(const std::string& name) {
513  return getDistributedObject<MultiMap<K, V> >(name);
514  }
515 
522  template<typename E>
523  IQueue<E> getQueue(const std::string& name) {
524  return getDistributedObject<IQueue<E> >(name);
525  }
526 
535  template<typename E>
536  ISet<E> getSet(const std::string& name) {
537  return getDistributedObject<ISet<E> >(name);
538  }
539 
547  template<typename E>
548  IList<E> getList(const std::string& name) {
549  return getDistributedObject<IList<E> >(name);
550  }
551 
558  template<typename E>
559  ITopic<E> getTopic(const std::string& name) {
560  return getDistributedObject<ITopic<E> >(name);
561  };
562 
569  template<typename E>
570  boost::shared_ptr<ReliableTopic<E> > getReliableTopic(const std::string& name) {
571  boost::shared_ptr<Ringbuffer<topic::impl::reliable::ReliableTopicMessage> > rb =
572  getRingbuffer<topic::impl::reliable::ReliableTopicMessage>(TOPIC_RB_PREFIX + name);
573  return boost::shared_ptr<ReliableTopic<E> >(new ReliableTopic<E>(name, &clientContext, rb));
574  }
575 
584  IdGenerator getIdGenerator(const std::string& name);
585 
593  IAtomicLong getIAtomicLong(const std::string& name);
594 
603  ICountDownLatch getICountDownLatch(const std::string& name);
604 
629  ILock getILock(const std::string& name);
630 
637  template <typename E>
638  boost::shared_ptr<Ringbuffer<E> > getRingbuffer(const std::string& name) {
639  return boost::shared_ptr<Ringbuffer<E> >(new proxy::RingbufferImpl<E>(name, &clientContext));
640  }
641 
649  ISemaphore getISemaphore(const std::string& name);
650 
655  ClientConfig& getClientConfig();
656 
662  TransactionContext newTransactionContext();
663 
670  TransactionContext newTransactionContext(const TransactionOptions& options);
671 
679  Cluster& getCluster();
680 
691  void addLifecycleListener(LifecycleListener *lifecycleListener);
692 
698  bool removeLifecycleListener(LifecycleListener *lifecycleListener);
699 
703  void shutdown();
704 
705  internal::nearcache::NearCacheManager &getNearCacheManager();
706 
707  serialization::pimpl::SerializationService &getSerializationService();
708  private:
709  boost::shared_ptr<spi::ClientProxy> getDistributedObjectForService(const std::string &serviceName,
710  const std::string &name,
711  spi::ClientProxyFactory &factory);
712 
713  ClientConfig clientConfig;
714  ClientProperties clientProperties;
715  spi::ClientContext clientContext;
716  spi::LifecycleService lifecycleService;
717  serialization::pimpl::SerializationService serializationService;
718  connection::ConnectionManager connectionManager;
719  internal::nearcache::NearCacheManager nearCacheManager;
720  spi::ClusterService clusterService;
721  spi::PartitionService partitionService;
722  spi::InvocationService invocationService;
723  spi::ServerListenerService serverListenerService;
724  Cluster cluster;
725  spi::ProxyManager proxyManager;
726 
727  HazelcastClient(const HazelcastClient& rhs);
728 
729  void operator=(const HazelcastClient& rhs);
730 
731  const std::string TOPIC_RB_PREFIX;
732  };
733 
734  }
735 }
736 
737 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
738 #pragma warning(pop)
739 #endif
740 
741 #endif /* HAZELCAST_CLIENT */
Contains the configuration for a Hazelcast transaction.
Definition: TransactionOptions.h:67
Concurrent, blocking, distributed, observable, client queue.
Definition: IQueue.h:38
ITopic< E > getTopic(const std::string &name)
Returns the distributed topic instance with the specified name and entry type E.
Definition: HazelcastClient.h:559
Cluster-wide unique id generator.
Definition: IdGenerator.h:42
IQueue< E > getQueue(const std::string &name)
Returns the distributed queue instance with the specified name and entry type E.
Definition: HazelcastClient.h:523
IAtomicLong is a distributed atomic long implementation.
Definition: IAtomicLong.h:38
ICountDownLatch is a backed-up distributed alternative to the java.util.concurrent.CountDownLatch java.util.concurrent.CountDownLatch.
Definition: ICountDownLatch.h:62
MultiMap< K, V > getMultiMap(const std::string &name)
Returns the distributed multimap instance with the specified name.
Definition: HazelcastClient.h:512
boost::shared_ptr< ReliableTopic< E > > getReliableTopic(const std::string &name)
Returns the distributed topic instance with the specified name and entry type E.
Definition: HazelcastClient.h:570
IList< E > getList(const std::string &name)
Returns the distributed list instance with the specified name.
Definition: HazelcastClient.h:548
A specialized distributed map client whose keys can be associated with multiple values.
Definition: MultiMap.h:41
Re-entrant Lock, Distributed client implementation of Lock.
Definition: ILock.h:40
Client Properties is an internal class.
Definition: ClientProperties.h:71
Concurrent, distributed , client implementation of std::list.
Definition: IList.h:42
Concurrent, distributed client implementation of std::unordered_set.
Definition: ISet.h:36
Hazelcast provides distribution mechanism for publishing messages that are delivered to multiple subs...
Definition: ITopic.h:41
Hazelcast provides distribution mechanism for publishing messages that are delivered to multiple subs...
Definition: ReliableTopic.h:45
boost::shared_ptr< Ringbuffer< E > > getRingbuffer(const std::string &name)
Returns the distributed Ringbuffer instance with the specified name.
Definition: HazelcastClient.h:638
Hazelcast cluster interface.
Definition: Cluster.h:38
NearCacheManager is the contract point to manage all existing NearCache instances.
Definition: NearCacheManager.h:40
ISet< E > getSet(const std::string &name)
Returns the distributed set instance with the specified name and entry type E.
Definition: HazelcastClient.h:536
Listener object for listening lifecycle events of hazelcast instance.
Definition: LifecycleListener.h:44
IMap< K, V > getMap(const std::string &name)
Definition: HazelcastClient.h:497
Concurrent, distributed, observable and queryable map client.
Definition: IMap.h:65
ISemaphore is a backed-up distributed alternative to the java.util.concurrent.Semaphore.
Definition: ISemaphore.h:56
HazelcastClient configuration class.
Definition: ClientConfig.h:51
Hazelcast Client enables you to do all Hazelcast operations without being a member of the cluster...
Definition: HazelcastClient.h:458
Provides a context to do transactional operations; so beginning/committing transactions, but also retrieving transactional data-structures like the TransactionalMap.
Definition: TransactionContext.h:52
T getDistributedObject(const std::string &name)
Definition: HazelcastClient.h:481