Hazelcast C++ Client
 All Classes Functions Variables Enumerations Pages
HazelcastClient.h
1 /*
2  * Copyright (c) 2008-2015, 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/proxy/RingbufferImpl.h"
20 #include "hazelcast/client/IMap.h"
21 #include "hazelcast/client/MultiMap.h"
22 #include "hazelcast/client/IQueue.h"
23 #include "hazelcast/client/ISet.h"
24 #include "hazelcast/client/IList.h"
25 #include "hazelcast/client/ITopic.h"
26 #include "hazelcast/client/TransactionOptions.h"
27 #include "hazelcast/client/TransactionContext.h"
28 #include "hazelcast/client/Cluster.h"
29 #include "hazelcast/client/ClientConfig.h"
30 #include "hazelcast/client/ClientProperties.h"
31 #include "hazelcast/client/spi/InvocationService.h"
32 #include "hazelcast/client/spi/PartitionService.h"
33 #include "hazelcast/client/spi/ServerListenerService.h"
34 #include "hazelcast/client/spi/LifecycleService.h"
35 #include "hazelcast/client/connection/ConnectionManager.h"
36 #include "hazelcast/client/Ringbuffer.h"
37 #include "hazelcast/client/ReliableTopic.h"
38 
39 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
40 #pragma warning(push)
41 #pragma warning(disable: 4251) //for dll export
42 #endif
43 
44 namespace hazelcast {
45  namespace client {
404  namespace connection {
405  class ConnectionManager;
406  }
407 
408  namespace serialization {
409  namespace pimpl {
410  class SerializationService;
411  }
412  }
413  namespace spi {
414  class ClientContext;
415 
416  class InvocationService;
417 
418  class ClusterService;
419 
420  class PartitionService;
421 
422  class LifecycleService;
423 
424  class ServerListenerService;
425 
426  }
427 
428  class ClientConfig;
429 
430  class IdGenerator;
431 
432  class IAtomicLong;
433 
434  class ICountDownLatch;
435 
436  class ISemaphore;
437 
438  class ILock;
439 
440  class TransactionContext;
441 
442  class TransactionOptions;
443 
444  class Cluster;
445 
453  class HAZELCAST_API HazelcastClient {
454  friend class spi::ClientContext;
455 
456  public:
463 
467  ~HazelcastClient();
468 
475  template<typename T>
476  T getDistributedObject(const std::string& name) {
477  T t(name, &(clientContext));
478  return t;
479  }
480 
491  template<typename K, typename V>
492  IMap<K, V> getMap(const std::string& name) {
493  return getDistributedObject<IMap<K, V> >(name);
494  }
495 
502  template<typename K, typename V>
503  MultiMap<K, V> getMultiMap(const std::string& name) {
504  return getDistributedObject<MultiMap<K, V> >(name);
505  }
506 
513  template<typename E>
514  IQueue<E> getQueue(const std::string& name) {
515  return getDistributedObject<IQueue<E> >(name);
516  }
517 
526  template<typename E>
527  ISet<E> getSet(const std::string& name) {
528  return getDistributedObject<ISet<E> >(name);
529  }
530 
538  template<typename E>
539  IList<E> getList(const std::string& name) {
540  return getDistributedObject<IList<E> >(name);
541  }
542 
549  template<typename E>
550  ITopic<E> getTopic(const std::string& name) {
551  return getDistributedObject<ITopic<E> >(name);
552  };
553 
560  template<typename E>
561  boost::shared_ptr<ReliableTopic<E> > getReliableTopic(const std::string& name) {
562  boost::shared_ptr<Ringbuffer<topic::impl::reliable::ReliableTopicMessage> > rb =
563  getRingbuffer<topic::impl::reliable::ReliableTopicMessage>(TOPIC_RB_PREFIX + name);
564  return boost::shared_ptr<ReliableTopic<E> >(new ReliableTopic<E>(name, &clientContext, rb));
565  }
566 
575  IdGenerator getIdGenerator(const std::string& name);
576 
584  IAtomicLong getIAtomicLong(const std::string& name);
585 
594  ICountDownLatch getICountDownLatch(const std::string& name);
595 
620  ILock getILock(const std::string& name);
621 
628  template <typename E>
629  boost::shared_ptr<Ringbuffer<E> > getRingbuffer(const std::string& name) {
630  return boost::shared_ptr<Ringbuffer<E> >(new proxy::RingbufferImpl<E>(name, &clientContext));
631  }
632 
640  ISemaphore getISemaphore(const std::string& name);
641 
646  ClientConfig& getClientConfig();
647 
653  TransactionContext newTransactionContext();
654 
661  TransactionContext newTransactionContext(const TransactionOptions& options);
662 
670  Cluster& getCluster();
671 
682  void addLifecycleListener(LifecycleListener *lifecycleListener);
683 
689  bool removeLifecycleListener(LifecycleListener *lifecycleListener);
690 
694  void shutdown();
695 
696  private:
697  ClientConfig clientConfig;
698  ClientProperties clientProperties;
699  spi::ClientContext clientContext;
700  spi::LifecycleService lifecycleService;
701  serialization::pimpl::SerializationService serializationService;
702  connection::ConnectionManager connectionManager;
703  spi::ClusterService clusterService;
704  spi::PartitionService partitionService;
705  spi::InvocationService invocationService;
706  spi::ServerListenerService serverListenerService;
707  Cluster cluster;
708 
709  HazelcastClient(const HazelcastClient& rhs);
710 
711  void operator=(const HazelcastClient& rhs);
712 
713  const std::string TOPIC_RB_PREFIX;
714  };
715 
716  }
717 }
718 
719 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
720 #pragma warning(pop)
721 #endif
722 
723 #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:550
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:514
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:503
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:561
IList< E > getList(const std::string &name)
Returns the distributed list instance with the specified name.
Definition: HazelcastClient.h:539
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:43
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:629
Hazelcast cluster interface.
Definition: Cluster.h:38
ISet< E > getSet(const std::string &name)
Returns the distributed set instance with the specified name and entry type E.
Definition: HazelcastClient.h:527
Listener object for listening lifecycle events of hazelcast instance.
Definition: LifecycleListener.h:44
IMap< K, V > getMap(const std::string &name)
Definition: HazelcastClient.h:492
Concurrent, distributed, observable and queryable map client.
Definition: IMap.h:58
ISemaphore is a backed-up distributed alternative to the java.util.concurrent.Semaphore.
Definition: ISemaphore.h:57
HazelcastClient configuration class.
Definition: ClientConfig.h:49
Hazelcast Client enables you to do all Hazelcast operations without being a member of the cluster...
Definition: HazelcastClient.h:453
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:476