You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by mm...@apache.org on 2018/01/24 06:15:16 UTC

[incubator-pulsar] branch master updated: ENH: Apply `make format` into C++ client (#1080)

This is an automated email from the ASF dual-hosted git repository.

mmerli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pulsar.git


The following commit(s) were added to refs/heads/master by this push:
     new a7dadd5  ENH: Apply `make format` into C++ client (#1080)
a7dadd5 is described below

commit a7dadd503a0d4d9e89f61d5194177c105667a3f7
Author: Licht Takeuchi <li...@outlook.jp>
AuthorDate: Wed Jan 24 15:15:13 2018 +0900

    ENH: Apply `make format` into C++ client (#1080)
    
    * Change clang-format options
    
    * Exclude the files generated by protobuf from `make format`
    
    * ENH: Apply `make format` into C++ client
    
    * Change clang-format version to 5.0
    
    * Use gpg2 when docker build
    See https://github.com/rvm/rvm/issues/3544
    
    * Apply clang-format-5.0
    
    * Use `make check-format` on docker-build.sh
    
    * Fix typo
---
 build/docker/Dockerfile                            |   5 +-
 pulsar-client-cpp/.clang-format                    |   7 +-
 pulsar-client-cpp/CMakeLists.txt                   |   4 +-
 .../build-support/clang_format_exclusions.txt      |   2 +
 pulsar-client-cpp/docker-build.sh                  |   2 +-
 pulsar-client-cpp/docs/MainPage.md                 |   2 +-
 pulsar-client-cpp/include/pulsar/Authentication.h  |  90 +--
 pulsar-client-cpp/include/pulsar/BatchMessageId.h  |  15 +-
 .../include/pulsar/BrokerConsumerStats.h           |  15 +-
 pulsar-client-cpp/include/pulsar/Client.h          |  45 +-
 .../include/pulsar/ClientConfiguration.h           |  13 +-
 pulsar-client-cpp/include/pulsar/CompressionType.h |   3 +-
 pulsar-client-cpp/include/pulsar/Consumer.h        |  45 +-
 .../include/pulsar/ConsumerConfiguration.h         |  17 +-
 pulsar-client-cpp/include/pulsar/ConsumerType.h    |  33 +-
 .../include/pulsar/DeprecatedException.h           |  16 +-
 pulsar-client-cpp/include/pulsar/Message.h         |  29 +-
 pulsar-client-cpp/include/pulsar/MessageBuilder.h  |   9 +-
 pulsar-client-cpp/include/pulsar/MessageId.h       |  15 +-
 .../include/pulsar/MessageRoutingPolicy.h          |  11 +-
 pulsar-client-cpp/include/pulsar/Producer.h        |  10 +-
 .../include/pulsar/ProducerConfiguration.h         |  15 +-
 pulsar-client-cpp/include/pulsar/Reader.h          |   8 +-
 .../include/pulsar/ReaderConfiguration.h           |  16 +-
 pulsar-client-cpp/include/pulsar/Result.h          |  39 +-
 pulsar-client-cpp/include/pulsar/TopicMetadata.h   |   4 +-
 pulsar-client-cpp/lib/Authentication.cc            | 203 +++----
 pulsar-client-cpp/lib/Backoff.cc                   |  15 +-
 pulsar-client-cpp/lib/Backoff.h                    |  13 +-
 .../lib/BatchAcknowledgementTracker.cc             |  60 +-
 .../lib/BatchAcknowledgementTracker.h              |  55 +-
 pulsar-client-cpp/lib/BatchMessageContainer.cc     |  67 +--
 pulsar-client-cpp/lib/BatchMessageContainer.h      |  51 +-
 pulsar-client-cpp/lib/BatchMessageId.cc            |  23 +-
 pulsar-client-cpp/lib/BinaryProtoLookupService.cc  | 193 +++---
 pulsar-client-cpp/lib/BinaryProtoLookupService.h   |  23 +-
 pulsar-client-cpp/lib/BlockingQueue.h              |  94 +--
 pulsar-client-cpp/lib/BrokerConsumerStats.cc       |  73 +--
 pulsar-client-cpp/lib/BrokerConsumerStatsImpl.cc   | 153 ++---
 pulsar-client-cpp/lib/BrokerConsumerStatsImpl.h    |  19 +-
 .../lib/BrokerConsumerStatsImplBase.h              |  64 +-
 pulsar-client-cpp/lib/Client.cc                    |  30 +-
 pulsar-client-cpp/lib/ClientConfiguration.cc       |  59 +-
 pulsar-client-cpp/lib/ClientConfigurationImpl.h    |  21 +-
 pulsar-client-cpp/lib/ClientConnection.cc          | 470 +++++++--------
 pulsar-client-cpp/lib/ClientConnection.h           |  36 +-
 pulsar-client-cpp/lib/ClientImpl.cc                | 621 ++++++++++----------
 pulsar-client-cpp/lib/ClientImpl.h                 |  32 +-
 pulsar-client-cpp/lib/Commands.cc                  |  58 +-
 pulsar-client-cpp/lib/Commands.h                   |  35 +-
 pulsar-client-cpp/lib/CompressionCodec.cc          |   7 +-
 pulsar-client-cpp/lib/CompressionCodec.h           |  18 +-
 pulsar-client-cpp/lib/CompressionCodecLZ4.cc       |   7 +-
 pulsar-client-cpp/lib/CompressionCodecLZ4.h        |   5 +-
 pulsar-client-cpp/lib/CompressionCodecZLib.cc      |  10 +-
 pulsar-client-cpp/lib/CompressionCodecZLib.h       |   5 +-
 pulsar-client-cpp/lib/ConnectionPool.cc            |  31 +-
 pulsar-client-cpp/lib/ConnectionPool.h             |  11 +-
 pulsar-client-cpp/lib/Consumer.cc                  |  18 +-
 pulsar-client-cpp/lib/ConsumerConfiguration.cc     |  41 +-
 pulsar-client-cpp/lib/ConsumerConfigurationImpl.h  |  15 +-
 pulsar-client-cpp/lib/ConsumerImpl.cc              | 245 ++++----
 pulsar-client-cpp/lib/ConsumerImpl.h               |  35 +-
 pulsar-client-cpp/lib/ConsumerImplBase.h           |  11 +-
 pulsar-client-cpp/lib/DeprecatedException.cc       |  10 +-
 pulsar-client-cpp/lib/DestinationName.cc           | 286 +++++----
 pulsar-client-cpp/lib/DestinationName.h            |  75 ++-
 pulsar-client-cpp/lib/ExecutorService.cc           |  26 +-
 pulsar-client-cpp/lib/ExecutorService.h            |  18 +-
 pulsar-client-cpp/lib/Future.h                     |  31 +-
 pulsar-client-cpp/lib/HTTPLookupService.cc         | 355 +++++------
 pulsar-client-cpp/lib/HTTPLookupService.h          |  58 +-
 pulsar-client-cpp/lib/HandlerBase.cc               |  55 +-
 pulsar-client-cpp/lib/HandlerBase.h                |  26 +-
 pulsar-client-cpp/lib/Latch.cc                     |  14 +-
 pulsar-client-cpp/lib/Latch.h                      |   4 +-
 pulsar-client-cpp/lib/LogUtils.cc                  |   9 +-
 pulsar-client-cpp/lib/LogUtils.h                   |  82 ++-
 pulsar-client-cpp/lib/LookupDataResult.h           |  57 +-
 pulsar-client-cpp/lib/LookupService.h              |   6 +-
 pulsar-client-cpp/lib/Message.cc                   |  57 +-
 pulsar-client-cpp/lib/MessageBuilder.cc            |  23 +-
 pulsar-client-cpp/lib/MessageId.cc                 |  25 +-
 pulsar-client-cpp/lib/MessageImpl.cc               |  99 ++--
 pulsar-client-cpp/lib/MessageImpl.h                |   8 +-
 pulsar-client-cpp/lib/NamedEntity.h                |   5 +-
 pulsar-client-cpp/lib/NamespaceName.cc             |  21 +-
 pulsar-client-cpp/lib/NamespaceName.h              |  13 +-
 pulsar-client-cpp/lib/ObjectPool.h                 |  88 ++-
 .../lib/PartitionedBrokerConsumerStatsImpl.cc      | 216 ++++---
 .../lib/PartitionedBrokerConsumerStatsImpl.h       |  11 +-
 pulsar-client-cpp/lib/PartitionedConsumerImpl.cc   | 650 ++++++++++-----------
 pulsar-client-cpp/lib/PartitionedConsumerImpl.h    | 148 +++--
 pulsar-client-cpp/lib/PartitionedProducerImpl.cc   | 351 ++++++-----
 pulsar-client-cpp/lib/PartitionedProducerImpl.h    |  39 +-
 pulsar-client-cpp/lib/Producer.cc                  |  23 +-
 pulsar-client-cpp/lib/ProducerConfiguration.cc     |  46 +-
 pulsar-client-cpp/lib/ProducerConfigurationImpl.h  |  22 +-
 pulsar-client-cpp/lib/ProducerImpl.cc              | 177 +++---
 pulsar-client-cpp/lib/ProducerImpl.h               |  27 +-
 pulsar-client-cpp/lib/ProducerImplBase.h           |  27 +-
 pulsar-client-cpp/lib/Reader.cc                    |  15 +-
 pulsar-client-cpp/lib/ReaderConfiguration.cc       |  37 +-
 pulsar-client-cpp/lib/ReaderConfigurationImpl.h    |   8 +-
 pulsar-client-cpp/lib/ReaderImpl.cc                |  39 +-
 pulsar-client-cpp/lib/ReaderImpl.h                 |  15 +-
 pulsar-client-cpp/lib/Result.cc                    |   4 +-
 pulsar-client-cpp/lib/RoundRobinMessageRouter.cc   |  29 +-
 pulsar-client-cpp/lib/RoundRobinMessageRouter.h    |  27 +-
 pulsar-client-cpp/lib/ServiceUnitId.h              |   5 +-
 pulsar-client-cpp/lib/SharedBuffer.h               | 122 ++--
 .../lib/SinglePartitionMessageRouter.cc            |  28 +-
 .../lib/SinglePartitionMessageRouter.h             |  22 +-
 pulsar-client-cpp/lib/TopicMetadataImpl.cc         |  10 +-
 pulsar-client-cpp/lib/TopicMetadataImpl.h          |   6 +-
 .../lib/UnAckedMessageTrackerDisabled.h            |  19 +-
 .../lib/UnAckedMessageTrackerEnabled.cc            |  20 +-
 .../lib/UnAckedMessageTrackerEnabled.h             |   7 +-
 .../lib/UnAckedMessageTrackerInterface.h           |  11 +-
 pulsar-client-cpp/lib/UnboundedBlockingQueue.h     |  36 +-
 pulsar-client-cpp/lib/Url.cc                       |  44 +-
 pulsar-client-cpp/lib/Url.h                        |   9 +-
 pulsar-client-cpp/lib/UtilAllocator.h              |  26 +-
 pulsar-client-cpp/lib/Utils.h                      |  64 +-
 pulsar-client-cpp/lib/auth/AuthAthenz.cc           | 124 ++--
 pulsar-client-cpp/lib/auth/AuthAthenz.h            |  55 +-
 pulsar-client-cpp/lib/auth/AuthTls.cc              |  59 +-
 pulsar-client-cpp/lib/auth/AuthTls.h               |  53 +-
 pulsar-client-cpp/lib/auth/athenz/ZTSClient.cc     | 513 ++++++++--------
 pulsar-client-cpp/lib/auth/athenz/ZTSClient.h      |  71 +--
 pulsar-client-cpp/lib/checksum/ChecksumProvider.cc |  19 +-
 pulsar-client-cpp/lib/checksum/ChecksumProvider.h  |   8 +-
 pulsar-client-cpp/lib/checksum/crc32c_sse42.cc     | 122 ++--
 pulsar-client-cpp/lib/checksum/crc32c_sse42.h      |  23 +-
 pulsar-client-cpp/lib/checksum/crc32c_sw.cc        |  16 +-
 pulsar-client-cpp/lib/checksum/int_types.h         |  12 +-
 pulsar-client-cpp/lib/lz4/lz4.h                    | 207 ++++---
 pulsar-client-cpp/lib/stats/ConsumerStatsBase.h    |   6 +-
 .../lib/stats/ConsumerStatsDisabled.h              |   2 +-
 pulsar-client-cpp/lib/stats/ConsumerStatsImpl.cc   |  57 +-
 pulsar-client-cpp/lib/stats/ConsumerStatsImpl.h    |  23 +-
 pulsar-client-cpp/lib/stats/ProducerStatsBase.h    |   8 +-
 .../lib/stats/ProducerStatsDisabled.h              |  11 +-
 pulsar-client-cpp/lib/stats/ProducerStatsImpl.cc   |  97 ++-
 pulsar-client-cpp/lib/stats/ProducerStatsImpl.h    |  53 +-
 pulsar-client-cpp/tests/AuthPluginTest.cc          |  69 ++-
 pulsar-client-cpp/tests/BackoffTest.cc             |  10 +-
 pulsar-client-cpp/tests/BasicEndToEndTest.cc       | 269 ++++-----
 pulsar-client-cpp/tests/BatchMessageTest.cc        | 289 ++++-----
 pulsar-client-cpp/tests/BinaryLookupServiceTest.cc |   3 +-
 pulsar-client-cpp/tests/BlockingQueueTest.cc       |  34 +-
 pulsar-client-cpp/tests/ClientDeduplicationTest.cc |  29 +-
 pulsar-client-cpp/tests/ClientTest.cc              |  34 +-
 pulsar-client-cpp/tests/ConsumerStatsTest.cc       |  48 +-
 pulsar-client-cpp/tests/ConsumerTest.h             |   6 +-
 pulsar-client-cpp/tests/CustomRoutingPolicy.h      |  10 +-
 pulsar-client-cpp/tests/DestinationNameTest.cc     |  44 +-
 pulsar-client-cpp/tests/HttpHelper.cc              |  13 +-
 pulsar-client-cpp/tests/HttpHelper.h               |   1 -
 pulsar-client-cpp/tests/LatchTest.cc               |  12 +-
 pulsar-client-cpp/tests/MessageTest.cc             |  14 +-
 pulsar-client-cpp/tests/PulsarFriend.h             |  16 +-
 pulsar-client-cpp/tests/ReaderTest.cc              |   5 +-
 .../tests/RoundRobinMessageRouterTest.cc           |   6 +-
 .../tests/SinglePartitionMessageRouterTest.cc      |   6 +-
 pulsar-client-cpp/tests/UrlTest.cc                 |   8 +-
 pulsar-client-cpp/tests/ZTSClientTest.cc           |  20 +-
 pulsar-client-cpp/tests/mocks/GMockMessage.h       |  16 +-
 168 files changed, 4489 insertions(+), 5200 deletions(-)

diff --git a/build/docker/Dockerfile b/build/docker/Dockerfile
index 2da41e6..2075135 100644
--- a/build/docker/Dockerfile
+++ b/build/docker/Dockerfile
@@ -27,7 +27,8 @@ RUN apt-get update
 RUN apt-get install -y maven tig g++ cmake libssl-dev libcurl4-openssl-dev \
                 liblog4cxx-dev libprotobuf-dev libboost-all-dev google-mock libgtest-dev \
                 libjsoncpp-dev libxml2-utils protobuf-compiler wget \
-                curl doxygen openjdk-8-jdk-headless clang-format-4.0
+                curl doxygen openjdk-8-jdk-headless clang-format-5.0 \
+                gnupg2
 
 # Compile and install gtest
 RUN cd /usr/src/gtest && cmake . && make && cp libgtest.a /usr/lib
@@ -44,7 +45,7 @@ ENV JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64
 
 # Install Ruby-2.4.1
 RUN apt-get install -y
-RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB && \
+RUN gpg2 --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB && \
     (curl -sSL https://get.rvm.io | bash -s stable)
 ENV PATH "$PATH:/usr/local/rvm/bin"
 RUN rvm install 2.4.1
diff --git a/pulsar-client-cpp/.clang-format b/pulsar-client-cpp/.clang-format
index 76ceab1..cb40b50 100644
--- a/pulsar-client-cpp/.clang-format
+++ b/pulsar-client-cpp/.clang-format
@@ -17,4 +17,9 @@
 
 
 BasedOnStyle: Google
-ColumnLimit: 90
+IndentWidth: 4
+ColumnLimit: 110
+SortIncludes: false
+BreakBeforeBraces: Custom
+BraceWrapping:
+  AfterEnum: true
diff --git a/pulsar-client-cpp/CMakeLists.txt b/pulsar-client-cpp/CMakeLists.txt
index 999af9f..d99f7a8 100644
--- a/pulsar-client-cpp/CMakeLists.txt
+++ b/pulsar-client-cpp/CMakeLists.txt
@@ -200,7 +200,7 @@ add_subdirectory(tests)
 add_subdirectory(python)
 
 # `make format` option
-set(CLANG_FORMAT_VERSION "4.0")
+set(CLANG_FORMAT_VERSION "5.0")
 find_package(ClangTools)
 set(BUILD_SUPPORT_DIR "${CMAKE_SOURCE_DIR}/build-support")
 add_custom_target(format ${BUILD_SUPPORT_DIR}/run_clang_format.py
@@ -218,4 +218,4 @@ add_custom_target(check-format ${BUILD_SUPPORT_DIR}/run_clang_format.py
         ${BUILD_SUPPORT_DIR}/clang_format_exclusions.txt
         ${CMAKE_SOURCE_DIR}/lib
         ${CMAKE_SOURCE_DIR}/tests
-        ${CMAKE_SOURCE_DIR}/include)
\ No newline at end of file
+        ${CMAKE_SOURCE_DIR}/include)
diff --git a/pulsar-client-cpp/build-support/clang_format_exclusions.txt b/pulsar-client-cpp/build-support/clang_format_exclusions.txt
index e69de29..d3594ec 100644
--- a/pulsar-client-cpp/build-support/clang_format_exclusions.txt
+++ b/pulsar-client-cpp/build-support/clang_format_exclusions.txt
@@ -0,0 +1,2 @@
+*.pb.h
+*.pb.cc
diff --git a/pulsar-client-cpp/docker-build.sh b/pulsar-client-cpp/docker-build.sh
index 3bcd0d5..b0439b1 100755
--- a/pulsar-client-cpp/docker-build.sh
+++ b/pulsar-client-cpp/docker-build.sh
@@ -41,4 +41,4 @@ DOCKER_CMD="docker run -i -v $ROOT_DIR:/pulsar $IMAGE"
 find . -name CMakeCache.txt | xargs rm -f
 find . -name CMakeFiles | xargs rm -rf
 
-$DOCKER_CMD bash -c "cd /pulsar/pulsar-client-cpp && cmake . $CMAKE_ARGS && make"
+$DOCKER_CMD bash -c "cd /pulsar/pulsar-client-cpp && cmake . $CMAKE_ARGS && make check-format && make"
diff --git a/pulsar-client-cpp/docs/MainPage.md b/pulsar-client-cpp/docs/MainPage.md
index 143ecdc..ec1c3c5 100644
--- a/pulsar-client-cpp/docs/MainPage.md
+++ b/pulsar-client-cpp/docs/MainPage.md
@@ -177,4 +177,4 @@ After you changed code, run auto-formatting by the following command.
 make format
 ```
 You need to have the following installed to use the auto-formatting.
-* [clang-format 4.0](https://clang.llvm.org/)
\ No newline at end of file
+* [clang-format 5.0](https://clang.llvm.org/)
diff --git a/pulsar-client-cpp/include/pulsar/Authentication.h b/pulsar-client-cpp/include/pulsar/Authentication.h
index 7def5f2..ea3536d 100644
--- a/pulsar-client-cpp/include/pulsar/Authentication.h
+++ b/pulsar-client-cpp/include/pulsar/Authentication.h
@@ -30,55 +30,57 @@
 
 namespace pulsar {
 
-    class ClientConfiguration;
-    class Authentication;
+class ClientConfiguration;
+class Authentication;
 
-    class AuthenticationDataProvider {
-    public:
-        virtual ~AuthenticationDataProvider();
-        virtual bool hasDataForTls();
-        virtual std::string getTlsCertificates();
-        virtual std::string getTlsPrivateKey();
-        virtual bool hasDataForHttp();
-        virtual std::string getHttpAuthType();
-        virtual std::string getHttpHeaders();
-        virtual bool hasDataFromCommand();
-        virtual std::string getCommandData();
-    protected:
-        AuthenticationDataProvider();
-    };
+class AuthenticationDataProvider {
+   public:
+    virtual ~AuthenticationDataProvider();
+    virtual bool hasDataForTls();
+    virtual std::string getTlsCertificates();
+    virtual std::string getTlsPrivateKey();
+    virtual bool hasDataForHttp();
+    virtual std::string getHttpAuthType();
+    virtual std::string getHttpHeaders();
+    virtual bool hasDataFromCommand();
+    virtual std::string getCommandData();
 
-    typedef boost::shared_ptr<AuthenticationDataProvider> AuthenticationDataPtr;
-    typedef boost::shared_ptr<Authentication> AuthenticationPtr;
-    typedef std::map<std::string, std::string> ParamMap;
+   protected:
+    AuthenticationDataProvider();
+};
 
-    class Authentication {
-    public:
-        virtual ~Authentication();
-        virtual const std::string getAuthMethodName() const = 0;
-        virtual Result getAuthData(AuthenticationDataPtr& authDataContent) const {
-            authDataContent = authData_;
-            return ResultOk;
-        }
-    protected:
-        Authentication();
-        AuthenticationDataPtr authData_;
-        friend class ClientConfiguration;
-    };
+typedef boost::shared_ptr<AuthenticationDataProvider> AuthenticationDataPtr;
+typedef boost::shared_ptr<Authentication> AuthenticationPtr;
+typedef std::map<std::string, std::string> ParamMap;
 
-    class AuthFactory {
-    public:
-        static AuthenticationPtr Disabled();
-        static AuthenticationPtr create(const std::string& dynamicLibPath);
-        static AuthenticationPtr create(const std::string& dynamicLibPath, const std::string& authParamsString);
-        static AuthenticationPtr create(const std::string& dynamicLibPath, ParamMap& params);
+class Authentication {
+   public:
+    virtual ~Authentication();
+    virtual const std::string getAuthMethodName() const = 0;
+    virtual Result getAuthData(AuthenticationDataPtr& authDataContent) const {
+        authDataContent = authData_;
+        return ResultOk;
+    }
 
-    protected:
-        static bool isShutdownHookRegistered_;
-        static std::vector<void *> loadedLibrariesHandles_;
-        static void release_handles();
-    };
-}
+   protected:
+    Authentication();
+    AuthenticationDataPtr authData_;
+    friend class ClientConfiguration;
+};
+
+class AuthFactory {
+   public:
+    static AuthenticationPtr Disabled();
+    static AuthenticationPtr create(const std::string& dynamicLibPath);
+    static AuthenticationPtr create(const std::string& dynamicLibPath, const std::string& authParamsString);
+    static AuthenticationPtr create(const std::string& dynamicLibPath, ParamMap& params);
+
+   protected:
+    static bool isShutdownHookRegistered_;
+    static std::vector<void*> loadedLibrariesHandles_;
+    static void release_handles();
+};
+}  // namespace pulsar
 // namespace pulsar
 
 #pragma GCC visibility pop
diff --git a/pulsar-client-cpp/include/pulsar/BatchMessageId.h b/pulsar-client-cpp/include/pulsar/BatchMessageId.h
index 1afa552..b647886 100644
--- a/pulsar-client-cpp/include/pulsar/BatchMessageId.h
+++ b/pulsar-client-cpp/include/pulsar/BatchMessageId.h
@@ -29,17 +29,13 @@ namespace pulsar {
 class PulsarWrapper;
 
 class BatchMessageId : public MessageId {
- public:
+   public:
     BatchMessageId(int64_t ledgerId, int64_t entryId, int batchIndex = -1)
-            : MessageId(ledgerId, entryId),
-              batchIndex_(batchIndex) {
-    }
+        : MessageId(ledgerId, entryId), batchIndex_(batchIndex) {}
 
     BatchMessageId(const MessageId& msgId);
 
-    BatchMessageId()
-            : batchIndex_(-1) {
-    }
+    BatchMessageId() : batchIndex_(-1) {}
 
     virtual void serialize(std::string& result) const;
 
@@ -48,7 +44,7 @@ class BatchMessageId : public MessageId {
     bool operator<=(const BatchMessageId& other) const;
     bool operator==(const BatchMessageId& other) const;
 
-  protected:
+   protected:
     virtual int64_t getBatchIndex() const;
 
     friend class Commands;
@@ -65,8 +61,7 @@ class BatchMessageId : public MessageId {
 
     friend std::ostream& operator<<(std::ostream& s, const BatchMessageId& messageId);
 };
-
-}
+}  // namespace pulsar
 #pragma GCC visibility pop
 
 #endif /* LIB_BATCHMESSAGEID_H_ */
diff --git a/pulsar-client-cpp/include/pulsar/BrokerConsumerStats.h b/pulsar-client-cpp/include/pulsar/BrokerConsumerStats.h
index 78cff0a..2786614 100644
--- a/pulsar-client-cpp/include/pulsar/BrokerConsumerStats.h
+++ b/pulsar-client-cpp/include/pulsar/BrokerConsumerStats.h
@@ -33,9 +33,10 @@ class PulsarWrapper;
 
 /* @note: isValid() or getXXX() methods are not allowed on an invalid BrokerConsumerStats */
 class BrokerConsumerStats {
- private:
+   private:
     boost::shared_ptr<BrokerConsumerStatsImplBase> impl_;
- public:
+
+   public:
     explicit BrokerConsumerStats(boost::shared_ptr<BrokerConsumerStatsImplBase> impl);
 
     BrokerConsumerStats();
@@ -83,12 +84,12 @@ class BrokerConsumerStats {
     boost::shared_ptr<BrokerConsumerStatsImplBase> getImpl() const;
 
     friend class PulsarWrapper;
-    friend std::ostream& operator<<(std::ostream &os, const BrokerConsumerStats &obj);
+    friend std::ostream &operator<<(std::ostream &os, const BrokerConsumerStats &obj);
 };
-typedef boost::function<void(Result result, BrokerConsumerStats brokerConsumerStats)> BrokerConsumerStatsCallback;
-
-}
+typedef boost::function<void(Result result, BrokerConsumerStats brokerConsumerStats)>
+    BrokerConsumerStatsCallback;
+}  // namespace pulsar
 
 #pragma GCC visibility pop
 
-#endif //PULSAR_CPP_BROKERCONSUMERSTATS_H
+#endif  // PULSAR_CPP_BROKERCONSUMERSTATS_H
diff --git a/pulsar-client-cpp/include/pulsar/Client.h b/pulsar-client-cpp/include/pulsar/Client.h
index 295980e..07b4355 100644
--- a/pulsar-client-cpp/include/pulsar/Client.h
+++ b/pulsar-client-cpp/include/pulsar/Client.h
@@ -41,18 +41,21 @@ class PulsarFriend;
 class PulsarWrapper;
 
 class Client {
- public:
+   public:
     /**
-     * Create a Pulsar client object connecting to the specified cluster address and using the default configuration.
+     * Create a Pulsar client object connecting to the specified cluster address and using the default
+     * configuration.
      *
      * @param serviceUrl the Pulsar endpoint to use (eg: pulsar://localhost:6650)
      */
     Client(const std::string& serviceUrl);
 
     /**
-     * Create a Pulsar client object connecting to the specified cluster address and using the specified configuration.
+     * Create a Pulsar client object connecting to the specified cluster address and using the specified
+     * configuration.
      *
-     * @param serviceUrl the Pulsar endpoint to use (eg: http://brokerv2-pdev.messaging.corp.gq1.yahoo.com:4080 for Sandbox access)
+     * @param serviceUrl the Pulsar endpoint to use (eg:
+     * http://brokerv2-pdev.messaging.corp.gq1.yahoo.com:4080 for Sandbox access)
      * @param clientConfiguration the client configuration to use
      */
     Client(const std::string& serviceUrl, const ClientConfiguration& clientConfiguration);
@@ -80,8 +83,7 @@ class Client {
      * @return ResultOk if the producer has been successfully created
      * @return ResultError if there was an error
      */
-    Result createProducer(const std::string& topic, const ProducerConfiguration& conf,
-                          Producer& producer);
+    Result createProducer(const std::string& topic, const ProducerConfiguration& conf, Producer& producer);
 
     void createProducerAsync(const std::string& topic, CreateProducerCallback callback);
 
@@ -98,34 +100,39 @@ class Client {
                         const ConsumerConfiguration& conf, SubscribeCallback callback);
 
     /**
-     * Create a topic reader with given {@code ReaderConfiguration} for reading messages from the specified topic.
+     * Create a topic reader with given {@code ReaderConfiguration} for reading messages from the specified
+     * topic.
      * <p>
-     * The Reader provides a low-level abstraction that allows for manual positioning in the topic, without using a
+     * The Reader provides a low-level abstraction that allows for manual positioning in the topic, without
+     * using a
      * subscription. Reader can only work on non-partitioned topics.
      * <p>
      * The initial reader positioning is done by specifying a message id. The options are:
      * <ul>
      * <li><code>MessageId.earliest</code> : Start reading from the earliest message available in the topic
-     * <li><code>MessageId.latest</code> : Start reading from the end topic, only getting messages published after the
+     * <li><code>MessageId.latest</code> : Start reading from the end topic, only getting messages published
+     * after the
      * reader was created
-     * <li><code>MessageId</code> : When passing a particular message id, the reader will position itself on that
+     * <li><code>MessageId</code> : When passing a particular message id, the reader will position itself on
+     * that
      * specific position. The first message to be read will be the message next to the specified messageId.
      * </ul>
      *
      * @param topic
      *            The name of the topic where to read
      * @param startMessageId
-     *            The message id where the reader will position itself. The first message returned will be the one after
+     *            The message id where the reader will position itself. The first message returned will be the
+     * one after
      *            the specified startMessageId
      * @param conf
      *            The {@code ReaderConfiguration} object
      * @return The {@code Reader} object
      */
-     Result createReader(const std::string& topic, const MessageId& startMessageId,
-                       const ReaderConfiguration& conf, Reader& reader);
+    Result createReader(const std::string& topic, const MessageId& startMessageId,
+                        const ReaderConfiguration& conf, Reader& reader);
 
-     void createReaderAsync(const std::string& topic, const MessageId& startMessageId,
-                            const ReaderConfiguration& conf, ReaderCallback callback);
+    void createReaderAsync(const std::string& topic, const MessageId& startMessageId,
+                           const ReaderConfiguration& conf, ReaderCallback callback);
 
     /**
      *
@@ -137,16 +144,16 @@ class Client {
 
     void shutdown();
 
- private:
-    Client(const std::string& serviceUrl, const ClientConfiguration& clientConfiguration, bool poolConnections);
+   private:
+    Client(const std::string& serviceUrl, const ClientConfiguration& clientConfiguration,
+           bool poolConnections);
     Client(const boost::shared_ptr<ClientImpl>);
 
     friend class PulsarFriend;
     friend class PulsarWrapper;
     boost::shared_ptr<ClientImpl> impl_;
 };
-
-}
+}  // namespace pulsar
 
 #pragma GCC visibility pop
 
diff --git a/pulsar-client-cpp/include/pulsar/ClientConfiguration.h b/pulsar-client-cpp/include/pulsar/ClientConfiguration.h
index e8914a4..08cfdf0 100644
--- a/pulsar-client-cpp/include/pulsar/ClientConfiguration.h
+++ b/pulsar-client-cpp/include/pulsar/ClientConfiguration.h
@@ -25,8 +25,7 @@ namespace pulsar {
 class PulsarWrapper;
 class ClientConfigurationImpl;
 class ClientConfiguration {
- public:
-
+   public:
     ClientConfiguration();
     ~ClientConfiguration();
     ClientConfiguration(const ClientConfiguration&);
@@ -89,7 +88,8 @@ class ClientConfiguration {
 
     /**
      * Number of concurrent lookup-requests allowed on each broker-connection to prevent overload on broker.
-     * <i>(default: 5000)</i> It should be configured with higher value only in case of it requires to produce/subscribe on
+     * <i>(default: 5000)</i> It should be configured with higher value only in case of it requires to
+     * produce/subscribe on
      * thousands of topic using created {@link PulsarClient}
      *
      * @param concurrentLookupRequest
@@ -116,7 +116,7 @@ class ClientConfiguration {
     ClientConfiguration& setUseTls(bool useTls);
     bool isUseTls() const;
 
-    ClientConfiguration& setTlsTrustCertsFilePath(const std::string &tlsTrustCertsFilePath);
+    ClientConfiguration& setTlsTrustCertsFilePath(const std::string& tlsTrustCertsFilePath);
     std::string getTlsTrustCertsFilePath() const;
 
     ClientConfiguration& setTlsAllowInsecureConnection(bool allowInsecure);
@@ -136,12 +136,11 @@ class ClientConfiguration {
     friend class ClientImpl;
     friend class PulsarWrapper;
 
- private:
+   private:
     const AuthenticationPtr& getAuthPtr() const;
     boost::shared_ptr<ClientConfigurationImpl> impl_;
 };
-}
+}  // namespace pulsar
 
 #pragma GCC visibility pop
 #endif /* PULSAR_CLIENTCONFIGURATION_H_ */
-
diff --git a/pulsar-client-cpp/include/pulsar/CompressionType.h b/pulsar-client-cpp/include/pulsar/CompressionType.h
index 6028418..9dc92be 100644
--- a/pulsar-client-cpp/include/pulsar/CompressionType.h
+++ b/pulsar-client-cpp/include/pulsar/CompressionType.h
@@ -20,7 +20,8 @@
 #define PULSAR_COMPRESSIONTYPE_H_
 #pragma GCC visibility push(default)
 namespace pulsar {
-enum CompressionType {
+enum CompressionType
+{
     CompressionNone = 0,
     CompressionLZ4 = 1,
     CompressionZLib = 2
diff --git a/pulsar-client-cpp/include/pulsar/Consumer.h b/pulsar-client-cpp/include/pulsar/Consumer.h
index c02c260..ff222ee 100644
--- a/pulsar-client-cpp/include/pulsar/Consumer.h
+++ b/pulsar-client-cpp/include/pulsar/Consumer.h
@@ -25,7 +25,6 @@
 #include <pulsar/ConsumerConfiguration.h>
 #pragma GCC visibility push(default)
 
-
 namespace pulsar {
 class PulsarWrapper;
 class ConsumerImplBase;
@@ -34,7 +33,7 @@ class PulsarFriend;
  *
  */
 class Consumer {
- public:
+   public:
     /**
      * Construct an uninitialized consumer object
      */
@@ -139,7 +138,8 @@ class Consumer {
      * waiting for the callback to be triggered.
      *
      * @param message the last message in the stream to acknowledge
-     * @return ResultOk if the message was successfully acknowledged. All previously delivered messages for this topic are also acknowledged.
+     * @return ResultOk if the message was successfully acknowledged. All previously delivered messages for
+     * this topic are also acknowledged.
      * @return ResultError if there was a failure
      */
     Result acknowledgeCumulative(const Message& message);
@@ -174,17 +174,22 @@ class Consumer {
     Result resumeMessageListener();
 
     /**
-     * Redelivers all the unacknowledged messages. In Failover mode, the request is ignored if the consumer is not
-     * active for the given topic. In Shared mode, the consumers messages to be redelivered are distributed across all
-     * the connected consumers. This is a non blocking call and doesn't throw an exception. In case the connection
+     * Redelivers all the unacknowledged messages. In Failover mode, the request is ignored if the consumer is
+     * not
+     * active for the given topic. In Shared mode, the consumers messages to be redelivered are distributed
+     * across all
+     * the connected consumers. This is a non blocking call and doesn't throw an exception. In case the
+     * connection
      * breaks, the messages are redelivered after reconnect.
      */
     void redeliverUnacknowledgedMessages();
 
     /**
      * Gets Consumer Stats from broker.
-     * The stats are cached for 30 seconds, if a call is made before the stats returned by the previous call expires
-     * then cached data will be returned. BrokerConsumerStats::isValid() function can be used to check if the stats are
+     * The stats are cached for 30 seconds, if a call is made before the stats returned by the previous call
+     * expires
+     * then cached data will be returned. BrokerConsumerStats::isValid() function can be used to check if the
+     * stats are
      * still valid.
      *
      * @param brokerConsumerStats - if the function returns ResultOk, this object will contain consumer stats
@@ -194,16 +199,19 @@ class Consumer {
     Result getBrokerConsumerStats(BrokerConsumerStats& brokerConsumerStats);
 
     /**
-    * Asynchronous call to gets Consumer Stats from broker.
-    * The stats are cached for 30 seconds, if a call is made before the stats returned by the previous call expires
-    * then cached data will be returned. BrokerConsumerStats::isValid() function can be used to check if the stats are
-    * still valid.
-    *
-    * @param callback - callback function to get the brokerConsumerStats,
-    *                   if result is ResultOk then the brokerConsumerStats will be populated
-    */
+     * Asynchronous call to gets Consumer Stats from broker.
+     * The stats are cached for 30 seconds, if a call is made before the stats returned by the previous call
+     * expires
+     * then cached data will be returned. BrokerConsumerStats::isValid() function can be used to check if the
+     * stats are
+     * still valid.
+     *
+     * @param callback - callback function to get the brokerConsumerStats,
+     *                   if result is ResultOk then the brokerConsumerStats will be populated
+     */
     void getBrokerConsumerStatsAsync(BrokerConsumerStatsCallback callback);
-private:
+
+   private:
     typedef boost::shared_ptr<ConsumerImplBase> ConsumerImplBasePtr;
     ConsumerImplBasePtr impl_;
     explicit Consumer(ConsumerImplBasePtr);
@@ -215,8 +223,7 @@ private:
     friend class ClientImpl;
     friend class ConsumerTest;
 };
-
-}
+}  // namespace pulsar
 
 #pragma GCC visibility pop
 
diff --git a/pulsar-client-cpp/include/pulsar/ConsumerConfiguration.h b/pulsar-client-cpp/include/pulsar/ConsumerConfiguration.h
index 9f600a4..4ffe6df 100644
--- a/pulsar-client-cpp/include/pulsar/ConsumerConfiguration.h
+++ b/pulsar-client-cpp/include/pulsar/ConsumerConfiguration.h
@@ -43,7 +43,7 @@ class ConsumerConfigurationImpl;
  * Class specifying the configuration of a consumer.
  */
 class ConsumerConfiguration {
- public:
+   public:
     ConsumerConfiguration();
     ~ConsumerConfiguration();
     ConsumerConfiguration(const ConsumerConfiguration&);
@@ -80,9 +80,12 @@ class ConsumerConfiguration {
      * application calls receive(). Using a higher value could potentially increase the consumer throughput
      * at the expense of bigger memory utilization.
      *
-     * Setting the consumer queue size as zero decreases the throughput of the consumer, by disabling pre-fetching of
-     * messages. This approach improves the message distribution on shared subscription, by pushing messages only to
-     * the consumers that are ready to process them. Neither receive with timeout nor Partitioned Topics can be
+     * Setting the consumer queue size as zero decreases the throughput of the consumer, by disabling
+     * pre-fetching of
+     * messages. This approach improves the message distribution on shared subscription, by pushing messages
+     * only to
+     * the consumers that are ready to process them. Neither receive with timeout nor Partitioned Topics can
+     * be
      * used if the consumer queue size is zero. The receive() function call should not be interrupted when
      * the consumer queue size is zero.
      *
@@ -123,11 +126,9 @@ class ConsumerConfiguration {
     long getBrokerConsumerStatsCacheTimeInMs() const;
     friend class PulsarWrapper;
 
- private:
+   private:
     boost::shared_ptr<ConsumerConfigurationImpl> impl_;
 };
-
-}
+}  // namespace pulsar
 #pragma GCC visibility pop
 #endif /* PULSAR_CONSUMERCONFIGURATION_H_ */
-
diff --git a/pulsar-client-cpp/include/pulsar/ConsumerType.h b/pulsar-client-cpp/include/pulsar/ConsumerType.h
index ead4462..28a068d 100644
--- a/pulsar-client-cpp/include/pulsar/ConsumerType.h
+++ b/pulsar-client-cpp/include/pulsar/ConsumerType.h
@@ -21,23 +21,24 @@
 
 #pragma GCC visibility push(default)
 namespace pulsar {
-    enum ConsumerType {
-        /**
-         * There can be only 1 consumer on the same topic with the same consumerName
-         */
-        ConsumerExclusive,
+enum ConsumerType
+{
+    /**
+     * There can be only 1 consumer on the same topic with the same consumerName
+     */
+    ConsumerExclusive,
 
-        /**
-         * Multiple consumers will be able to use the same consumerName and the messages
-         *  will be dispatched according to a round-robin rotation between the connected consumers
-         */
-        ConsumerShared,
+    /**
+     * Multiple consumers will be able to use the same consumerName and the messages
+     *  will be dispatched according to a round-robin rotation between the connected consumers
+     */
+    ConsumerShared,
 
-        /** Only one consumer is active on the subscription; Subscription can have N consumers
-         *  connected one of which will get promoted to master if the current master becomes inactive
-         */
-        ConsumerFailover
-    };
+    /** Only one consumer is active on the subscription; Subscription can have N consumers
+     *  connected one of which will get promoted to master if the current master becomes inactive
+     */
+    ConsumerFailover
+};
 }
 #pragma GCC visibility pop
-#endif //PULSAR_CPP_CONSUMERTYPE_H
+#endif  // PULSAR_CPP_CONSUMERTYPE_H
diff --git a/pulsar-client-cpp/include/pulsar/DeprecatedException.h b/pulsar-client-cpp/include/pulsar/DeprecatedException.h
index 123edaa..91e9c67 100644
--- a/pulsar-client-cpp/include/pulsar/DeprecatedException.h
+++ b/pulsar-client-cpp/include/pulsar/DeprecatedException.h
@@ -23,13 +23,13 @@
 #include <string>
 
 namespace pulsar {
-    class DeprecatedException: public std::runtime_error {
-    public:
-        explicit DeprecatedException(const std::string& __arg);
+class DeprecatedException : public std::runtime_error {
+   public:
+    explicit DeprecatedException(const std::string& __arg);
 
-    private:
-        static const std::string message_prefix;
-    };
-}
+   private:
+    static const std::string message_prefix;
+};
+}  // namespace pulsar
 
-#endif //DEPRECATED_EXCEPTION_HPP_
+#endif  // DEPRECATED_EXCEPTION_HPP_
diff --git a/pulsar-client-cpp/include/pulsar/Message.h b/pulsar-client-cpp/include/pulsar/Message.h
index 9c13424..5462a68 100644
--- a/pulsar-client-cpp/include/pulsar/Message.h
+++ b/pulsar-client-cpp/include/pulsar/Message.h
@@ -28,20 +28,21 @@
 #pragma GCC visibility push(default)
 
 namespace pulsar {
-    namespace proto {
-        class CommandMessage;
-        class MessageMetadata;
-        class SingleMessageMetadata;
-    }
+namespace proto {
+class CommandMessage;
+class MessageMetadata;
+class SingleMessageMetadata;
+}  // namespace proto
 
 class SharedBuffer;
 class MessageBuilder;
 class MessageImpl;
 class PulsarWrapper;
 
-// TODO: When releasing 2.0.0, make all methods virtual and create the virtual destructor for Google Mock tests
+// TODO: When releasing 2.0.0, make all methods virtual and create the virtual destructor for Google Mock
+// tests
 class Message {
- public:
+   public:
     typedef std::map<std::string, std::string> StringMap;
 
     Message();
@@ -96,7 +97,8 @@ class Message {
     /**
      * Get the unique message ID associated with this message.
      *
-     * The message id can be used to univocally refer to a message without having to keep the entire payload in memory.
+     * The message id can be used to univocally refer to a message without having to keep the entire payload
+     * in memory.
      *
      * Only messages received from the consumer will have a message id assigned.
      *
@@ -111,7 +113,8 @@ class Message {
     bool hasPartitionKey() const;
 
     /**
-     * Get the UTC based timestamp in milliseconds referring to when the message was published by the client producer
+     * Get the UTC based timestamp in milliseconds referring to when the message was published by the client
+     * producer
      */
     uint64_t getPublishTimestamp() const;
 
@@ -120,14 +123,15 @@ class Message {
      */
     uint64_t getEventTimestamp() const;
 
-  private:
+   private:
     typedef boost::shared_ptr<MessageImpl> MessageImplPtr;
     MessageImplPtr impl_;
 
     Message(MessageImplPtr& impl);
     Message(const proto::CommandMessage& msg, proto::MessageMetadata& data, SharedBuffer& payload);
     /// Used for Batch Messages
-    Message(const BatchMessageId& messageID, proto::MessageMetadata& metadata, SharedBuffer& payload, proto::SingleMessageMetadata& singleMetadata);
+    Message(const BatchMessageId& messageID, proto::MessageMetadata& metadata, SharedBuffer& payload,
+            proto::SingleMessageMetadata& singleMetadata);
     friend class PartitionedProducerImpl;
     friend class PartitionedConsumerImpl;
     friend class MessageBuilder;
@@ -141,8 +145,7 @@ class Message {
     friend std::ostream& operator<<(std::ostream& s, const StringMap& map);
     friend std::ostream& operator<<(std::ostream& s, const Message& msg);
 };
-
-}
+}  // namespace pulsar
 
 #pragma GCC visibility pop
 #endif /* MESSAGE_HPP_ */
diff --git a/pulsar-client-cpp/include/pulsar/MessageBuilder.h b/pulsar-client-cpp/include/pulsar/MessageBuilder.h
index 7f63fe3..7a08817 100644
--- a/pulsar-client-cpp/include/pulsar/MessageBuilder.h
+++ b/pulsar-client-cpp/include/pulsar/MessageBuilder.h
@@ -28,8 +28,7 @@ namespace pulsar {
 class PulsarWrapper;
 
 class MessageBuilder {
- public:
-
+   public:
     MessageBuilder();
 
     typedef std::map<std::string, std::string> StringMap;
@@ -117,7 +116,8 @@ class MessageBuilder {
      *
      */
     MessageBuilder& create();
- private:
+
+   private:
     MessageBuilder(const MessageBuilder&);
     void checkMetadata();
     static boost::shared_ptr<MessageImpl> createMessageImpl();
@@ -125,8 +125,7 @@ class MessageBuilder {
 
     friend class PulsarWrapper;
 };
-
-}
+}  // namespace pulsar
 
 #pragma GCC visibility pop
 
diff --git a/pulsar-client-cpp/include/pulsar/MessageId.h b/pulsar-client-cpp/include/pulsar/MessageId.h
index 6fd2d51..40fe5d0 100644
--- a/pulsar-client-cpp/include/pulsar/MessageId.h
+++ b/pulsar-client-cpp/include/pulsar/MessageId.h
@@ -32,7 +32,7 @@ class UnAckedMessageTrackerEnabled;
 class PulsarWrapper;
 
 class MessageId {
- public:
+   public:
     MessageId& operator=(const MessageId&);
     MessageId();
     virtual ~MessageId() {}
@@ -61,8 +61,7 @@ class MessageId {
     bool operator<(const MessageId& other) const;
     bool operator==(const MessageId& other) const;
 
- protected:
-
+   protected:
     virtual int64_t getBatchIndex() const;
     friend class ConsumerImpl;
     friend class Message;
@@ -77,13 +76,11 @@ class MessageId {
     MessageId(int64_t, int64_t);
     friend std::ostream& operator<<(std::ostream& s, const MessageId& messageId);
     int64_t ledgerId_;
-    int64_t entryId_ :48;
-    short partition_ :16;
+    int64_t entryId_ : 48;
+    short partition_ : 16;
 };
-
-
-}
+}  // namespace pulsar
 
 #pragma GCC visibility pop
 
-#endif //MESSAGE_ID_H
+#endif  // MESSAGE_ID_H
diff --git a/pulsar-client-cpp/include/pulsar/MessageRoutingPolicy.h b/pulsar-client-cpp/include/pulsar/MessageRoutingPolicy.h
index 3b72e86..2c81ce8 100644
--- a/pulsar-client-cpp/include/pulsar/MessageRoutingPolicy.h
+++ b/pulsar-client-cpp/include/pulsar/MessageRoutingPolicy.h
@@ -33,15 +33,16 @@
 namespace pulsar {
 
 class MessageRoutingPolicy {
- public:
+   public:
     virtual ~MessageRoutingPolicy() {}
 
     /** @deprecated
        Use int getPartition(const Message& msg, const TopicMetadata& topicMetadata)
     */
     virtual int getPartition(const Message& msg) {
-        throw DeprecatedException("Use int getPartition(const Message& msg,"
-                                          " const TopicMetadata& topicMetadata)");
+        throw DeprecatedException(
+            "Use int getPartition(const Message& msg,"
+            " const TopicMetadata& topicMetadata)");
     }
 
     virtual int getPartition(const Message& msg, const TopicMetadata& topicMetadata) {
@@ -50,8 +51,8 @@ class MessageRoutingPolicy {
 };
 
 typedef boost::shared_ptr<MessageRoutingPolicy> MessageRoutingPolicyPtr;
-}
+}  // namespace pulsar
 
 #pragma GCC visibility pop
 
-#endif // PULSAR_MESSAGE_ROUTING_POLICY_HEADER_
+#endif  // PULSAR_MESSAGE_ROUTING_POLICY_HEADER_
diff --git a/pulsar-client-cpp/include/pulsar/Producer.h b/pulsar-client-cpp/include/pulsar/Producer.h
index a091f52..1955c7f 100644
--- a/pulsar-client-cpp/include/pulsar/Producer.h
+++ b/pulsar-client-cpp/include/pulsar/Producer.h
@@ -30,7 +30,7 @@ class ProducerImplBase;
 class PulsarWrapper;
 class PulsarFriend;
 class Producer {
- public:
+   public:
     /**
      * Construct an uninitialized Producer.
      */
@@ -86,7 +86,8 @@ class Producer {
      * This represent either the automatically assigned or custom sequence id (set on the MessageBuilder) that
      * was published and acknowledged by the broker.
      *
-     * After recreating a producer with the same producer name, this will return the last message that was published in
+     * After recreating a producer with the same producer name, this will return the last message that was
+     * published in
      * the previous producer session, or -1 if there no message was ever published.
      *
      * @return the last sequence id published by this producer
@@ -113,7 +114,7 @@ class Producer {
      */
     void closeAsync(CloseCallback callback);
 
- private:
+   private:
     typedef boost::shared_ptr<ProducerImplBase> ProducerImplBasePtr;
     explicit Producer(ProducerImplBasePtr);
 
@@ -123,8 +124,7 @@ class Producer {
 
     ProducerImplBasePtr impl_;
 };
-
-}
+}  // namespace pulsar
 
 #pragma GCC visibility pop
 
diff --git a/pulsar-client-cpp/include/pulsar/ProducerConfiguration.h b/pulsar-client-cpp/include/pulsar/ProducerConfiguration.h
index e64a859..2c745a3 100644
--- a/pulsar-client-cpp/include/pulsar/ProducerConfiguration.h
+++ b/pulsar-client-cpp/include/pulsar/ProducerConfiguration.h
@@ -37,8 +37,9 @@ class PulsarWrapper;
  * Class that holds the configuration for a producer
  */
 class ProducerConfiguration {
- public:
-    enum PartitionsRoutingMode {
+   public:
+    enum PartitionsRoutingMode
+    {
         UseSinglePartition,
         RoundRobinDistribution,
         CustomPartition
@@ -80,20 +81,18 @@ class ProducerConfiguration {
     const unsigned int& getBatchingMaxMessages() const;
 
     ProducerConfiguration& setBatchingMaxAllowedSizeInBytes(
-            const unsigned long& batchingMaxAllowedSizeInBytes);
+        const unsigned long& batchingMaxAllowedSizeInBytes);
     const unsigned long& getBatchingMaxAllowedSizeInBytes() const;
 
-    ProducerConfiguration& setBatchingMaxPublishDelayMs(
-            const unsigned long& batchingMaxPublishDelayMs);
+    ProducerConfiguration& setBatchingMaxPublishDelayMs(const unsigned long& batchingMaxPublishDelayMs);
     const unsigned long& getBatchingMaxPublishDelayMs() const;
 
     friend class PulsarWrapper;
 
- private:
+   private:
     struct Impl;
     boost::shared_ptr<ProducerConfigurationImpl> impl_;
 };
-}
+}  // namespace pulsar
 #pragma GCC visibility pop
 #endif /* PULSAR_PRODUCERCONFIGURATION_H_ */
-
diff --git a/pulsar-client-cpp/include/pulsar/Reader.h b/pulsar-client-cpp/include/pulsar/Reader.h
index c57084f..2985f50 100644
--- a/pulsar-client-cpp/include/pulsar/Reader.h
+++ b/pulsar-client-cpp/include/pulsar/Reader.h
@@ -24,7 +24,6 @@
 
 #pragma GCC visibility push(default)
 
-
 namespace pulsar {
 class PulsarWrapper;
 class PulsarFriend;
@@ -34,7 +33,7 @@ class ReaderImpl;
  * A Reader can be used to scan through all the messages currently available in a topic.
  */
 class Reader {
- public:
+   public:
     /**
      * Construct an uninitialized reader object
      */
@@ -72,7 +71,7 @@ class Reader {
 
     void closeAsync(ResultCallback callback);
 
-private:
+   private:
     typedef boost::shared_ptr<ReaderImpl> ReaderImplPtr;
     ReaderImplPtr impl_;
     explicit Reader(ReaderImplPtr);
@@ -82,8 +81,7 @@ private:
     friend class ReaderImpl;
     friend class ReaderTest;
 };
-
-}
+}  // namespace pulsar
 
 #pragma GCC visibility pop
 
diff --git a/pulsar-client-cpp/include/pulsar/ReaderConfiguration.h b/pulsar-client-cpp/include/pulsar/ReaderConfiguration.h
index 188992b..7e47628 100644
--- a/pulsar-client-cpp/include/pulsar/ReaderConfiguration.h
+++ b/pulsar-client-cpp/include/pulsar/ReaderConfiguration.h
@@ -42,7 +42,7 @@ class ReaderConfigurationImpl;
  * Class specifying the configuration of a consumer.
  */
 class ReaderConfiguration {
- public:
+   public:
     ReaderConfiguration();
     ~ReaderConfiguration();
     ReaderConfiguration(const ReaderConfiguration&);
@@ -63,9 +63,12 @@ class ReaderConfiguration {
      * application calls receive(). Using a higher value could potentially increase the consumer throughput
      * at the expense of bigger memory utilization.
      *
-     * Setting the consumer queue size as zero decreases the throughput of the consumer, by disabling pre-fetching of
-     * messages. This approach improves the message distribution on shared subscription, by pushing messages only to
-     * the consumers that are ready to process them. Neither receive with timeout nor Partitioned Topics can be
+     * Setting the consumer queue size as zero decreases the throughput of the consumer, by disabling
+     * pre-fetching of
+     * messages. This approach improves the message distribution on shared subscription, by pushing messages
+     * only to
+     * the consumers that are ready to process them. Neither receive with timeout nor Partitioned Topics can
+     * be
      * used if the consumer queue size is zero. The receive() function call should not be interrupted when
      * the consumer queue size is zero.
      *
@@ -80,10 +83,9 @@ class ReaderConfiguration {
     void setReaderName(const std::string& readerName);
     const std::string& getReaderName() const;
 
- private:
+   private:
     boost::shared_ptr<ReaderConfigurationImpl> impl_;
 };
-
-}
+}  // namespace pulsar
 #pragma GCC visibility pop
 #endif /* PULSAR_READER_CONFIGURATION_H_ */
diff --git a/pulsar-client-cpp/include/pulsar/Result.h b/pulsar-client-cpp/include/pulsar/Result.h
index 2334b35..de72a71 100644
--- a/pulsar-client-cpp/include/pulsar/Result.h
+++ b/pulsar-client-cpp/include/pulsar/Result.h
@@ -28,8 +28,9 @@ namespace pulsar {
 /**
  * Collection of return codes
  */
-enum Result {
-    ResultOk,            /// Operation successful
+enum Result
+{
+    ResultOk,  /// Operation successful
 
     ResultUnknownError,  /// Unknown error happened on broker
 
@@ -41,41 +42,41 @@ enum Result {
     ResultReadError,     /// Failed to read from socket
 
     ResultAuthenticationError,             /// Authentication failed on broker
-    ResultAuthorizationError,  /// Client is not authorized to create producer/consumer
+    ResultAuthorizationError,              /// Client is not authorized to create producer/consumer
     ResultErrorGettingAuthenticationData,  /// Client cannot find authorization data
 
     ResultBrokerMetadataError,     /// Broker failed in updating metadata
     ResultBrokerPersistenceError,  /// Broker failed to persist entry
     ResultChecksumError,           /// Corrupt message checksum failure
 
-    ResultConsumerBusy,  /// Exclusive consumer is already connected
-    ResultNotConnected,  /// Producer/Consumer is not currently connected to broker
+    ResultConsumerBusy,   /// Exclusive consumer is already connected
+    ResultNotConnected,   /// Producer/Consumer is not currently connected to broker
     ResultAlreadyClosed,  /// Producer/Consumer is already closed and not accepting any operation
 
     ResultInvalidMessage,  /// Error in publishing an already used message
 
-    ResultConsumerNotInitialized,  /// Consumer is not initialized
-    ResultProducerNotInitialized,  /// Producer is not initialized
-    ResultTooManyLookupRequestException, /// Too Many concurrent LookupRequest
+    ResultConsumerNotInitialized,         /// Consumer is not initialized
+    ResultProducerNotInitialized,         /// Producer is not initialized
+    ResultTooManyLookupRequestException,  /// Too Many concurrent LookupRequest
 
-    ResultInvalidTopicName,         /// Invalid topic name
+    ResultInvalidTopicName,  /// Invalid topic name
     ResultInvalidUrl,  /// Client Initialized with Invalid Broker Url (VIP Url passed to Client Constructor)
-    ResultServiceUnitNotReady,  /// Service Unit unloaded between client did lookup and producer/consumer got created
+    ResultServiceUnitNotReady,  /// Service Unit unloaded between client did lookup and producer/consumer got
+                                /// created
     ResultOperationNotSupported,
-    ResultProducerBlockedQuotaExceededError,     /// Producer is blocked
+    ResultProducerBlockedQuotaExceededError,      /// Producer is blocked
     ResultProducerBlockedQuotaExceededException,  /// Producer is getting exception
-    ResultProducerQueueIsFull, /// Producer queue is full
-    ResultMessageTooBig, /// Trying to send a messages exceeding the max size
-    ResultTopicNotFound, /// Topic not found
-    ResultSubscriptionNotFound, /// Subscription not found
-    ResultConsumerNotFound, /// Consumer not found
-    ResultUnsupportedVersionError /// Error when an older client/version doesn't support a required feature
+    ResultProducerQueueIsFull,                    /// Producer queue is full
+    ResultMessageTooBig,                          /// Trying to send a messages exceeding the max size
+    ResultTopicNotFound,                          /// Topic not found
+    ResultSubscriptionNotFound,                   /// Subscription not found
+    ResultConsumerNotFound,                       /// Consumer not found
+    ResultUnsupportedVersionError  /// Error when an older client/version doesn't support a required feature
 };
 
 // Return string representation of result code
 const char* strResult(Result result);
-
-}
+}  // namespace pulsar
 
 std::ostream& operator<<(std::ostream& s, pulsar::Result result);
 
diff --git a/pulsar-client-cpp/include/pulsar/TopicMetadata.h b/pulsar-client-cpp/include/pulsar/TopicMetadata.h
index d541ca9..fbfd92c 100644
--- a/pulsar-client-cpp/include/pulsar/TopicMetadata.h
+++ b/pulsar-client-cpp/include/pulsar/TopicMetadata.h
@@ -24,9 +24,9 @@ namespace pulsar {
  * Metadata of a topic that can be used for message routing.
  */
 class TopicMetadata {
-public:
+   public:
     virtual int getNumPartitions() const = 0;
 };
-}
+}  // namespace pulsar
 
 #endif /* TOPIC_METADATA_HPP_ */
diff --git a/pulsar-client-cpp/lib/Authentication.cc b/pulsar-client-cpp/lib/Authentication.cc
index 805d100..84bbf34 100644
--- a/pulsar-client-cpp/lib/Authentication.cc
+++ b/pulsar-client-cpp/lib/Authentication.cc
@@ -34,157 +34,128 @@ DECLARE_LOG_OBJECT()
 
 namespace pulsar {
 
-    AuthenticationDataProvider::AuthenticationDataProvider(){
+AuthenticationDataProvider::AuthenticationDataProvider() {}
 
-    }
+AuthenticationDataProvider::~AuthenticationDataProvider() {}
 
-    AuthenticationDataProvider::~AuthenticationDataProvider() {
+bool AuthenticationDataProvider::hasDataForTls() { return false; }
 
-    }
+std::string AuthenticationDataProvider::getTlsCertificates() { return "none"; }
 
-    bool AuthenticationDataProvider::hasDataForTls() {
-        return false;
-    }
+std::string AuthenticationDataProvider::getTlsPrivateKey() { return "none"; }
 
-    std::string AuthenticationDataProvider::getTlsCertificates() {
-        return "none";
-    }
+bool AuthenticationDataProvider::hasDataForHttp() { return false; }
 
-    std::string AuthenticationDataProvider::getTlsPrivateKey() {
-        return "none";
-    }
+std::string AuthenticationDataProvider::getHttpAuthType() { return "none"; }
 
-    bool AuthenticationDataProvider::hasDataForHttp() {
-        return false;
-    }
+std::string AuthenticationDataProvider::getHttpHeaders() { return "none"; }
 
-    std::string AuthenticationDataProvider::getHttpAuthType() {
-        return "none";
-    }
+bool AuthenticationDataProvider::hasDataFromCommand() { return false; }
 
-    std::string AuthenticationDataProvider::getHttpHeaders() {
-        return "none";
-    }
+std::string AuthenticationDataProvider::getCommandData() { return "none"; }
 
-    bool AuthenticationDataProvider::hasDataFromCommand(){
-        return false;
-    }
+Authentication::Authentication() {}
 
-    std::string AuthenticationDataProvider::getCommandData() {
-        return "none";
-    }
+Authentication::~Authentication() {}
 
+class AuthDisabledData : public AuthenticationDataProvider {
+   public:
+    AuthDisabledData(ParamMap& params) {}
+};
 
-    Authentication::Authentication() {
-    }
+class AuthDisabled : public Authentication {
+   public:
+    AuthDisabled(AuthenticationDataPtr& authData) { authData_ = authData; }
 
-    Authentication::~Authentication() {
+    static AuthenticationPtr create(ParamMap& params) {
+        AuthenticationDataPtr authData = AuthenticationDataPtr(new AuthDisabledData(params));
+        return AuthenticationPtr(new AuthDisabled(authData));
     }
 
-    class AuthDisabledData : public AuthenticationDataProvider {
-    public:
-        AuthDisabledData(ParamMap& params){
-        }
-    };
+    const std::string getAuthMethodName() const { return "none"; }
+};
 
-    class AuthDisabled : public Authentication {
-    public:
-        AuthDisabled(AuthenticationDataPtr& authData) {
-            authData_ = authData;
-        }
-
-        static AuthenticationPtr create(ParamMap& params) {
-            AuthenticationDataPtr authData = AuthenticationDataPtr(new AuthDisabledData(params));
-            return AuthenticationPtr(new AuthDisabled(authData));
-        }
+AuthenticationPtr AuthFactory::Disabled() {
+    ParamMap params;
+    return AuthDisabled::create(params);
+}
 
-        const std::string getAuthMethodName() const {
-            return "none";
-        }
-    };
+AuthenticationPtr AuthFactory::create(const std::string& dynamicLibPath) {
+    ParamMap params;
+    return AuthFactory::create(dynamicLibPath, params);
+}
 
+boost::mutex mutex;
+std::vector<void*> AuthFactory::loadedLibrariesHandles_;
+bool AuthFactory::isShutdownHookRegistered_ = false;
 
-    AuthenticationPtr AuthFactory::Disabled() {
-        ParamMap params;
-        return AuthDisabled::create(params);
+void AuthFactory::release_handles() {
+    boost::lock_guard<boost::mutex> lock(mutex);
+    for (std::vector<void*>::iterator ite = AuthFactory::loadedLibrariesHandles_.begin();
+         ite != AuthFactory::loadedLibrariesHandles_.end(); ite++) {
+        dlclose(*ite);
     }
+    loadedLibrariesHandles_.clear();
+}
 
-    AuthenticationPtr AuthFactory::create(const std::string& dynamicLibPath) {
-        ParamMap params;
-        return AuthFactory::create(dynamicLibPath, params);
-    }
-
-    boost::mutex mutex;
-    std::vector<void*> AuthFactory::loadedLibrariesHandles_;
-    bool AuthFactory::isShutdownHookRegistered_ = false;
-
-    void AuthFactory::release_handles() {
+AuthenticationPtr AuthFactory::create(const std::string& dynamicLibPath,
+                                      const std::string& authParamsString) {
+    {
         boost::lock_guard<boost::mutex> lock(mutex);
-        for (std::vector<void*>::iterator ite = AuthFactory::loadedLibrariesHandles_.begin(); ite != AuthFactory::loadedLibrariesHandles_.end();
-             ite++) {
-            dlclose(*ite);
+        if (!AuthFactory::isShutdownHookRegistered_) {
+            atexit(release_handles);
+            AuthFactory::isShutdownHookRegistered_ = true;
         }
-        loadedLibrariesHandles_.clear();
     }
-
-    AuthenticationPtr AuthFactory::create(const std::string& dynamicLibPath, const std::string& authParamsString) {
+    Authentication* auth = NULL;
+    void* handle = dlopen(dynamicLibPath.c_str(), RTLD_LAZY);
+    if (handle != NULL) {
         {
             boost::lock_guard<boost::mutex> lock(mutex);
-            if (!AuthFactory::isShutdownHookRegistered_) {
-                atexit(release_handles);
-                AuthFactory::isShutdownHookRegistered_ = true;
-            }
+            loadedLibrariesHandles_.push_back(handle);
         }
-        Authentication *auth = NULL;
-        void *handle = dlopen(dynamicLibPath.c_str(), RTLD_LAZY);
-        if (handle != NULL) {
-            {
-                boost::lock_guard<boost::mutex> lock(mutex);
-                loadedLibrariesHandles_.push_back(handle);
-            }
-            Authentication *(*createAuthentication)(const std::string&);
-            *(void **) (&createAuthentication) = dlsym(handle, "create");
-            if (createAuthentication != NULL) {
-                auth = createAuthentication(authParamsString);
-            } else {
-                ParamMap paramMap;
-                if(!authParamsString.empty()) {
-                    std::vector<std::string> params;
-                    boost::algorithm::split(params, authParamsString, boost::is_any_of(","));
-                    for(int i = 0; i<params.size(); i++) {
-                        std::vector<std::string> kv;
-                        boost::algorithm::split(kv, params[i], boost::is_any_of(":"));
-                        if (kv.size() == 2) {
-                            paramMap[kv[0]] = kv[1];
-                        }
+        Authentication* (*createAuthentication)(const std::string&);
+        *(void**)(&createAuthentication) = dlsym(handle, "create");
+        if (createAuthentication != NULL) {
+            auth = createAuthentication(authParamsString);
+        } else {
+            ParamMap paramMap;
+            if (!authParamsString.empty()) {
+                std::vector<std::string> params;
+                boost::algorithm::split(params, authParamsString, boost::is_any_of(","));
+                for (int i = 0; i < params.size(); i++) {
+                    std::vector<std::string> kv;
+                    boost::algorithm::split(kv, params[i], boost::is_any_of(":"));
+                    if (kv.size() == 2) {
+                        paramMap[kv[0]] = kv[1];
                     }
                 }
-                return AuthFactory::create(dynamicLibPath, paramMap);
             }
+            return AuthFactory::create(dynamicLibPath, paramMap);
         }
-        return AuthenticationPtr(auth);
     }
+    return AuthenticationPtr(auth);
+}
 
-    AuthenticationPtr AuthFactory::create(const std::string& dynamicLibPath, ParamMap& params) {
-        {
-            boost::lock_guard<boost::mutex> lock(mutex);
-            if (!AuthFactory::isShutdownHookRegistered_) {
-                atexit(release_handles);
-                AuthFactory::isShutdownHookRegistered_ = true;
-            }
+AuthenticationPtr AuthFactory::create(const std::string& dynamicLibPath, ParamMap& params) {
+    {
+        boost::lock_guard<boost::mutex> lock(mutex);
+        if (!AuthFactory::isShutdownHookRegistered_) {
+            atexit(release_handles);
+            AuthFactory::isShutdownHookRegistered_ = true;
         }
-        Authentication *auth = NULL;
-        void *handle = dlopen(dynamicLibPath.c_str(), RTLD_LAZY);
-        if (handle != NULL) {
-            boost::lock_guard<boost::mutex> lock(mutex);
-            loadedLibrariesHandles_.push_back(handle);
-            Authentication *(*createAuthentication)(ParamMap&);
-            *(void **) (&createAuthentication) = dlsym(handle, "createFromMap");
-            if (createAuthentication != NULL) {
-                auth = createAuthentication(params);
-            }
+    }
+    Authentication* auth = NULL;
+    void* handle = dlopen(dynamicLibPath.c_str(), RTLD_LAZY);
+    if (handle != NULL) {
+        boost::lock_guard<boost::mutex> lock(mutex);
+        loadedLibrariesHandles_.push_back(handle);
+        Authentication* (*createAuthentication)(ParamMap&);
+        *(void**)(&createAuthentication) = dlsym(handle, "createFromMap");
+        if (createAuthentication != NULL) {
+            auth = createAuthentication(params);
         }
-        return AuthenticationPtr(auth);
     }
-
+    return AuthenticationPtr(auth);
 }
+}  // namespace pulsar
diff --git a/pulsar-client-cpp/lib/Backoff.cc b/pulsar-client-cpp/lib/Backoff.cc
index aba88f5..5abb055 100644
--- a/pulsar-client-cpp/lib/Backoff.cc
+++ b/pulsar-client-cpp/lib/Backoff.cc
@@ -21,13 +21,12 @@
 namespace pulsar {
 
 Backoff::Backoff(const TimeDuration& initial, const TimeDuration& max, const TimeDuration& mandatoryStop)
-        : initial_(initial),
-          max_(max),
-          next_(initial),
-          mandatoryStopMade_(false),
-          mandatoryStop_(mandatoryStop),
-          randomSeed_(time(NULL)) {
-}
+    : initial_(initial),
+      max_(max),
+      next_(initial),
+      mandatoryStopMade_(false),
+      mandatoryStop_(mandatoryStop),
+      randomSeed_(time(NULL)) {}
 
 TimeDuration Backoff::next() {
     TimeDuration current = next_;
@@ -57,4 +56,4 @@ void Backoff::reset() {
     mandatoryStopMade_ = false;
 }
 
-}  //pulsar - namespace end
+}  // namespace pulsar
diff --git a/pulsar-client-cpp/lib/Backoff.h b/pulsar-client-cpp/lib/Backoff.h
index d06b84d..9b10577 100644
--- a/pulsar-client-cpp/lib/Backoff.h
+++ b/pulsar-client-cpp/lib/Backoff.h
@@ -16,12 +16,12 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-#ifndef  _PULSAR_BACKOFF_HEADER_
+#ifndef _PULSAR_BACKOFF_HEADER_
 #define _PULSAR_BACKOFF_HEADER_
 #include <boost/date_time/posix_time/posix_time.hpp>
-#include <stdlib.h>     /* srand, rand */
+#include <stdlib.h> /* srand, rand */
 #include <algorithm>
-#include <time.h>       /* time */
+#include <time.h> /* time */
 
 #pragma GCC visibility push(default)
 
@@ -30,11 +30,12 @@ namespace pulsar {
 typedef boost::posix_time::time_duration TimeDuration;
 
 class Backoff {
- public:
+   public:
     Backoff(const TimeDuration&, const TimeDuration&, const TimeDuration&);
     TimeDuration next();
     void reset();
- private:
+
+   private:
     const TimeDuration initial_;
     const TimeDuration max_;
     TimeDuration next_;
@@ -44,7 +45,7 @@ class Backoff {
     unsigned int randomSeed_;
     friend class PulsarFriend;
 };
-}
+}  // namespace pulsar
 
 #pragma GCC visibility pop
 
diff --git a/pulsar-client-cpp/lib/BatchAcknowledgementTracker.cc b/pulsar-client-cpp/lib/BatchAcknowledgementTracker.cc
index bcc25d7..868c050 100644
--- a/pulsar-client-cpp/lib/BatchAcknowledgementTracker.cc
+++ b/pulsar-client-cpp/lib/BatchAcknowledgementTracker.cc
@@ -21,12 +21,13 @@
 namespace pulsar {
 DECLARE_LOG_OBJECT()
 
-BatchAcknowledgementTracker::BatchAcknowledgementTracker(const std::string topic, const std::string subscription,
-                               const long consumerId)
-        : greatestCumulativeAckSent_(BatchMessageId()) {
+BatchAcknowledgementTracker::BatchAcknowledgementTracker(const std::string topic,
+                                                         const std::string subscription,
+                                                         const long consumerId)
+    : greatestCumulativeAckSent_(BatchMessageId()) {
     std::stringstream consumerStrStream;
-    consumerStrStream << "BatchAcknowledgementTracker for [" << topic << ", " << subscription
-                      << ", " << consumerId << "] ";
+    consumerStrStream << "BatchAcknowledgementTracker for [" << topic << ", " << subscription << ", "
+                      << consumerId << "] ";
     name_ = consumerStrStream.str();
     LOG_DEBUG(name_ << "Constructed BatchAcknowledgementTracker");
 }
@@ -46,14 +47,17 @@ void BatchAcknowledgementTracker::receivedMessage(const Message& message) {
 
     // ignore message if it is less than the last cumulative ack sent or messageID is already being tracked
     TrackerMap::iterator pos = trackerMap_.find(msgID);
-    if (msgID < greatestCumulativeAckSent_ || pos != trackerMap_.end()
-            || std::find(sendList_.begin(), sendList_.end(), msgID) != sendList_.end()) {
+    if (msgID < greatestCumulativeAckSent_ || pos != trackerMap_.end() ||
+        std::find(sendList_.begin(), sendList_.end(), msgID) != sendList_.end()) {
         return;
     }
     LOG_DEBUG("Initializing the trackerMap_ with Message ID = " << msgID);
 
-    // Since dynamic_set (this version) doesn't have all() function, initializing all bits with 1 and then reseting them to 0 and using any()
-    trackerMap_.insert(pos, TrackerPair(msgID, boost::dynamic_bitset<>(message.impl_->metadata.num_messages_in_batch()).set()));
+    // Since dynamic_set (this version) doesn't have all() function, initializing all bits with 1 and then
+    // reseting them to 0 and using any()
+    trackerMap_.insert(
+        pos,
+        TrackerPair(msgID, boost::dynamic_bitset<>(message.impl_->metadata.num_messages_in_batch()).set()));
 }
 
 void BatchAcknowledgementTracker::deleteAckedMessage(const BatchMessageId& messageId,
@@ -78,36 +82,36 @@ void BatchAcknowledgementTracker::deleteAckedMessage(const BatchMessageId& messa
             }
         }
 
-        // std::remove shifts all to be deleted items to the end of the vector and returns an iterator to the first
+        // std::remove shifts all to be deleted items to the end of the vector and returns an iterator to the
+        // first
         // instance of item, then we erase all elements from this iterator to the end of the list
-        sendList_.erase(
-                std::remove_if(sendList_.begin(), sendList_.end(), SendRemoveCriteria(messageId)),
-                sendList_.end());
+        sendList_.erase(std::remove_if(sendList_.begin(), sendList_.end(), SendRemoveCriteria(messageId)),
+                        sendList_.end());
 
         if (greatestCumulativeAckSent_ < messageId) {
             greatestCumulativeAckSent_ = messageId;
-            LOG_DEBUG(
-                    *this << " The greatestCumulativeAckSent_ is now " << greatestCumulativeAckSent_);
+            LOG_DEBUG(*this << " The greatestCumulativeAckSent_ is now " << greatestCumulativeAckSent_);
         }
     } else {
         // Error - if it is a batch message and found in trackerMap_
         if (trackerMap_.find(messageId) != trackerMap_.end()) {
-            LOG_ERROR(
-                    *this << " - This should not happened - Message should have been removed from trakerMap_ and moved to sendList_ " << messageId);
+            LOG_ERROR(*this << " - This should not happened - Message should have been removed from "
+                               "trakerMap_ and moved to sendList_ "
+                            << messageId);
         }
 
-        sendList_.erase(std::remove(sendList_.begin(), sendList_.end(), messageId),
-                        sendList_.end());
+        sendList_.erase(std::remove(sendList_.begin(), sendList_.end(), messageId), sendList_.end());
     }
 }
 
-bool BatchAcknowledgementTracker::isBatchReady(const BatchMessageId& msgID, const proto::CommandAck_AckType ackType) {
+bool BatchAcknowledgementTracker::isBatchReady(const BatchMessageId& msgID,
+                                               const proto::CommandAck_AckType ackType) {
     Lock lock(mutex_);
     TrackerMap::iterator pos = trackerMap_.find(msgID);
-    if (pos == trackerMap_.end() ||
-            std::find(sendList_.begin(), sendList_.end(), msgID) != sendList_.end()) {
+    if (pos == trackerMap_.end() || std::find(sendList_.begin(), sendList_.end(), msgID) != sendList_.end()) {
         LOG_DEBUG(
-                "Batch is ready since message present in sendList_ or not present in trackerMap_ [message ID = " << msgID << "]");
+            "Batch is ready since message present in sendList_ or not present in trackerMap_ [message ID = "
+            << msgID << "]");
         return true;
     }
 
@@ -126,8 +130,8 @@ bool BatchAcknowledgementTracker::isBatchReady(const BatchMessageId& msgID, cons
     }
     sendList_.push_back(msgID);
     trackerMap_.erase(pos);
-    LOG_DEBUG(
-            "Batch is ready since message all bits are reset in trackerMap_ [message ID = " << msgID << "]");
+    LOG_DEBUG("Batch is ready since message all bits are reset in trackerMap_ [message ID = " << msgID
+                                                                                              << "]");
     return true;
 }
 
@@ -135,7 +139,7 @@ bool BatchAcknowledgementTracker::isBatchReady(const BatchMessageId& msgID, cons
 // - a batch message id < messageId
 // - same messageId if it is the last message in the batch
 const BatchMessageId BatchAcknowledgementTracker::getGreatestCumulativeAckReady(
-        const BatchMessageId& messageId) {
+    const BatchMessageId& messageId) {
     Lock lock(mutex_);
     BatchMessageId messageReadyForCumulativeAck = BatchMessageId();
     TrackerMap::iterator pos = trackerMap_.find(messageId);
@@ -145,7 +149,6 @@ const BatchMessageId BatchAcknowledgementTracker::getGreatestCumulativeAckReady(
         return BatchMessageId();
     }
 
-
     if (pos->second.size() - 1 != messageId.batchIndex_) {
         // Can't cumulatively ack this batch message
         if (pos == trackerMap_.begin()) {
@@ -157,5 +160,4 @@ const BatchMessageId BatchAcknowledgementTracker::getGreatestCumulativeAckReady(
 
     return pos->first;
 }
-
-}
+}  // namespace pulsar
diff --git a/pulsar-client-cpp/lib/BatchAcknowledgementTracker.h b/pulsar-client-cpp/lib/BatchAcknowledgementTracker.h
index 8734ab2..b6f8ba8 100644
--- a/pulsar-client-cpp/lib/BatchAcknowledgementTracker.h
+++ b/pulsar-client-cpp/lib/BatchAcknowledgementTracker.h
@@ -29,12 +29,12 @@
 #include "LogUtils.h"
 #include <string>
 #include <sstream>
-namespace pulsar{
+namespace pulsar {
 
 class ConsumerImpl;
 
 class BatchAcknowledgementTracker {
- private:
+   private:
     typedef boost::unique_lock<boost::mutex> Lock;
     typedef std::pair<BatchMessageId, boost::dynamic_bitset<> > TrackerPair;
     typedef std::map<BatchMessageId, boost::dynamic_bitset<> > TrackerMap;
@@ -42,17 +42,21 @@ class BatchAcknowledgementTracker {
 
     TrackerMap trackerMap_;
 
-    // SendList is used to reduce the time required to go over the dynamic_bitset and check if the entire batch is acked.
-    // It is useful in cases where the entire batch is acked but cnx is broken. In this case when any of the batch index
-    // is acked again, we just check the sendList to verify that the batch is acked w/o iterating over the dynamic_bitset.
+    // SendList is used to reduce the time required to go over the dynamic_bitset and check if the entire
+    // batch is acked.
+    // It is useful in cases where the entire batch is acked but cnx is broken. In this case when any of the
+    // batch index
+    // is acked again, we just check the sendList to verify that the batch is acked w/o iterating over the
+    // dynamic_bitset.
     std::vector<BatchMessageId> sendList_;
 
     // we don't need to track MessageId < greatestCumulativeAckReceived
     BatchMessageId greatestCumulativeAckSent_;
     std::string name_;
 
- public:
-    BatchAcknowledgementTracker(const std::string topic, const std::string subscription, const long consumerId);
+   public:
+    BatchAcknowledgementTracker(const std::string topic, const std::string subscription,
+                                const long consumerId);
 
     bool isBatchReady(const BatchMessageId& msgID, const proto::CommandAck_AckType ackType);
     const BatchMessageId getGreatestCumulativeAckReady(const BatchMessageId& messageId);
@@ -62,47 +66,40 @@ class BatchAcknowledgementTracker {
 
     void clear();
 
-    inline friend std::ostream& operator<<(std::ostream& os, const BatchAcknowledgementTracker& batchAcknowledgementTracker);
+    inline friend std::ostream& operator<<(std::ostream& os,
+                                           const BatchAcknowledgementTracker& batchAcknowledgementTracker);
 
     // Used for Cumulative acks only
     struct SendRemoveCriteria {
-        private:
+       private:
         const BatchMessageId& messageId_;
 
-        public:
-        SendRemoveCriteria(const BatchMessageId& messageId)
-            : messageId_(messageId) {}
+       public:
+        SendRemoveCriteria(const BatchMessageId& messageId) : messageId_(messageId) {}
 
-        bool operator()(const BatchMessageId &element) const {
-            return (element <= messageId_);
-        }
+        bool operator()(const BatchMessageId& element) const { return (element <= messageId_); }
     };
 
     // Used for Cumulative acks only
     struct TrackerMapRemoveCriteria {
-        private:
+       private:
         const BatchMessageId& messageId_;
 
-        public:
-        TrackerMapRemoveCriteria(const BatchMessageId& messageId)
-            : messageId_(messageId) {}
+       public:
+        TrackerMapRemoveCriteria(const BatchMessageId& messageId) : messageId_(messageId) {}
 
-        bool operator()(std::pair<const pulsar::BatchMessageId, boost::dynamic_bitset<> > &element) const {
+        bool operator()(std::pair<const pulsar::BatchMessageId, boost::dynamic_bitset<> >& element) const {
             return (element.first <= messageId_);
         }
     };
-
 };
 
-std::ostream& operator<<(std::ostream& os,
-                         const BatchAcknowledgementTracker& batchAcknowledgementTracker) {
-    os << "{ " <<  batchAcknowledgementTracker.name_
-            << " [greatestCumulativeAckReceived_-"
-            << batchAcknowledgementTracker.greatestCumulativeAckSent_ << "] [trackerMap size = "
-            << batchAcknowledgementTracker.trackerMap_.size() << " ]}";
+std::ostream& operator<<(std::ostream& os, const BatchAcknowledgementTracker& batchAcknowledgementTracker) {
+    os << "{ " << batchAcknowledgementTracker.name_ << " [greatestCumulativeAckReceived_-"
+       << batchAcknowledgementTracker.greatestCumulativeAckSent_
+       << "] [trackerMap size = " << batchAcknowledgementTracker.trackerMap_.size() << " ]}";
     return os;
 }
-
-}
+}  // namespace pulsar
 
 #endif /* LIB_BATCHACKNOWLEDGEMENTTRACKER_H_ */
diff --git a/pulsar-client-cpp/lib/BatchMessageContainer.cc b/pulsar-client-cpp/lib/BatchMessageContainer.cc
index ed108e9..01be503 100644
--- a/pulsar-client-cpp/lib/BatchMessageContainer.cc
+++ b/pulsar-client-cpp/lib/BatchMessageContainer.cc
@@ -25,27 +25,28 @@ static ObjectPool<BatchMessageContainer::MessageContainerList, 1000> messageCont
 DECLARE_LOG_OBJECT()
 
 BatchMessageContainer::BatchMessageContainer(ProducerImpl& producer)
-        : maxAllowedNumMessagesInBatch_(producer.conf_.getBatchingMaxMessages()),
-          maxAllowedMessageBatchSizeInBytes_(producer.conf_.getBatchingMaxAllowedSizeInBytes()),
-          topicName_(producer.topic_),
-          producerName_(producer.producerName_),
-          compressionType_(producer.conf_.getCompressionType()),
-          producer_(producer),
-          impl_(messagePool.create()),
-          timer_(producer.executor_->createDeadlineTimer()),
-          batchSizeInBytes_(0),
-          messagesContainerListPtr_(messageContainerListPool.create()),
-          averageBatchSize_(0),
-          numberOfBatchesSent_(0) {
+    : maxAllowedNumMessagesInBatch_(producer.conf_.getBatchingMaxMessages()),
+      maxAllowedMessageBatchSizeInBytes_(producer.conf_.getBatchingMaxAllowedSizeInBytes()),
+      topicName_(producer.topic_),
+      producerName_(producer.producerName_),
+      compressionType_(producer.conf_.getCompressionType()),
+      producer_(producer),
+      impl_(messagePool.create()),
+      timer_(producer.executor_->createDeadlineTimer()),
+      batchSizeInBytes_(0),
+      messagesContainerListPtr_(messageContainerListPool.create()),
+      averageBatchSize_(0),
+      numberOfBatchesSent_(0) {
     messagesContainerListPtr_->reserve(1000);
     LOG_INFO(*this << " BatchMessageContainer constructed");
 }
 
 void BatchMessageContainer::add(const Message& msg, SendCallback sendCallback, bool disableCheck) {
     // disableCheck is needed to avoid recursion in case the batchSizeInKB < IndividualMessageSizeInKB
-    LOG_DEBUG(*this << " Called add function for [message = " << msg << "] [disableCheck = "<<disableCheck << "]");
-    if ( !(disableCheck || hasSpaceInBatch(msg))) {
-        LOG_DEBUG(*this << " Batch is full" );
+    LOG_DEBUG(*this << " Called add function for [message = " << msg << "] [disableCheck = " << disableCheck
+                    << "]");
+    if (!(disableCheck || hasSpaceInBatch(msg))) {
+        LOG_DEBUG(*this << " Batch is full");
         sendMessage();
         add(msg, sendCallback, true);
         return;
@@ -59,9 +60,10 @@ void BatchMessageContainer::add(const Message& msg, SendCallback sendCallback, b
     }
     batchSizeInBytes_ += msg.impl_->payload.readableBytes();
 
-    LOG_DEBUG(*this << " Before serialization payload size in bytes = " <<impl_->payload.readableBytes());
-    Commands::serializeSingleMessageInBatchWithPayload(msg, impl_->payload, maxAllowedMessageBatchSizeInBytes_);
-    LOG_DEBUG(*this << " After serialization payload size in bytes = "<< impl_->payload.readableBytes());
+    LOG_DEBUG(*this << " Before serialization payload size in bytes = " << impl_->payload.readableBytes());
+    Commands::serializeSingleMessageInBatchWithPayload(msg, impl_->payload,
+                                                       maxAllowedMessageBatchSizeInBytes_);
+    LOG_DEBUG(*this << " After serialization payload size in bytes = " << impl_->payload.readableBytes());
 
     messagesContainerListPtr_->push_back(MessageContainer(msg, sendCallback));
 
@@ -77,9 +79,8 @@ void BatchMessageContainer::startTimer() {
     const unsigned long& publishDelayInMs = producer_.conf_.getBatchingMaxPublishDelayMs();
     LOG_DEBUG(*this << " Timer started with expiry after " << publishDelayInMs);
     timer_->expires_from_now(boost::posix_time::milliseconds(publishDelayInMs));
-    timer_->async_wait(
-            boost::bind(&pulsar::ProducerImpl::batchMessageTimeoutHandler, &producer_,
-                        boost::asio::placeholders::error));
+    timer_->async_wait(boost::bind(&pulsar::ProducerImpl::batchMessageTimeoutHandler, &producer_,
+                                   boost::asio::placeholders::error));
 }
 
 void BatchMessageContainer::sendMessage() {
@@ -96,30 +97,28 @@ void BatchMessageContainer::sendMessage() {
     msg.impl_ = impl_;
 
     // bind keeps a copy of the parameters
-    SendCallback callback = boost::bind(&BatchMessageContainer::batchMessageCallBack, _1, messagesContainerListPtr_);
+    SendCallback callback =
+        boost::bind(&BatchMessageContainer::batchMessageCallBack, _1, messagesContainerListPtr_);
 
     producer_.sendMessage(msg, callback);
     clear();
 }
 
 void BatchMessageContainer::compressPayLoad() {
-
     if (compressionType_ != CompressionNone) {
-        impl_->metadata.set_compression(
-                CompressionCodecProvider::convertType(compressionType_));
+        impl_->metadata.set_compression(CompressionCodecProvider::convertType(compressionType_));
         impl_->metadata.set_uncompressed_size(impl_->payload.readableBytes());
     }
     impl_->payload = CompressionCodecProvider::getCodec(compressionType_).encode(impl_->payload);
 }
 
-SharedBuffer BatchMessageContainer::getBatchedPayload() {
-    return impl_->payload;
-}
+SharedBuffer BatchMessageContainer::getBatchedPayload() { return impl_->payload; }
 
 void BatchMessageContainer::clear() {
     LOG_DEBUG(*this << " BatchMessageContainer::clear() called");
     timer_->cancel();
-    averageBatchSize_ = (messagesContainerListPtr_->size() + (averageBatchSize_ * numberOfBatchesSent_))/(numberOfBatchesSent_ + 1);
+    averageBatchSize_ = (messagesContainerListPtr_->size() + (averageBatchSize_ * numberOfBatchesSent_)) /
+                        (numberOfBatchesSent_ + 1);
     numberOfBatchesSent_++;
     messagesContainerListPtr_ = messageContainerListPool.create();
     // Try to optimize this
@@ -132,8 +131,10 @@ void BatchMessageContainer::batchMessageCallBack(Result r, MessageContainerListP
     if (!messagesContainerListPtr) {
         return;
     }
-    LOG_DEBUG("BatchMessageContainer::batchMessageCallBack called with [Result = " << r << "] [numOfMessages = " << messagesContainerListPtr->size() << "]");
-    for(MessageContainerList::iterator iter = messagesContainerListPtr->begin(); iter != messagesContainerListPtr->end(); iter++) {
+    LOG_DEBUG("BatchMessageContainer::batchMessageCallBack called with [Result = "
+              << r << "] [numOfMessages = " << messagesContainerListPtr->size() << "]");
+    for (MessageContainerList::iterator iter = messagesContainerListPtr->begin();
+         iter != messagesContainerListPtr->end(); iter++) {
         // callback(result, message)
         iter->sendCallback_(r, iter->message_);
     }
@@ -143,6 +144,6 @@ BatchMessageContainer::~BatchMessageContainer() {
     timer_->cancel();
     LOG_DEBUG(*this << " BatchMessageContainer Object destructed");
     LOG_INFO("[numberOfBatchesSent = " << numberOfBatchesSent_
-    << "] [averageBatchSize = " << averageBatchSize_ << "]");
-}
+                                       << "] [averageBatchSize = " << averageBatchSize_ << "]");
 }
+}  // namespace pulsar
diff --git a/pulsar-client-cpp/lib/BatchMessageContainer.h b/pulsar-client-cpp/lib/BatchMessageContainer.h
index bf7a6aa..0b7a0d3 100644
--- a/pulsar-client-cpp/lib/BatchMessageContainer.h
+++ b/pulsar-client-cpp/lib/BatchMessageContainer.h
@@ -19,7 +19,8 @@
 /*
  * \class BatchMessageContainer
  *
- * \brief This class is a container for holding individual messages being published until they are batched and sent to broker.
+ * \brief This class is a container for holding individual messages being published until they are batched and
+ * sent to broker.
  *
  * \note This class is not thread safe.
  */
@@ -43,13 +44,10 @@
 namespace pulsar {
 
 class BatchMessageContainer {
- public:
-
+   public:
     struct MessageContainer {
         MessageContainer(Message message, SendCallback sendCallback)
-        : message_(message),
-          sendCallback_(sendCallback) {
-        }
+            : message_(message), sendCallback_(sendCallback) {}
         Message message_;
         SendCallback sendCallback_;
     };
@@ -68,10 +66,11 @@ class BatchMessageContainer {
 
     static void batchMessageCallBack(Result r, MessageContainerListPtr messages);
 
-    friend inline std::ostream& operator<<(std::ostream& os, const BatchMessageContainer& batchMessageContainer);
+    friend inline std::ostream& operator<<(std::ostream& os,
+                                           const BatchMessageContainer& batchMessageContainer);
     friend class ProducerImpl;
 
- private:
+   private:
     const CompressionType compressionType_;
 
     const unsigned int maxAllowedNumMessagesInBatch_;
@@ -86,7 +85,8 @@ class BatchMessageContainer {
 
     Message::MessageImplPtr impl_;
 
-    // This copy (to vector) is needed since OpSendMsg no long holds the individual message and w/o a container
+    // This copy (to vector) is needed since OpSendMsg no long holds the individual message and w/o a
+    // container
     // the impl_ Shared Pointer will delete the data.
     MessageContainerListPtr messagesContainerListPtr_;
 
@@ -94,7 +94,6 @@ class BatchMessageContainer {
 
     DeadlineTimerPtr timer_;
 
-
     unsigned long numberOfBatchesSent_;
 
     double averageBatchSize_;
@@ -113,30 +112,28 @@ class BatchMessageContainer {
 };
 
 bool BatchMessageContainer::hasSpaceInBatch(const Message& msg) const {
-    return (msg.impl_->payload.readableBytes() + this->batchSizeInBytes_
-            <= this->maxAllowedMessageBatchSizeInBytes_)
-            && (this->messagesContainerListPtr_->size() < this->maxAllowedNumMessagesInBatch_);
+    return (msg.impl_->payload.readableBytes() + this->batchSizeInBytes_ <=
+            this->maxAllowedMessageBatchSizeInBytes_) &&
+           (this->messagesContainerListPtr_->size() < this->maxAllowedNumMessagesInBatch_);
 }
 
-bool BatchMessageContainer::isEmpty() const {
-    return this->messagesContainerListPtr_->empty();
-}
+bool BatchMessageContainer::isEmpty() const { return this->messagesContainerListPtr_->empty(); }
 
 bool BatchMessageContainer::isFull() const {
-    return (this->batchSizeInBytes_ >= this->maxAllowedMessageBatchSizeInBytes_
-            || this->messagesContainerListPtr_->size() >= this->maxAllowedNumMessagesInBatch_);
+    return (this->batchSizeInBytes_ >= this->maxAllowedMessageBatchSizeInBytes_ ||
+            this->messagesContainerListPtr_->size() >= this->maxAllowedNumMessagesInBatch_);
 }
 
 std::ostream& operator<<(std::ostream& os, const BatchMessageContainer& b) {
-    os << "{ BatchContainer [size = " << b.messagesContainerListPtr_->size() << "] [batchSizeInBytes_ = "
-            << b.batchSizeInBytes_ << "] [maxAllowedMessageBatchSizeInBytes_ = "
-            << b.maxAllowedMessageBatchSizeInBytes_ << "] [maxAllowedNumMessagesInBatch_ = "
-            << b.maxAllowedNumMessagesInBatch_ << "] [topicName = " << b.topicName_
-            << "] [producerName_ = " << b.producerName_ << "] [batchSizeInBytes_ = "
-            << b.batchSizeInBytes_ << "] [numberOfBatchesSent = " << b.numberOfBatchesSent_
-            << "] [averageBatchSize = " << b.averageBatchSize_ << "]}";
+    os << "{ BatchContainer [size = " << b.messagesContainerListPtr_->size()
+       << "] [batchSizeInBytes_ = " << b.batchSizeInBytes_
+       << "] [maxAllowedMessageBatchSizeInBytes_ = " << b.maxAllowedMessageBatchSizeInBytes_
+       << "] [maxAllowedNumMessagesInBatch_ = " << b.maxAllowedNumMessagesInBatch_
+       << "] [topicName = " << b.topicName_ << "] [producerName_ = " << b.producerName_
+       << "] [batchSizeInBytes_ = " << b.batchSizeInBytes_
+       << "] [numberOfBatchesSent = " << b.numberOfBatchesSent_
+       << "] [averageBatchSize = " << b.averageBatchSize_ << "]}";
     return os;
 }
-
-}
+}  // namespace pulsar
 #endif /* LIB_BATCHMESSAGECONTAINER_H_ */
diff --git a/pulsar-client-cpp/lib/BatchMessageId.cc b/pulsar-client-cpp/lib/BatchMessageId.cc
index 7649818..27d7bbd 100644
--- a/pulsar-client-cpp/lib/BatchMessageId.cc
+++ b/pulsar-client-cpp/lib/BatchMessageId.cc
@@ -26,9 +26,8 @@
 
 namespace pulsar {
 
-BatchMessageId::BatchMessageId(const MessageId& msgId) :
-        MessageId(msgId.ledgerId_, msgId.entryId_), batchIndex_(msgId.getBatchIndex()) {
-}
+BatchMessageId::BatchMessageId(const MessageId& msgId)
+    : MessageId(msgId.ledgerId_, msgId.entryId_), batchIndex_(msgId.getBatchIndex()) {}
 
 void BatchMessageId::serialize(std::string& result) const {
     proto::MessageIdData idData;
@@ -43,9 +42,7 @@ void BatchMessageId::serialize(std::string& result) const {
     idData.SerializeToString(&result);
 }
 
-int64_t BatchMessageId::getBatchIndex() const {
-    return batchIndex_;
-}
+int64_t BatchMessageId::getBatchIndex() const { return batchIndex_; }
 
 #pragma GCC visibility push(default)
 
@@ -63,21 +60,17 @@ bool BatchMessageId::operator<(const BatchMessageId& other) const {
     }
 }
 
-bool BatchMessageId::operator<=(const BatchMessageId& other) const {
-    return *this < other || *this == other;
-}
+bool BatchMessageId::operator<=(const BatchMessageId& other) const { return *this < other || *this == other; }
 
 bool BatchMessageId::operator==(const BatchMessageId& other) const {
-    return ledgerId_ == other.ledgerId_ && entryId_ == other.entryId_
-            && batchIndex_ == other.batchIndex_;
+    return ledgerId_ == other.ledgerId_ && entryId_ == other.entryId_ && batchIndex_ == other.batchIndex_;
 }
 
 std::ostream& operator<<(std::ostream& s, const BatchMessageId& messageId) {
-    s << '(' << messageId.ledgerId_ << ':' << messageId.entryId_ << ':' << messageId.batchIndex_
-      << ':' << messageId.partition_ << ')';
+    s << '(' << messageId.ledgerId_ << ':' << messageId.entryId_ << ':' << messageId.batchIndex_ << ':'
+      << messageId.partition_ << ')';
     return s;
 }
 
 #pragma GCC visibility pop
-
-}
+}  // namespace pulsar
diff --git a/pulsar-client-cpp/lib/BinaryProtoLookupService.cc b/pulsar-client-cpp/lib/BinaryProtoLookupService.cc
index 156c65b..6303449 100644
--- a/pulsar-client-cpp/lib/BinaryProtoLookupService.cc
+++ b/pulsar-client-cpp/lib/BinaryProtoLookupService.cc
@@ -30,112 +30,125 @@ DECLARE_LOG_OBJECT()
 
 namespace pulsar {
 
-    /*
-     * @param lookupUrl service url to do lookup
-     * Constructor
-     */
-    BinaryProtoLookupService::BinaryProtoLookupService(ConnectionPool& cnxPool, const std::string& lookupUrl)
-    :
-    cnxPool_(cnxPool),
-    serviceUrl_(lookupUrl),
-    mutex_(),
-    requestIdGenerator_(0) {}
+/*
+ * @param lookupUrl service url to do lookup
+ * Constructor
+ */
+BinaryProtoLookupService::BinaryProtoLookupService(ConnectionPool& cnxPool, const std::string& lookupUrl)
+    : cnxPool_(cnxPool), serviceUrl_(lookupUrl), mutex_(), requestIdGenerator_(0) {}
 
-    /*
-     * @param destination_name topic name to get broker for
-     *
-     * Looks up the owner broker for the given destination name
-     */
-    Future<Result, LookupDataResultPtr> BinaryProtoLookupService::lookupAsync(const std::string& destinationName) {
-        DestinationNamePtr dn = DestinationName::get(destinationName);
-        if (!dn) {
-            LOG_ERROR("Unable to parse destination - " << destinationName);
-            LookupDataResultPromisePtr promise = boost::make_shared<LookupDataResultPromise>();
-            promise->setFailed(ResultInvalidTopicName);
-            return promise->getFuture();
-        }
-        std::string lookupName = dn->toString();
+/*
+ * @param destination_name topic name to get broker for
+ *
+ * Looks up the owner broker for the given destination name
+ */
+Future<Result, LookupDataResultPtr> BinaryProtoLookupService::lookupAsync(
+    const std::string& destinationName) {
+    DestinationNamePtr dn = DestinationName::get(destinationName);
+    if (!dn) {
+        LOG_ERROR("Unable to parse destination - " << destinationName);
         LookupDataResultPromisePtr promise = boost::make_shared<LookupDataResultPromise>();
-        Future<Result, ClientConnectionWeakPtr> future = cnxPool_.getConnectionAsync(serviceUrl_);
-        future.addListener(boost::bind(&BinaryProtoLookupService::sendTopicLookupRequest, this, lookupName, false, _1, _2, promise));
+        promise->setFailed(ResultInvalidTopicName);
         return promise->getFuture();
     }
+    std::string lookupName = dn->toString();
+    LookupDataResultPromisePtr promise = boost::make_shared<LookupDataResultPromise>();
+    Future<Result, ClientConnectionWeakPtr> future = cnxPool_.getConnectionAsync(serviceUrl_);
+    future.addListener(boost::bind(&BinaryProtoLookupService::sendTopicLookupRequest, this, lookupName, false,
+                                   _1, _2, promise));
+    return promise->getFuture();
+}
 
-    /*
-     * @param    destination_name topic to get number of partitions.
-     *
-     */
-    Future<Result, LookupDataResultPtr> BinaryProtoLookupService::getPartitionMetadataAsync(const DestinationNamePtr& dn) {
-        LookupDataResultPromisePtr promise = boost::make_shared<LookupDataResultPromise>();
-        if (!dn) {
-            promise->setFailed(ResultInvalidTopicName);
-            return promise->getFuture();
-        }
-        std::string lookupName = dn->toString();
-        Future<Result, ClientConnectionWeakPtr> future = cnxPool_.getConnectionAsync(serviceUrl_);
-        future.addListener(boost::bind(&BinaryProtoLookupService::sendPartitionMetadataLookupRequest, this, lookupName, _1, _2, promise));
+/*
+ * @param    destination_name topic to get number of partitions.
+ *
+ */
+Future<Result, LookupDataResultPtr> BinaryProtoLookupService::getPartitionMetadataAsync(
+    const DestinationNamePtr& dn) {
+    LookupDataResultPromisePtr promise = boost::make_shared<LookupDataResultPromise>();
+    if (!dn) {
+        promise->setFailed(ResultInvalidTopicName);
         return promise->getFuture();
     }
+    std::string lookupName = dn->toString();
+    Future<Result, ClientConnectionWeakPtr> future = cnxPool_.getConnectionAsync(serviceUrl_);
+    future.addListener(boost::bind(&BinaryProtoLookupService::sendPartitionMetadataLookupRequest, this,
+                                   lookupName, _1, _2, promise));
+    return promise->getFuture();
+}
 
-
-    void BinaryProtoLookupService::sendTopicLookupRequest(const std::string& destinationName, bool authoritative, Result result, const ClientConnectionWeakPtr& clientCnx, LookupDataResultPromisePtr promise) {
-        if (result != ResultOk) {
-            promise->setFailed(ResultConnectError);
-            return;
-        }
-        LookupDataResultPromisePtr lookupPromise = boost::make_shared<LookupDataResultPromise>();
-        ClientConnectionPtr conn = clientCnx.lock();
-        uint64_t requestId = newRequestId();
-        conn->newTopicLookup(destinationName, authoritative, requestId, lookupPromise);
-        lookupPromise->getFuture().addListener(boost::bind(&BinaryProtoLookupService::handleLookup, this, destinationName, _1, _2, clientCnx, promise));
+void BinaryProtoLookupService::sendTopicLookupRequest(const std::string& destinationName, bool authoritative,
+                                                      Result result, const ClientConnectionWeakPtr& clientCnx,
+                                                      LookupDataResultPromisePtr promise) {
+    if (result != ResultOk) {
+        promise->setFailed(ResultConnectError);
+        return;
     }
+    LookupDataResultPromisePtr lookupPromise = boost::make_shared<LookupDataResultPromise>();
+    ClientConnectionPtr conn = clientCnx.lock();
+    uint64_t requestId = newRequestId();
+    conn->newTopicLookup(destinationName, authoritative, requestId, lookupPromise);
+    lookupPromise->getFuture().addListener(boost::bind(&BinaryProtoLookupService::handleLookup, this,
+                                                       destinationName, _1, _2, clientCnx, promise));
+}
 
-    void BinaryProtoLookupService::handleLookup(const std::string& destinationName,
-            Result result, LookupDataResultPtr data, const ClientConnectionWeakPtr& clientCnx,
-            LookupDataResultPromisePtr promise) {
-        if (data) {
-            if(data ->isRedirect()) {
-                LOG_DEBUG("Lookup request is for " << destinationName << " redirected to " << data->getBrokerUrl());
-                Future<Result, ClientConnectionWeakPtr> future = cnxPool_.getConnectionAsync(data->getBrokerUrl());
-                future.addListener(boost::bind(&BinaryProtoLookupService::sendTopicLookupRequest, this, destinationName, data->isAuthoritative(), _1, _2, promise));
-            } else {
-                LOG_DEBUG("Lookup response for " << destinationName << ", lookup-broker-url " << data->getBrokerUrl());
-                promise->setValue(data);
-            }
+void BinaryProtoLookupService::handleLookup(const std::string& destinationName, Result result,
+                                            LookupDataResultPtr data,
+                                            const ClientConnectionWeakPtr& clientCnx,
+                                            LookupDataResultPromisePtr promise) {
+    if (data) {
+        if (data->isRedirect()) {
+            LOG_DEBUG("Lookup request is for " << destinationName << " redirected to "
+                                               << data->getBrokerUrl());
+            Future<Result, ClientConnectionWeakPtr> future =
+                cnxPool_.getConnectionAsync(data->getBrokerUrl());
+            future.addListener(boost::bind(&BinaryProtoLookupService::sendTopicLookupRequest, this,
+                                           destinationName, data->isAuthoritative(), _1, _2, promise));
         } else {
-            LOG_DEBUG("Lookup failed for " << destinationName << ", result " << result);
-            promise->setFailed(result);
+            LOG_DEBUG("Lookup response for " << destinationName << ", lookup-broker-url "
+                                             << data->getBrokerUrl());
+            promise->setValue(data);
         }
+    } else {
+        LOG_DEBUG("Lookup failed for " << destinationName << ", result " << result);
+        promise->setFailed(result);
     }
+}
 
-    void BinaryProtoLookupService::sendPartitionMetadataLookupRequest(const std::string& destinationName, Result result, const ClientConnectionWeakPtr& clientCnx, LookupDataResultPromisePtr promise) {
-        if (result != ResultOk) {
-            promise->setFailed(ResultConnectError);
-            Future<Result, LookupDataResultPtr> future = promise->getFuture();
-            return;
-        }
-        LookupDataResultPromisePtr lookupPromise = boost::make_shared<LookupDataResultPromise>();
-        ClientConnectionPtr conn = clientCnx.lock();
-        uint64_t requestId = newRequestId();
-        conn->newPartitionedMetadataLookup(destinationName, requestId, lookupPromise);
-        lookupPromise->getFuture().addListener(boost::bind(&BinaryProtoLookupService::handlePartitionMetadataLookup, this, destinationName, _1, _2, clientCnx, promise));
-    }
-
-    void BinaryProtoLookupService::handlePartitionMetadataLookup(const std::string& destinationName,
-            Result result, LookupDataResultPtr data, const ClientConnectionWeakPtr& clientCnx,
-            LookupDataResultPromisePtr promise) {
-        if (data) {
-            LOG_DEBUG("PartitionMetadataLookup response for " << destinationName << ", lookup-broker-url " << data->getBrokerUrl());
-            promise->setValue(data);
-        } else {
-            LOG_DEBUG("PartitionMetadataLookup failed for " << destinationName << ", result " << result);
-            promise->setFailed(result);
-        }
+void BinaryProtoLookupService::sendPartitionMetadataLookupRequest(const std::string& destinationName,
+                                                                  Result result,
+                                                                  const ClientConnectionWeakPtr& clientCnx,
+                                                                  LookupDataResultPromisePtr promise) {
+    if (result != ResultOk) {
+        promise->setFailed(ResultConnectError);
+        Future<Result, LookupDataResultPtr> future = promise->getFuture();
+        return;
     }
+    LookupDataResultPromisePtr lookupPromise = boost::make_shared<LookupDataResultPromise>();
+    ClientConnectionPtr conn = clientCnx.lock();
+    uint64_t requestId = newRequestId();
+    conn->newPartitionedMetadataLookup(destinationName, requestId, lookupPromise);
+    lookupPromise->getFuture().addListener(
+        boost::bind(&BinaryProtoLookupService::handlePartitionMetadataLookup, this, destinationName, _1, _2,
+                    clientCnx, promise));
+}
 
-    uint64_t BinaryProtoLookupService::newRequestId() {
-        Lock lock(mutex_);
-        return ++requestIdGenerator_;
+void BinaryProtoLookupService::handlePartitionMetadataLookup(const std::string& destinationName,
+                                                             Result result, LookupDataResultPtr data,
+                                                             const ClientConnectionWeakPtr& clientCnx,
+                                                             LookupDataResultPromisePtr promise) {
+    if (data) {
+        LOG_DEBUG("PartitionMetadataLookup response for " << destinationName << ", lookup-broker-url "
+                                                          << data->getBrokerUrl());
+        promise->setValue(data);
+    } else {
+        LOG_DEBUG("PartitionMetadataLookup failed for " << destinationName << ", result " << result);
+        promise->setFailed(result);
     }
+}
 
+uint64_t BinaryProtoLookupService::newRequestId() {
+    Lock lock(mutex_);
+    return ++requestIdGenerator_;
 }
+}  // namespace pulsar
diff --git a/pulsar-client-cpp/lib/BinaryProtoLookupService.h b/pulsar-client-cpp/lib/BinaryProtoLookupService.h
index ebcb121..26dd9a0 100644
--- a/pulsar-client-cpp/lib/BinaryProtoLookupService.h
+++ b/pulsar-client-cpp/lib/BinaryProtoLookupService.h
@@ -30,7 +30,7 @@ namespace pulsar {
 class LookupDataResult;
 
 class BinaryProtoLookupService : public LookupService {
- public:
+   public:
     /*
      * constructor
      */
@@ -40,8 +40,7 @@ class BinaryProtoLookupService : public LookupService {
 
     Future<Result, LookupDataResultPtr> getPartitionMetadataAsync(const DestinationNamePtr& dn);
 
- private:
-
+   private:
     boost::mutex mutex_;
     uint64_t requestIdGenerator_;
 
@@ -49,26 +48,24 @@ class BinaryProtoLookupService : public LookupService {
     ConnectionPool& cnxPool_;
 
     void sendTopicLookupRequest(const std::string& destinationName, bool authoritative, Result result,
-                     const ClientConnectionWeakPtr& clientCnx, LookupDataResultPromisePtr promise);
+                                const ClientConnectionWeakPtr& clientCnx, LookupDataResultPromisePtr promise);
 
     void handleLookup(const std::string& destinationName, Result result, LookupDataResultPtr data,
                       const ClientConnectionWeakPtr& clientCnx, LookupDataResultPromisePtr promise);
 
-
     void sendPartitionMetadataLookupRequest(const std::string& destinationName, Result result,
-                                   const ClientConnectionWeakPtr& clientCnx,
-                                   LookupDataResultPromisePtr promise);
-
-    void handlePartitionMetadataLookup(const std::string& destinationName, Result result, LookupDataResultPtr data,
-                          const ClientConnectionWeakPtr& clientCnx, LookupDataResultPromisePtr promise);
+                                            const ClientConnectionWeakPtr& clientCnx,
+                                            LookupDataResultPromisePtr promise);
 
+    void handlePartitionMetadataLookup(const std::string& destinationName, Result result,
+                                       LookupDataResultPtr data, const ClientConnectionWeakPtr& clientCnx,
+                                       LookupDataResultPromisePtr promise);
 
     uint64_t newRequestId();
-
 };
 typedef boost::shared_ptr<BinaryProtoLookupService> BinaryProtoLookupServicePtr;
-}
+}  // namespace pulsar
 
 #pragma GCC visibility pop
 
-#endif //_PULSAR_BINARY_LOOKUP_SERVICE_HEADER_
+#endif  //_PULSAR_BINARY_LOOKUP_SERVICE_HEADER_
diff --git a/pulsar-client-cpp/lib/BlockingQueue.h b/pulsar-client-cpp/lib/BlockingQueue.h
index d084dd2..44bfac6 100644
--- a/pulsar-client-cpp/lib/BlockingQueue.h
+++ b/pulsar-client-cpp/lib/BlockingQueue.h
@@ -28,52 +28,34 @@
  * This is done in order to avoid spurious wake up problem.
  * Details: https://www.justsoftwaresolutions.co.uk/threading/condition-variable-spurious-wakes.html
  */
-template<typename Container>
+template <typename Container>
 struct QueueNotEmpty {
     const Container& queue_;
-    QueueNotEmpty(const Container& queue)
-            : queue_(queue) {
-
-    }
-    bool operator()() const {
-        return !queue_.isEmptyNoMutex();
-    }
+    QueueNotEmpty(const Container& queue) : queue_(queue) {}
+    bool operator()() const { return !queue_.isEmptyNoMutex(); }
 };
 
-template<typename Container>
+template <typename Container>
 struct QueueNotFull {
     const Container& queue_;
-    QueueNotFull(const Container& queue)
-            : queue_(queue) {
-
-    }
-    bool operator()() const {
-        return !queue_.isFullNoMutex();
-    }
+    QueueNotFull(const Container& queue) : queue_(queue) {}
+    bool operator()() const { return !queue_.isFullNoMutex(); }
 };
 
-template<typename T>
+template <typename T>
 class BlockingQueue {
- public:
+   public:
     typedef typename boost::circular_buffer<T> Container;
     typedef typename Container::iterator iterator;
     typedef typename Container::const_iterator const_iterator;
 
     class ReservedSpot {
-     public:
-        ReservedSpot()
-                : queue_(),
-                  released_(true) {
-        }
+       public:
+        ReservedSpot() : queue_(), released_(true) {}
 
-        ReservedSpot(BlockingQueue<T>& queue)
-                : queue_(&queue),
-                  released_(false) {
-        }
+        ReservedSpot(BlockingQueue<T>& queue) : queue_(&queue), released_(false) {}
 
-        ~ReservedSpot() {
-            release();
-        }
+        ~ReservedSpot() { release(); }
 
         void release() {
             if (!released_) {
@@ -82,24 +64,19 @@ class BlockingQueue {
             }
         }
 
-     private:
+       private:
         BlockingQueue<T>* queue_;
         bool released_;
 
-        friend class BlockingQueue<T> ;
+        friend class BlockingQueue<T>;
     };
 
-    BlockingQueue(size_t maxSize)
-            : maxSize_(maxSize),
-              mutex_(),
-              queue_(maxSize),
-              reservedSpots_(0) {
-    }
+    BlockingQueue(size_t maxSize) : maxSize_(maxSize), mutex_(), queue_(maxSize), reservedSpots_(0) {}
 
     bool tryReserve(size_t noOfSpots) {
         assert(noOfSpots <= maxSize_);
         Lock lock(mutex_);
-        if(noOfSpots <= maxSize_ - (reservedSpots_ + queue_.size())) {
+        if (noOfSpots <= maxSize_ - (reservedSpots_ + queue_.size())) {
             reservedSpots_ += noOfSpots;
             return true;
         }
@@ -109,7 +86,7 @@ class BlockingQueue {
     void reserve(size_t noOfSpots) {
         assert(noOfSpots <= maxSize_);
         Lock lock(mutex_);
-        while(noOfSpots--) {
+        while (noOfSpots--) {
             queueFullCondition.wait(lock, QueueNotFull<BlockingQueue<T> >(*this));
             reservedSpots_++;
         }
@@ -224,8 +201,7 @@ class BlockingQueue {
 
     bool pop(T& value, const boost::posix_time::time_duration& timeout) {
         Lock lock(mutex_);
-        if (!queueEmptyCondition.timed_wait(lock, timeout,
-                                            QueueNotEmpty<BlockingQueue<T> >(*this))) {
+        if (!queueEmptyCondition.timed_wait(lock, timeout, QueueNotEmpty<BlockingQueue<T> >(*this))) {
             return false;
         }
 
@@ -265,9 +241,7 @@ class BlockingQueue {
         return queue_.size();
     }
 
-    size_t maxSize() const {
-        return maxSize_;
-    }
+    size_t maxSize() const { return maxSize_; }
 
     bool empty() const {
         Lock lock(mutex_);
@@ -279,23 +253,15 @@ class BlockingQueue {
         return isFullNoMutex();
     }
 
-    const_iterator begin() const {
-        return queue_.begin();
-    }
+    const_iterator begin() const { return queue_.begin(); }
 
-    const_iterator end() const {
-        return queue_.end();
-    }
+    const_iterator end() const { return queue_.end(); }
 
-    iterator begin() {
-        return queue_.begin();
-    }
+    iterator begin() { return queue_.begin(); }
 
-    iterator end() {
-        return queue_.end();
-    }
+    iterator end() { return queue_.end(); }
 
- private:
+   private:
     void releaseReservedSpot() {
         Lock lock(mutex_);
         bool wasFull = isFullNoMutex();
@@ -308,13 +274,9 @@ class BlockingQueue {
         }
     }
 
-    bool isEmptyNoMutex() const {
-        return queue_.empty();
-    }
+    bool isEmptyNoMutex() const { return queue_.empty(); }
 
-    bool isFullNoMutex() const {
-        return (queue_.size() + reservedSpots_) == maxSize_;
-    }
+    bool isFullNoMutex() const { return (queue_.size() + reservedSpots_) == maxSize_; }
 
     const size_t maxSize_;
     mutable boost::mutex mutex_;
@@ -325,8 +287,8 @@ class BlockingQueue {
 
     typedef boost::unique_lock<boost::mutex> Lock;
     friend class QueueReservedSpot;
-    friend struct QueueNotEmpty<BlockingQueue<T> > ;
-    friend struct QueueNotFull<BlockingQueue<T> > ;
+    friend struct QueueNotEmpty<BlockingQueue<T> >;
+    friend struct QueueNotFull<BlockingQueue<T> >;
 };
 
 #endif /* LIB_BLOCKINGQUEUE_H_ */
diff --git a/pulsar-client-cpp/lib/BrokerConsumerStats.cc b/pulsar-client-cpp/lib/BrokerConsumerStats.cc
index f11a857..544ef20 100644
--- a/pulsar-client-cpp/lib/BrokerConsumerStats.cc
+++ b/pulsar-client-cpp/lib/BrokerConsumerStats.cc
@@ -20,27 +20,22 @@
 #include <lib/BrokerConsumerStatsImplBase.h>
 
 namespace pulsar {
-BrokerConsumerStats::BrokerConsumerStats(boost::shared_ptr<BrokerConsumerStatsImplBase> impl)
-        : impl_(impl) {
-}
+BrokerConsumerStats::BrokerConsumerStats(boost::shared_ptr<BrokerConsumerStatsImplBase> impl) : impl_(impl) {}
 
-BrokerConsumerStats::BrokerConsumerStats() {
-}
+BrokerConsumerStats::BrokerConsumerStats() {}
 
-boost::shared_ptr<BrokerConsumerStatsImplBase> BrokerConsumerStats::getImpl() const {
-    return impl_;
-}
+boost::shared_ptr<BrokerConsumerStatsImplBase> BrokerConsumerStats::getImpl() const { return impl_; }
 
-bool BrokerConsumerStats::isValid() const {
-    return impl_->isValid();
-}
+bool BrokerConsumerStats::isValid() const { return impl_->isValid(); }
 
 #pragma GCC visibility push(default)
-std::ostream& operator<<(std::ostream &os, const BrokerConsumerStats& obj) {
-    os << "\nBrokerConsumerStats [" << "validTill_ = " << obj.isValid() << ", msgRateOut_ = "
-       << obj.getMsgRateOut() << ", msgThroughputOut_ = " << obj.getMsgThroughputOut()
-       << ", msgRateRedeliver_ = " << obj.getMsgRateRedeliver() << ", consumerName_ = "
-       << obj.getConsumerName() << ", availablePermits_ = " << obj.getAvailablePermits()
+std::ostream& operator<<(std::ostream& os, const BrokerConsumerStats& obj) {
+    os << "\nBrokerConsumerStats ["
+       << "validTill_ = " << obj.isValid() << ", msgRateOut_ = " << obj.getMsgRateOut()
+       << ", msgThroughputOut_ = " << obj.getMsgThroughputOut()
+       << ", msgRateRedeliver_ = " << obj.getMsgRateRedeliver()
+       << ", consumerName_ = " << obj.getConsumerName()
+       << ", availablePermits_ = " << obj.getAvailablePermits()
        << ", unackedMessages_ = " << obj.getUnackedMessages()
        << ", blockedConsumerOnUnackedMsgs_ = " << obj.isBlockedConsumerOnUnackedMsgs()
        << ", address_ = " << obj.getAddress() << ", connectedSince_ = " << obj.getConnectedSince()
@@ -50,51 +45,29 @@ std::ostream& operator<<(std::ostream &os, const BrokerConsumerStats& obj) {
 }
 #pragma GCC visibility pop
 
-double BrokerConsumerStats::getMsgRateOut() const {
-    return impl_->getMsgRateOut();
-}
+double BrokerConsumerStats::getMsgRateOut() const { return impl_->getMsgRateOut(); }
 
-double BrokerConsumerStats::getMsgThroughputOut() const {
-    return impl_->getMsgThroughputOut();
-}
+double BrokerConsumerStats::getMsgThroughputOut() const { return impl_->getMsgThroughputOut(); }
 
-double BrokerConsumerStats::getMsgRateRedeliver() const {
-    return impl_->getMsgRateRedeliver();
-}
+double BrokerConsumerStats::getMsgRateRedeliver() const { return impl_->getMsgRateRedeliver(); }
 
-const std::string BrokerConsumerStats::getConsumerName() const {
-    return impl_->getConsumerName();
-}
+const std::string BrokerConsumerStats::getConsumerName() const { return impl_->getConsumerName(); }
 
-uint64_t BrokerConsumerStats::getAvailablePermits() const {
-    return impl_->getAvailablePermits();
-}
+uint64_t BrokerConsumerStats::getAvailablePermits() const { return impl_->getAvailablePermits(); }
 
-uint64_t BrokerConsumerStats::getUnackedMessages() const {
-    return impl_->getUnackedMessages();
-}
+uint64_t BrokerConsumerStats::getUnackedMessages() const { return impl_->getUnackedMessages(); }
 
 bool BrokerConsumerStats::isBlockedConsumerOnUnackedMsgs() const {
     return impl_->isBlockedConsumerOnUnackedMsgs();
 }
 
-const std::string BrokerConsumerStats::getAddress() const {
-    return impl_->getAddress();
-}
+const std::string BrokerConsumerStats::getAddress() const { return impl_->getAddress(); }
 
-const std::string BrokerConsumerStats::getConnectedSince() const {
-    return impl_->getConnectedSince();
-}
+const std::string BrokerConsumerStats::getConnectedSince() const { return impl_->getConnectedSince(); }
 
-const ConsumerType BrokerConsumerStats::getType() const {
-    return impl_->getType();
-}
+const ConsumerType BrokerConsumerStats::getType() const { return impl_->getType(); }
 
-double BrokerConsumerStats::getMsgRateExpired() const {
-    return impl_->getMsgRateExpired();
-}
+double BrokerConsumerStats::getMsgRateExpired() const { return impl_->getMsgRateExpired(); }
 
-uint64_t BrokerConsumerStats::getMsgBacklog() const {
-    return impl_->getMsgBacklog();
-}
-}
+uint64_t BrokerConsumerStats::getMsgBacklog() const { return impl_->getMsgBacklog(); }
+}  // namespace pulsar
diff --git a/pulsar-client-cpp/lib/BrokerConsumerStatsImpl.cc b/pulsar-client-cpp/lib/BrokerConsumerStatsImpl.cc
index c9c4e42..4032f5f 100644
--- a/pulsar-client-cpp/lib/BrokerConsumerStatsImpl.cc
+++ b/pulsar-client-cpp/lib/BrokerConsumerStatsImpl.cc
@@ -20,110 +20,83 @@
 #include <boost/date_time/local_time/local_time.hpp>
 
 namespace pulsar {
-    BrokerConsumerStatsImpl::BrokerConsumerStatsImpl() : validTill_(boost::posix_time::microsec_clock::universal_time()) {};
-
-    BrokerConsumerStatsImpl::BrokerConsumerStatsImpl(double msgRateOut, double msgThroughputOut,
-                                                     double msgRateRedeliver, std::string consumerName,
-                                                     uint64_t availablePermits,
-                                                     uint64_t unackedMessages, bool blockedConsumerOnUnackedMsgs,
-                                                     std::string address,
-                                                     std::string connectedSince, const std::string& type,
-                                                     double msgRateExpired, uint64_t msgBacklog) :
-            msgRateOut_(msgRateOut),
-            msgThroughputOut_(msgThroughputOut),
-            msgRateRedeliver_(msgRateRedeliver),
-            consumerName_(consumerName),
-            availablePermits_(availablePermits),
-            unackedMessages_(unackedMessages),
-            blockedConsumerOnUnackedMsgs_(blockedConsumerOnUnackedMsgs),
-            address_(address),
-            connectedSince_(connectedSince),
-            type_(convertStringToConsumerType(type)),
-            msgRateExpired_(msgRateExpired),
-            msgBacklog_(msgBacklog) {}
-
-    bool BrokerConsumerStatsImpl::isValid() const {
-        return boost::posix_time::microsec_clock::universal_time() <= validTill_;
-    }
+BrokerConsumerStatsImpl::BrokerConsumerStatsImpl()
+    : validTill_(boost::posix_time::microsec_clock::universal_time()){};
+
+BrokerConsumerStatsImpl::BrokerConsumerStatsImpl(double msgRateOut, double msgThroughputOut,
+                                                 double msgRateRedeliver, std::string consumerName,
+                                                 uint64_t availablePermits, uint64_t unackedMessages,
+                                                 bool blockedConsumerOnUnackedMsgs, std::string address,
+                                                 std::string connectedSince, const std::string& type,
+                                                 double msgRateExpired, uint64_t msgBacklog)
+    : msgRateOut_(msgRateOut),
+      msgThroughputOut_(msgThroughputOut),
+      msgRateRedeliver_(msgRateRedeliver),
+      consumerName_(consumerName),
+      availablePermits_(availablePermits),
+      unackedMessages_(unackedMessages),
+      blockedConsumerOnUnackedMsgs_(blockedConsumerOnUnackedMsgs),
+      address_(address),
+      connectedSince_(connectedSince),
+      type_(convertStringToConsumerType(type)),
+      msgRateExpired_(msgRateExpired),
+      msgBacklog_(msgBacklog) {}
+
+bool BrokerConsumerStatsImpl::isValid() const {
+    return boost::posix_time::microsec_clock::universal_time() <= validTill_;
+}
 
-    std::ostream& operator<<(std::ostream &os, const BrokerConsumerStatsImpl& obj) {
-        os << "\nBrokerConsumerStatsImpl ["
-           << "validTill_ = " << obj.isValid()
-           << ", msgRateOut_ = " << obj.getMsgRateOut()
-           << ", msgThroughputOut_ = " << obj.getMsgThroughputOut()
-           << ", msgRateRedeliver_ = " << obj.getMsgRateRedeliver()
-           << ", consumerName_ = " << obj.getConsumerName()
-           << ", availablePermits_ = " << obj.getAvailablePermits()
-           << ", unackedMessages_ = " << obj.getUnackedMessages()
-           << ", blockedConsumerOnUnackedMsgs_ = " << obj.isBlockedConsumerOnUnackedMsgs()
-           << ", address_ = " << obj.getAddress()
-           << ", connectedSince_ = " << obj.getConnectedSince()
-           << ", type_ = " << obj.getType()
-           << ", msgRateExpired_ = " << obj.getMsgRateExpired()
-           << ", msgBacklog_ = " << obj.getMsgBacklog()
-           << "]";
-        return os;
-    }
+std::ostream& operator<<(std::ostream& os, const BrokerConsumerStatsImpl& obj) {
+    os << "\nBrokerConsumerStatsImpl ["
+       << "validTill_ = " << obj.isValid() << ", msgRateOut_ = " << obj.getMsgRateOut()
+       << ", msgThroughputOut_ = " << obj.getMsgThroughputOut()
+       << ", msgRateRedeliver_ = " << obj.getMsgRateRedeliver()
+       << ", consumerName_ = " << obj.getConsumerName()
+       << ", availablePermits_ = " << obj.getAvailablePermits()
+       << ", unackedMessages_ = " << obj.getUnackedMessages()
+       << ", blockedConsumerOnUnackedMsgs_ = " << obj.isBlockedConsumerOnUnackedMsgs()
+       << ", address_ = " << obj.getAddress() << ", connectedSince_ = " << obj.getConnectedSince()
+       << ", type_ = " << obj.getType() << ", msgRateExpired_ = " << obj.getMsgRateExpired()
+       << ", msgBacklog_ = " << obj.getMsgBacklog() << "]";
+    return os;
+}
 
-    double BrokerConsumerStatsImpl::getMsgRateOut() const {
-        return msgRateOut_;
-    }
+double BrokerConsumerStatsImpl::getMsgRateOut() const { return msgRateOut_; }
 
-    double BrokerConsumerStatsImpl::getMsgThroughputOut() const {
-        return msgThroughputOut_;
-    }
+double BrokerConsumerStatsImpl::getMsgThroughputOut() const { return msgThroughputOut_; }
 
-    double BrokerConsumerStatsImpl::getMsgRateRedeliver() const {
-        return msgRateRedeliver_;
-    }
+double BrokerConsumerStatsImpl::getMsgRateRedeliver() const { return msgRateRedeliver_; }
 
-    const std::string BrokerConsumerStatsImpl::getConsumerName() const {
-        return consumerName_;
-    }
+const std::string BrokerConsumerStatsImpl::getConsumerName() const { return consumerName_; }
 
-    uint64_t BrokerConsumerStatsImpl::getAvailablePermits() const {
-        return availablePermits_;
-    }
+uint64_t BrokerConsumerStatsImpl::getAvailablePermits() const { return availablePermits_; }
 
-    uint64_t BrokerConsumerStatsImpl::getUnackedMessages() const {
-        return unackedMessages_;
-    }
+uint64_t BrokerConsumerStatsImpl::getUnackedMessages() const { return unackedMessages_; }
 
-    bool BrokerConsumerStatsImpl::isBlockedConsumerOnUnackedMsgs() const {
-        return blockedConsumerOnUnackedMsgs_;
-    }
+bool BrokerConsumerStatsImpl::isBlockedConsumerOnUnackedMsgs() const { return blockedConsumerOnUnackedMsgs_; }
 
-    const std::string BrokerConsumerStatsImpl::getAddress() const {
-        return address_;
-    }
+const std::string BrokerConsumerStatsImpl::getAddress() const { return address_; }
 
-    const std::string BrokerConsumerStatsImpl::getConnectedSince() const {
-        return connectedSince_;
-    }
+const std::string BrokerConsumerStatsImpl::getConnectedSince() const { return connectedSince_; }
 
-    const ConsumerType BrokerConsumerStatsImpl::getType() const {
-        return type_;
-    }
+const ConsumerType BrokerConsumerStatsImpl::getType() const { return type_; }
 
-    double BrokerConsumerStatsImpl::getMsgRateExpired() const {
-        return msgRateExpired_;
-    }
+double BrokerConsumerStatsImpl::getMsgRateExpired() const { return msgRateExpired_; }
 
-    uint64_t BrokerConsumerStatsImpl::getMsgBacklog() const {
-        return msgBacklog_;
-    }
+uint64_t BrokerConsumerStatsImpl::getMsgBacklog() const { return msgBacklog_; }
 
-    void BrokerConsumerStatsImpl::setCacheTime(uint64_t cacehTimeInMs) {
-        validTill_ = boost::posix_time::microsec_clock::universal_time() + boost::posix_time::milliseconds(cacehTimeInMs);
-    }
+void BrokerConsumerStatsImpl::setCacheTime(uint64_t cacehTimeInMs) {
+    validTill_ =
+        boost::posix_time::microsec_clock::universal_time() + boost::posix_time::milliseconds(cacehTimeInMs);
+}
 
-    ConsumerType BrokerConsumerStatsImpl::convertStringToConsumerType(const std::string& str) {
-        if (str == "ConsumerFailover" || str == "Failover") {
-            return ConsumerFailover;
-        } else if (str == "ConsumerShared" || str == "Shared") {
-            return ConsumerShared;
-        } else {
-            return ConsumerExclusive;
-        }
+ConsumerType BrokerConsumerStatsImpl::convertStringToConsumerType(const std::string& str) {
+    if (str == "ConsumerFailover" || str == "Failover") {
+        return ConsumerFailover;
+    } else if (str == "ConsumerShared" || str == "Shared") {
+        return ConsumerShared;
+    } else {
+        return ConsumerExclusive;
     }
 }
+}  // namespace pulsar
diff --git a/pulsar-client-cpp/lib/BrokerConsumerStatsImpl.h b/pulsar-client-cpp/lib/BrokerConsumerStatsImpl.h
index f680294..731fa3e 100644
--- a/pulsar-client-cpp/lib/BrokerConsumerStatsImpl.h
+++ b/pulsar-client-cpp/lib/BrokerConsumerStatsImpl.h
@@ -29,7 +29,7 @@
 #pragma GCC visibility push(default)
 namespace pulsar {
 class BrokerConsumerStatsImpl : public BrokerConsumerStatsImplBase {
- private:
+   private:
     /** validTill_ - Stats will be valid till this time.*/
     boost::posix_time::ptime validTill_;
 
@@ -69,15 +69,14 @@ class BrokerConsumerStatsImpl : public BrokerConsumerStatsImplBase {
     /** Number of messages in the subscription backlog */
     uint64_t msgBacklog_;
 
-public:
-
+   public:
     BrokerConsumerStatsImpl();
 
     BrokerConsumerStatsImpl(double msgRateOut, double msgThroughputOut, double msgRateRedeliver,
-                            std::string consumerName, uint64_t availablePermits,
-                            uint64_t unackedMessages, bool blockedConsumerOnUnackedMsgs,
-                            std::string address, std::string connectedSince, const std::string& type,
-                            double msgRateExpired, uint64_t msgBacklog);
+                            std::string consumerName, uint64_t availablePermits, uint64_t unackedMessages,
+                            bool blockedConsumerOnUnackedMsgs, std::string address,
+                            std::string connectedSince, const std::string& type, double msgRateExpired,
+                            uint64_t msgBacklog);
 
     /** Returns true if the Stats are still valid **/
     virtual bool isValid() const;
@@ -120,10 +119,10 @@ public:
 
     void setCacheTime(uint64_t cacehTimeInMs);
 
-    friend std::ostream& operator<<(std::ostream &os, const BrokerConsumerStatsImpl &obj);
+    friend std::ostream& operator<<(std::ostream& os, const BrokerConsumerStatsImpl& obj);
 
     static ConsumerType convertStringToConsumerType(const std::string& str);
 };
-}
+}  // namespace pulsar
 #pragma GCC visibility pop
-#endif //PULSAR_CPP_BROKERCONSUMERSTATSIMPL_H
+#endif  // PULSAR_CPP_BROKERCONSUMERSTATSIMPL_H
diff --git a/pulsar-client-cpp/lib/BrokerConsumerStatsImplBase.h b/pulsar-client-cpp/lib/BrokerConsumerStatsImplBase.h
index e09d80f..dce23eb 100644
--- a/pulsar-client-cpp/lib/BrokerConsumerStatsImplBase.h
+++ b/pulsar-client-cpp/lib/BrokerConsumerStatsImplBase.h
@@ -22,48 +22,48 @@
 #include <pulsar/BrokerConsumerStats.h>
 
 namespace pulsar {
-    class BrokerConsumerStatsImplBase {
-    public:
-        /** Returns true if the Stats are still valid **/
-        virtual bool isValid() const = 0;
+class BrokerConsumerStatsImplBase {
+   public:
+    /** Returns true if the Stats are still valid **/
+    virtual bool isValid() const = 0;
 
-        /** Returns the rate of messages delivered to the consumer. msg/s */
-        virtual double getMsgRateOut() const = 0;
+    /** Returns the rate of messages delivered to the consumer. msg/s */
+    virtual double getMsgRateOut() const = 0;
 
-        /** Returns the throughput delivered to the consumer. bytes/s */
-        virtual double getMsgThroughputOut() const = 0;
+    /** Returns the throughput delivered to the consumer. bytes/s */
+    virtual double getMsgThroughputOut() const = 0;
 
-        /** Returns the rate of messages redelivered by this consumer. msg/s */
-        virtual double getMsgRateRedeliver() const = 0;
+    /** Returns the rate of messages redelivered by this consumer. msg/s */
+    virtual double getMsgRateRedeliver() const = 0;
 
-        /** Returns the Name of the consumer */
-        virtual const std::string getConsumerName() const = 0;
+    /** Returns the Name of the consumer */
+    virtual const std::string getConsumerName() const = 0;
 
-        /** Returns the Number of available message permits for the consumer */
-        virtual uint64_t getAvailablePermits() const = 0;
+    /** Returns the Number of available message permits for the consumer */
+    virtual uint64_t getAvailablePermits() const = 0;
 
-        /** Returns the Number of unacknowledged messages for the consumer */
-        virtual uint64_t getUnackedMessages() const = 0;
+    /** Returns the Number of unacknowledged messages for the consumer */
+    virtual uint64_t getUnackedMessages() const = 0;
 
-        /** Returns true if the consumer is blocked due to unacked messages.  */
-        virtual bool isBlockedConsumerOnUnackedMsgs() const = 0;
+    /** Returns true if the consumer is blocked due to unacked messages.  */
+    virtual bool isBlockedConsumerOnUnackedMsgs() const = 0;
 
-        /** Returns the Address of this consumer */
-        virtual const std::string getAddress() const = 0;
+    /** Returns the Address of this consumer */
+    virtual const std::string getAddress() const = 0;
 
-        /** Returns the Timestamp of connection */
-        virtual const std::string getConnectedSince() const = 0;
+    /** Returns the Timestamp of connection */
+    virtual const std::string getConnectedSince() const = 0;
 
-        /** Returns Whether this subscription is Exclusive or Shared or Failover */
-        virtual const ConsumerType getType() const = 0;
+    /** Returns Whether this subscription is Exclusive or Shared or Failover */
+    virtual const ConsumerType getType() const = 0;
 
-        /** Returns the rate of messages expired on this subscription. msg/s */
-        virtual double getMsgRateExpired() const = 0;
+    /** Returns the rate of messages expired on this subscription. msg/s */
+    virtual double getMsgRateExpired() const = 0;
 
-        /** Returns the Number of messages in the subscription backlog */
-        virtual uint64_t getMsgBacklog() const = 0;
-    };
-    typedef boost::shared_ptr<BrokerConsumerStatsImplBase> BrokerConsumerStatsImplBasePtr;
-}
+    /** Returns the Number of messages in the subscription backlog */
+    virtual uint64_t getMsgBacklog() const = 0;
+};
+typedef boost::shared_ptr<BrokerConsumerStatsImplBase> BrokerConsumerStatsImplBasePtr;
+}  // namespace pulsar
 
-#endif //PULSAR_CPP_BROKERCONSUMERSTATSIMPLBASE_H
+#endif  // PULSAR_CPP_BROKERCONSUMERSTATSIMPLBASE_H
diff --git a/pulsar-client-cpp/lib/Client.cc b/pulsar-client-cpp/lib/Client.cc
index 8adf401..5936e48 100644
--- a/pulsar-client-cpp/lib/Client.cc
+++ b/pulsar-client-cpp/lib/Client.cc
@@ -32,21 +32,17 @@ DECLARE_LOG_OBJECT()
 
 namespace pulsar {
 
-Client::Client(const boost::shared_ptr<ClientImpl> impl) : impl_(impl) {
-}
+Client::Client(const boost::shared_ptr<ClientImpl> impl) : impl_(impl) {}
 
 Client::Client(const std::string& serviceUrl)
-        : impl_(boost::make_shared<ClientImpl>(serviceUrl, ClientConfiguration(), true)) {
-}
+    : impl_(boost::make_shared<ClientImpl>(serviceUrl, ClientConfiguration(), true)) {}
 
 Client::Client(const std::string& serviceUrl, const ClientConfiguration& clientConfiguration)
-        : impl_(boost::make_shared<ClientImpl>(serviceUrl, clientConfiguration, true)) {
-}
+    : impl_(boost::make_shared<ClientImpl>(serviceUrl, clientConfiguration, true)) {}
 
 Client::Client(const std::string& serviceUrl, const ClientConfiguration& clientConfiguration,
                bool poolConnections)
-        : impl_(boost::make_shared<ClientImpl>(serviceUrl, clientConfiguration, poolConnections)) {
-}
+    : impl_(boost::make_shared<ClientImpl>(serviceUrl, clientConfiguration, poolConnections)) {}
 
 Result Client::createProducer(const std::string& topic, Producer& producer) {
     return createProducer(topic, ProducerConfiguration(), producer);
@@ -70,8 +66,7 @@ void Client::createProducerAsync(const std::string& topic, ProducerConfiguration
     impl_->createProducerAsync(topic, conf, callback);
 }
 
-Result Client::subscribe(const std::string& topic, const std::string& consumerName,
-                         Consumer& consumer) {
+Result Client::subscribe(const std::string& topic, const std::string& consumerName, Consumer& consumer) {
     return subscribe(topic, consumerName, ConsumerConfiguration(), consumer);
 }
 
@@ -96,7 +91,7 @@ void Client::subscribeAsync(const std::string& topic, const std::string& consume
 }
 
 Result Client::createReader(const std::string& topic, const MessageId& startMessageId,
-        const ReaderConfiguration& conf, Reader& reader) {
+                            const ReaderConfiguration& conf, Reader& reader) {
     Promise<Result, Reader> promise;
     createReaderAsync(topic, startMessageId, conf, WaitForCallbackValue<Reader>(promise));
     Future<Result, Reader> future = promise.getFuture();
@@ -105,7 +100,7 @@ Result Client::createReader(const std::string& topic, const MessageId& startMess
 }
 
 void Client::createReaderAsync(const std::string& topic, const MessageId& startMessageId,
-        const ReaderConfiguration& conf, ReaderCallback callback) {
+                               const ReaderConfiguration& conf, ReaderCallback callback) {
     impl_->createReaderAsync(topic, startMessageId, conf, callback);
 }
 
@@ -118,12 +113,7 @@ Result Client::close() {
     return result;
 }
 
-void Client::closeAsync(CloseCallback callback) {
-    impl_->closeAsync(callback);
-}
-
-void Client::shutdown() {
-    impl_->shutdown();
-}
+void Client::closeAsync(CloseCallback callback) { impl_->closeAsync(callback); }
 
-}
+void Client::shutdown() { impl_->shutdown(); }
+}  // namespace pulsar
diff --git a/pulsar-client-cpp/lib/ClientConfiguration.cc b/pulsar-client-cpp/lib/ClientConfiguration.cc
index d7f30ba..6f011e3 100644
--- a/pulsar-client-cpp/lib/ClientConfiguration.cc
+++ b/pulsar-client-cpp/lib/ClientConfiguration.cc
@@ -20,16 +20,11 @@
 
 namespace pulsar {
 
-ClientConfiguration::ClientConfiguration()
-        : impl_(boost::make_shared<ClientConfigurationImpl>()) {
-}
+ClientConfiguration::ClientConfiguration() : impl_(boost::make_shared<ClientConfigurationImpl>()) {}
 
-ClientConfiguration::~ClientConfiguration() {
-}
+ClientConfiguration::~ClientConfiguration() {}
 
-ClientConfiguration::ClientConfiguration(const ClientConfiguration& x)
-    : impl_(x.impl_) {
-}
+ClientConfiguration::ClientConfiguration(const ClientConfiguration& x) : impl_(x.impl_) {}
 
 ClientConfiguration& ClientConfiguration::operator=(const ClientConfiguration& x) {
     impl_ = x.impl_;
@@ -41,87 +36,68 @@ ClientConfiguration& ClientConfiguration::setAuth(const AuthenticationPtr& authe
     return *this;
 }
 
-const Authentication& ClientConfiguration::getAuth() const {
-    return *impl_->authenticationPtr;
-}
+const Authentication& ClientConfiguration::getAuth() const { return *impl_->authenticationPtr; }
 
-const AuthenticationPtr& ClientConfiguration::getAuthPtr() const {
-    return impl_->authenticationPtr;
-}
+const AuthenticationPtr& ClientConfiguration::getAuthPtr() const { return impl_->authenticationPtr; }
 
 ClientConfiguration& ClientConfiguration::setOperationTimeoutSeconds(int timeout) {
     impl_->operationTimeoutSeconds = timeout;
     return *this;
 }
 
-int ClientConfiguration::getOperationTimeoutSeconds() const {
-    return impl_->operationTimeoutSeconds;
-}
+int ClientConfiguration::getOperationTimeoutSeconds() const { return impl_->operationTimeoutSeconds; }
 
 ClientConfiguration& ClientConfiguration::setIOThreads(int threads) {
     impl_->ioThreads = threads;
     return *this;
 }
 
-int ClientConfiguration::getIOThreads() const {
-    return impl_->ioThreads;
-}
+int ClientConfiguration::getIOThreads() const { return impl_->ioThreads; }
 
 ClientConfiguration& ClientConfiguration::setMessageListenerThreads(int threads) {
     impl_->messageListenerThreads = threads;
     return *this;
 }
 
-int ClientConfiguration::getMessageListenerThreads() const {
-    return impl_->messageListenerThreads;
-}
+int ClientConfiguration::getMessageListenerThreads() const { return impl_->messageListenerThreads; }
 
 ClientConfiguration& ClientConfiguration::setUseTls(bool useTls) {
     impl_->useTls = useTls;
     return *this;
 }
 
-bool ClientConfiguration::isUseTls() const {
-    return impl_->useTls;
-}
+bool ClientConfiguration::isUseTls() const { return impl_->useTls; }
 
-ClientConfiguration& ClientConfiguration::setTlsTrustCertsFilePath(const std::string &filePath) {
+ClientConfiguration& ClientConfiguration::setTlsTrustCertsFilePath(const std::string& filePath) {
     impl_->tlsTrustCertsFilePath = filePath;
     return *this;
 }
 
-std::string ClientConfiguration::getTlsTrustCertsFilePath() const {
-    return impl_->tlsTrustCertsFilePath;
-}
+std::string ClientConfiguration::getTlsTrustCertsFilePath() const { return impl_->tlsTrustCertsFilePath; }
 
 ClientConfiguration& ClientConfiguration::setTlsAllowInsecureConnection(bool allowInsecure) {
     impl_->tlsAllowInsecureConnection = allowInsecure;
     return *this;
 }
 
-bool ClientConfiguration::isTlsAllowInsecureConnection() const {
-    return impl_->tlsAllowInsecureConnection;
-}
+bool ClientConfiguration::isTlsAllowInsecureConnection() const { return impl_->tlsAllowInsecureConnection; }
 
 ClientConfiguration& ClientConfiguration::setConcurrentLookupRequest(int concurrentLookupRequest) {
     impl_->concurrentLookupRequest = concurrentLookupRequest;
     return *this;
 }
 
-int ClientConfiguration::getConcurrentLookupRequest() const {
-    return impl_->concurrentLookupRequest;
-}
+int ClientConfiguration::getConcurrentLookupRequest() const { return impl_->concurrentLookupRequest; }
 
 ClientConfiguration& ClientConfiguration::setLogConfFilePath(const std::string& logConfFilePath) {
     impl_->logConfFilePath = logConfFilePath;
     return *this;
 }
 
-const std::string& ClientConfiguration::getLogConfFilePath() const {
-    return impl_->logConfFilePath;
-}
+const std::string& ClientConfiguration::getLogConfFilePath() const { return impl_->logConfFilePath; }
 
-ClientConfiguration& ClientConfiguration::setStatsIntervalInSeconds(const unsigned int& statsIntervalInSeconds) {
+ClientConfiguration& ClientConfiguration::setStatsIntervalInSeconds(
+    const unsigned int& statsIntervalInSeconds) {
     impl_->statsIntervalInSeconds = statsIntervalInSeconds;
     return *this;
 }
@@ -129,5 +105,4 @@ ClientConfiguration& ClientConfiguration::setStatsIntervalInSeconds(const unsign
 const unsigned int& ClientConfiguration::getStatsIntervalInSeconds() const {
     return impl_->statsIntervalInSeconds;
 }
-
-}
+}  // namespace pulsar
diff --git a/pulsar-client-cpp/lib/ClientConfigurationImpl.h b/pulsar-client-cpp/lib/ClientConfigurationImpl.h
index 40b6a9b..14a5fda 100644
--- a/pulsar-client-cpp/lib/ClientConfigurationImpl.h
+++ b/pulsar-client-cpp/lib/ClientConfigurationImpl.h
@@ -34,17 +34,18 @@ struct ClientConfigurationImpl {
     std::string tlsTrustCertsFilePath;
     bool tlsAllowInsecureConnection;
     unsigned int statsIntervalInSeconds;
-    ClientConfigurationImpl() : authenticationPtr(AuthFactory::Disabled()),
-             ioThreads(1),
-             operationTimeoutSeconds(30),
-             messageListenerThreads(1),
-             concurrentLookupRequest(5000),
-             logConfFilePath(),
-             useTls(false),
-             tlsAllowInsecureConnection(true),
-             statsIntervalInSeconds(600) { // 10 minutes
+    ClientConfigurationImpl()
+        : authenticationPtr(AuthFactory::Disabled()),
+          ioThreads(1),
+          operationTimeoutSeconds(30),
+          messageListenerThreads(1),
+          concurrentLookupRequest(5000),
+          logConfFilePath(),
+          useTls(false),
+          tlsAllowInsecureConnection(true),
+          statsIntervalInSeconds(600) {  // 10 minutes
     }
 };
-}
+}  // namespace pulsar
 
 #endif /* LIB_CLIENTCONFIGURATIONIMPL_H_ */
diff --git a/pulsar-client-cpp/lib/ClientConnection.cc b/pulsar-client-cpp/lib/ClientConnection.cc
index 6b24d75..7e954cd 100644
--- a/pulsar-client-cpp/lib/ClientConnection.cc
+++ b/pulsar-client-cpp/lib/ClientConnection.cc
@@ -81,10 +81,10 @@ static Result getResult(ServerError serverError) {
             return ResultServiceUnitNotReady;
 
         case ProducerBlockedQuotaExceededError:
-        	return ResultProducerBlockedQuotaExceededError;
+            return ResultProducerBlockedQuotaExceededError;
 
         case ProducerBlockedQuotaExceededException:
-        	return ResultProducerBlockedQuotaExceededException;
+            return ResultProducerBlockedQuotaExceededException;
 
         case TopicNotFound:
             return ResultTopicNotFound;
@@ -105,29 +105,30 @@ static Result getResult(ServerError serverError) {
 }
 
 ClientConnection::ClientConnection(const std::string& endpoint, ExecutorServicePtr executor,
-                                   const ClientConfiguration& clientConfiguration, const AuthenticationPtr& authentication)
-: state_(Pending),
-operationsTimeout_(seconds(clientConfiguration.getOperationTimeoutSeconds())),
-authentication_(authentication),
-serverProtocolVersion_(ProtocolVersion_MIN),
-executor_(executor),
-resolver_(executor->createTcpResolver()),
-socket_(executor->createSocket()),
-address_(endpoint),
-cnxString_("[<none> -> " + endpoint + "] "),
-error_(boost::system::error_code()),
-incomingBuffer_(SharedBuffer::allocate(DefaultBufferSize)),
-incomingCmd_(),
-pendingWriteBuffers_(),
-pendingWriteOperations_(0),
-outgoingBuffer_(SharedBuffer::allocate(DefaultBufferSize)),
-outgoingCmd_(),
-havePendingPingRequest_(false),
-keepAliveTimer_(),
-maxPendingLookupRequest_(clientConfiguration.getConcurrentLookupRequest()),
-consumerStatsRequestTimer_(executor_->createDeadlineTimer()),
-numOfPendingLookupRequest_(0),
-isTlsAllowInsecureConnection_(false) {
+                                   const ClientConfiguration& clientConfiguration,
+                                   const AuthenticationPtr& authentication)
+    : state_(Pending),
+      operationsTimeout_(seconds(clientConfiguration.getOperationTimeoutSeconds())),
+      authentication_(authentication),
+      serverProtocolVersion_(ProtocolVersion_MIN),
+      executor_(executor),
+      resolver_(executor->createTcpResolver()),
+      socket_(executor->createSocket()),
+      address_(endpoint),
+      cnxString_("[<none> -> " + endpoint + "] "),
+      error_(boost::system::error_code()),
+      incomingBuffer_(SharedBuffer::allocate(DefaultBufferSize)),
+      incomingCmd_(),
+      pendingWriteBuffers_(),
+      pendingWriteOperations_(0),
+      outgoingBuffer_(SharedBuffer::allocate(DefaultBufferSize)),
+      outgoingCmd_(),
+      havePendingPingRequest_(false),
+      keepAliveTimer_(),
+      maxPendingLookupRequest_(clientConfiguration.getConcurrentLookupRequest()),
+      consumerStatsRequestTimer_(executor_->createDeadlineTimer()),
+      numOfPendingLookupRequest_(0),
+      isTlsAllowInsecureConnection_(false) {
     if (clientConfiguration.isUseTls()) {
         using namespace boost::filesystem;
 
@@ -152,7 +153,7 @@ isTlsAllowInsecureConnection_(false) {
         }
 
         AuthenticationDataPtr authData;
-        if (authentication_->getAuthData(authData) == ResultOk && authData->hasDataForTls()){
+        if (authentication_->getAuthData(authData) == ResultOk && authData->hasDataForTls()) {
             std::string tlsCertificates = authData->getTlsCertificates();
             std::string tlsPrivateKey = authData->getTlsPrivateKey();
 
@@ -177,9 +178,7 @@ isTlsAllowInsecureConnection_(false) {
     }
 }
 
-ClientConnection::~ClientConnection() {
-    LOG_INFO(cnxString_ << "Destroyed connection");
-}
+ClientConnection::~ClientConnection() { LOG_INFO(cnxString_ << "Destroyed connection"); }
 
 void ClientConnection::handlePulsarConnected(const CommandConnected& cmdConnected) {
     if (!cmdConnected.has_server_version()) {
@@ -197,7 +196,7 @@ void ClientConnection::handlePulsarConnected(const CommandConnected& cmdConnecte
         keepAliveTimer_ = executor_->createDeadlineTimer();
         keepAliveTimer_->expires_from_now(boost::posix_time::seconds(KeepAliveIntervalInSeconds));
         keepAliveTimer_->async_wait(
-                boost::bind(&ClientConnection::handleKeepAliveTimeout, shared_from_this()));
+            boost::bind(&ClientConnection::handleKeepAliveTimeout, shared_from_this()));
     }
 
     if (serverProtocolVersion_ >= v8) {
@@ -212,7 +211,8 @@ void ClientConnection::startConsumerStatsTimer(std::vector<uint64_t> consumerSta
     for (int i = 0; i < consumerStatsRequests.size(); i++) {
         PendingConsumerStatsMap::iterator it = pendingConsumerStatsMap_.find(consumerStatsRequests[i]);
         if (it != pendingConsumerStatsMap_.end()) {
-            LOG_DEBUG(cnxString_ << " removing request_id " << it->first << " from the pendingConsumerStatsMap_");
+            LOG_DEBUG(cnxString_ << " removing request_id " << it->first
+                                 << " from the pendingConsumerStatsMap_");
             consumerStatsPromises.push_back(it->second);
             pendingConsumerStatsMap_.erase(it);
         } else {
@@ -226,9 +226,9 @@ void ClientConnection::startConsumerStatsTimer(std::vector<uint64_t> consumerSta
         consumerStatsRequests.push_back(it->first);
     }
     consumerStatsRequestTimer_->expires_from_now(operationsTimeout_);
-    consumerStatsRequestTimer_->async_wait(
-            boost::bind(&ClientConnection::handleConsumerStatsTimeout, shared_from_this(),
-                        boost::asio::placeholders::error, consumerStatsRequests));
+    consumerStatsRequestTimer_->async_wait(boost::bind(&ClientConnection::handleConsumerStatsTimeout,
+                                                       shared_from_this(), boost::asio::placeholders::error,
+                                                       consumerStatsRequests));
     lock.unlock();
     // Complex logic since promises need to be fulfilled outside the lock
     for (int i = 0; i < consumerStatsPromises.size(); i++) {
@@ -237,18 +237,21 @@ void ClientConnection::startConsumerStatsTimer(std::vector<uint64_t> consumerSta
     }
 }
 
-/// The number of unacknowledged probes to send before considering the connection dead and notifying the application layer
+/// The number of unacknowledged probes to send before considering the connection dead and notifying the
+/// application layer
 typedef boost::asio::detail::socket_option::integer<IPPROTO_TCP, TCP_KEEPCNT> tcp_keep_alive_count;
 
-/// The interval between subsequential keepalive probes, regardless of what the connection has exchanged in the meantime
+/// The interval between subsequential keepalive probes, regardless of what the connection has exchanged in
+/// the meantime
 typedef boost::asio::detail::socket_option::integer<IPPROTO_TCP, TCP_KEEPINTVL> tcp_keep_alive_interval;
 
-/// The interval between the last data packet sent (simple ACKs are not considered data) and the first keepalive
+/// The interval between the last data packet sent (simple ACKs are not considered data) and the first
+/// keepalive
 /// probe; after the connection is marked to need keepalive, this counter is not used any further
 #ifdef __APPLE__
-  typedef boost::asio::detail::socket_option::integer<IPPROTO_TCP, TCP_KEEPALIVE> tcp_keep_alive_idle;
+typedef boost::asio::detail::socket_option::integer<IPPROTO_TCP, TCP_KEEPALIVE> tcp_keep_alive_idle;
 #else
-  typedef boost::asio::detail::socket_option::integer<IPPROTO_TCP, TCP_KEEPIDLE> tcp_keep_alive_idle;
+typedef boost::asio::detail::socket_option::integer<IPPROTO_TCP, TCP_KEEPIDLE> tcp_keep_alive_idle;
 #endif
 
 /*
@@ -291,7 +294,9 @@ void ClientConnection::handleTcpConnected(const boost::system::error_code& err,
                     return;
                 }
             }
-            tlsSocket_->async_handshake(boost::asio::ssl::stream<tcp::socket>::client, boost::bind(&ClientConnection::handleHandshake, shared_from_this(), boost::asio::placeholders::error));
+            tlsSocket_->async_handshake(boost::asio::ssl::stream<tcp::socket>::client,
+                                        boost::bind(&ClientConnection::handleHandshake, shared_from_this(),
+                                                    boost::asio::placeholders::error));
         } else {
             handleHandshake(boost::system::errc::make_error_code(boost::system::errc::success));
         }
@@ -299,37 +304,33 @@ void ClientConnection::handleTcpConnected(const boost::system::error_code& err,
         // The connection failed. Try the next endpoint in the list.
         socket_->close();
         tcp::endpoint endpoint = *endpointIterator;
-        socket_->async_connect(
-                endpoint,
-                boost::bind(&ClientConnection::handleTcpConnected, shared_from_this(),
-                            boost::asio::placeholders::error, ++endpointIterator));
+        socket_->async_connect(endpoint,
+                               boost::bind(&ClientConnection::handleTcpConnected, shared_from_this(),
+                                           boost::asio::placeholders::error, ++endpointIterator));
     } else {
         LOG_ERROR(cnxString_ << "Failed to establish connection: " << err.message());
         close();
         return;
-
     }
-
 }
 
 void ClientConnection::handleHandshake(const boost::system::error_code& err) {
-        SharedBuffer buffer = Commands::newConnect(authentication_);
-        // Send CONNECT command to broker
-        asyncWrite(
-                buffer.const_asio_buffer(),
-                boost::bind(&ClientConnection::handleSentPulsarConnect, shared_from_this(),
-                            boost::asio::placeholders::error, buffer));
+    SharedBuffer buffer = Commands::newConnect(authentication_);
+    // Send CONNECT command to broker
+    asyncWrite(buffer.const_asio_buffer(),
+               boost::bind(&ClientConnection::handleSentPulsarConnect, shared_from_this(),
+                           boost::asio::placeholders::error, buffer));
 }
 
 void ClientConnection::handleSentPulsarConnect(const boost::system::error_code& err,
-                                            const SharedBuffer& buffer) {
+                                               const SharedBuffer& buffer) {
     if (err) {
         LOG_ERROR(cnxString_ << "Failed to establish connection: " << err.message());
         close();
         return;
     }
 
-// Schedule the reading of CONNECTED command from broker
+    // Schedule the reading of CONNECTED command from broker
     readNextCommand();
 }
 
@@ -349,18 +350,17 @@ void ClientConnection::tcpConnectAsync() {
     }
 
     if (service_url.protocol() != "pulsar" && service_url.protocol() != "pulsar+ssl") {
-        LOG_ERROR(cnxString_ << "Invalid Url protocol '" <<  service_url.protocol() << "'. Valid values are 'pulsar' and 'pulsar+ssl'");
+        LOG_ERROR(cnxString_ << "Invalid Url protocol '" << service_url.protocol()
+                             << "'. Valid values are 'pulsar' and 'pulsar+ssl'");
         close();
         return;
     }
 
     LOG_DEBUG(cnxString_ << "Connecting to " << service_url.host() << ":" << service_url.port());
-    tcp::resolver::query query(service_url.host(),
-                               boost::lexical_cast<std::string>(service_url.port()));
+    tcp::resolver::query query(service_url.host(), boost::lexical_cast<std::string>(service_url.port()));
     resolver_->async_resolve(
-            query,
-            boost::bind(&ClientConnection::handleResolve, shared_from_this(),
-                        boost::asio::placeholders::error, boost::asio::placeholders::iterator));
+        query, boost::bind(&ClientConnection::handleResolve, shared_from_this(),
+                           boost::asio::placeholders::error, boost::asio::placeholders::iterator));
 }
 
 void ClientConnection::handleResolve(const boost::system::error_code& err,
@@ -373,11 +373,10 @@ void ClientConnection::handleResolve(const boost::system::error_code& err,
 
     if (endpointIterator != tcp::resolver::iterator()) {
         LOG_DEBUG(cnxString_ << "Resolved hostname " << endpointIterator->host_name()  //
-                << " to " << endpointIterator->endpoint());
-        socket_->async_connect(
-                *endpointIterator++,
-                boost::bind(&ClientConnection::handleTcpConnected, shared_from_this(),
-                            boost::asio::placeholders::error, endpointIterator));
+                             << " to " << endpointIterator->endpoint());
+        socket_->async_connect(*endpointIterator++,
+                               boost::bind(&ClientConnection::handleTcpConnected, shared_from_this(),
+                                           boost::asio::placeholders::error, endpointIterator));
     } else {
         LOG_WARN(cnxString_ << "No IP address found");
         close();
@@ -387,11 +386,9 @@ void ClientConnection::handleResolve(const boost::system::error_code& err,
 
 void ClientConnection::readNextCommand() {
     const static uint32_t minReadSize = sizeof(uint32_t);
-    asyncReceive(
-            incomingBuffer_.asio_buffer(),
-            customAllocReadHandler(
-                    boost::bind(&ClientConnection::handleRead, shared_from_this(), _1, _2,
-                                minReadSize)));
+    asyncReceive(incomingBuffer_.asio_buffer(),
+                 customAllocReadHandler(
+                     boost::bind(&ClientConnection::handleRead, shared_from_this(), _1, _2, minReadSize)));
 }
 
 void ClientConnection::handleRead(const boost::system::error_code& err, size_t bytesTransferred,
@@ -405,11 +402,9 @@ void ClientConnection::handleRead(const boost::system::error_code& err, size_t b
         // Read the remaining part, use a slice of buffer to write on the next
         // region
         SharedBuffer buffer = incomingBuffer_.slice(bytesTransferred);
-        asyncReceive(
-                buffer.asio_buffer(),
-                customAllocReadHandler(
-                        boost::bind(&ClientConnection::handleRead, shared_from_this(), _1, _2,
-                                    minReadSize - bytesTransferred)));
+        asyncReceive(buffer.asio_buffer(),
+                     customAllocReadHandler(boost::bind(&ClientConnection::handleRead, shared_from_this(), _1,
+                                                        _2, minReadSize - bytesTransferred)));
     } else {
         processIncomingBuffer();
     }
@@ -418,7 +413,6 @@ void ClientConnection::handleRead(const boost::system::error_code& err, size_t b
 void ClientConnection::processIncomingBuffer() {
     // Process all the available frames from the incoming buffer
     while (incomingBuffer_.readableBytes() >= sizeof(uint32_t)) {
-
         // Extract message frames from incoming buffer
         // At this point we have at least 4 bytes in the buffer
         uint32_t frameSize = incomingBuffer_.readUnsignedInt();
@@ -433,23 +427,18 @@ void ClientConnection::processIncomingBuffer() {
 
             if (bytesToReceive <= incomingBuffer_.writableBytes()) {
                 // The rest of the frame still fits in the current buffer
-                asyncReceive(
-                        incomingBuffer_.asio_buffer(),
-                        customAllocReadHandler(
-                                boost::bind(&ClientConnection::handleRead, shared_from_this(), _1,
-                                            _2, bytesToReceive)));
+                asyncReceive(incomingBuffer_.asio_buffer(),
+                             customAllocReadHandler(boost::bind(&ClientConnection::handleRead,
+                                                                shared_from_this(), _1, _2, bytesToReceive)));
                 return;
             } else {
                 // Need to allocate a buffer big enough for the frame
-                uint32_t newBufferSize = std::max<uint32_t>(DefaultBufferSize,
-                                                            frameSize + sizeof(uint32_t));
+                uint32_t newBufferSize = std::max<uint32_t>(DefaultBufferSize, frameSize + sizeof(uint32_t));
                 incomingBuffer_ = SharedBuffer::copyFrom(incomingBuffer_, newBufferSize);
 
-                asyncReceive(
-                        incomingBuffer_.asio_buffer(),
-                        customAllocReadHandler(
-                                boost::bind(&ClientConnection::handleRead, shared_from_this(), _1,
-                                            _2, bytesToReceive)));
+                asyncReceive(incomingBuffer_.asio_buffer(),
+                             customAllocReadHandler(boost::bind(&ClientConnection::handleRead,
+                                                                shared_from_this(), _1, _2, bytesToReceive)));
                 return;
             }
         }
@@ -468,14 +457,16 @@ void ClientConnection::processIncomingBuffer() {
             // Parse message metadata and extract payload
             MessageMetadata msgMetadata;
 
-            //read checksum
+            // read checksum
             bool isChecksumValid = verifyChecksum(incomingBuffer_, incomingCmd_);
 
             uint32_t metadataSize = incomingBuffer_.readUnsignedInt();
             if (!msgMetadata.ParseFromArray(incomingBuffer_.data(), metadataSize)) {
                 LOG_ERROR(cnxString_ << "[consumer id " << incomingCmd_.message().consumer_id()  //
-                        << ", message ledger id " << incomingCmd_.message().message_id().ledgerid() //
-                        << ", entry id " << incomingCmd_.message().message_id().entryid() << "] Error parsing message metadata");
+                                     << ", message ledger id "
+                                     << incomingCmd_.message().message_id().ledgerid()  //
+                                     << ", entry id " << incomingCmd_.message().message_id().entryid()
+                                     << "] Error parsing message metadata");
                 close();
                 return;
             }
@@ -501,11 +492,9 @@ void ClientConnection::processIncomingBuffer() {
         // At least we need to read 4 bytes to have the complete frame size
         uint32_t minReadSize = sizeof(uint32_t) - incomingBuffer_.readableBytes();
 
-        asyncReceive(
-                incomingBuffer_.asio_buffer(),
-                customAllocReadHandler(
-                        boost::bind(&ClientConnection::handleRead, shared_from_this(), _1, _2,
-                                    minReadSize)));
+        asyncReceive(incomingBuffer_.asio_buffer(),
+                     customAllocReadHandler(boost::bind(&ClientConnection::handleRead, shared_from_this(), _1,
+                                                        _2, minReadSize)));
         return;
     }
 
@@ -528,11 +517,12 @@ bool ClientConnection::verifyChecksum(SharedBuffer& incomingBuffer_, proto::Base
         isChecksumValid = (storedChecksum == computedChecksum);
 
         if (!isChecksumValid) {
-            LOG_ERROR("[consumer id " << incomingCmd_.message().consumer_id()  //
-                    << ", message ledger id " << incomingCmd_.message().message_id().ledgerid()//
-                    << ", entry id " << incomingCmd_.message().message_id().entryid()//
-                    << "stored-checksum" << storedChecksum << "computedChecksum" << computedChecksum//
-                    << "] Checksum verification failed");
+            LOG_ERROR("[consumer id "
+                      << incomingCmd_.message().consumer_id()                                           //
+                      << ", message ledger id " << incomingCmd_.message().message_id().ledgerid()       //
+                      << ", entry id " << incomingCmd_.message().message_id().entryid()                 //
+                      << "stored-checksum" << storedChecksum << "computedChecksum" << computedChecksum  //
+                      << "] Checksum verification failed");
         }
     } else {
         incomingBuffer_.setReaderIndex(readerIndex);
@@ -541,8 +531,7 @@ bool ClientConnection::verifyChecksum(SharedBuffer& incomingBuffer_, proto::Base
 }
 
 void ClientConnection::handleIncomingMessage(const proto::CommandMessage& msg, bool isChecksumValid,
-                                             proto::MessageMetadata& msgMetadata,
-                                             SharedBuffer& payload) {
+                                             proto::MessageMetadata& msgMetadata, SharedBuffer& payload) {
     LOG_DEBUG(cnxString_ << "Received a message from the server for consumer: " << msg.consumer_id());
 
     Lock lock(mutex_);
@@ -557,18 +546,17 @@ void ClientConnection::handleIncomingMessage(const proto::CommandMessage& msg, b
             consumer->messageReceived(shared_from_this(), msg, isChecksumValid, msgMetadata, payload);
         } else {
             consumers_.erase(msg.consumer_id());
-            LOG_DEBUG(
-                    cnxString_ << "Ignoring incoming message for already destroyed consumer " << msg.consumer_id());
+            LOG_DEBUG(cnxString_ << "Ignoring incoming message for already destroyed consumer "
+                                 << msg.consumer_id());
         }
     } else {
-        LOG_DEBUG(cnxString_ << "Got invalid consumer Id in "            //
-                << msg.consumer_id() << " -- msg: "<< msgMetadata.sequence_id());
+        LOG_DEBUG(cnxString_ << "Got invalid consumer Id in "  //
+                             << msg.consumer_id() << " -- msg: " << msgMetadata.sequence_id());
     }
 }
 
 void ClientConnection::handleIncomingCommand() {
-    LOG_DEBUG(
-            cnxString_ << "Handling incoming command: " << Commands::messageType(incomingCmd_.type()));
+    LOG_DEBUG(cnxString_ << "Handling incoming command: " << Commands::messageType(incomingCmd_.type()));
 
     switch (state_) {
         case Pending: {
@@ -600,8 +588,8 @@ void ClientConnection::handleIncomingCommand() {
                     int producerId = sendReceipt.producer_id();
                     uint64_t sequenceId = sendReceipt.sequence_id();
 
-                    LOG_DEBUG(
-                            cnxString_ << "Got receipt for producer: " << producerId << " -- msg: "<< sequenceId);
+                    LOG_DEBUG(cnxString_ << "Got receipt for producer: " << producerId
+                                         << " -- msg: " << sequenceId);
 
                     Lock lock(mutex_);
                     ProducersMap::iterator it = producers_.find(producerId);
@@ -611,13 +599,14 @@ void ClientConnection::handleIncomingCommand() {
 
                         if (producer) {
                             if (!producer->ackReceived(sequenceId)) {
-                                // If the producer fails to process the ack, we need to close the connection to give it a chance to recover from there
+                                // If the producer fails to process the ack, we need to close the connection
+                                // to give it a chance to recover from there
                                 close();
                             }
                         }
                     } else {
                         LOG_ERROR(cnxString_ << "Got invalid producer Id in SendReceipt: "  //
-                                << producerId << " -- msg: "<< sequenceId);
+                                             << producerId << " -- msg: " << sequenceId);
                     }
 
                     break;
@@ -637,7 +626,8 @@ void ClientConnection::handleIncomingCommand() {
 
                             if (producer) {
                                 if (!producer->removeCorruptMessage(sequenceId)) {
-                                    // If the producer fails to remove corrupt msg, we need to close the connection to give it a chance to recover from there
+                                    // If the producer fails to remove corrupt msg, we need to close the
+                                    // connection to give it a chance to recover from there
                                     close();
                                 }
                             }
@@ -650,8 +640,8 @@ void ClientConnection::handleIncomingCommand() {
 
                 case BaseCommand::SUCCESS: {
                     const CommandSuccess& success = incomingCmd_.success();
-                    LOG_DEBUG(
-                            cnxString_ << "Received success response from server. req_id: " << success.request_id());
+                    LOG_DEBUG(cnxString_ << "Received success response from server. req_id: "
+                                         << success.request_id());
 
                     Lock lock(mutex_);
                     PendingRequestsMap::iterator it = pendingRequests_.find(success.request_id());
@@ -668,53 +658,54 @@ void ClientConnection::handleIncomingCommand() {
 
                 case BaseCommand::PARTITIONED_METADATA_RESPONSE: {
                     const CommandPartitionedTopicMetadataResponse& partitionMetadataResponse =
-                            incomingCmd_.partitionmetadataresponse();
-                    LOG_DEBUG(
-                            cnxString_ << "Received partition-metadata response from server. req_id: " << partitionMetadataResponse.request_id());
+                        incomingCmd_.partitionmetadataresponse();
+                    LOG_DEBUG(cnxString_ << "Received partition-metadata response from server. req_id: "
+                                         << partitionMetadataResponse.request_id());
 
                     Lock lock(mutex_);
-                    PendingLookupRequestsMap::iterator it = pendingLookupRequests_.find(
-                            partitionMetadataResponse.request_id());
+                    PendingLookupRequestsMap::iterator it =
+                        pendingLookupRequests_.find(partitionMetadataResponse.request_id());
                     if (it != pendingLookupRequests_.end()) {
                         LookupDataResultPromisePtr lookupDataPromise = it->second;
                         pendingLookupRequests_.erase(it);
                         numOfPendingLookupRequest_--;
                         lock.unlock();
 
-                        if (!partitionMetadataResponse.has_response()
-                                || (partitionMetadataResponse.response()
-                                        == CommandPartitionedTopicMetadataResponse::Failed)) {
+                        if (!partitionMetadataResponse.has_response() ||
+                            (partitionMetadataResponse.response() ==
+                             CommandPartitionedTopicMetadataResponse::Failed)) {
                             if (partitionMetadataResponse.has_error()) {
-                                LOG_ERROR(
-                                        cnxString_ << "Failed partition-metadata lookup req_id: " << partitionMetadataResponse.request_id() << " error: " << partitionMetadataResponse.error());
+                                LOG_ERROR(cnxString_ << "Failed partition-metadata lookup req_id: "
+                                                     << partitionMetadataResponse.request_id()
+                                                     << " error: " << partitionMetadataResponse.error());
                             } else {
-                                LOG_ERROR(
-                                        cnxString_ << "Failed partition-metadata lookup req_id: " << partitionMetadataResponse.request_id() << " with empty response: ");
+                                LOG_ERROR(cnxString_ << "Failed partition-metadata lookup req_id: "
+                                                     << partitionMetadataResponse.request_id()
+                                                     << " with empty response: ");
                             }
                             lookupDataPromise->setFailed(ResultConnectError);
                         } else {
-                            LookupDataResultPtr lookupResultPtr = boost::make_shared<
-                                    LookupDataResult>();
+                            LookupDataResultPtr lookupResultPtr = boost::make_shared<LookupDataResult>();
                             lookupResultPtr->setPartitions(partitionMetadataResponse.partitions());
                             lookupDataPromise->setValue(lookupResultPtr);
                         }
 
                     } else {
-                        LOG_WARN(
-                                "Received unknown request id from server: " << partitionMetadataResponse.request_id());
+                        LOG_WARN("Received unknown request id from server: "
+                                 << partitionMetadataResponse.request_id());
                     }
                     break;
                 }
 
                 case BaseCommand::CONSUMER_STATS_RESPONSE: {
-                    const CommandConsumerStatsResponse& consumerStatsResponse = incomingCmd_.consumerstatsresponse();
-                    LOG_DEBUG(
-                            cnxString_
-                                    << "ConsumerStatsResponse command - Received consumer stats response from server. req_id: "
-                                    << consumerStatsResponse.request_id());
+                    const CommandConsumerStatsResponse& consumerStatsResponse =
+                        incomingCmd_.consumerstatsresponse();
+                    LOG_DEBUG(cnxString_ << "ConsumerStatsResponse command - Received consumer stats "
+                                            "response from server. req_id: "
+                                         << consumerStatsResponse.request_id());
                     Lock lock(mutex_);
-                    PendingConsumerStatsMap::iterator it = pendingConsumerStatsMap_.find(
-                            consumerStatsResponse.request_id());
+                    PendingConsumerStatsMap::iterator it =
+                        pendingConsumerStatsMap_.find(consumerStatsResponse.request_id());
                     if (it != pendingConsumerStatsMap_.end()) {
                         Promise<Result, BrokerConsumerStatsImpl> consumerStatsPromise = it->second;
                         pendingConsumerStatsMap_.erase(it);
@@ -727,66 +718,65 @@ void ClientConnection::handleIncomingCommand() {
                             }
                             consumerStatsPromise.setFailed(getResult(consumerStatsResponse.error_code()));
                         } else {
-                            LOG_DEBUG(
-                                    cnxString_
-                                            << "ConsumerStatsResponse command - Received consumer stats response from server. req_id: "
-                                            << consumerStatsResponse.request_id() << " Stats: ");
-                            BrokerConsumerStatsImpl brokerStats(consumerStatsResponse.msgrateout(),
-                                                            consumerStatsResponse.msgthroughputout(),
-                                                            consumerStatsResponse.msgrateredeliver(),
-                                                            consumerStatsResponse.consumername(),
-                                                            consumerStatsResponse.availablepermits(),
-                                                            consumerStatsResponse.unackedmessages(),
-                                                            consumerStatsResponse.blockedconsumeronunackedmsgs(),
-                                                            consumerStatsResponse.address(),
-                                                            consumerStatsResponse.connectedsince(),
-                                                            consumerStatsResponse.type(),
-                                                            consumerStatsResponse.msgrateexpired(),
-                                                            consumerStatsResponse.msgbacklog());
+                            LOG_DEBUG(cnxString_ << "ConsumerStatsResponse command - Received consumer stats "
+                                                    "response from server. req_id: "
+                                                 << consumerStatsResponse.request_id() << " Stats: ");
+                            BrokerConsumerStatsImpl brokerStats(
+                                consumerStatsResponse.msgrateout(), consumerStatsResponse.msgthroughputout(),
+                                consumerStatsResponse.msgrateredeliver(),
+                                consumerStatsResponse.consumername(),
+                                consumerStatsResponse.availablepermits(),
+                                consumerStatsResponse.unackedmessages(),
+                                consumerStatsResponse.blockedconsumeronunackedmsgs(),
+                                consumerStatsResponse.address(), consumerStatsResponse.connectedsince(),
+                                consumerStatsResponse.type(), consumerStatsResponse.msgrateexpired(),
+                                consumerStatsResponse.msgbacklog());
                             consumerStatsPromise.setValue(brokerStats);
                         }
                     } else {
-                        LOG_WARN(
-                                "ConsumerStatsResponse command - Received unknown request id from server: "
-                                        << consumerStatsResponse.request_id());
+                        LOG_WARN("ConsumerStatsResponse command - Received unknown request id from server: "
+                                 << consumerStatsResponse.request_id());
                     }
                     break;
-
                 }
 
                 case BaseCommand::LOOKUP_RESPONSE: {
-                    const CommandLookupTopicResponse& lookupTopicResponse = incomingCmd_.lookuptopicresponse();
-                    LOG_DEBUG(
-                            cnxString_ << "Received lookup response from server. req_id: " << lookupTopicResponse.request_id());
+                    const CommandLookupTopicResponse& lookupTopicResponse =
+                        incomingCmd_.lookuptopicresponse();
+                    LOG_DEBUG(cnxString_ << "Received lookup response from server. req_id: "
+                                         << lookupTopicResponse.request_id());
 
                     Lock lock(mutex_);
-                    PendingLookupRequestsMap::iterator it = pendingLookupRequests_.find(
-                            lookupTopicResponse.request_id());
+                    PendingLookupRequestsMap::iterator it =
+                        pendingLookupRequests_.find(lookupTopicResponse.request_id());
                     if (it != pendingLookupRequests_.end()) {
                         LookupDataResultPromisePtr lookupDataPromise = it->second;
                         pendingLookupRequests_.erase(it);
                         numOfPendingLookupRequest_--;
                         lock.unlock();
 
-                        if (!lookupTopicResponse.has_response()
-                                || (lookupTopicResponse.response()
-                                        == CommandLookupTopicResponse::Failed)) {
+                        if (!lookupTopicResponse.has_response() ||
+                            (lookupTopicResponse.response() == CommandLookupTopicResponse::Failed)) {
                             if (lookupTopicResponse.has_error()) {
-                                LOG_ERROR(
-                                        cnxString_ << "Failed lookup req_id: " << lookupTopicResponse.request_id() << " error: " << lookupTopicResponse.error());
+                                LOG_ERROR(cnxString_
+                                          << "Failed lookup req_id: " << lookupTopicResponse.request_id()
+                                          << " error: " << lookupTopicResponse.error());
                             } else {
-                                LOG_ERROR(
-                                        cnxString_ << "Failed lookup req_id: " << lookupTopicResponse.request_id() << " with empty response: ");
+                                LOG_ERROR(cnxString_
+                                          << "Failed lookup req_id: " << lookupTopicResponse.request_id()
+                                          << " with empty response: ");
                             }
-                            lookupDataPromise -> setFailed(ResultConnectError);
+                            lookupDataPromise->setFailed(ResultConnectError);
                         } else {
-                            LOG_DEBUG(
-                                    cnxString_ << "Received lookup response from server. req_id: " << lookupTopicResponse.request_id()  //
-                                    << " -- broker-url: " << lookupTopicResponse.brokerserviceurl() << " -- broker-tls-url: "//
-                                    << lookupTopicResponse.brokerserviceurltls() << " authoritative: " << lookupTopicResponse.authoritative()//
-                                    << " redirect: " << lookupTopicResponse.response());
-                            LookupDataResultPtr lookupResultPtr =
-                                                            boost::make_shared<LookupDataResult>();
+                            LOG_DEBUG(cnxString_
+                                      << "Received lookup response from server. req_id: "
+                                      << lookupTopicResponse.request_id()  //
+                                      << " -- broker-url: " << lookupTopicResponse.brokerserviceurl()
+                                      << " -- broker-tls-url: "  //
+                                      << lookupTopicResponse.brokerserviceurltls()
+                                      << " authoritative: " << lookupTopicResponse.authoritative()  //
+                                      << " redirect: " << lookupTopicResponse.response());
+                            LookupDataResultPtr lookupResultPtr = boost::make_shared<LookupDataResult>();
 
                             if (tlsSocket_) {
                                 lookupResultPtr->setBrokerUrl(lookupTopicResponse.brokerserviceurltls());
@@ -794,39 +784,35 @@ void ClientConnection::handleIncomingCommand() {
                                 lookupResultPtr->setBrokerUrl(lookupTopicResponse.brokerserviceurl());
                             }
 
-                            lookupResultPtr->setBrokerUrlSsl(
-                                    lookupTopicResponse.brokerserviceurltls());
+                            lookupResultPtr->setBrokerUrlSsl(lookupTopicResponse.brokerserviceurltls());
                             lookupResultPtr->setAuthoritative(lookupTopicResponse.authoritative());
-                            lookupResultPtr->setRedirect(
-                                    lookupTopicResponse.response()
-                                            == CommandLookupTopicResponse::Redirect);
+                            lookupResultPtr->setRedirect(lookupTopicResponse.response() ==
+                                                         CommandLookupTopicResponse::Redirect);
                             lookupDataPromise->setValue(lookupResultPtr);
                         }
 
                     } else {
                         LOG_WARN(
-                                "Received unknown request id from server: " << lookupTopicResponse.request_id());
+                            "Received unknown request id from server: " << lookupTopicResponse.request_id());
                     }
                     break;
                 }
 
-
                 case BaseCommand::PRODUCER_SUCCESS: {
                     const CommandProducerSuccess& producerSuccess = incomingCmd_.producer_success();
-                    LOG_DEBUG(
-                            cnxString_ << "Received success producer response from server. req_id: " << producerSuccess.request_id()  //
-                            << " -- producer name: " << producerSuccess.producer_name());
+                    LOG_DEBUG(cnxString_ << "Received success producer response from server. req_id: "
+                                         << producerSuccess.request_id()  //
+                                         << " -- producer name: " << producerSuccess.producer_name());
 
                     Lock lock(mutex_);
-                    PendingRequestsMap::iterator it = pendingRequests_.find(
-                            producerSuccess.request_id());
+                    PendingRequestsMap::iterator it = pendingRequests_.find(producerSuccess.request_id());
                     if (it != pendingRequests_.end()) {
                         PendingRequestData requestData = it->second;
                         pendingRequests_.erase(it);
                         lock.unlock();
 
                         requestData.promise.setValue(
-                                { producerSuccess.producer_name(), producerSuccess.last_sequence_id() });
+                            {producerSuccess.producer_name(), producerSuccess.last_sequence_id()});
                         requestData.timer->cancel();
                     }
                     break;
@@ -835,8 +821,8 @@ void ClientConnection::handleIncomingCommand() {
                 case BaseCommand::ERROR: {
                     const CommandError& error = incomingCmd_.error();
                     Result result = getResult(error.error());
-                    LOG_WARN(
-                            cnxString_ << "Received error response from server: " << result << " -- req_id: "<< error.request_id());
+                    LOG_WARN(cnxString_ << "Received error response from server: " << result
+                                        << " -- req_id: " << error.request_id());
 
                     Lock lock(mutex_);
                     PendingRequestsMap::iterator it = pendingRequests_.find(error.request_id());
@@ -870,8 +856,8 @@ void ClientConnection::handleIncomingCommand() {
                             producer->disconnectProducer();
                         }
                     } else {
-                        LOG_ERROR(
-                                cnxString_ << "Got invalid producer Id in closeProducer command: "<< producerId);
+                        LOG_ERROR(cnxString_ << "Got invalid producer Id in closeProducer command: "
+                                             << producerId);
                     }
 
                     break;
@@ -894,8 +880,8 @@ void ClientConnection::handleIncomingCommand() {
                             consumer->disconnectConsumer();
                         }
                     } else {
-                        LOG_ERROR(
-                                cnxString_ << "Got invalid consumer Id in closeConsumer command: "<< consumerId);
+                        LOG_ERROR(cnxString_ << "Got invalid consumer Id in closeConsumer command: "
+                                             << consumerId);
                     }
 
                     break;
@@ -903,7 +889,7 @@ void ClientConnection::handleIncomingCommand() {
 
                 case BaseCommand::PING: {
                     // Respond to ping request
-                    LOG_DEBUG(cnxString_  << "Replying to ping command");
+                    LOG_DEBUG(cnxString_ << "Replying to ping command");
                     sendCommand(Commands::newPong());
                     break;
                 }
@@ -924,8 +910,8 @@ void ClientConnection::handleIncomingCommand() {
     }
 }
 
-Future<Result, BrokerConsumerStatsImpl>
-ClientConnection::newConsumerStats(uint64_t consumerId, uint64_t requestId) {
+Future<Result, BrokerConsumerStatsImpl> ClientConnection::newConsumerStats(uint64_t consumerId,
+                                                                           uint64_t requestId) {
     Lock lock(mutex_);
     Promise<Result, BrokerConsumerStatsImpl> promise;
     if (isClosed()) {
@@ -940,17 +926,14 @@ ClientConnection::newConsumerStats(uint64_t consumerId, uint64_t requestId) {
 }
 
 void ClientConnection::newTopicLookup(const std::string& destinationName, bool authoritative,
-                                      const uint64_t requestId,
-                                      LookupDataResultPromisePtr promise) {
-    newLookup(Commands::newLookup(destinationName, authoritative, requestId),
-              requestId, promise);
+                                      const uint64_t requestId, LookupDataResultPromisePtr promise) {
+    newLookup(Commands::newLookup(destinationName, authoritative, requestId), requestId, promise);
 }
 
 void ClientConnection::newPartitionedMetadataLookup(const std::string& destinationName,
                                                     const uint64_t requestId,
                                                     LookupDataResultPromisePtr promise) {
-    newLookup(Commands::newPartitionMetadataRequest(destinationName, requestId),
-              requestId, promise);
+    newLookup(Commands::newPartitionMetadataRequest(destinationName, requestId), requestId, promise);
 }
 
 void ClientConnection::newLookup(const SharedBuffer& cmd, const uint64_t requestId,
@@ -977,12 +960,9 @@ void ClientConnection::sendCommand(const SharedBuffer& cmd) {
     Lock lock(mutex_);
 
     if (pendingWriteOperations_++ == 0) {
-
         // Write immediately to socket
-        asyncWrite(
-                cmd.const_asio_buffer(),
-                customAllocWriteHandler(
-                        boost::bind(&ClientConnection::handleSend, shared_from_this(), _1, cmd)));
+        asyncWrite(cmd.const_asio_buffer(), customAllocWriteHandler(boost::bind(
+                                                &ClientConnection::handleSend, shared_from_this(), _1, cmd)));
     } else {
         // Queue to send later
         pendingWriteBuffers_.push_back(cmd);
@@ -993,16 +973,12 @@ void ClientConnection::sendMessage(const OpSendMsg& opSend) {
     Lock lock(mutex_);
 
     if (pendingWriteOperations_++ == 0) {
-
-        PairSharedBuffer buffer = Commands::newSend(outgoingBuffer_, outgoingCmd_,
-                                                    opSend.producerId_, opSend.sequenceId_,
-                                                    getChecksumType(), opSend.msg_);
+        PairSharedBuffer buffer = Commands::newSend(outgoingBuffer_, outgoingCmd_, opSend.producerId_,
+                                                    opSend.sequenceId_, getChecksumType(), opSend.msg_);
 
         // Write immediately to socket
-        asyncWrite(
-                buffer,
-                customAllocWriteHandler(
-                        boost::bind(&ClientConnection::handleSendPair, shared_from_this(), _1)));
+        asyncWrite(buffer, customAllocWriteHandler(
+                               boost::bind(&ClientConnection::handleSendPair, shared_from_this(), _1)));
     } else {
         // Queue to send later
         pendingWriteBuffers_.push_back(opSend);
@@ -1037,24 +1013,18 @@ void ClientConnection::sendPendingCommands() {
 
         if (any.type() == typeid(SharedBuffer)) {
             SharedBuffer buffer = boost::any_cast<SharedBuffer>(any);
-            asyncWrite(
-                    buffer.const_asio_buffer(),
-                    customAllocWriteHandler(
-                            boost::bind(&ClientConnection::handleSend, shared_from_this(), _1,
-                                        buffer)));
+            asyncWrite(buffer.const_asio_buffer(),
+                       customAllocWriteHandler(
+                           boost::bind(&ClientConnection::handleSend, shared_from_this(), _1, buffer)));
         } else {
             assert(any.type() == typeid(OpSendMsg));
 
             const OpSendMsg& op = boost::any_cast<const OpSendMsg&>(any);
-            PairSharedBuffer buffer = Commands::newSend(outgoingBuffer_, outgoingCmd_,
-                                                        op.producerId_, op.sequenceId_,
-                                                        getChecksumType(), op.msg_);
-
-            asyncWrite(
-                    buffer,
-                    customAllocWriteHandler(
-                            boost::bind(&ClientConnection::handleSendPair, shared_from_this(),
-                                        _1)));
+            PairSharedBuffer buffer = Commands::newSend(outgoingBuffer_, outgoingCmd_, op.producerId_,
+                                                        op.sequenceId_, getChecksumType(), op.msg_);
+
+            asyncWrite(buffer, customAllocWriteHandler(
+                                   boost::bind(&ClientConnection::handleSendPair, shared_from_this(), _1)));
         }
     } else {
         // No more pending writes
@@ -1076,8 +1046,7 @@ Future<Result, ResponseData> ClientConnection::sendRequestWithId(SharedBuffer cm
     requestData.timer = executor_->createDeadlineTimer();
     requestData.timer->expires_from_now(operationsTimeout_);
     requestData.timer->async_wait(
-            boost::bind(&ClientConnection::handleRequestTimeout, shared_from_this(), _1,
-                        requestData));
+        boost::bind(&ClientConnection::handleRequestTimeout, shared_from_this(), _1, requestData));
 
     pendingRequests_.insert(std::make_pair(requestId, requestData));
     lock.unlock();
@@ -1109,7 +1078,7 @@ void ClientConnection::handleKeepAliveTimeout() {
 
         keepAliveTimer_->expires_from_now(boost::posix_time::seconds(KeepAliveIntervalInSeconds));
         keepAliveTimer_->async_wait(
-                boost::bind(&ClientConnection::handleKeepAliveTimeout, shared_from_this()));
+            boost::bind(&ClientConnection::handleKeepAliveTimeout, shared_from_this()));
     }
 }
 
@@ -1153,7 +1122,7 @@ void ClientConnection::close() {
     connectPromise_.setFailed(ResultConnectError);
 
     // Fail all pending operations on the connection
-    for (PendingRequestsMap::iterator it = pendingRequests_.begin(); it != pendingRequests_.end(); ++it ) {
+    for (PendingRequestsMap::iterator it = pendingRequests_.begin(); it != pendingRequests_.end(); ++it) {
         it->second.promise.setFailed(ResultConnectError);
     }
 
@@ -1167,11 +1136,11 @@ void ClientConnection::close() {
     pendingConsumerStatsMap_.swap(pendingConsumerStatsMap);
     lock.unlock();
 
-    for (PendingLookupRequestsMap::iterator it = pendingLookupRequests.begin(); it != pendingLookupRequests.end(); ++it) {
+    for (PendingLookupRequestsMap::iterator it = pendingLookupRequests.begin();
+         it != pendingLookupRequests.end(); ++it) {
         it->second->setFailed(ResultConnectError);
     }
 
-
     for (PendingConsumerStatsMap::iterator it = pendingConsumerStatsMap.begin();
          it != pendingConsumerStatsMap.end(); ++it) {
         LOG_ERROR(cnxString_ << " Closing Client Connection, please try again later");
@@ -1183,9 +1152,7 @@ void ClientConnection::close() {
     }
 }
 
-bool ClientConnection::isClosed() const {
-    return state_ == Disconnected;
-}
+bool ClientConnection::isClosed() const { return state_ == Disconnected; }
 
 Future<Result, ClientConnectionWeakPtr> ClientConnection::getConnectFuture() {
     return connectPromise_.getFuture();
@@ -1211,20 +1178,13 @@ void ClientConnection::removeConsumer(int consumerId) {
     consumers_.erase(consumerId);
 }
 
-const std::string& ClientConnection::brokerAddress() const {
-    return address_;
-}
+const std::string& ClientConnection::brokerAddress() const { return address_; }
 
-const std::string& ClientConnection::cnxString() const {
-    return cnxString_;
-}
+const std::string& ClientConnection::cnxString() const { return cnxString_; }
 
-int ClientConnection::getServerProtocolVersion() const {
-    return serverProtocolVersion_;
-}
+int ClientConnection::getServerProtocolVersion() const { return serverProtocolVersion_; }
 
 Commands::ChecksumType ClientConnection::getChecksumType() const {
-    return getServerProtocolVersion() >= proto::v6 ?
-            Commands::Crc32c : Commands::None;
-}
+    return getServerProtocolVersion() >= proto::v6 ? Commands::Crc32c : Commands::None;
 }
+}  // namespace pulsar
diff --git a/pulsar-client-cpp/lib/ClientConnection.h b/pulsar-client-cpp/lib/ClientConnection.h
index 171a6fb..4fb4abd 100644
--- a/pulsar-client-cpp/lib/ClientConnection.h
+++ b/pulsar-client-cpp/lib/ClientConnection.h
@@ -71,14 +71,15 @@ struct OpSendMsg;
 typedef std::pair<std::string, int64_t> ResponseData;
 
 class ClientConnection : public boost::enable_shared_from_this<ClientConnection> {
-    enum State {
+    enum State
+    {
         Pending,
         TcpConnected,
         Ready,
         Disconnected
     };
 
- public:
+   public:
     typedef boost::shared_ptr<boost::asio::ip::tcp::socket> SocketPtr;
     typedef boost::shared_ptr<boost::asio::ssl::stream<boost::asio::ip::tcp::socket&> > TlsSocketPtr;
     typedef boost::shared_ptr<ClientConnection> ConnectionPtr;
@@ -109,7 +110,7 @@ class ClientConnection : public boost::enable_shared_from_this<ClientConnection>
     Future<Result, ClientConnectionWeakPtr> getCloseFuture();
 
     void newTopicLookup(const std::string& destinationName, bool authoritative, const uint64_t requestId,
-                   LookupDataResultPromisePtr promise);
+                        LookupDataResultPromisePtr promise);
 
     void newPartitionedMetadataLookup(const std::string& destinationName, const uint64_t requestId,
                                       LookupDataResultPromisePtr promise);
@@ -137,8 +138,9 @@ class ClientConnection : public boost::enable_shared_from_this<ClientConnection>
 
     Commands::ChecksumType getChecksumType() const;
 
-    Future<Result, BrokerConsumerStatsImpl> newConsumerStats(uint64_t consumerId, uint64_t requestId) ;
- private:
+    Future<Result, BrokerConsumerStatsImpl> newConsumerStats(uint64_t consumerId, uint64_t requestId);
+
+   private:
     struct PendingRequestData {
         Promise<Result, ResponseData> promise;
         DeadlineTimerPtr timer;
@@ -176,26 +178,24 @@ class ClientConnection : public boost::enable_shared_from_this<ClientConnection>
     void handleSend(const boost::system::error_code& err, const SharedBuffer& cmd);
     void handleSendPair(const boost::system::error_code& err);
     void sendPendingCommands();
-    void newLookup(const SharedBuffer& cmd, const uint64_t requestId,
-                   LookupDataResultPromisePtr promise);
-
+    void newLookup(const SharedBuffer& cmd, const uint64_t requestId, LookupDataResultPromisePtr promise);
 
     void handleRequestTimeout(const boost::system::error_code& ec, PendingRequestData pendingRequestData);
 
     void handleKeepAliveTimeout();
 
-    template<typename Handler>
+    template <typename Handler>
     inline AllocHandler<Handler> customAllocReadHandler(Handler h) {
         return AllocHandler<Handler>(readHandlerAllocator_, h);
     }
 
-    template<typename Handler>
+    template <typename Handler>
     inline AllocHandler<Handler> customAllocWriteHandler(Handler h) {
         return AllocHandler<Handler>(writeHandlerAllocator_, h);
     }
 
-    template<typename ConstBufferSequence, typename WriteHandler>
-    inline void asyncWrite(const ConstBufferSequence &buffers, WriteHandler handler) {
+    template <typename ConstBufferSequence, typename WriteHandler>
+    inline void asyncWrite(const ConstBufferSequence& buffers, WriteHandler handler) {
         if (tlsSocket_) {
             boost::asio::async_write(*tlsSocket_, buffers, handler);
         } else {
@@ -203,8 +203,8 @@ class ClientConnection : public boost::enable_shared_from_this<ClientConnection>
         }
     }
 
-    template<typename MutableBufferSequence, typename ReadHandler>
-    inline void asyncReceive(const MutableBufferSequence &buffers, ReadHandler handler) {
+    template <typename MutableBufferSequence, typename ReadHandler>
+    inline void asyncReceive(const MutableBufferSequence& buffers, ReadHandler handler) {
         if (tlsSocket_) {
             tlsSocket_->async_read_some(buffers, handler);
         } else {
@@ -259,7 +259,6 @@ class ClientConnection : public boost::enable_shared_from_this<ClientConnection>
     typedef std::map<uint64_t, Promise<Result, BrokerConsumerStatsImpl> > PendingConsumerStatsMap;
     PendingConsumerStatsMap pendingConsumerStatsMap_;
 
-
     boost::mutex mutex_;
     typedef boost::unique_lock<boost::mutex> Lock;
 
@@ -278,7 +277,7 @@ class ClientConnection : public boost::enable_shared_from_this<ClientConnection>
     DeadlineTimerPtr keepAliveTimer_;
     DeadlineTimerPtr consumerStatsRequestTimer_;
 
-    void handleConsumerStatsTimeout(const boost::system::error_code &ec,
+    void handleConsumerStatsTimeout(const boost::system::error_code& ec,
                                     std::vector<uint64_t> consumerStatsRequests);
 
     void startConsumerStatsTimer(std::vector<uint64_t> consumerStatsRequests);
@@ -288,7 +287,6 @@ class ClientConnection : public boost::enable_shared_from_this<ClientConnection>
 
     bool isTlsAllowInsecureConnection_;
 };
+}  // namespace pulsar
 
-}
-
-#endif//_PULSAR_CLIENT_CONNECTION_HEADER_
+#endif  //_PULSAR_CLIENT_CONNECTION_HEADER_
diff --git a/pulsar-client-cpp/lib/ClientImpl.cc b/pulsar-client-cpp/lib/ClientImpl.cc
index 99be8b6..a95cd49 100644
--- a/pulsar-client-cpp/lib/ClientImpl.cc
+++ b/pulsar-client-cpp/lib/ClientImpl.cc
@@ -36,389 +36,360 @@ DECLARE_LOG_OBJECT()
 
 namespace pulsar {
 
-    static const char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
-
-    const std::string generateRandomName() {
-        unsigned char hash[SHA_DIGEST_LENGTH];  // == 20;
-        boost::posix_time::ptime t(boost::posix_time::microsec_clock::universal_time());
-        long nanoSeconds = t.time_of_day().total_nanoseconds();
-        std::stringstream ss;
-        ss << nanoSeconds;
-        SHA1(reinterpret_cast<const unsigned char*>(ss.str().c_str()), ss.str().length(), hash);
-
-        const int nameLength = 6;
-        std::stringstream hexHash;
-        for (int i = 0; i < nameLength / 2; i++) {
-            hexHash << hexDigits[(hash[i] & 0xF0) >> 4];
-            hexHash << hexDigits[hash[i] & 0x0F];
-        }
-
-        return hexHash.str();
-    }
-    typedef boost::unique_lock<boost::mutex> Lock;
-
-    ClientImpl::ClientImpl(const std::string& serviceUrl,
-                           const ClientConfiguration& clientConfiguration, bool poolConnections)
-        : mutex_(),
-          state_(Open),
-          serviceUrl_(serviceUrl),
-          clientConfiguration_(clientConfiguration),
-          ioExecutorProvider_(boost::make_shared<ExecutorServiceProvider>(clientConfiguration.getIOThreads())),
-          listenerExecutorProvider_(boost::make_shared<ExecutorServiceProvider>(clientConfiguration.getMessageListenerThreads())),
-          partitionListenerExecutorProvider_(boost::make_shared<ExecutorServiceProvider>(clientConfiguration.getMessageListenerThreads())),
-          pool_(clientConfiguration, ioExecutorProvider_, clientConfiguration.getAuthPtr(), poolConnections),
-          producerIdGenerator_(0),
-          consumerIdGenerator_(0),
-          requestIdGenerator_(0) {
-        LogUtils::init(clientConfiguration.getLogConfFilePath());
-        if (serviceUrl_.compare(0, 4, "http") == 0) {
-            LOG_DEBUG("Using HTTP Lookup");
-            lookupServicePtr_ = boost::make_shared<HTTPLookupService>(boost::cref(serviceUrl_),
-                                                                      boost::cref(clientConfiguration_),
-                                                                      boost::cref(
-                                                                              clientConfiguration.getAuthPtr()));
-        } else {
-            LOG_DEBUG("Using Binary Lookup");
-            lookupServicePtr_ = boost::make_shared<BinaryProtoLookupService>(boost::ref(pool_), boost::ref(serviceUrl));
-        }
+static const char hexDigits[] = {'0', '1', '2', '3', '4', '5', '6', '7',
+                                 '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
+
+const std::string generateRandomName() {
+    unsigned char hash[SHA_DIGEST_LENGTH];  // == 20;
+    boost::posix_time::ptime t(boost::posix_time::microsec_clock::universal_time());
+    long nanoSeconds = t.time_of_day().total_nanoseconds();
+    std::stringstream ss;
+    ss << nanoSeconds;
+    SHA1(reinterpret_cast<const unsigned char*>(ss.str().c_str()), ss.str().length(), hash);
+
+    const int nameLength = 6;
+    std::stringstream hexHash;
+    for (int i = 0; i < nameLength / 2; i++) {
+        hexHash << hexDigits[(hash[i] & 0xF0) >> 4];
+        hexHash << hexDigits[hash[i] & 0x0F];
     }
 
-    ClientImpl::~ClientImpl() {
-        shutdown();
+    return hexHash.str();
+}
+typedef boost::unique_lock<boost::mutex> Lock;
+
+ClientImpl::ClientImpl(const std::string& serviceUrl, const ClientConfiguration& clientConfiguration,
+                       bool poolConnections)
+    : mutex_(),
+      state_(Open),
+      serviceUrl_(serviceUrl),
+      clientConfiguration_(clientConfiguration),
+      ioExecutorProvider_(boost::make_shared<ExecutorServiceProvider>(clientConfiguration.getIOThreads())),
+      listenerExecutorProvider_(
+          boost::make_shared<ExecutorServiceProvider>(clientConfiguration.getMessageListenerThreads())),
+      partitionListenerExecutorProvider_(
+          boost::make_shared<ExecutorServiceProvider>(clientConfiguration.getMessageListenerThreads())),
+      pool_(clientConfiguration, ioExecutorProvider_, clientConfiguration.getAuthPtr(), poolConnections),
+      producerIdGenerator_(0),
+      consumerIdGenerator_(0),
+      requestIdGenerator_(0) {
+    LogUtils::init(clientConfiguration.getLogConfFilePath());
+    if (serviceUrl_.compare(0, 4, "http") == 0) {
+        LOG_DEBUG("Using HTTP Lookup");
+        lookupServicePtr_ =
+            boost::make_shared<HTTPLookupService>(boost::cref(serviceUrl_), boost::cref(clientConfiguration_),
+                                                  boost::cref(clientConfiguration.getAuthPtr()));
+    } else {
+        LOG_DEBUG("Using Binary Lookup");
+        lookupServicePtr_ =
+            boost::make_shared<BinaryProtoLookupService>(boost::ref(pool_), boost::ref(serviceUrl));
     }
+}
 
-    const ClientConfiguration& ClientImpl::conf() const {
-        return clientConfiguration_;
-    }
+ClientImpl::~ClientImpl() { shutdown(); }
 
-    ExecutorServiceProviderPtr ClientImpl::getIOExecutorProvider() {
-        return ioExecutorProvider_;
-    }
+const ClientConfiguration& ClientImpl::conf() const { return clientConfiguration_; }
 
-    ExecutorServiceProviderPtr ClientImpl::getListenerExecutorProvider() {
-        return listenerExecutorProvider_;
-    }
+ExecutorServiceProviderPtr ClientImpl::getIOExecutorProvider() { return ioExecutorProvider_; }
+
+ExecutorServiceProviderPtr ClientImpl::getListenerExecutorProvider() { return listenerExecutorProvider_; }
 
-    ExecutorServiceProviderPtr ClientImpl::getPartitionListenerExecutorProvider() {
-        return partitionListenerExecutorProvider_;
+ExecutorServiceProviderPtr ClientImpl::getPartitionListenerExecutorProvider() {
+    return partitionListenerExecutorProvider_;
+}
+void ClientImpl::createProducerAsync(const std::string& topic, ProducerConfiguration conf,
+                                     CreateProducerCallback callback) {
+    DestinationNamePtr dn;
+    {
+        Lock lock(mutex_);
+        if (state_ != Open) {
+            lock.unlock();
+            callback(ResultAlreadyClosed, Producer());
+            return;
+        } else if (!(dn = DestinationName::get(topic))) {
+            lock.unlock();
+            callback(ResultInvalidTopicName, Producer());
+            return;
+        }
     }
-    void ClientImpl::createProducerAsync(const std::string& topic,
-                                         ProducerConfiguration conf,
-                                         CreateProducerCallback callback) {
-        DestinationNamePtr dn;
-        {
-            Lock lock(mutex_);
-            if (state_ != Open) {
-                lock.unlock();
-                callback(ResultAlreadyClosed, Producer());
-                return;
-            } else if (!(dn = DestinationName::get(topic))) {
-                lock.unlock();
-                callback(ResultInvalidTopicName, Producer());
-                return;
-            }
+    lookupServicePtr_->getPartitionMetadataAsync(dn).addListener(
+        boost::bind(&ClientImpl::handleCreateProducer, shared_from_this(), _1, _2, dn, conf, callback));
+}
+
+void ClientImpl::handleCreateProducer(const Result result, const LookupDataResultPtr partitionMetadata,
+                                      DestinationNamePtr dn, ProducerConfiguration conf,
+                                      CreateProducerCallback callback) {
+    if (!result) {
+        ProducerImplBasePtr producer;
+        if (partitionMetadata->getPartitions() > 1) {
+            producer = boost::make_shared<PartitionedProducerImpl>(shared_from_this(), dn,
+                                                                   partitionMetadata->getPartitions(), conf);
+        } else {
+            producer = boost::make_shared<ProducerImpl>(shared_from_this(), dn->toString(), conf);
         }
-        lookupServicePtr_->getPartitionMetadataAsync(dn).addListener(boost::bind(&ClientImpl::handleCreateProducer,
-                                    shared_from_this(), _1, _2, dn, conf, callback));
+        producer->getProducerCreatedFuture().addListener(
+            boost::bind(&ClientImpl::handleProducerCreated, shared_from_this(), _1, _2, callback, producer));
+        Lock lock(mutex_);
+        producers_.push_back(producer);
+        lock.unlock();
+        producer->start();
+    } else {
+        LOG_ERROR("Error Checking/Getting Partition Metadata while creating producer on "
+                  << dn->toString() << " -- " << result);
+        callback(result, Producer());
     }
+}
 
-    void ClientImpl::handleCreateProducer(const Result result,
-            const LookupDataResultPtr partitionMetadata,
-            DestinationNamePtr dn,
-            ProducerConfiguration conf,
-            CreateProducerCallback callback) {
-        if (!result) {
-            ProducerImplBasePtr producer;
-            if (partitionMetadata->getPartitions() > 1) {
-                producer = boost::make_shared<PartitionedProducerImpl>(shared_from_this(),
-                                                                       dn, partitionMetadata->getPartitions(), conf);
-            } else {
-                producer = boost::make_shared<ProducerImpl>(shared_from_this(), dn->toString(), conf);
-            }
-            producer->getProducerCreatedFuture().addListener(boost::bind(&ClientImpl::handleProducerCreated,
-                                                                         shared_from_this(), _1, _2, callback,
-                                                                         producer));
-            Lock lock(mutex_);
-            producers_.push_back(producer);
+void ClientImpl::handleProducerCreated(Result result, ProducerImplBaseWeakPtr producerBaseWeakPtr,
+                                       CreateProducerCallback callback, ProducerImplBasePtr producer) {
+    callback(result, Producer(producer));
+}
+
+void ClientImpl::createReaderAsync(const std::string& topic, const MessageId& startMessageId,
+                                   const ReaderConfiguration& conf, ReaderCallback callback) {
+    DestinationNamePtr dn;
+    {
+        Lock lock(mutex_);
+        if (state_ != Open) {
             lock.unlock();
-            producer->start();
-        } else {
-            LOG_ERROR("Error Checking/Getting Partition Metadata while creating producer on " << dn->toString() << " -- " << result );
-            callback (result, Producer());
+            callback(ResultAlreadyClosed, Reader());
+            return;
+        } else if (!(dn = DestinationName::get(topic))) {
+            lock.unlock();
+            callback(ResultInvalidTopicName, Reader());
+            return;
         }
+    }
 
+    BatchMessageId msgId(startMessageId);
+    lookupServicePtr_->getPartitionMetadataAsync(dn).addListener(boost::bind(
+        &ClientImpl::handleReaderMetadataLookup, shared_from_this(), _1, _2, dn, msgId, conf, callback));
+}
+
+void ClientImpl::handleReaderMetadataLookup(const Result result, const LookupDataResultPtr partitionMetadata,
+                                            DestinationNamePtr dn, BatchMessageId startMessageId,
+                                            ReaderConfiguration conf, ReaderCallback callback) {
+    if (result != ResultOk) {
+        LOG_ERROR("Error Checking/Getting Partition Metadata while creating reader: " << result);
+        callback(result, Reader());
+        return;
     }
 
-    void ClientImpl::handleProducerCreated(Result result, ProducerImplBaseWeakPtr producerBaseWeakPtr,
-                                           CreateProducerCallback callback, ProducerImplBasePtr producer) {
-        callback(result, Producer(producer));
+    if (partitionMetadata->getPartitions() > 1) {
+        LOG_ERROR("Topic reader cannot be created on a partitioned topic: " << dn->toString());
+        callback(ResultOperationNotSupported, Reader());
+        return;
     }
 
-    void ClientImpl::createReaderAsync(const std::string& topic,
-            const MessageId& startMessageId,
-            const ReaderConfiguration& conf,
-            ReaderCallback callback) {
-        DestinationNamePtr dn;
-        {
-            Lock lock(mutex_);
-            if (state_ != Open) {
-                lock.unlock();
-                callback(ResultAlreadyClosed, Reader());
-                return;
-            } else if (!(dn = DestinationName::get(topic))) {
-                lock.unlock();
-                callback(ResultInvalidTopicName, Reader());
-                return;
-            }
-        }
+    ReaderImplPtr reader = boost::make_shared<ReaderImpl>(shared_from_this(), dn->toString(), conf,
+                                                          getListenerExecutorProvider()->get(), callback);
+    reader->start(startMessageId);
 
-        BatchMessageId msgId(startMessageId);
-        lookupServicePtr_->getPartitionMetadataAsync(dn).addListener(boost::bind(&ClientImpl::handleReaderMetadataLookup,
-                        shared_from_this(), _1, _2, dn, msgId, conf, callback));
-    }
+    Lock lock(mutex_);
+    consumers_.push_back(reader->getConsumer());
+}
 
-    void ClientImpl::handleReaderMetadataLookup(const Result result,
-            const LookupDataResultPtr partitionMetadata,
-            DestinationNamePtr dn,
-            BatchMessageId startMessageId,
-            ReaderConfiguration conf,
-            ReaderCallback callback) {
-        if (result != ResultOk) {
-            LOG_ERROR("Error Checking/Getting Partition Metadata while creating reader: " << result);
-            callback(result, Reader());
+void ClientImpl::subscribeAsync(const std::string& topic, const std::string& consumerName,
+                                const ConsumerConfiguration& conf, SubscribeCallback callback) {
+    DestinationNamePtr dn;
+    {
+        Lock lock(mutex_);
+        if (state_ != Open) {
+            lock.unlock();
+            callback(ResultAlreadyClosed, Consumer());
             return;
-        }
-
-        if (partitionMetadata->getPartitions() > 1) {
-            LOG_ERROR("Topic reader cannot be created on a partitioned topic: " << dn->toString());
-            callback(ResultOperationNotSupported, Reader());
+        } else if (!(dn = DestinationName::get(topic))) {
+            lock.unlock();
+            callback(ResultInvalidTopicName, Consumer());
             return;
         }
-
-        ReaderImplPtr reader = boost::make_shared<ReaderImpl>(shared_from_this(), dn->toString(),
-                 conf, getListenerExecutorProvider()->get(), callback);
-        reader->start(startMessageId);
-
-        Lock lock(mutex_);
-        consumers_.push_back(reader->getConsumer());
     }
 
-    void ClientImpl::subscribeAsync(const std::string& topic, const std::string& consumerName,
-                                    const ConsumerConfiguration& conf, SubscribeCallback callback) {
-        DestinationNamePtr dn;
-        {
-            Lock lock(mutex_);
-            if (state_ != Open) {
-                lock.unlock();
-                callback(ResultAlreadyClosed, Consumer());
-                return;
-            } else if (!(dn = DestinationName::get(topic))) {
-                lock.unlock();
-                callback(ResultInvalidTopicName, Consumer());
-                return;
-            }
+    lookupServicePtr_->getPartitionMetadataAsync(dn).addListener(boost::bind(
+        &ClientImpl::handleSubscribe, shared_from_this(), _1, _2, dn, consumerName, conf, callback));
+}
+
+void ClientImpl::handleSubscribe(const Result result, const LookupDataResultPtr partitionMetadata,
+                                 DestinationNamePtr dn, const std::string& consumerName,
+                                 ConsumerConfiguration conf, SubscribeCallback callback) {
+    if (result == ResultOk) {
+        // generate random name if not supplied by the customer.
+        if (conf.getConsumerName().empty()) {
+            conf.setConsumerName(generateRandomName());
         }
-
-        lookupServicePtr_->getPartitionMetadataAsync(dn).addListener(boost::bind(&ClientImpl::handleSubscribe,
-                                    shared_from_this(), _1, _2, dn, consumerName, conf, callback));
-    }
-
-    void ClientImpl::handleSubscribe(const Result result,
-            const LookupDataResultPtr partitionMetadata,
-            DestinationNamePtr dn,
-            const std::string& consumerName,
-            ConsumerConfiguration conf,
-            SubscribeCallback callback) {
-        if (result == ResultOk) {
-            // generate random name if not supplied by the customer.
-            if(conf.getConsumerName().empty()) {
-                conf.setConsumerName(generateRandomName());
-            }
-            ConsumerImplBasePtr consumer;
-            if (partitionMetadata->getPartitions() > 1) {
-                if (conf.getReceiverQueueSize() == 0) {
-                    LOG_ERROR("Can't use partitioned topic if the queue size is 0.");
-                    callback (ResultInvalidConfiguration, Consumer());
-                    return;
-                }
-                consumer = boost::make_shared<PartitionedConsumerImpl>(shared_from_this(),
-                                                                       consumerName,
-                                                                       dn,
-                                                                       partitionMetadata->getPartitions(),
-                                                                       conf);
-            } else  {
-                consumer = boost::make_shared<ConsumerImpl>(shared_from_this(), dn->toString(),
-                                                            consumerName, conf);
+        ConsumerImplBasePtr consumer;
+        if (partitionMetadata->getPartitions() > 1) {
+            if (conf.getReceiverQueueSize() == 0) {
+                LOG_ERROR("Can't use partitioned topic if the queue size is 0.");
+                callback(ResultInvalidConfiguration, Consumer());
+                return;
             }
-            consumer->getConsumerCreatedFuture().addListener(boost::bind(&ClientImpl::handleConsumerCreated,
-                                                                         shared_from_this(), _1, _2, callback,
-                                                                         consumer));
-            Lock lock(mutex_);
-            consumers_.push_back(consumer);
-            lock.unlock();
-            consumer->start();
+            consumer = boost::make_shared<PartitionedConsumerImpl>(shared_from_this(), consumerName, dn,
+                                                                   partitionMetadata->getPartitions(), conf);
         } else {
-            LOG_ERROR("Error Checking/Getting Partition Metadata while Subscribing- " <<  result );
-            callback (result, Consumer());
+            consumer =
+                boost::make_shared<ConsumerImpl>(shared_from_this(), dn->toString(), consumerName, conf);
         }
-
+        consumer->getConsumerCreatedFuture().addListener(
+            boost::bind(&ClientImpl::handleConsumerCreated, shared_from_this(), _1, _2, callback, consumer));
+        Lock lock(mutex_);
+        consumers_.push_back(consumer);
+        lock.unlock();
+        consumer->start();
+    } else {
+        LOG_ERROR("Error Checking/Getting Partition Metadata while Subscribing- " << result);
+        callback(result, Consumer());
     }
-
-    void ClientImpl::handleConsumerCreated(Result result,
-                                           ConsumerImplBaseWeakPtr consumerImplBaseWeakPtr,
-                                           SubscribeCallback callback,
-                                           ConsumerImplBasePtr consumer) {
-        callback(result, Consumer(consumer));
+}
+
+void ClientImpl::handleConsumerCreated(Result result, ConsumerImplBaseWeakPtr consumerImplBaseWeakPtr,
+                                       SubscribeCallback callback, ConsumerImplBasePtr consumer) {
+    callback(result, Consumer(consumer));
+}
+
+Future<Result, ClientConnectionWeakPtr> ClientImpl::getConnection(const std::string& topic) {
+    Promise<Result, ClientConnectionWeakPtr> promise;
+    lookupServicePtr_->lookupAsync(topic).addListener(
+        boost::bind(&ClientImpl::handleLookup, this, _1, _2, promise));
+    return promise.getFuture();
+}
+
+void ClientImpl::handleLookup(Result result, LookupDataResultPtr data,
+                              Promise<Result, ClientConnectionWeakPtr> promise) {
+    if (data) {
+        LOG_DEBUG("Getting connection to broker: " << data->getBrokerUrl());
+        Future<Result, ClientConnectionWeakPtr> future = pool_.getConnectionAsync(data->getBrokerUrl());
+        future.addListener(boost::bind(&ClientImpl::handleNewConnection, this, _1, _2, promise));
+    } else {
+        promise.setFailed(result);
     }
-
-    Future<Result, ClientConnectionWeakPtr> ClientImpl::getConnection(const std::string& topic) {
-        Promise<Result, ClientConnectionWeakPtr> promise;
-        lookupServicePtr_->lookupAsync(topic).addListener(boost::bind(&ClientImpl::handleLookup, this, _1, _2, promise));
-        return promise.getFuture();
+}
+
+void ClientImpl::handleNewConnection(Result result, const ClientConnectionWeakPtr& conn,
+                                     Promise<Result, ClientConnectionWeakPtr> promise) {
+    if (result == ResultOk) {
+        promise.setValue(conn);
+    } else {
+        promise.setFailed(ResultConnectError);
     }
+}
 
-    void ClientImpl::handleLookup(Result result, LookupDataResultPtr data,
-                                      Promise<Result, ClientConnectionWeakPtr> promise) {
-            if (data) {
-                LOG_DEBUG("Getting connection to broker: " << data->getBrokerUrl());
-                Future<Result, ClientConnectionWeakPtr> future = pool_.getConnectionAsync(
-                                                                                          data->getBrokerUrl());
-                future.addListener(boost::bind(&ClientImpl::handleNewConnection, this, _1, _2, promise));
-            } else {
-                promise.setFailed(result);
-            }
+void ClientImpl::closeAsync(CloseCallback callback) {
+    Lock lock(mutex_);
+    ProducersList producers(producers_);
+    ConsumersList consumers(consumers_);
+
+    if (state_ != Open && callback) {
+        lock.unlock();
+        callback(ResultAlreadyClosed);
+        return;
+    }
+    // Set the state to Closing so that no producers could get added
+    state_ = Closing;
+    lock.unlock();
+
+    LOG_DEBUG("Closing Pulsar client");
+    SharedInt numberOfOpenHandlers = boost::make_shared<int>(producers.size() + consumers.size());
+
+    for (ProducersList::iterator it = producers.begin(); it != producers.end(); ++it) {
+        ProducerImplBasePtr producer = it->lock();
+        if (producer && !producer->isClosed()) {
+            producer->closeAsync(boost::bind(&ClientImpl::handleClose, shared_from_this(), _1,
+                                             numberOfOpenHandlers, callback));
+        } else {
+            // Since the connection is already closed
+            (*numberOfOpenHandlers)--;
         }
+    }
 
-    void ClientImpl::handleNewConnection(Result result, const ClientConnectionWeakPtr& conn,
-                                         Promise<Result, ClientConnectionWeakPtr> promise) {
-        if (result == ResultOk) {
-            promise.setValue(conn);
+    for (ConsumersList::iterator it = consumers.begin(); it != consumers.end(); ++it) {
+        ConsumerImplBasePtr consumer = it->lock();
+        if (consumer && !consumer->isClosed()) {
+            consumer->closeAsync(boost::bind(&ClientImpl::handleClose, shared_from_this(), _1,
+                                             numberOfOpenHandlers, callback));
         } else {
-            promise.setFailed(ResultConnectError);
+            // Since the connection is already closed
+            (*numberOfOpenHandlers)--;
         }
     }
 
-    void ClientImpl::closeAsync(CloseCallback callback) {
+    if (*numberOfOpenHandlers == 0 && callback) {
+        callback(ResultOk);
+    }
+}
+
+void ClientImpl::handleClose(Result result, SharedInt numberOfOpenHandlers, ResultCallback callback) {
+    static bool errorClosing = false;
+    static Result failResult = ResultOk;
+    if (result != ResultOk) {
+        errorClosing = true;
+        failResult = result;
+    }
+    if (*numberOfOpenHandlers > 0) {
+        --(*numberOfOpenHandlers);
+    }
+    if (*numberOfOpenHandlers == 0) {
         Lock lock(mutex_);
-        ProducersList producers(producers_);
-        ConsumersList consumers(consumers_);
-
-        if (state_ != Open && callback) {
-            lock.unlock();
-            callback(ResultAlreadyClosed);
-            return;
-        }
-        // Set the state to Closing so that no producers could get added
-        state_ = Closing;
+        state_ = Closed;
         lock.unlock();
-
-        LOG_DEBUG("Closing Pulsar client");
-        SharedInt numberOfOpenHandlers = boost::make_shared<int>(producers.size() + consumers.size());
-
-        for (ProducersList::iterator it = producers.begin(); it != producers.end(); ++it) {
-            ProducerImplBasePtr producer = it->lock();
-            if (producer && !producer->isClosed()) {
-                producer->closeAsync(
-                                     boost::bind(&ClientImpl::handleClose, shared_from_this(), _1, numberOfOpenHandlers,
-                                                 callback));
-            } else {
-                // Since the connection is already closed
-                (*numberOfOpenHandlers)--;
-            }
-        }
-
-        for (ConsumersList::iterator it = consumers.begin(); it != consumers.end(); ++it) {
-            ConsumerImplBasePtr consumer = it->lock();
-            if (consumer && !consumer->isClosed()) {
-                consumer->closeAsync(
-                                     boost::bind(&ClientImpl::handleClose, shared_from_this(), _1, numberOfOpenHandlers,
-                                                 callback));
-            } else {
-                // Since the connection is already closed
-                (*numberOfOpenHandlers)--;
+        if (errorClosing) {
+            LOG_DEBUG("Problem in closing client, could not close one or more consumers or producers");
+            if (callback) {
+                callback(failResult);
             }
         }
 
-        if (*numberOfOpenHandlers == 0 && callback) {
+        LOG_DEBUG("Shutting down producers and consumers for client");
+        shutdown();
+        if (callback) {
             callback(ResultOk);
         }
     }
+}
 
-    void ClientImpl::handleClose(Result result, SharedInt numberOfOpenHandlers, ResultCallback callback) {
-        static bool errorClosing = false;
-        static Result failResult = ResultOk;
-        if (result != ResultOk) {
-            errorClosing = true;
-            failResult = result;
-        }
-        if(*numberOfOpenHandlers > 0) {
-            --(*numberOfOpenHandlers);
-        }
-        if (*numberOfOpenHandlers == 0) {
+void ClientImpl::shutdown() {
+    Lock lock(mutex_);
+    ProducersList producers;
+    ConsumersList consumers;
 
-            Lock lock(mutex_);
-            state_ = Closed;
-            lock.unlock();
-            if (errorClosing) {
-                LOG_DEBUG("Problem in closing client, could not close one or more consumers or producers");
-                if (callback) {
-                    callback(failResult);
-                }
-            }
+    producers.swap(producers_);
+    consumers.swap(consumers_);
+    lock.unlock();
 
-            LOG_DEBUG("Shutting down producers and consumers for client");
-            shutdown();
-            if (callback) {
-                callback(ResultOk);
-            }
+    for (ProducersList::iterator it = producers.begin(); it != producers.end(); ++it) {
+        ProducerImplBasePtr producer = it->lock();
+        if (producer) {
+            producer->shutdown();
         }
     }
 
-    void ClientImpl::shutdown() {
-        Lock lock(mutex_);
-        ProducersList producers;
-        ConsumersList consumers;
-
-        producers.swap(producers_);
-        consumers.swap(consumers_);
-        lock.unlock();
-
-        for (ProducersList::iterator it = producers.begin(); it != producers.end(); ++it) {
-            ProducerImplBasePtr producer = it->lock();
-            if (producer) {
-                producer->shutdown();
-            }
+    for (ConsumersList::iterator it = consumers.begin(); it != consumers.end(); ++it) {
+        ConsumerImplBasePtr consumer = it->lock();
+        if (consumer) {
+            consumer->shutdown();
         }
-
-        for (ConsumersList::iterator it = consumers.begin(); it != consumers.end(); ++it) {
-            ConsumerImplBasePtr consumer = it->lock();
-            if (consumer) {
-                consumer->shutdown();
-            }
-        }
-
-        ioExecutorProvider_->close();
-        listenerExecutorProvider_->close();
-        partitionListenerExecutorProvider_->close();
     }
 
-    uint64_t ClientImpl::newProducerId() {
-        Lock lock(mutex_);
-        return producerIdGenerator_++;
-    }
+    ioExecutorProvider_->close();
+    listenerExecutorProvider_->close();
+    partitionListenerExecutorProvider_->close();
+}
 
-    uint64_t ClientImpl::newConsumerId() {
-        Lock lock(mutex_);
-        return consumerIdGenerator_++;
-    }
+uint64_t ClientImpl::newProducerId() {
+    Lock lock(mutex_);
+    return producerIdGenerator_++;
+}
 
-    uint64_t ClientImpl::newRequestId() {
-        Lock lock(mutex_);
-        return requestIdGenerator_++;
-    }
+uint64_t ClientImpl::newConsumerId() {
+    Lock lock(mutex_);
+    return consumerIdGenerator_++;
+}
 
-    const ClientConfiguration& ClientImpl::getClientConfig() const {
-        return clientConfiguration_;
-    }
+uint64_t ClientImpl::newRequestId() {
+    Lock lock(mutex_);
+    return requestIdGenerator_++;
+}
+
+const ClientConfiguration& ClientImpl::getClientConfig() const { return clientConfiguration_; }
 
 } /* namespace pulsar */
diff --git a/pulsar-client-cpp/lib/ClientImpl.h b/pulsar-client-cpp/lib/ClientImpl.h
index c146f21..679e2de 100644
--- a/pulsar-client-cpp/lib/ClientImpl.h
+++ b/pulsar-client-cpp/lib/ClientImpl.h
@@ -46,7 +46,7 @@ typedef boost::weak_ptr<ReaderImpl> ReaderImplWeakPtr;
 const std::string generateRandomName();
 
 class ClientImpl : public boost::enable_shared_from_this<ClientImpl> {
- public:
+   public:
     ClientImpl(const std::string& serviceUrl, const ClientConfiguration& clientConfiguration,
                bool poolConnections);
     ~ClientImpl();
@@ -57,10 +57,8 @@ class ClientImpl : public boost::enable_shared_from_this<ClientImpl> {
     void subscribeAsync(const std::string& topic, const std::string& consumerName,
                         const ConsumerConfiguration& conf, SubscribeCallback callback);
 
-    void createReaderAsync(const std::string& topic,
-                           const MessageId& startMessageId,
-                           const ReaderConfiguration& conf,
-                           ReaderCallback callback);
+    void createReaderAsync(const std::string& topic, const MessageId& startMessageId,
+                           const ReaderConfiguration& conf, ReaderCallback callback);
 
     Future<Result, ClientConnectionWeakPtr> getConnection(const std::string& topic);
     void handleLookup(Result result, LookupDataResultPtr data,
@@ -83,23 +81,16 @@ class ClientImpl : public boost::enable_shared_from_this<ClientImpl> {
     ExecutorServiceProviderPtr getPartitionListenerExecutorProvider();
     friend class PulsarFriend;
 
- private:
-
-    void handleCreateProducer(const Result result,
-                              const LookupDataResultPtr partitionMetadata,
-                              DestinationNamePtr dn,
-                              ProducerConfiguration conf,
+   private:
+    void handleCreateProducer(const Result result, const LookupDataResultPtr partitionMetadata,
+                              DestinationNamePtr dn, ProducerConfiguration conf,
                               CreateProducerCallback callback);
 
-    void handleSubscribe(const Result result,
-                             const LookupDataResultPtr partitionMetadata,
-                             DestinationNamePtr dn,
-                             const std::string& consumerName,
-                             ConsumerConfiguration conf,
-                             SubscribeCallback callback);
+    void handleSubscribe(const Result result, const LookupDataResultPtr partitionMetadata,
+                         DestinationNamePtr dn, const std::string& consumerName, ConsumerConfiguration conf,
+                         SubscribeCallback callback);
 
-    void handleReaderMetadataLookup(const Result result,
-                                    const LookupDataResultPtr partitionMetadata,
+    void handleReaderMetadataLookup(const Result result, const LookupDataResultPtr partitionMetadata,
                                     DestinationNamePtr dn, BatchMessageId startMessageId,
                                     ReaderConfiguration conf, ReaderCallback callback);
 
@@ -112,7 +103,8 @@ class ClientImpl : public boost::enable_shared_from_this<ClientImpl> {
 
     void handleClose(Result result, SharedInt remaining, ResultCallback callback);
 
-    enum State {
+    enum State
+    {
         Open,
         Closing,
         Closed
diff --git a/pulsar-client-cpp/lib/Commands.cc b/pulsar-client-cpp/lib/Commands.cc
index a7b7ce3..59cf2a2 100644
--- a/pulsar-client-cpp/lib/Commands.cc
+++ b/pulsar-client-cpp/lib/Commands.cc
@@ -60,8 +60,7 @@ SharedBuffer Commands::newPartitionMetadataRequest(const std::string& topic, uin
     return buffer;
 }
 
-SharedBuffer Commands::newLookup(const std::string& topic, const bool authoritative,
-                                 uint64_t requestId) {
+SharedBuffer Commands::newLookup(const std::string& topic, const bool authoritative, uint64_t requestId) {
     static BaseCommand cmd;
     static boost::mutex mutex;
     mutex.lock();
@@ -90,8 +89,8 @@ SharedBuffer Commands::newConsumerStats(uint64_t consumerId, uint64_t requestId)
     return buffer;
 }
 
-PairSharedBuffer Commands::newSend(SharedBuffer& headers, BaseCommand& cmd,
-                                   uint64_t producerId, uint64_t sequenceId, ChecksumType checksumType, const Message& msg) {
+PairSharedBuffer Commands::newSend(SharedBuffer& headers, BaseCommand& cmd, uint64_t producerId,
+                                   uint64_t sequenceId, ChecksumType checksumType, const Message& msg) {
     const proto::MessageMetadata& metadata = msg.impl_->metadata;
     SharedBuffer& payload = msg.impl_->payload;
 
@@ -110,10 +109,10 @@ PairSharedBuffer Commands::newSend(SharedBuffer& headers, BaseCommand& cmd,
     int msgMetadataSize = metadata.ByteSize();
     int payloadSize = payload.readableBytes();
 
-    int magicAndChecksumLength =
-            (Crc32c == (checksumType)) ? (2 + 4 /* magic + checksumLength*/) : 0;
+    int magicAndChecksumLength = (Crc32c == (checksumType)) ? (2 + 4 /* magic + checksumLength*/) : 0;
     bool includeChecksum = magicAndChecksumLength > 0;
-    int headerContentSize = 4 + cmdSize + magicAndChecksumLength + 4 + msgMetadataSize;  // cmdLength + cmdSize + magicLength +
+    int headerContentSize =
+        4 + cmdSize + magicAndChecksumLength + 4 + msgMetadataSize;  // cmdLength + cmdSize + magicLength +
     // checksumSize + msgMetadataLength + msgMetadataSize
     int totalSize = headerContentSize + payloadSize;
     int headersSize = 4 + headerContentSize;  // totalSize + headerLength
@@ -132,7 +131,7 @@ PairSharedBuffer Commands::newSend(SharedBuffer& headers, BaseCommand& cmd,
     if (includeChecksum) {
         headers.writeUnsignedShort(magicCrc32c);
         checksumReaderIndex = headers.writerIndex();
-        headers.skipBytes(checksumSize);  //skip 4 bytes of checksum
+        headers.skipBytes(checksumSize);  // skip 4 bytes of checksum
     }
 
     // Write metadata
@@ -148,10 +147,9 @@ PairSharedBuffer Commands::newSend(SharedBuffer& headers, BaseCommand& cmd,
     if (includeChecksum) {
         int writeIndex = headers.writerIndex();
         int metadataStartIndex = checksumReaderIndex + checksumSize;
-        uint32_t metadataChecksum = computeChecksum(
-                0, headers.data() + metadataStartIndex, (writeIndex - metadataStartIndex));
-        uint32_t computedChecksum = computeChecksum(metadataChecksum, payload.data(),
-                                               payload.writerIndex());
+        uint32_t metadataChecksum =
+            computeChecksum(0, headers.data() + metadataStartIndex, (writeIndex - metadataStartIndex));
+        uint32_t computedChecksum = computeChecksum(metadataChecksum, payload.data(), payload.writerIndex());
         // set computed checksum
         headers.setWriterIndex(checksumReaderIndex);
         headers.writeUnsignedInt(computedChecksum);
@@ -176,11 +174,9 @@ SharedBuffer Commands::newConnect(const AuthenticationPtr& authentication) {
     return writeMessageWithSize(cmd);
 }
 
-SharedBuffer Commands::newSubscribe(const std::string& topic, const std::string&subscription,
-                                    uint64_t consumerId, uint64_t requestId,
-                                    CommandSubscribe_SubType subType,
-                                    const std::string& consumerName,
-                                    SubscriptionMode subscriptionMode,
+SharedBuffer Commands::newSubscribe(const std::string& topic, const std::string& subscription,
+                                    uint64_t consumerId, uint64_t requestId, CommandSubscribe_SubType subType,
+                                    const std::string& consumerName, SubscriptionMode subscriptionMode,
                                     Optional<BatchMessageId> startMessageId) {
     BaseCommand cmd;
     cmd.set_type(BaseCommand::SUBSCRIBE);
@@ -231,8 +227,7 @@ SharedBuffer Commands::newProducer(const std::string& topic, uint64_t producerId
     return writeMessageWithSize(cmd);
 }
 
-SharedBuffer Commands::newAck(uint64_t consumerId, const MessageIdData& messageId,
-                              CommandAck_AckType ackType,
+SharedBuffer Commands::newAck(uint64_t consumerId, const MessageIdData& messageId, CommandAck_AckType ackType,
                               int validationError) {
     BaseCommand cmd;
     cmd.set_type(BaseCommand::ACK);
@@ -240,7 +235,7 @@ SharedBuffer Commands::newAck(uint64_t consumerId, const MessageIdData& messageI
     ack->set_consumer_id(consumerId);
     ack->set_ack_type(ackType);
     if (CommandAck_AckType_IsValid(validationError)) {
-        ack->set_validation_error((CommandAck_ValidationError) validationError);
+        ack->set_validation_error((CommandAck_ValidationError)validationError);
     }
     *(ack->mutable_message_id()) = messageId;
     return writeMessageWithSize(cmd);
@@ -375,8 +370,7 @@ std::string Commands::messageType(BaseCommand_Type type) {
     };
 }
 
-void Commands::initBatchMessageMetadata(const Message &msg, pulsar::proto::MessageMetadata &batchMetadata)
-{
+void Commands::initBatchMessageMetadata(const Message& msg, pulsar::proto::MessageMetadata& batchMetadata) {
     if (msg.impl_->metadata.has_publish_time()) {
         batchMetadata.set_publish_time(msg.impl_->metadata.publish_time());
     }
@@ -390,16 +384,16 @@ void Commands::initBatchMessageMetadata(const Message &msg, pulsar::proto::Messa
     }
 }
 
-void Commands::serializeSingleMessageInBatchWithPayload(const Message &msg,
-                                                        SharedBuffer& batchPayLoad, const unsigned long& maxMessageSizeInBytes) {
+void Commands::serializeSingleMessageInBatchWithPayload(const Message& msg, SharedBuffer& batchPayLoad,
+                                                        const unsigned long& maxMessageSizeInBytes) {
     SingleMessageMetadata metadata;
     if (msg.impl_->hasPartitionKey()) {
         metadata.set_partition_key(msg.impl_->getPartitionKey());
     }
 
     for (MessageBuilder::StringMap::const_iterator it = msg.impl_->properties().begin();
-            it != msg.impl_->properties().end(); it++) {
-        proto::KeyValue *keyValue = proto::KeyValue().New();
+         it != msg.impl_->properties().end(); it++) {
+        proto::KeyValue* keyValue = proto::KeyValue().New();
         keyValue->set_key(it->first);
         keyValue->set_value(it->second);
         metadata.mutable_properties()->AddAllocated(keyValue);
@@ -415,8 +409,11 @@ void Commands::serializeSingleMessageInBatchWithPayload(const Message &msg,
 
     unsigned long requiredSpace = sizeof(uint32_t) + msgMetadataSize + payloadSize;
     if (batchPayLoad.writableBytes() <= sizeof(uint32_t) + msgMetadataSize + payloadSize) {
-        LOG_DEBUG("remaining size of batchPayLoad buffer [" << batchPayLoad.writableBytes() << "] can't accomodate new payload [" << requiredSpace << "] - expanding the batchPayload buffer");
-        SharedBuffer buffer = SharedBuffer::allocate(batchPayLoad.readableBytes() +  std::max(requiredSpace, maxMessageSizeInBytes));
+        LOG_DEBUG("remaining size of batchPayLoad buffer ["
+                  << batchPayLoad.writableBytes() << "] can't accomodate new payload [" << requiredSpace
+                  << "] - expanding the batchPayload buffer");
+        SharedBuffer buffer = SharedBuffer::allocate(batchPayLoad.readableBytes() +
+                                                     std::max(requiredSpace, maxMessageSizeInBytes));
         // Adding batch created so far
         buffer.write(batchPayLoad.data(), batchPayLoad.readableBytes());
         batchPayLoad = buffer;
@@ -445,11 +442,10 @@ Message Commands::deSerializeSingleMessageInBatch(Message& batchedMessage) {
     SharedBuffer payload = uncompressedPayload.slice(0, payloadSize);
     uncompressedPayload.consume(payloadSize);
 
-    Message singleMessage(batchedMessage.impl_->messageId, batchedMessage.impl_->metadata, payload,
-                          metadata);
+    Message singleMessage(batchedMessage.impl_->messageId, batchedMessage.impl_->metadata, payload, metadata);
     singleMessage.impl_->cnx_ = batchedMessage.impl_->cnx_;
 
     return singleMessage;
 }
-}
+}  // namespace pulsar
 /* namespace pulsar */
diff --git a/pulsar-client-cpp/lib/Commands.h b/pulsar-client-cpp/lib/Commands.h
index 1edbb73..1fd9e48 100644
--- a/pulsar-client-cpp/lib/Commands.h
+++ b/pulsar-client-cpp/lib/Commands.h
@@ -38,19 +38,22 @@ typedef boost::shared_ptr<proto::MessageMetadata> MessageMetadataPtr;
  * Buffer are already including the 4 byte size at the beginning
  */
 class Commands {
- public:
-
-    enum ChecksumType {
+   public:
+    enum ChecksumType
+    {
         Crc32c,
         None
     };
-    enum WireFormatConstant {
+    enum WireFormatConstant
+    {
         MaxMessageSize = (5 * 1024 * 1024 - (10 * 1024)),
         MaxFrameSize = (5 * 1024 * 1024)
     };
 
-    enum SubscriptionMode {
-        // Make the subscription to be backed by a durable cursor that will retain messages and persist the current
+    enum SubscriptionMode
+    {
+        // Make the subscription to be backed by a durable cursor that will retain messages and persist the
+        // current
         // position
         SubscriptionModeDurable,
 
@@ -65,16 +68,14 @@ class Commands {
 
     static SharedBuffer newPartitionMetadataRequest(const std::string& topic, uint64_t requestId);
 
-    static SharedBuffer newLookup(const std::string& topic, const bool authoritative,
-                                  uint64_t requestId);
+    static SharedBuffer newLookup(const std::string& topic, const bool authoritative, uint64_t requestId);
 
-    static PairSharedBuffer newSend(SharedBuffer& headers, proto::BaseCommand& cmd,
-                                    uint64_t producerId, uint64_t sequenceId, ChecksumType checksumType, const Message& msg);
+    static PairSharedBuffer newSend(SharedBuffer& headers, proto::BaseCommand& cmd, uint64_t producerId,
+                                    uint64_t sequenceId, ChecksumType checksumType, const Message& msg);
 
-    static SharedBuffer newSubscribe(const std::string& topic, const std::string&subscription,
+    static SharedBuffer newSubscribe(const std::string& topic, const std::string& subscription,
                                      uint64_t consumerId, uint64_t requestId,
-                                     proto::CommandSubscribe_SubType subType,
-                                     const std::string& consumerName,
+                                     proto::CommandSubscribe_SubType subType, const std::string& consumerName,
                                      SubscriptionMode subscriptionMode,
                                      Optional<BatchMessageId> startMessageId);
 
@@ -99,19 +100,19 @@ class Commands {
 
     static std::string messageType(proto::BaseCommand::Type type);
 
-    static void initBatchMessageMetadata(const Message &msg, pulsar::proto::MessageMetadata &batchMetadata);
+    static void initBatchMessageMetadata(const Message& msg, pulsar::proto::MessageMetadata& batchMetadata);
 
-    static void serializeSingleMessageInBatchWithPayload(const Message &msg, SharedBuffer& batchPayLoad, const unsigned long& maxMessageSizeInBytes);
+    static void serializeSingleMessageInBatchWithPayload(const Message& msg, SharedBuffer& batchPayLoad,
+                                                         const unsigned long& maxMessageSizeInBytes);
 
     static Message deSerializeSingleMessageInBatch(Message& batchedMessage);
 
     static SharedBuffer newConsumerStats(uint64_t consumerId, uint64_t requestId);
 
- private:
+   private:
     Commands();
 
     static SharedBuffer writeMessageWithSize(const proto::BaseCommand& cmd);
-
 };
 
 } /* namespace pulsar */
diff --git a/pulsar-client-cpp/lib/CompressionCodec.cc b/pulsar-client-cpp/lib/CompressionCodec.cc
index 38635fb..e453887 100644
--- a/pulsar-client-cpp/lib/CompressionCodec.cc
+++ b/pulsar-client-cpp/lib/CompressionCodec.cc
@@ -62,14 +62,11 @@ proto::CompressionType CompressionCodecProvider::convertType(CompressionType typ
     }
 }
 
-SharedBuffer CompressionCodecNone::encode(const SharedBuffer& raw) {
-    return raw;
-}
+SharedBuffer CompressionCodecNone::encode(const SharedBuffer& raw) { return raw; }
 
 bool CompressionCodecNone::decode(const SharedBuffer& encoded, uint32_t uncompressedSize,
                                   SharedBuffer& decoded) {
     decoded = encoded;
     return true;
 }
-
-}
+}  // namespace pulsar
diff --git a/pulsar-client-cpp/lib/CompressionCodec.h b/pulsar-client-cpp/lib/CompressionCodec.h
index 1716c24..2fc6ead 100644
--- a/pulsar-client-cpp/lib/CompressionCodec.h
+++ b/pulsar-client-cpp/lib/CompressionCodec.h
@@ -37,21 +37,21 @@ class CompressionCodecLZ4;
 class CompressionCodecZLib;
 
 class CompressionCodecProvider {
- public:
+   public:
     static CompressionType convertType(proto::CompressionType type);
     static proto::CompressionType convertType(CompressionType type);
 
     static CompressionCodec& getCodec(CompressionType compressionType);
- private:
+
+   private:
     static CompressionCodecNone compressionCodecNone_;
     static CompressionCodecLZ4 compressionCodecLZ4_;
     static CompressionCodecZLib compressionCodecZLib_;
 };
 
 class CompressionCodec {
- public:
-    virtual ~CompressionCodec() {
-    }
+   public:
+    virtual ~CompressionCodec() {}
 
     /**
      * Compress a buffer
@@ -75,17 +75,15 @@ class CompressionCodec {
      *             were the result will be passed
      * @return true if the buffer was decompressed, false otherwise
      */
-    virtual bool decode(const SharedBuffer& encoded, uint32_t uncompressedSize,
-                        SharedBuffer& decoded) = 0;
+    virtual bool decode(const SharedBuffer& encoded, uint32_t uncompressedSize, SharedBuffer& decoded) = 0;
 };
 
 class CompressionCodecNone : public CompressionCodec {
- public:
+   public:
     SharedBuffer encode(const SharedBuffer& raw);
 
     bool decode(const SharedBuffer& encoded, uint32_t uncompressedSize, SharedBuffer& decoded);
 };
-
-}
+}  // namespace pulsar
 
 #endif /* LIB_COMPRESSIONCODEC_H_ */
diff --git a/pulsar-client-cpp/lib/CompressionCodecLZ4.cc b/pulsar-client-cpp/lib/CompressionCodecLZ4.cc
index 470c227..508e4f4 100644
--- a/pulsar-client-cpp/lib/CompressionCodecLZ4.cc
+++ b/pulsar-client-cpp/lib/CompressionCodecLZ4.cc
@@ -28,8 +28,8 @@ SharedBuffer CompressionCodecLZ4::encode(const SharedBuffer& raw) {
     int maxCompressedSize = LZ4_compressBound(raw.readableBytes());
     SharedBuffer compressed = SharedBuffer::allocate(maxCompressedSize);
 
-    int compressedSize = LZ4_compress_default(raw.data(), compressed.mutableData(),
-                                              raw.readableBytes(), maxCompressedSize);
+    int compressedSize =
+        LZ4_compress_default(raw.data(), compressed.mutableData(), raw.readableBytes(), maxCompressedSize);
     assert(compressedSize > 0);
     compressed.bytesWritten(compressedSize);
 
@@ -50,5 +50,4 @@ bool CompressionCodecLZ4::decode(const SharedBuffer& encoded, uint32_t uncompres
         return false;
     }
 }
-
-}
+}  // namespace pulsar
diff --git a/pulsar-client-cpp/lib/CompressionCodecLZ4.h b/pulsar-client-cpp/lib/CompressionCodecLZ4.h
index a7fe76c..147e013 100644
--- a/pulsar-client-cpp/lib/CompressionCodecLZ4.h
+++ b/pulsar-client-cpp/lib/CompressionCodecLZ4.h
@@ -24,11 +24,10 @@
 namespace pulsar {
 
 class CompressionCodecLZ4 : public CompressionCodec {
- public:
+   public:
     SharedBuffer encode(const SharedBuffer& raw);
 
     bool decode(const SharedBuffer& encoded, uint32_t uncompressedSize, SharedBuffer& decoded);
 };
-
-}
+}  // namespace pulsar
 #endif /* LIB_COMPRESSIONCODECLZ4_H_ */
diff --git a/pulsar-client-cpp/lib/CompressionCodecZLib.cc b/pulsar-client-cpp/lib/CompressionCodecZLib.cc
index bc3dc48..0ddc644 100644
--- a/pulsar-client-cpp/lib/CompressionCodecZLib.cc
+++ b/pulsar-client-cpp/lib/CompressionCodecZLib.cc
@@ -34,8 +34,8 @@ SharedBuffer CompressionCodecZLib::encode(const SharedBuffer& raw) {
     SharedBuffer compressed = SharedBuffer::allocate(maxCompressedSize);
 
     unsigned long bytesWritten = maxCompressedSize;
-    int res = compress((Bytef*) compressed.mutableData(), &bytesWritten, (const Bytef*) raw.data(),
-             raw.readableBytes());
+    int res = compress((Bytef*)compressed.mutableData(), &bytesWritten, (const Bytef*)raw.data(),
+                       raw.readableBytes());
     if (res != Z_OK) {
         LOG_ERROR("Failed to compress buffer. res=" << res);
         abort();
@@ -50,7 +50,8 @@ bool CompressionCodecZLib::decode(const SharedBuffer& encoded, uint32_t uncompre
     SharedBuffer decompressed = SharedBuffer::allocate(uncompressedSize);
 
     unsigned long bytesUncompressed = uncompressedSize;
-    int res = uncompress((Bytef*) decompressed.mutableData(), &bytesUncompressed, (Bytef*) encoded.data(), encoded.readableBytes());
+    int res = uncompress((Bytef*)decompressed.mutableData(), &bytesUncompressed, (Bytef*)encoded.data(),
+                         encoded.readableBytes());
 
     decompressed.bytesWritten(bytesUncompressed);
     if (res == Z_OK) {
@@ -60,5 +61,4 @@ bool CompressionCodecZLib::decode(const SharedBuffer& encoded, uint32_t uncompre
         return false;
     }
 }
-
-}
+}  // namespace pulsar
diff --git a/pulsar-client-cpp/lib/CompressionCodecZLib.h b/pulsar-client-cpp/lib/CompressionCodecZLib.h
index 9495201..52e43ff 100644
--- a/pulsar-client-cpp/lib/CompressionCodecZLib.h
+++ b/pulsar-client-cpp/lib/CompressionCodecZLib.h
@@ -26,12 +26,11 @@
 namespace pulsar {
 
 class CompressionCodecZLib : public CompressionCodec {
- public:
+   public:
     SharedBuffer encode(const SharedBuffer& raw);
 
     bool decode(const SharedBuffer& encoded, uint32_t uncompressedSize, SharedBuffer& decoded);
 };
-
-}
+}  // namespace pulsar
 
 #endif /* LIB_COMPRESSIONCODECZLIB_H_ */
diff --git a/pulsar-client-cpp/lib/ConnectionPool.cc b/pulsar-client-cpp/lib/ConnectionPool.cc
index 076b177..6ee0e9d 100644
--- a/pulsar-client-cpp/lib/ConnectionPool.cc
+++ b/pulsar-client-cpp/lib/ConnectionPool.cc
@@ -24,19 +24,16 @@ DECLARE_LOG_OBJECT()
 
 namespace pulsar {
 
-ConnectionPool::ConnectionPool(const ClientConfiguration& conf,
-                               ExecutorServiceProviderPtr executorProvider,
+ConnectionPool::ConnectionPool(const ClientConfiguration& conf, ExecutorServiceProviderPtr executorProvider,
                                const AuthenticationPtr& authentication, bool poolConnections)
-        : clientConfiguration_(conf),
-          executorProvider_(executorProvider),
-          authentication_(authentication),
-          pool_(),
-          poolConnections_(poolConnections),
-          mutex_() {
-}
+    : clientConfiguration_(conf),
+      executorProvider_(executorProvider),
+      authentication_(authentication),
+      pool_(),
+      poolConnections_(poolConnections),
+      mutex_() {}
 
-Future<Result, ClientConnectionWeakPtr> ConnectionPool::getConnectionAsync(
-        const std::string& endpoint) {
+Future<Result, ClientConnectionWeakPtr> ConnectionPool::getConnectionAsync(const std::string& endpoint) {
     boost::unique_lock<boost::mutex> lock(mutex_);
 
     if (poolConnections_) {
@@ -47,19 +44,20 @@ Future<Result, ClientConnectionWeakPtr> ConnectionPool::getConnectionAsync(
             if (cnx && !cnx->isClosed()) {
                 // Found a valid or pending connection in the pool
                 LOG_DEBUG("Got connection from pool for " << endpoint << " use_count: "  //
-                        << (cnx.use_count() - 1) << " @ " << cnx.get());
+                                                          << (cnx.use_count() - 1) << " @ " << cnx.get());
                 return cnx->getConnectFuture();
             } else {
                 // Deleting stale connection
-                LOG_INFO("Deleting stale connection from pool for " << endpoint << " use_count: "
-                        << (cnx.use_count() - 1) << " @ " << cnx.get());
+                LOG_INFO("Deleting stale connection from pool for "
+                         << endpoint << " use_count: " << (cnx.use_count() - 1) << " @ " << cnx.get());
                 pool_.erase(endpoint);
             }
         }
     }
 
     // No valid or pending connection found in the pool, creating a new one
-    ClientConnectionPtr cnx(new ClientConnection(endpoint, executorProvider_->get(), clientConfiguration_, authentication_));
+    ClientConnectionPtr cnx(
+        new ClientConnection(endpoint, executorProvider_->get(), clientConfiguration_, authentication_));
 
     LOG_INFO("Created connection for " << endpoint);
 
@@ -71,5 +69,4 @@ Future<Result, ClientConnectionWeakPtr> ConnectionPool::getConnectionAsync(
     cnx->tcpConnectAsync();
     return future;
 }
-
-}
+}  // namespace pulsar
diff --git a/pulsar-client-cpp/lib/ConnectionPool.h b/pulsar-client-cpp/lib/ConnectionPool.h
index af67474..8a12890 100644
--- a/pulsar-client-cpp/lib/ConnectionPool.h
+++ b/pulsar-client-cpp/lib/ConnectionPool.h
@@ -17,7 +17,7 @@
  * under the License.
  */
 #ifndef _PULSAR_CONNECTION_POOL_HEADER_
-#define  _PULSAR_CONNECTION_POOL_HEADER_
+#define _PULSAR_CONNECTION_POOL_HEADER_
 
 #include <pulsar/Result.h>
 
@@ -32,13 +32,13 @@ namespace pulsar {
 class ExecutorService;
 
 class ConnectionPool {
- public:
+   public:
     ConnectionPool(const ClientConfiguration& conf, ExecutorServiceProviderPtr executorProvider,
                    const AuthenticationPtr& authentication, bool poolConnections = true);
 
     Future<Result, ClientConnectionWeakPtr> getConnectionAsync(const std::string& endpoint);
 
- private:
+   private:
     ClientConfiguration clientConfiguration_;
     ExecutorServiceProviderPtr executorProvider_;
     AuthenticationPtr authentication_;
@@ -49,7 +49,6 @@ class ConnectionPool {
 
     friend class ConnectionPoolTest;
 };
-
-}
+}  // namespace pulsar
 #pragma GCC visibility pop
-#endif //_PULSAR_CONNECTION_POOL_HEADER_
+#endif  //_PULSAR_CONNECTION_POOL_HEADER_
diff --git a/pulsar-client-cpp/lib/Consumer.cc b/pulsar-client-cpp/lib/Consumer.cc
index 010cd1a..726676d 100644
--- a/pulsar-client-cpp/lib/Consumer.cc
+++ b/pulsar-client-cpp/lib/Consumer.cc
@@ -27,17 +27,11 @@ namespace pulsar {
 
 static const std::string EMPTY_STRING;
 
-Consumer::Consumer()
-        : impl_() {
-}
+Consumer::Consumer() : impl_() {}
 
-Consumer::Consumer(ConsumerImplBasePtr impl)
-        : impl_(impl) {
-}
+Consumer::Consumer(ConsumerImplBasePtr impl) : impl_(impl) {}
 
-const std::string& Consumer::getTopic() const {
-    return impl_ != NULL ? impl_->getTopic() : EMPTY_STRING;
-}
+const std::string& Consumer::getTopic() const { return impl_ != NULL ? impl_->getTopic() : EMPTY_STRING; }
 
 const std::string& Consumer::getSubscriptionName() const {
     return impl_ != NULL ? impl_->getSubscriptionName() : EMPTY_STRING;
@@ -79,9 +73,7 @@ Result Consumer::receive(Message& msg, int timeoutMs) {
     return impl_->receive(msg, timeoutMs);
 }
 
-Result Consumer::acknowledge(const Message& message) {
-    return acknowledge(message.getMessageId());
-}
+Result Consumer::acknowledge(const Message& message) { return acknowledge(message.getMessageId()); }
 
 Result Consumer::acknowledge(const MessageId& messageId) {
     if (!impl_) {
@@ -197,4 +189,4 @@ void Consumer::getBrokerConsumerStatsAsync(BrokerConsumerStatsCallback callback)
     }
     impl_->getBrokerConsumerStatsAsync(callback);
 }
-}
+}  // namespace pulsar
diff --git a/pulsar-client-cpp/lib/ConsumerConfiguration.cc b/pulsar-client-cpp/lib/ConsumerConfiguration.cc
index 35d75b7..be19a44 100644
--- a/pulsar-client-cpp/lib/ConsumerConfiguration.cc
+++ b/pulsar-client-cpp/lib/ConsumerConfiguration.cc
@@ -20,16 +20,11 @@
 
 namespace pulsar {
 
-ConsumerConfiguration::ConsumerConfiguration()
-        : impl_(boost::make_shared<ConsumerConfigurationImpl>()) {
-}
+ConsumerConfiguration::ConsumerConfiguration() : impl_(boost::make_shared<ConsumerConfigurationImpl>()) {}
 
-ConsumerConfiguration::~ConsumerConfiguration() {
-}
+ConsumerConfiguration::~ConsumerConfiguration() {}
 
-ConsumerConfiguration::ConsumerConfiguration(const ConsumerConfiguration& x)
-    : impl_(x.impl_) {
-}
+ConsumerConfiguration::ConsumerConfiguration(const ConsumerConfiguration& x) : impl_(x.impl_) {}
 
 ConsumerConfiguration& ConsumerConfiguration::operator=(const ConsumerConfiguration& x) {
     impl_ = x.impl_;
@@ -49,9 +44,7 @@ ConsumerConfiguration& ConsumerConfiguration::setConsumerType(ConsumerType consu
     return *this;
 }
 
-ConsumerType ConsumerConfiguration::getConsumerType() const {
-    return impl_->consumerType;
-}
+ConsumerType ConsumerConfiguration::getConsumerType() const { return impl_->consumerType; }
 
 ConsumerConfiguration& ConsumerConfiguration::setMessageListener(MessageListener messageListener) {
     impl_->messageListener = messageListener;
@@ -59,33 +52,21 @@ ConsumerConfiguration& ConsumerConfiguration::setMessageListener(MessageListener
     return *this;
 }
 
-MessageListener ConsumerConfiguration::getMessageListener() const {
-    return impl_->messageListener;
-}
+MessageListener ConsumerConfiguration::getMessageListener() const { return impl_->messageListener; }
 
-bool ConsumerConfiguration::hasMessageListener() const {
-    return impl_->hasMessageListener;
-}
+bool ConsumerConfiguration::hasMessageListener() const { return impl_->hasMessageListener; }
 
-void ConsumerConfiguration::setReceiverQueueSize(int size) {
-    impl_->receiverQueueSize = size;
-}
+void ConsumerConfiguration::setReceiverQueueSize(int size) { impl_->receiverQueueSize = size; }
 
-int ConsumerConfiguration::getReceiverQueueSize() const {
-    return impl_->receiverQueueSize;
-}
+int ConsumerConfiguration::getReceiverQueueSize() const { return impl_->receiverQueueSize; }
 
-const std::string& ConsumerConfiguration::getConsumerName() const {
-    return impl_->consumerName;
-}
+const std::string& ConsumerConfiguration::getConsumerName() const { return impl_->consumerName; }
 
 void ConsumerConfiguration::setConsumerName(const std::string& consumerName) {
     impl_->consumerName = consumerName;
 }
 
-long ConsumerConfiguration::getUnAckedMessagesTimeoutMs() const {
-    return impl_->unAckedMessagesTimeoutMs;
-}
+long ConsumerConfiguration::getUnAckedMessagesTimeoutMs() const { return impl_->unAckedMessagesTimeoutMs; }
 
 void ConsumerConfiguration::setUnAckedMessagesTimeoutMs(const uint64_t milliSeconds) {
     if (milliSeconds < 10000) {
@@ -93,4 +74,4 @@ void ConsumerConfiguration::setUnAckedMessagesTimeoutMs(const uint64_t milliSeco
     }
     impl_->unAckedMessagesTimeoutMs = milliSeconds;
 }
-}
+}  // namespace pulsar
diff --git a/pulsar-client-cpp/lib/ConsumerConfigurationImpl.h b/pulsar-client-cpp/lib/ConsumerConfigurationImpl.h
index 9f03e02..3f7ad06 100644
--- a/pulsar-client-cpp/lib/ConsumerConfigurationImpl.h
+++ b/pulsar-client-cpp/lib/ConsumerConfigurationImpl.h
@@ -32,13 +32,12 @@ struct ConsumerConfigurationImpl {
     std::string consumerName;
     long brokerConsumerStatsCacheTimeInMs;
     ConsumerConfigurationImpl()
-            : unAckedMessagesTimeoutMs(0),
-              consumerType(ConsumerExclusive),
-              messageListener(),
-              hasMessageListener(false),
-              brokerConsumerStatsCacheTimeInMs(30 * 1000), // 30 seconds
-              receiverQueueSize(1000) {
-    }
+        : unAckedMessagesTimeoutMs(0),
+          consumerType(ConsumerExclusive),
+          messageListener(),
+          hasMessageListener(false),
+          brokerConsumerStatsCacheTimeInMs(30 * 1000),  // 30 seconds
+          receiverQueueSize(1000) {}
 };
-}
+}  // namespace pulsar
 #endif /* LIB_CONSUMERCONFIGURATIONIMPL_H_ */
diff --git a/pulsar-client-cpp/lib/ConsumerImpl.cc b/pulsar-client-cpp/lib/ConsumerImpl.cc
index d46f974..ce20747 100644
--- a/pulsar-client-cpp/lib/ConsumerImpl.cc
+++ b/pulsar-client-cpp/lib/ConsumerImpl.cc
@@ -38,31 +38,32 @@ ConsumerImpl::ConsumerImpl(const ClientImplPtr client, const std::string& topic,
                            const ConsumerTopicType consumerTopicType /* = NonPartitioned by default */,
                            Commands::SubscriptionMode subscriptionMode,
                            Optional<BatchMessageId> startMessageId)
-        : HandlerBase(client, topic, Backoff(milliseconds(100), seconds(60), milliseconds(0))),
-          waitingForZeroQueueSizeMessage(false),
-          config_(conf),
-          subscription_(subscription),
-          originalSubscriptionName_(subscription),
-          messageListener_(config_.getMessageListener()),
-          consumerTopicType_(consumerTopicType),
-          subscriptionMode_(subscriptionMode),
-          startMessageId_(startMessageId),
-          // This is the initial capacity of the queue
-          incomingMessages_(std::max(config_.getReceiverQueueSize(), 1)),
-          availablePermits_(conf.getReceiverQueueSize()),
-          consumerId_(client->newConsumerId()),
-          consumerName_(config_.getConsumerName()),
-          partitionIndex_(-1),
-          consumerCreatedPromise_(),
-          messageListenerRunning_(true),
-          batchAcknowledgementTracker_(topic_, subscription, (long)consumerId_),
-          brokerConsumerStats_(),
-          consumerStatsBasePtr_() {
+    : HandlerBase(client, topic, Backoff(milliseconds(100), seconds(60), milliseconds(0))),
+      waitingForZeroQueueSizeMessage(false),
+      config_(conf),
+      subscription_(subscription),
+      originalSubscriptionName_(subscription),
+      messageListener_(config_.getMessageListener()),
+      consumerTopicType_(consumerTopicType),
+      subscriptionMode_(subscriptionMode),
+      startMessageId_(startMessageId),
+      // This is the initial capacity of the queue
+      incomingMessages_(std::max(config_.getReceiverQueueSize(), 1)),
+      availablePermits_(conf.getReceiverQueueSize()),
+      consumerId_(client->newConsumerId()),
+      consumerName_(config_.getConsumerName()),
+      partitionIndex_(-1),
+      consumerCreatedPromise_(),
+      messageListenerRunning_(true),
+      batchAcknowledgementTracker_(topic_, subscription, (long)consumerId_),
+      brokerConsumerStats_(),
+      consumerStatsBasePtr_() {
     std::stringstream consumerStrStream;
     consumerStrStream << "[" << topic_ << ", " << subscription_ << ", " << consumerId_ << "] ";
     consumerStr_ = consumerStrStream.str();
     if (conf.getUnAckedMessagesTimeoutMs() != 0) {
-        unAckedMessageTrackerPtr_.reset(new UnAckedMessageTrackerEnabled(conf.getUnAckedMessagesTimeoutMs(), client, *this));
+        unAckedMessageTrackerPtr_.reset(
+            new UnAckedMessageTrackerEnabled(conf.getUnAckedMessagesTimeoutMs(), client, *this));
     } else {
         unAckedMessageTrackerPtr_.reset(new UnAckedMessageTrackerDisabled());
     }
@@ -75,8 +76,8 @@ ConsumerImpl::ConsumerImpl(const ClientImplPtr client, const std::string& topic,
     unsigned int statsIntervalInSeconds = client->getClientConfig().getStatsIntervalInSeconds();
     if (statsIntervalInSeconds) {
         consumerStatsBasePtr_ = boost::make_shared<ConsumerStatsImpl>(
-                consumerStr_, client->getIOExecutorProvider()->get()->createDeadlineTimer(),
-                statsIntervalInSeconds);
+            consumerStr_, client->getIOExecutorProvider()->get()->createDeadlineTimer(),
+            statsIntervalInSeconds);
     } else {
         consumerStatsBasePtr_ = boost::make_shared<ConsumerStatsDisabled>();
     }
@@ -91,33 +92,21 @@ ConsumerImpl::~ConsumerImpl() {
     }
 }
 
-void ConsumerImpl::setPartitionIndex(int partitionIndex) {
-     partitionIndex_ = partitionIndex;
-}
+void ConsumerImpl::setPartitionIndex(int partitionIndex) { partitionIndex_ = partitionIndex; }
 
-int ConsumerImpl::getPartitionIndex() {
-    return partitionIndex_;
-}
+int ConsumerImpl::getPartitionIndex() { return partitionIndex_; }
 
-uint64_t ConsumerImpl::getConsumerId() {
-    return consumerId_;
-}
+uint64_t ConsumerImpl::getConsumerId() { return consumerId_; }
 
 Future<Result, ConsumerImplBaseWeakPtr> ConsumerImpl::getConsumerCreatedFuture() {
     return consumerCreatedPromise_.getFuture();
 }
 
-const std::string& ConsumerImpl::getSubscriptionName() const {
-    return originalSubscriptionName_;
-}
+const std::string& ConsumerImpl::getSubscriptionName() const { return originalSubscriptionName_; }
 
-const std::string& ConsumerImpl::getTopic() const {
-    return topic_;
-}
+const std::string& ConsumerImpl::getTopic() const { return topic_; }
 
-void ConsumerImpl::start() {
-    grabCnx();
-}
+void ConsumerImpl::start() { grabCnx(); }
 
 void ConsumerImpl::connectionOpened(const ClientConnectionPtr& cnx) {
     Lock lock(mutex_);
@@ -141,11 +130,10 @@ void ConsumerImpl::connectionOpened(const ClientConnectionPtr& cnx) {
 
     ClientImplPtr client = client_.lock();
     uint64_t requestId = client->newRequestId();
-    SharedBuffer cmd = Commands::newSubscribe(topic_, subscription_, consumerId_, requestId,
-                                              getSubType(), consumerName_, subscriptionMode_,
-                                              startMessageId_);
-    cnx->sendRequestWithId(cmd, requestId).addListener(
-            boost::bind(&ConsumerImpl::handleCreateConsumer, shared_from_this(), cnx, _1));
+    SharedBuffer cmd = Commands::newSubscribe(topic_, subscription_, consumerId_, requestId, getSubType(),
+                                              consumerName_, subscriptionMode_, startMessageId_);
+    cnx->sendRequestWithId(cmd, requestId)
+        .addListener(boost::bind(&ConsumerImpl::handleCreateConsumer, shared_from_this(), cnx, _1));
 }
 
 void ConsumerImpl::connectionFailed(Result result) {
@@ -184,10 +172,8 @@ void ConsumerImpl::handleCreateConsumer(const ClientConnectionPtr& cnx, Result r
             availablePermits_ = 0;
         }
 
-
         LOG_DEBUG(getName() << "Send initial flow permits: " << config_.getReceiverQueueSize());
-        if ((consumerTopicType_ == NonPartitioned || !firstTime)
-                && config_.getReceiverQueueSize() != 0) {
+        if ((consumerTopicType_ == NonPartitioned || !firstTime) && config_.getReceiverQueueSize() != 0) {
             receiveMessages(cnx, config_.getReceiverQueueSize());
         }
         consumerCreatedPromise_.setValue(shared_from_this());
@@ -197,20 +183,17 @@ void ConsumerImpl::handleCreateConsumer(const ClientConnectionPtr& cnx, Result r
             // in case it was indeed created, otherwise it might prevent new subscribe operation,
             // since we are not closing the connection
             int requestId = client_.lock()->newRequestId();
-            cnx->sendRequestWithId(Commands::newCloseConsumer(consumerId_, requestId),
-                                   requestId);
+            cnx->sendRequestWithId(Commands::newCloseConsumer(consumerId_, requestId), requestId);
         }
 
         if (consumerCreatedPromise_.isComplete()) {
             // Consumer had already been initially created, we need to retry connecting in any case
-            LOG_WARN(
-                    getName() << "Failed to reconnect consumer: " << strResult(result));
+            LOG_WARN(getName() << "Failed to reconnect consumer: " << strResult(result));
             scheduleReconnection(shared_from_this());
         } else {
             // Consumer was not yet created, retry to connect to broker if it's possible
             if (isRetriableError(result) && (creationTimestamp_ + operationTimeut_ < now())) {
-                LOG_WARN(
-                        getName() << "Temporary error in creating consumer : " << strResult(result));
+                LOG_WARN(getName() << "Temporary error in creating consumer : " << strResult(result));
                 scheduleReconnection(shared_from_this());
             } else {
                 LOG_ERROR(getName() << "Failed to create consumer: " << strResult(result));
@@ -228,8 +211,8 @@ void ConsumerImpl::unsubscribeAsync(ResultCallback callback) {
     if (state_ != Ready) {
         lock.unlock();
         callback(ResultAlreadyClosed);
-        LOG_ERROR(
-                getName() << "Can not unsubscribe a closed subscription, please call subscribe again and then call unsubscribe");
+        LOG_ERROR(getName() << "Can not unsubscribe a closed subscription, please call subscribe again and "
+                               "then call unsubscribe");
         return;
     }
 
@@ -240,8 +223,8 @@ void ConsumerImpl::unsubscribeAsync(ResultCallback callback) {
         lock.unlock();
         int requestId = client->newRequestId();
         SharedBuffer cmd = Commands::newUnsubscribe(consumerId_, requestId);
-        cnx->sendRequestWithId(cmd, requestId).addListener(
-                boost::bind(&ConsumerImpl::handleUnsubscribe, shared_from_this(), _1, callback));
+        cnx->sendRequestWithId(cmd, requestId)
+            .addListener(boost::bind(&ConsumerImpl::handleUnsubscribe, shared_from_this(), _1, callback));
     } else {
         Result result = ResultNotConnected;
         lock.unlock();
@@ -281,8 +264,9 @@ void ConsumerImpl::messageReceived(const ClientConnectionPtr& cnx, const proto::
     m.impl_->messageId.partition_ = partitionIndex_;
     m.impl_->cnx_ = cnx.get();
 
-    LOG_DEBUG(getName() << " metadata.num_messages_in_batch() = "<< metadata.num_messages_in_batch());
-    LOG_DEBUG(getName() << " metadata.has_num_messages_in_batch() = "<< metadata.has_num_messages_in_batch());
+    LOG_DEBUG(getName() << " metadata.num_messages_in_batch() = " << metadata.num_messages_in_batch());
+    LOG_DEBUG(getName() << " metadata.has_num_messages_in_batch() = "
+                        << metadata.has_num_messages_in_batch());
 
     unsigned int numOfMessageReceived = 1;
     if (metadata.has_num_messages_in_batch()) {
@@ -294,7 +278,7 @@ void ConsumerImpl::messageReceived(const ClientConnectionPtr& cnx, const proto::
             incomingMessages_.push(m);
         } else {
             Lock lock(mutex_);
-            if(waitingForZeroQueueSizeMessage) {
+            if (waitingForZeroQueueSizeMessage) {
                 lock.unlock();
                 incomingMessages_.push(m);
             }
@@ -308,19 +292,19 @@ void ConsumerImpl::messageReceived(const ClientConnectionPtr& cnx, const proto::
         }
         lock.unlock();
         // Trigger message listener callback in a separate thread
-        while(numOfMessageReceived--) {
-            listenerExecutor_->postWork(
-                boost::bind(&ConsumerImpl::internalListener, shared_from_this()));
+        while (numOfMessageReceived--) {
+            listenerExecutor_->postWork(boost::bind(&ConsumerImpl::internalListener, shared_from_this()));
         }
     }
 }
 
 // Zero Queue size is not supported with Batch Messages
-uint32_t ConsumerImpl::receiveIndividualMessagesFromBatch(const ClientConnectionPtr& cnx, Message& batchedMessage) {
+uint32_t ConsumerImpl::receiveIndividualMessagesFromBatch(const ClientConnectionPtr& cnx,
+                                                          Message& batchedMessage) {
     unsigned int batchSize = batchedMessage.impl_->metadata.num_messages_in_batch();
     batchAcknowledgementTracker_.receivedMessage(batchedMessage);
     LOG_DEBUG("Received Batch messages of size - " << batchSize
-             << " -- msgId: " << batchedMessage.getMessageId());
+                                                   << " -- msgId: " << batchedMessage.getMessageId());
 
     int skippedMessages = 0;
 
@@ -334,11 +318,11 @@ uint32_t ConsumerImpl::receiveIndividualMessagesFromBatch(const ClientConnection
 
             // If we are receiving a batch message, we need to discard messages that were prior
             // to the startMessageId
-            if (msgId.ledgerId_ == startMessageId_.value().ledgerId_
-                    && msgId.entryId_ == startMessageId_.value().entryId_
-                    && msgId.batchIndex_ <= startMessageId_.value().batchIndex_) {
-                LOG_DEBUG(
-                        getName() << "Ignoring message from before the startMessageId" << msg.getMessageId());
+            if (msgId.ledgerId_ == startMessageId_.value().ledgerId_ &&
+                msgId.entryId_ == startMessageId_.value().entryId_ &&
+                msgId.batchIndex_ <= startMessageId_.value().batchIndex_) {
+                LOG_DEBUG(getName() << "Ignoring message from before the startMessageId"
+                                    << msg.getMessageId());
                 ++skippedMessages;
                 continue;
             }
@@ -355,10 +339,8 @@ uint32_t ConsumerImpl::receiveIndividualMessagesFromBatch(const ClientConnection
     return batchSize - skippedMessages;
 }
 
-bool ConsumerImpl::uncompressMessageIfNeeded(const ClientConnectionPtr& cnx,
-                                             const proto::CommandMessage& msg,
-                                             const proto::MessageMetadata& metadata,
-                                             SharedBuffer& payload) {
+bool ConsumerImpl::uncompressMessageIfNeeded(const ClientConnectionPtr& cnx, const proto::CommandMessage& msg,
+                                             const proto::MessageMetadata& metadata, SharedBuffer& payload) {
     if (!metadata.has_compression()) {
         return true;
     }
@@ -370,15 +352,14 @@ bool ConsumerImpl::uncompressMessageIfNeeded(const ClientConnectionPtr& cnx,
     if (payloadSize > Commands::MaxMessageSize) {
         // Uncompressed size is itself corrupted since it cannot be bigger than the MaxMessageSize
         LOG_ERROR(getName() << "Got corrupted payload message size " << payloadSize  //
-                << " at  " << msg.message_id().ledgerid() << ":" << msg.message_id().entryid());
-        discardCorruptedMessage(cnx, msg.message_id(),
-                                proto::CommandAck::UncompressedSizeCorruption);
+                            << " at  " << msg.message_id().ledgerid() << ":" << msg.message_id().entryid());
+        discardCorruptedMessage(cnx, msg.message_id(), proto::CommandAck::UncompressedSizeCorruption);
         return false;
     }
 
     if (!CompressionCodecProvider::getCodec(compressionType).decode(payload, uncompressedSize, payload)) {
         LOG_ERROR(getName() << "Failed to decompress message with " << uncompressedSize  //
-                << " at  " << msg.message_id().ledgerid() << ":" << msg.message_id().entryid());
+                            << " at  " << msg.message_id().ledgerid() << ":" << msg.message_id().entryid());
         discardCorruptedMessage(cnx, msg.message_id(), proto::CommandAck::DecompressionError);
         return false;
     }
@@ -389,10 +370,11 @@ bool ConsumerImpl::uncompressMessageIfNeeded(const ClientConnectionPtr& cnx,
 void ConsumerImpl::discardCorruptedMessage(const ClientConnectionPtr& cnx,
                                            const proto::MessageIdData& messageId,
                                            proto::CommandAck::ValidationError validationError) {
-    LOG_ERROR(
-            getName() << "Discarding corrupted message at " << messageId.ledgerid() << ":" << messageId.entryid());
+    LOG_ERROR(getName() << "Discarding corrupted message at " << messageId.ledgerid() << ":"
+                        << messageId.entryid());
 
-    SharedBuffer cmd  = Commands::newAck(consumerId_, messageId, proto::CommandAck::Individual, validationError);
+    SharedBuffer cmd =
+        Commands::newAck(consumerId_, messageId, proto::CommandAck::Individual, validationError);
 
     cnx->sendCommand(cmd);
     increaseAvailablePermits(cnx);
@@ -431,7 +413,7 @@ Result ConsumerImpl::fetchSingleMessageFromBroker(Message& msg) {
     // Just being cautious
     if (incomingMessages_.size() != 0) {
         LOG_ERROR(
-                getName() << "The incoming message queue should never be greater than 0 when Queue size is 0");
+            getName() << "The incoming message queue should never be greater than 0 when Queue size is 0");
         incomingMessages_.clear();
     }
     Lock localLock(mutex_);
@@ -446,7 +428,8 @@ Result ConsumerImpl::fetchSingleMessageFromBroker(Message& msg) {
     while (true) {
         incomingMessages_.pop(msg);
         {
-            // Lock needed to prevent race between connectionOpened and the check "msg.impl_->cnx_ == currentCnx.get())"
+            // Lock needed to prevent race between connectionOpened and the check "msg.impl_->cnx_ ==
+            // currentCnx.get())"
             Lock localLock(mutex_);
             // if message received due to an old flow - discard it and wait for the message from the
             // latest flow command
@@ -523,8 +506,7 @@ Result ConsumerImpl::receiveHelper(Message& msg, int timeout) {
 
 void ConsumerImpl::messageProcessed(Message& msg) {
     Lock lock(mutex_);
-    lastDequedMessage_ = Optional<BatchMessageId>::of(
-            static_cast<const BatchMessageId&>(msg.getMessageId()));
+    lastDequedMessage_ = Optional<BatchMessageId>::of(static_cast<const BatchMessageId&>(msg.getMessageId()));
 
     ClientConnectionPtr currentCnx = getCnx().lock();
     if (currentCnx && msg.impl_->cnx_ != currentCnx.get()) {
@@ -536,38 +518,41 @@ void ConsumerImpl::messageProcessed(Message& msg) {
 }
 
 /**
- * Clear the internal receiver queue and returns the message id of what was the 1st message in the queue that was
+ * Clear the internal receiver queue and returns the message id of what was the 1st message in the queue that
+ * was
  * not seen by the application
  */
 Optional<BatchMessageId> ConsumerImpl::clearReceiveQueue() {
     Message nextMessageInQueue;
     if (incomingMessages_.peekAndClear(nextMessageInQueue)) {
         // There was at least one message pending in the queue
-        // We can safely cast to 'BatchMessageId' since all the messages queued will have that type of message id,
+        // We can safely cast to 'BatchMessageId' since all the messages queued will have that type of message
+        // id,
         // irrespective of whether they were part of a batch or not.
         const BatchMessageId& nextMessageId =
-                static_cast<const BatchMessageId&>(nextMessageInQueue.getMessageId());
+            static_cast<const BatchMessageId&>(nextMessageInQueue.getMessageId());
         BatchMessageId previousMessageId;
         if (nextMessageId.batchIndex_ >= 0) {
             previousMessageId = BatchMessageId(nextMessageId.ledgerId_, nextMessageId.entryId_,
                                                nextMessageId.batchIndex_ - 1);
         } else {
-            previousMessageId = BatchMessageId(nextMessageId.ledgerId_, nextMessageId.entryId_ - 1,
-                                               -1);
+            previousMessageId = BatchMessageId(nextMessageId.ledgerId_, nextMessageId.entryId_ - 1, -1);
         }
         return Optional<BatchMessageId>::of(previousMessageId);
     } else if (lastDequedMessage_.is_present()) {
-        // If the queue was empty we need to restart from the message just after the last one that has been dequeued
+        // If the queue was empty we need to restart from the message just after the last one that has been
+        // dequeued
         // in the past
         return lastDequedMessage_;
     } else {
-        // No message was received or dequeued by this consumer. Next message would still be the startMessageId
+        // No message was received or dequeued by this consumer. Next message would still be the
+        // startMessageId
         return startMessageId_;
     }
 }
 
 void ConsumerImpl::increaseAvailablePermits(const ClientConnectionPtr& currentCnx, int numberOfPermits) {
-    int additionalPermits =  0;
+    int additionalPermits = 0;
 
     availablePermits_ += numberOfPermits;
     if (availablePermits_ >= config_.getReceiverQueueSize() / 2) {
@@ -598,7 +583,6 @@ inline proto::CommandSubscribe_SubType ConsumerImpl::getSubType() {
     }
 }
 
-
 void ConsumerImpl::statsCallback(Result res, ResultCallback callback, proto::CommandAck_AckType ackType) {
     consumerStatsBasePtr_->messageAcknowledged(res, ackType);
     if (callback) {
@@ -607,9 +591,11 @@ void ConsumerImpl::statsCallback(Result res, ResultCallback callback, proto::Com
 }
 
 void ConsumerImpl::acknowledgeAsync(const MessageId& msgId, ResultCallback callback) {
-    ResultCallback cb = boost::bind(&ConsumerImpl::statsCallback, this, _1, callback, proto::CommandAck_AckType_Individual);
+    ResultCallback cb =
+        boost::bind(&ConsumerImpl::statsCallback, this, _1, callback, proto::CommandAck_AckType_Individual);
     const BatchMessageId& batchMsgId = (const BatchMessageId&)msgId;
-    if(batchMsgId.batchIndex_ != -1 && !batchAcknowledgementTracker_.isBatchReady(batchMsgId, proto::CommandAck_AckType_Individual)) {
+    if (batchMsgId.batchIndex_ != -1 &&
+        !batchAcknowledgementTracker_.isBatchReady(batchMsgId, proto::CommandAck_AckType_Individual)) {
         cb(ResultOk);
         return;
     }
@@ -617,11 +603,13 @@ void ConsumerImpl::acknowledgeAsync(const MessageId& msgId, ResultCallback callb
 }
 
 void ConsumerImpl::acknowledgeCumulativeAsync(const MessageId& mId, ResultCallback callback) {
-    ResultCallback cb = boost::bind(&ConsumerImpl::statsCallback, this, _1, callback, proto::CommandAck_AckType_Cumulative);
-    const BatchMessageId& msgId = (const BatchMessageId&) mId;
-    if(msgId.batchIndex_ != -1 && !batchAcknowledgementTracker_.isBatchReady(msgId, proto::CommandAck_AckType_Cumulative)) {
+    ResultCallback cb =
+        boost::bind(&ConsumerImpl::statsCallback, this, _1, callback, proto::CommandAck_AckType_Cumulative);
+    const BatchMessageId& msgId = (const BatchMessageId&)mId;
+    if (msgId.batchIndex_ != -1 &&
+        !batchAcknowledgementTracker_.isBatchReady(msgId, proto::CommandAck_AckType_Cumulative)) {
         BatchMessageId messageId = batchAcknowledgementTracker_.getGreatestCumulativeAckReady(msgId);
-        if(messageId == BatchMessageId()) {
+        if (messageId == BatchMessageId()) {
             // nothing to ack
             cb(ResultOk);
         } else {
@@ -634,7 +622,6 @@ void ConsumerImpl::acknowledgeCumulativeAsync(const MessageId& mId, ResultCallba
 
 void ConsumerImpl::doAcknowledge(const BatchMessageId& messageId, proto::CommandAck_AckType ackType,
                                  ResultCallback callback) {
-
     proto::MessageIdData messageIdData;
     messageIdData.set_ledgerid(messageId.ledgerId_);
     messageIdData.set_entryid(messageId.entryId_);
@@ -649,12 +636,12 @@ void ConsumerImpl::doAcknowledge(const BatchMessageId& messageId, proto::Command
         }
         batchAcknowledgementTracker_.deleteAckedMessage((BatchMessageId&)messageId, ackType);
         callback(ResultOk);
-        LOG_DEBUG(
-                getName() << "ack request sent for message - [" << messageIdData.ledgerid() << "," << messageIdData.entryid() << "]");
+        LOG_DEBUG(getName() << "ack request sent for message - [" << messageIdData.ledgerid() << ","
+                            << messageIdData.entryid() << "]");
 
     } else {
         LOG_DEBUG(getName() << "Connection is not ready, Acknowledge failed for message - ["  //
-                << messageIdData.ledgerid() << "," << messageIdData.entryid() << "]");
+                            << messageIdData.ledgerid() << "," << messageIdData.entryid() << "]");
         callback(ResultNotConnected);
     }
 }
@@ -687,7 +674,6 @@ void ConsumerImpl::closeAsync(ResultCallback callback) {
         return;
     }
 
-
     ClientImplPtr client = client_.lock();
     if (!client) {
         lock.unlock();
@@ -701,13 +687,11 @@ void ConsumerImpl::closeAsync(ResultCallback callback) {
     // Lock is no longer required
     lock.unlock();
     int requestId = client->newRequestId();
-    Future<Result, ResponseData> future = cnx->sendRequestWithId(
-            Commands::newCloseConsumer(consumerId_, requestId), requestId);
+    Future<Result, ResponseData> future =
+        cnx->sendRequestWithId(Commands::newCloseConsumer(consumerId_, requestId), requestId);
     if (!callback.empty()) {
-        future.addListener(
-                boost::bind(&ConsumerImpl::handleClose, shared_from_this(), _1, callback));
+        future.addListener(boost::bind(&ConsumerImpl::handleClose, shared_from_this(), _1, callback));
     }
-
 }
 
 void ConsumerImpl::handleClose(Result result, ResultCallback callback) {
@@ -729,10 +713,7 @@ void ConsumerImpl::handleClose(Result result, ResultCallback callback) {
     callback(result);
 }
 
-
-const std::string& ConsumerImpl::getName() const {
-    return consumerStr_;
-}
+const std::string& ConsumerImpl::getName() const { return consumerStr_; }
 
 void ConsumerImpl::shutdown() {
     Lock lock(mutex_);
@@ -777,8 +758,7 @@ Result ConsumerImpl::resumeMessageListener() {
 
     for (size_t i = 0; i < count; i++) {
         // Trigger message listener callback in a separate thread
-        listenerExecutor_->postWork(
-                boost::bind(&ConsumerImpl::internalListener, shared_from_this()));
+        listenerExecutor_->postWork(boost::bind(&ConsumerImpl::internalListener, shared_from_this()));
     }
     return ResultOk;
 }
@@ -786,10 +766,9 @@ Result ConsumerImpl::resumeMessageListener() {
 void ConsumerImpl::redeliverUnacknowledgedMessages() {
     ClientConnectionPtr cnx = getCnx().lock();
     if (cnx) {
-        if(cnx->getServerProtocolVersion() >= proto::v2) {
+        if (cnx->getServerProtocolVersion() >= proto::v2) {
             cnx->sendCommand(Commands::newRedeliverUnacknowledgedMessages(consumerId_));
-            LOG_DEBUG(
-                "Sending RedeliverUnacknowledgedMessages command for Consumer - " << getConsumerId());
+            LOG_DEBUG("Sending RedeliverUnacknowledgedMessages command for Consumer - " << getConsumerId());
         } else {
             LOG_DEBUG("Reconnecting the client to redeliver the messages for Consumer - " << getName());
             cnx->close();
@@ -799,9 +778,7 @@ void ConsumerImpl::redeliverUnacknowledgedMessages() {
     }
 }
 
-int ConsumerImpl::getNumOfPrefetchedMessages() const {
-    return incomingMessages_.size();
-}
+int ConsumerImpl::getNumOfPrefetchedMessages() const { return incomingMessages_.size(); }
 
 void ConsumerImpl::getBrokerConsumerStatsAsync(BrokerConsumerStatsCallback callback) {
     Lock lock(mutex_);
@@ -816,7 +793,8 @@ void ConsumerImpl::getBrokerConsumerStatsAsync(BrokerConsumerStatsCallback callb
         LOG_DEBUG(getName() << "Serving data from cache");
         BrokerConsumerStatsImpl brokerConsumerStats = brokerConsumerStats_;
         lock.unlock();
-        callback(ResultOk, BrokerConsumerStats(boost::make_shared<BrokerConsumerStatsImpl>(brokerConsumerStats_)));
+        callback(ResultOk,
+                 BrokerConsumerStats(boost::make_shared<BrokerConsumerStatsImpl>(brokerConsumerStats_)));
         return;
     }
     lock.unlock();
@@ -826,14 +804,16 @@ void ConsumerImpl::getBrokerConsumerStatsAsync(BrokerConsumerStatsCallback callb
         if (cnx->getServerProtocolVersion() >= proto::v8) {
             ClientImplPtr client = client_.lock();
             uint64_t requestId = client->newRequestId();
-            LOG_DEBUG(getName() <<
-                    " Sending ConsumerStats Command for Consumer - " << getConsumerId() << ", requestId - "<<requestId);
+            LOG_DEBUG(getName() << " Sending ConsumerStats Command for Consumer - " << getConsumerId()
+                                << ", requestId - " << requestId);
 
-            cnx->newConsumerStats(consumerId_, requestId).addListener(
-                    boost::bind(&ConsumerImpl::brokerConsumerStatsListener, shared_from_this(), _1, _2, callback));
+            cnx->newConsumerStats(consumerId_, requestId)
+                .addListener(boost::bind(&ConsumerImpl::brokerConsumerStatsListener, shared_from_this(), _1,
+                                         _2, callback));
             return;
         } else {
-            LOG_ERROR(getName() << " Operation not supported since server protobuf version " << cnx->getServerProtocolVersion() << " is older than proto::v7");
+            LOG_ERROR(getName() << " Operation not supported since server protobuf version "
+                                << cnx->getServerProtocolVersion() << " is older than proto::v7");
             callback(ResultUnsupportedVersionError, BrokerConsumerStats());
             return;
         }
@@ -842,9 +822,8 @@ void ConsumerImpl::getBrokerConsumerStatsAsync(BrokerConsumerStatsCallback callb
     callback(ResultNotConnected, BrokerConsumerStats());
 }
 
-void ConsumerImpl::brokerConsumerStatsListener(Result res, BrokerConsumerStatsImpl brokerConsumerStats
-        , BrokerConsumerStatsCallback callback) {
-
+void ConsumerImpl::brokerConsumerStatsListener(Result res, BrokerConsumerStatsImpl brokerConsumerStats,
+                                               BrokerConsumerStatsCallback callback) {
     if (res == ResultOk) {
         Lock lock(mutex_);
         brokerConsumerStats.setCacheTime(config_.getBrokerConsumerStatsCacheTimeInMs());
diff --git a/pulsar-client-cpp/lib/ConsumerImpl.h b/pulsar-client-cpp/lib/ConsumerImpl.h
index dd94134..c68abf4 100644
--- a/pulsar-client-cpp/lib/ConsumerImpl.h
+++ b/pulsar-client-cpp/lib/ConsumerImpl.h
@@ -52,16 +52,18 @@ class BatchAcknowledgementTracker;
 typedef boost::shared_ptr<ConsumerImpl> ConsumerImplPtr;
 typedef boost::weak_ptr<ConsumerImpl> ConsumerImplWeakPtr;
 
-enum ConsumerTopicType {
+enum ConsumerTopicType
+{
     NonPartitioned,
     Partitioned
 };
 
- class ConsumerImpl : public ConsumerImplBase, public HandlerBase, public boost::enable_shared_from_this<ConsumerImpl> {
-
- public:
-    ConsumerImpl(const ClientImplPtr client, const std::string& topic,
-                 const std::string& subscription, const ConsumerConfiguration&,
+class ConsumerImpl : public ConsumerImplBase,
+                     public HandlerBase,
+                     public boost::enable_shared_from_this<ConsumerImpl> {
+   public:
+    ConsumerImpl(const ClientImplPtr client, const std::string& topic, const std::string& subscription,
+                 const ConsumerConfiguration&,
                  const ExecutorServicePtr listenerExecutor = ExecutorServicePtr(),
                  const ConsumerTopicType consumerTopicType = NonPartitioned,
                  Commands::SubscriptionMode = Commands::SubscriptionModeDurable,
@@ -72,8 +74,7 @@ enum ConsumerTopicType {
     void receiveMessages(const ClientConnectionPtr& cnx, unsigned int count);
     uint64_t getConsumerId();
     void messageReceived(const ClientConnectionPtr& cnx, const proto::CommandMessage& msg,
-                         bool& isChecksumValid, proto::MessageMetadata& msgMetadata,
-                         SharedBuffer& payload);
+                         bool& isChecksumValid, proto::MessageMetadata& msgMetadata, SharedBuffer& payload);
     int incrementAndGetPermits(uint64_t cnxSequenceId);
     void messageProcessed(Message& msg);
     inline proto::CommandSubscribe_SubType getSubType();
@@ -99,30 +100,28 @@ enum ConsumerTopicType {
     virtual Result resumeMessageListener();
     virtual void redeliverUnacknowledgedMessages();
     virtual void getBrokerConsumerStatsAsync(BrokerConsumerStatsCallback callback);
- protected:
+
+   protected:
     void connectionOpened(const ClientConnectionPtr& cnx);
     void connectionFailed(Result result);
     void handleCreateConsumer(const ClientConnectionPtr& cnx, Result result);
 
     void internalListener();
     void handleClose(Result result, ResultCallback callback);
-    virtual HandlerBaseWeakPtr get_weak_from_this() {
-        return shared_from_this();
-    }
+    virtual HandlerBaseWeakPtr get_weak_from_this() { return shared_from_this(); }
     virtual const std::string& getName() const;
-    virtual int getNumOfPrefetchedMessages() const ;
+    virtual int getNumOfPrefetchedMessages() const;
     ConsumerStatsBasePtr consumerStatsBasePtr_;
-private:
+
+   private:
     bool waitingForZeroQueueSizeMessage;
     bool uncompressMessageIfNeeded(const ClientConnectionPtr& cnx, const proto::CommandMessage& msg,
                                    const proto::MessageMetadata& metadata, SharedBuffer& payload);
-    void discardCorruptedMessage(const ClientConnectionPtr& cnx,
-                                 const proto::MessageIdData& messageId,
+    void discardCorruptedMessage(const ClientConnectionPtr& cnx, const proto::MessageIdData& messageId,
                                  proto::CommandAck::ValidationError validationError);
     void increaseAvailablePermits(const ClientConnectionPtr& currentCnx, int numberOfPermits = 1);
     void drainIncomingMessageQueue(size_t count);
-    uint32_t receiveIndividualMessagesFromBatch(const ClientConnectionPtr& cnx,
-                                                Message &batchedMessage);
+    uint32_t receiveIndividualMessagesFromBatch(const ClientConnectionPtr& cnx, Message& batchedMessage);
     void brokerConsumerStatsListener(Result, BrokerConsumerStatsImpl, BrokerConsumerStatsCallback);
 
     // TODO - Convert these functions to lambda when we move to C++11
diff --git a/pulsar-client-cpp/lib/ConsumerImplBase.h b/pulsar-client-cpp/lib/ConsumerImplBase.h
index 7ca4602..a1f3bd5 100644
--- a/pulsar-client-cpp/lib/ConsumerImplBase.h
+++ b/pulsar-client-cpp/lib/ConsumerImplBase.h
@@ -28,12 +28,11 @@ typedef boost::weak_ptr<ConsumerImplBase> ConsumerImplBaseWeakPtr;
 typedef boost::shared_ptr<ConsumerImplBase> ConsumerImplBasePtr;
 
 class ConsumerImplBase {
-public:
-    virtual ~ConsumerImplBase(){
-    }
+   public:
+    virtual ~ConsumerImplBase() {}
     virtual Future<Result, ConsumerImplBaseWeakPtr> getConsumerCreatedFuture() = 0;
     virtual const std::string& getSubscriptionName() const = 0;
-    virtual const std::string& getTopic() const  = 0;
+    virtual const std::string& getTopic() const = 0;
     virtual Result receive(Message& msg) = 0;
     virtual Result receive(Message& msg, int timeout) = 0;
     virtual void unsubscribeAsync(ResultCallback callback) = 0;
@@ -51,5 +50,5 @@ public:
     virtual int getNumOfPrefetchedMessages() const = 0;
     virtual void getBrokerConsumerStatsAsync(BrokerConsumerStatsCallback callback) = 0;
 };
-}
-#endif //PULSAR_CONSUMER_IMPL_BASE_HEADER
+}  // namespace pulsar
+#endif  // PULSAR_CONSUMER_IMPL_BASE_HEADER
diff --git a/pulsar-client-cpp/lib/DeprecatedException.cc b/pulsar-client-cpp/lib/DeprecatedException.cc
index 8b788bf..283d8bb 100644
--- a/pulsar-client-cpp/lib/DeprecatedException.cc
+++ b/pulsar-client-cpp/lib/DeprecatedException.cc
@@ -19,10 +19,8 @@
 #include <pulsar/DeprecatedException.h>
 
 namespace pulsar {
-    const std::string DeprecatedException::message_prefix = "Deprecated: ";
+const std::string DeprecatedException::message_prefix = "Deprecated: ";
 
-    DeprecatedException::DeprecatedException(const std::string& __arg)
-            : std::runtime_error(message_prefix + __arg) {
-
-    }
-}
\ No newline at end of file
+DeprecatedException::DeprecatedException(const std::string& __arg)
+    : std::runtime_error(message_prefix + __arg) {}
+}  // namespace pulsar
\ No newline at end of file
diff --git a/pulsar-client-cpp/lib/DestinationName.cc b/pulsar-client-cpp/lib/DestinationName.cc
index 77dd727..5c8eb3e 100644
--- a/pulsar-client-cpp/lib/DestinationName.cc
+++ b/pulsar-client-cpp/lib/DestinationName.cc
@@ -34,156 +34,140 @@
 DECLARE_LOG_OBJECT()
 namespace pulsar {
 
-    typedef boost::unique_lock<boost::mutex> Lock;
-    // static members
-    CURL* DestinationName::curl = NULL;
-    boost::mutex DestinationName::curlHandleMutex;
-
-    CURL* DestinationName::getCurlHandle() {
-        if (curl == NULL) {
-            // this handle can not be shared across threads, so had to get here everytime
-            curl = curl_easy_init();
-        }
-        return curl;
-    }
-    //********************************************************************
-    DestinationName::DestinationName() {
-    }
-
-    bool DestinationName::init(const std::string& destinationName) {
-        destination_ = destinationName;
-        if(destinationName.find("://") == std::string::npos){
-            LOG_ERROR("Destination Name Invalid, domain not present - " << destinationName);
-            return false;
-        }
-        parse(destination_, domain_, property_, cluster_, namespacePortion_, localName_);
-        if(localName_.empty()) {
-            LOG_ERROR("Destination Name is not valid, topic name is empty - " << destination_);
-            return false;
-        }
-        namespaceName_ = NamespaceName::get(property_, cluster_, namespacePortion_);
-        return true;
-    }
-    void DestinationName::parse(const std::string& destinationName,
-                                std::string& domain,
-                                std::string& property,
-                                std::string& cluster,
-                                std::string& namespacePortion,
-                                std::string& localName) {
-        std::string destinationNameCopy = destinationName;
-        boost::replace_first(destinationNameCopy, "://", "/");
-        std::vector<std::string> pathTokens;
-        boost::algorithm::split(pathTokens, destinationNameCopy, boost::algorithm::is_any_of("/"));
-        if (pathTokens.size() < 5) {
-            LOG_ERROR("Destination Name Invalid, does not have enough parts - " << destinationName);
-            return;
-        }
-        domain = pathTokens[0];
-        property = pathTokens[1];
-        cluster = pathTokens[2];
-        namespacePortion = pathTokens[3];
-        size_t slashIndex = -1;
-        //find four '/', whatever is left is topic local name
-        for(int i=0; i < 4; i++) {
-            slashIndex = destinationNameCopy.find('/', slashIndex + 1);
-        }
-        // get index to next char to '/'
-        slashIndex++;
-        localName = destinationNameCopy.substr( slashIndex, (destinationNameCopy.size() - slashIndex));
-    }
-    std::string DestinationName::getEncodedName(const std::string& nameBeforeEncoding) {
-        Lock lock(curlHandleMutex);
-        std::string nameAfterEncoding;
-        if(getCurlHandle()) {
-            char *encodedName = curl_easy_escape(getCurlHandle(), nameBeforeEncoding.c_str(), nameBeforeEncoding.size());
-            if(encodedName) {
-                nameAfterEncoding.assign(encodedName);
-                curl_free(encodedName);
-            } else {
-                LOG_ERROR("Unable to encode the name using curl_easy_escape, name - " << nameBeforeEncoding);
-            }
+typedef boost::unique_lock<boost::mutex> Lock;
+// static members
+CURL* DestinationName::curl = NULL;
+boost::mutex DestinationName::curlHandleMutex;
+
+CURL* DestinationName::getCurlHandle() {
+    if (curl == NULL) {
+        // this handle can not be shared across threads, so had to get here everytime
+        curl = curl_easy_init();
+    }
+    return curl;
+}
+//********************************************************************
+DestinationName::DestinationName() {}
+
+bool DestinationName::init(const std::string& destinationName) {
+    destination_ = destinationName;
+    if (destinationName.find("://") == std::string::npos) {
+        LOG_ERROR("Destination Name Invalid, domain not present - " << destinationName);
+        return false;
+    }
+    parse(destination_, domain_, property_, cluster_, namespacePortion_, localName_);
+    if (localName_.empty()) {
+        LOG_ERROR("Destination Name is not valid, topic name is empty - " << destination_);
+        return false;
+    }
+    namespaceName_ = NamespaceName::get(property_, cluster_, namespacePortion_);
+    return true;
+}
+void DestinationName::parse(const std::string& destinationName, std::string& domain, std::string& property,
+                            std::string& cluster, std::string& namespacePortion, std::string& localName) {
+    std::string destinationNameCopy = destinationName;
+    boost::replace_first(destinationNameCopy, "://", "/");
+    std::vector<std::string> pathTokens;
+    boost::algorithm::split(pathTokens, destinationNameCopy, boost::algorithm::is_any_of("/"));
+    if (pathTokens.size() < 5) {
+        LOG_ERROR("Destination Name Invalid, does not have enough parts - " << destinationName);
+        return;
+    }
+    domain = pathTokens[0];
+    property = pathTokens[1];
+    cluster = pathTokens[2];
+    namespacePortion = pathTokens[3];
+    size_t slashIndex = -1;
+    // find four '/', whatever is left is topic local name
+    for (int i = 0; i < 4; i++) {
+        slashIndex = destinationNameCopy.find('/', slashIndex + 1);
+    }
+    // get index to next char to '/'
+    slashIndex++;
+    localName = destinationNameCopy.substr(slashIndex, (destinationNameCopy.size() - slashIndex));
+}
+std::string DestinationName::getEncodedName(const std::string& nameBeforeEncoding) {
+    Lock lock(curlHandleMutex);
+    std::string nameAfterEncoding;
+    if (getCurlHandle()) {
+        char* encodedName =
+            curl_easy_escape(getCurlHandle(), nameBeforeEncoding.c_str(), nameBeforeEncoding.size());
+        if (encodedName) {
+            nameAfterEncoding.assign(encodedName);
+            curl_free(encodedName);
         } else {
-            LOG_ERROR("Unable to get CURL handle to encode the name - " << nameBeforeEncoding);
+            LOG_ERROR("Unable to encode the name using curl_easy_escape, name - " << nameBeforeEncoding);
         }
-        return nameAfterEncoding;
-    }
-
-    std::string DestinationName::getDomain() {
-        return domain_;
-    }
-
-    std::string DestinationName::getProperty() {
-        return property_;
-    }
-
-    std::string DestinationName::getCluster() {
-        return cluster_;
-    }
-
-    std::string DestinationName::getNamespacePortion() {
-        return namespacePortion_;
-    }
-
-    std::string DestinationName::getLocalName() {
-        return localName_;
-    }
-
-    std::string DestinationName::getEncodedLocalName() {
-        return getEncodedName(localName_);
-    }
-
-    bool DestinationName::operator ==(const DestinationName& other) {
-        return (this->destination_.compare(other.destination_) == 0);
-    }
-
-    bool DestinationName::validateDestination() {
-        // check domain matches to "persistent", in future check "memory" when server is ready
-        if (domain_.compare("persistent") != 0) {
-            return false;
-        }
-        if (!property_.empty() && !cluster_.empty() && !namespacePortion_.empty() && !localName_.empty()) {
-            return NamedEntity::checkName(property_) && NamedEntity::checkName(cluster_)
-                && NamedEntity::checkName(namespacePortion_);
-        } else {
-            return false;
-        }
-    }
-
-    boost::shared_ptr<DestinationName> DestinationName::get(const std::string& destination) {
-        boost::shared_ptr<DestinationName> ptr(new DestinationName());
-        if (!ptr->init(destination)) {
-            LOG_ERROR("Destination Name Initialization failed");
-            return boost::shared_ptr<DestinationName>();
-        }
-        if (ptr->validateDestination()) {
-            return ptr;
-        } else {
-            LOG_ERROR("Destination Name Validation Failed");
-            return boost::shared_ptr<DestinationName>();
-        }
-    }
-
-    //TODO - for now return empty string if there's any error in format, later think about better error handling
-    std::string DestinationName::getLookupName() {
-        std::stringstream ss;
-        std::string seperator("/");
-        ss << domain_ << seperator << property_ << seperator << cluster_ << seperator
-           << namespacePortion_ << seperator << getEncodedLocalName();
-        return ss.str();
-    }
-
-    std::string DestinationName::toString() {
-        std::stringstream ss;
-        std::string seperator("/");
-        ss << domain_ << "://" << property_ << seperator << cluster_ << seperator
-           << namespacePortion_ << seperator << localName_;
-        return ss.str();
-    }
-
-    const std::string DestinationName::getTopicPartitionName(unsigned int partition) {
-        std::stringstream topicPartitionName;
-        // make this topic name as well
-        topicPartitionName << toString()<< PartitionedProducerImpl::PARTITION_NAME_SUFFIX << partition ;
-        return topicPartitionName.str();
-    }
-} //namespace pulsar
+    } else {
+        LOG_ERROR("Unable to get CURL handle to encode the name - " << nameBeforeEncoding);
+    }
+    return nameAfterEncoding;
+}
+
+std::string DestinationName::getDomain() { return domain_; }
+
+std::string DestinationName::getProperty() { return property_; }
+
+std::string DestinationName::getCluster() { return cluster_; }
+
+std::string DestinationName::getNamespacePortion() { return namespacePortion_; }
+
+std::string DestinationName::getLocalName() { return localName_; }
+
+std::string DestinationName::getEncodedLocalName() { return getEncodedName(localName_); }
+
+bool DestinationName::operator==(const DestinationName& other) {
+    return (this->destination_.compare(other.destination_) == 0);
+}
+
+bool DestinationName::validateDestination() {
+    // check domain matches to "persistent", in future check "memory" when server is ready
+    if (domain_.compare("persistent") != 0) {
+        return false;
+    }
+    if (!property_.empty() && !cluster_.empty() && !namespacePortion_.empty() && !localName_.empty()) {
+        return NamedEntity::checkName(property_) && NamedEntity::checkName(cluster_) &&
+               NamedEntity::checkName(namespacePortion_);
+    } else {
+        return false;
+    }
+}
+
+boost::shared_ptr<DestinationName> DestinationName::get(const std::string& destination) {
+    boost::shared_ptr<DestinationName> ptr(new DestinationName());
+    if (!ptr->init(destination)) {
+        LOG_ERROR("Destination Name Initialization failed");
+        return boost::shared_ptr<DestinationName>();
+    }
+    if (ptr->validateDestination()) {
+        return ptr;
+    } else {
+        LOG_ERROR("Destination Name Validation Failed");
+        return boost::shared_ptr<DestinationName>();
+    }
+}
+
+// TODO - for now return empty string if there's any error in format, later think about better error handling
+std::string DestinationName::getLookupName() {
+    std::stringstream ss;
+    std::string seperator("/");
+    ss << domain_ << seperator << property_ << seperator << cluster_ << seperator << namespacePortion_
+       << seperator << getEncodedLocalName();
+    return ss.str();
+}
+
+std::string DestinationName::toString() {
+    std::stringstream ss;
+    std::string seperator("/");
+    ss << domain_ << "://" << property_ << seperator << cluster_ << seperator << namespacePortion_
+       << seperator << localName_;
+    return ss.str();
+}
+
+const std::string DestinationName::getTopicPartitionName(unsigned int partition) {
+    std::stringstream topicPartitionName;
+    // make this topic name as well
+    topicPartitionName << toString() << PartitionedProducerImpl::PARTITION_NAME_SUFFIX << partition;
+    return topicPartitionName.str();
+}
+}  // namespace pulsar
diff --git a/pulsar-client-cpp/lib/DestinationName.h b/pulsar-client-cpp/lib/DestinationName.h
index afc6511..251a01a 100644
--- a/pulsar-client-cpp/lib/DestinationName.h
+++ b/pulsar-client-cpp/lib/DestinationName.h
@@ -30,47 +30,44 @@
 #pragma GCC visibility push(default)
 
 namespace pulsar {
-    class DestinationName : public ServiceUnitId {
-    private:
-        std::string destination_;
-        std::string domain_;
-        std::string property_;
-        std::string cluster_;
-        std::string namespacePortion_;
-        std::string localName_;
-        boost::shared_ptr<NamespaceName> namespaceName_;
+class DestinationName : public ServiceUnitId {
+   private:
+    std::string destination_;
+    std::string domain_;
+    std::string property_;
+    std::string cluster_;
+    std::string namespacePortion_;
+    std::string localName_;
+    boost::shared_ptr<NamespaceName> namespaceName_;
 
-    public:
-        std::string getLookupName();
-        std::string getDomain();
-        std::string getProperty();
-        std::string getCluster();
-        std::string getNamespacePortion();
-        std::string getLocalName();
-        std::string getEncodedLocalName();
-        std::string toString();
-        static boost::shared_ptr<DestinationName> get(const std::string& destination);
-        bool operator ==(const DestinationName& other);
-        static std::string getEncodedName(const std::string& nameBeforeEncoding);
-        const std::string getTopicPartitionName(unsigned int partition);
-    private:
-        static CURL* getCurlHandle();
-        static CURL* curl;
-        static boost::mutex curlHandleMutex;
-        static void parse(const std::string& destinationName,
-                          std::string& domain,
-                          std::string& property,
-                          std::string& cluster,
-                          std::string& namespacePortion,
-                          std::string& localName);
-        DestinationName();
-        bool validateDestination();
-        bool init(const std::string& destinationName);
-    };
-    typedef  boost::shared_ptr<DestinationName> DestinationNamePtr;
-}
+   public:
+    std::string getLookupName();
+    std::string getDomain();
+    std::string getProperty();
+    std::string getCluster();
+    std::string getNamespacePortion();
+    std::string getLocalName();
+    std::string getEncodedLocalName();
+    std::string toString();
+    static boost::shared_ptr<DestinationName> get(const std::string& destination);
+    bool operator==(const DestinationName& other);
+    static std::string getEncodedName(const std::string& nameBeforeEncoding);
+    const std::string getTopicPartitionName(unsigned int partition);
+
+   private:
+    static CURL* getCurlHandle();
+    static CURL* curl;
+    static boost::mutex curlHandleMutex;
+    static void parse(const std::string& destinationName, std::string& domain, std::string& property,
+                      std::string& cluster, std::string& namespacePortion, std::string& localName);
+    DestinationName();
+    bool validateDestination();
+    bool init(const std::string& destinationName);
+};
+typedef boost::shared_ptr<DestinationName> DestinationNamePtr;
+}  // namespace pulsar
 // end of namespace pulsar
 
 #pragma GCC visibility pop
 
-#endif //_PULSAR_DESTINATION_NAME_HEADER_
+#endif  //_PULSAR_DESTINATION_NAME_HEADER_
diff --git a/pulsar-client-cpp/lib/ExecutorService.cc b/pulsar-client-cpp/lib/ExecutorService.cc
index 5ad9e5f..1710933 100644
--- a/pulsar-client-cpp/lib/ExecutorService.cc
+++ b/pulsar-client-cpp/lib/ExecutorService.cc
@@ -27,14 +27,11 @@
 namespace pulsar {
 
 ExecutorService::ExecutorService()
-        : io_service_(),
-          work_(new BackgroundWork(io_service_)),
-          worker_(boost::bind(&boost::asio::io_service::run, &io_service_)) {
-}
+    : io_service_(),
+      work_(new BackgroundWork(io_service_)),
+      worker_(boost::bind(&boost::asio::io_service::run, &io_service_)) {}
 
-ExecutorService::~ExecutorService() {
-    close();
-}
+ExecutorService::~ExecutorService() { close(); }
 
 /*
  *  factory method of boost::asio::ip::tcp::socket associated with io_service_ instance
@@ -45,7 +42,8 @@ SocketPtr ExecutorService::createSocket() {
 }
 
 TlsSocketPtr ExecutorService::createTlsSocket(SocketPtr &socket, boost::asio::ssl::context &ctx) {
-    return boost::shared_ptr<boost::asio::ssl::stream<boost::asio::ip::tcp::socket&> >(new boost::asio::ssl::stream<boost::asio::ip::tcp::socket&> (*socket, ctx));
+    return boost::shared_ptr<boost::asio::ssl::stream<boost::asio::ip::tcp::socket &> >(
+        new boost::asio::ssl::stream<boost::asio::ip::tcp::socket &>(*socket, ctx));
 }
 
 /*
@@ -66,17 +64,12 @@ void ExecutorService::close() {
     worker_.join();
 }
 
-void ExecutorService::postWork(boost::function<void(void)> task) {
-    io_service_.post(task);
-}
+void ExecutorService::postWork(boost::function<void(void)> task) { io_service_.post(task); }
 
 /////////////////////
 
 ExecutorServiceProvider::ExecutorServiceProvider(int nthreads)
-        : executors_(nthreads),
-          executorIdx_(0),
-          mutex_() {
-}
+    : executors_(nthreads), executorIdx_(0), mutex_() {}
 
 ExecutorServicePtr ExecutorServiceProvider::get() {
     Lock lock(mutex_);
@@ -97,5 +90,4 @@ void ExecutorServiceProvider::close() {
         it->reset();
     }
 }
-
-}
+}  // namespace pulsar
diff --git a/pulsar-client-cpp/lib/ExecutorService.h b/pulsar-client-cpp/lib/ExecutorService.h
index 2bce046..af48bed 100644
--- a/pulsar-client-cpp/lib/ExecutorService.h
+++ b/pulsar-client-cpp/lib/ExecutorService.h
@@ -30,12 +30,13 @@
 
 namespace pulsar {
 typedef boost::shared_ptr<boost::asio::ip::tcp::socket> SocketPtr;
-typedef boost::shared_ptr<boost::asio::ssl::stream<boost::asio::ip::tcp::socket&> > TlsSocketPtr;
+typedef boost::shared_ptr<boost::asio::ssl::stream<boost::asio::ip::tcp::socket &> > TlsSocketPtr;
 typedef boost::shared_ptr<boost::asio::ip::tcp::resolver> TcpResolverPtr;
 typedef boost::shared_ptr<boost::asio::deadline_timer> DeadlineTimerPtr;
 class ExecutorService : private boost::noncopyable {
- friend class ClientConnection;
- public:
+    friend class ClientConnection;
+
+   public:
     ExecutorService();
     ~ExecutorService();
 
@@ -45,8 +46,8 @@ class ExecutorService : private boost::noncopyable {
     DeadlineTimerPtr createDeadlineTimer();
     void postWork(boost::function<void(void)> task);
     void close();
- private:
 
+   private:
     /*
      *  only called once and within lock so no need to worry about thread-safety
      */
@@ -75,14 +76,14 @@ class ExecutorService : private boost::noncopyable {
 typedef boost::shared_ptr<ExecutorService> ExecutorServicePtr;
 
 class ExecutorServiceProvider {
- public:
+   public:
     explicit ExecutorServiceProvider(int nthreads);
 
     ExecutorServicePtr get();
 
     void close();
 
- private:
+   private:
     typedef std::vector<ExecutorServicePtr> ExecutorList;
     ExecutorList executors_;
     int executorIdx_;
@@ -91,9 +92,8 @@ class ExecutorServiceProvider {
 };
 
 typedef boost::shared_ptr<ExecutorServiceProvider> ExecutorServiceProviderPtr;
-
-}
+}  // namespace pulsar
 
 #pragma GCC visibility pop
 
-#endif //_PULSAR_EXECUTOR_SERVICE_HEADER_
+#endif  //_PULSAR_EXECUTOR_SERVICE_HEADER_
diff --git a/pulsar-client-cpp/lib/Future.h b/pulsar-client-cpp/lib/Future.h
index 7992275..aab83a4 100644
--- a/pulsar-client-cpp/lib/Future.h
+++ b/pulsar-client-cpp/lib/Future.h
@@ -33,7 +33,7 @@ typedef boost::unique_lock<boost::mutex> Lock;
 
 namespace pulsar {
 
-template<typename Result, typename Type>
+template <typename Result, typename Type>
 struct InternalState {
     boost::mutex mutex;
     boost::condition_variable condition;
@@ -44,9 +44,9 @@ struct InternalState {
     std::list<typename boost::function<void(Result, const Type&)> > listeners;
 };
 
-template<typename Result, typename Type>
+template <typename Result, typename Type>
 class Future {
- public:
+   public:
     typedef boost::function<void(Result, const Type&)> ListenerCallback;
 
     Future& addListener(ListenerCallback callback) {
@@ -78,24 +78,20 @@ class Future {
         return state->result;
     }
 
- private:
+   private:
     typedef boost::shared_ptr<InternalState<Result, Type> > InternalStatePtr;
-    Future(InternalStatePtr state)
-            : state_(state) {
-    }
+    Future(InternalStatePtr state) : state_(state) {}
 
     boost::shared_ptr<InternalState<Result, Type> > state_;
 
-    template<typename U, typename V>
+    template <typename U, typename V>
     friend class Promise;
 };
 
-template<typename Result, typename Type>
+template <typename Result, typename Type>
 class Promise {
- public:
-    Promise()
-            : state_(boost::make_shared<InternalState<Result, Type> >()) {
-    }
+   public:
+    Promise() : state_(boost::make_shared<InternalState<Result, Type> >()) {}
 
     bool setValue(const Type& value) {
         InternalState<Result, Type>* state = state_.get();
@@ -148,17 +144,14 @@ class Promise {
         return state->complete;
     }
 
-    Future<Result, Type> getFuture() const {
-        return Future<Result, Type>(state_);
-    }
+    Future<Result, Type> getFuture() const { return Future<Result, Type>(state_); }
 
- private:
+   private:
     typedef boost::function<void(Result, const Type&)> ListenerCallback;
     boost::shared_ptr<InternalState<Result, Type> > state_;
 };
 
-class Void {
-};
+class Void {};
 
 } /* namespace pulsar */
 
diff --git a/pulsar-client-cpp/lib/HTTPLookupService.cc b/pulsar-client-cpp/lib/HTTPLookupService.cc
index c8536bd..816a7e9 100644
--- a/pulsar-client-cpp/lib/HTTPLookupService.cc
+++ b/pulsar-client-cpp/lib/HTTPLookupService.cc
@@ -21,196 +21,203 @@
 DECLARE_LOG_OBJECT()
 
 namespace pulsar {
-    const static std::string V2_PATH = "/lookup/v2/destination/";
-    const static std::string PARTITION_PATH = "/admin/persistent/";
-    const static int MAX_HTTP_REDIRECTS = 20;
-    const static std::string PARTITION_METHOD_NAME = "partitions";
-    const static int NUMBER_OF_LOOKUP_THREADS = 1;
+const static std::string V2_PATH = "/lookup/v2/destination/";
+const static std::string PARTITION_PATH = "/admin/persistent/";
+const static int MAX_HTTP_REDIRECTS = 20;
+const static std::string PARTITION_METHOD_NAME = "partitions";
+const static int NUMBER_OF_LOOKUP_THREADS = 1;
 
-    HTTPLookupService::CurlInitializer HTTPLookupService::curlInitializer;
+HTTPLookupService::CurlInitializer HTTPLookupService::curlInitializer;
 
-    HTTPLookupService::HTTPLookupService(const std::string &lookupUrl,
-            const ClientConfiguration &clientConfiguration,
-            const AuthenticationPtr &authData)
+HTTPLookupService::HTTPLookupService(const std::string &lookupUrl,
+                                     const ClientConfiguration &clientConfiguration,
+                                     const AuthenticationPtr &authData)
     : executorProvider_(boost::make_shared<ExecutorServiceProvider>(NUMBER_OF_LOOKUP_THREADS)),
-    authenticationPtr_(authData),
-    lookupTimeoutInSeconds_(clientConfiguration.getOperationTimeoutSeconds()) {
-        if (lookupUrl[lookupUrl.length() - 1] == '/') {
-            // Remove trailing '/'
-            adminUrl_ = lookupUrl.substr(0, lookupUrl.length() - 1);
-        } else {
-            adminUrl_ = lookupUrl;
-        }
+      authenticationPtr_(authData),
+      lookupTimeoutInSeconds_(clientConfiguration.getOperationTimeoutSeconds()) {
+    if (lookupUrl[lookupUrl.length() - 1] == '/') {
+        // Remove trailing '/'
+        adminUrl_ = lookupUrl.substr(0, lookupUrl.length() - 1);
+    } else {
+        adminUrl_ = lookupUrl;
     }
+}
 
-    Future<Result, LookupDataResultPtr> HTTPLookupService::lookupAsync(const std::string &destinationName) {
-        LookupPromise promise;
-        boost::shared_ptr<DestinationName> dn = DestinationName::get(destinationName);
-        if (!dn) {
-            LOG_ERROR("Unable to parse destination - " << destinationName);
-            promise.setFailed(ResultInvalidTopicName);
-            return promise.getFuture();
-        }
-
-        std::stringstream completeUrlStream;
-        completeUrlStream << adminUrl_ << V2_PATH << "persistent/" << dn->getProperty() << '/' << dn->getCluster()
-        << '/' << dn->getNamespacePortion() << '/' << dn->getEncodedLocalName();
-        executorProvider_->get()->postWork(boost::bind(&HTTPLookupService::sendHTTPRequest, shared_from_this(), promise, completeUrlStream.str(), Lookup));
+Future<Result, LookupDataResultPtr> HTTPLookupService::lookupAsync(const std::string &destinationName) {
+    LookupPromise promise;
+    boost::shared_ptr<DestinationName> dn = DestinationName::get(destinationName);
+    if (!dn) {
+        LOG_ERROR("Unable to parse destination - " << destinationName);
+        promise.setFailed(ResultInvalidTopicName);
         return promise.getFuture();
     }
 
-    Future<Result, LookupDataResultPtr> HTTPLookupService::getPartitionMetadataAsync(const DestinationNamePtr &dn) {
-        LookupPromise promise;
-        std::stringstream completeUrlStream;
-        completeUrlStream << adminUrl_ << PARTITION_PATH << dn->getProperty() << '/' << dn->getCluster()
-        << '/' << dn->getNamespacePortion() << '/' << dn->getEncodedLocalName() << '/'
-        << PARTITION_METHOD_NAME;
-        executorProvider_->get()->postWork(boost::bind(&HTTPLookupService::sendHTTPRequest, shared_from_this(), promise, completeUrlStream.str(), PartitionMetaData));
-        return promise.getFuture();
-    }
+    std::stringstream completeUrlStream;
+    completeUrlStream << adminUrl_ << V2_PATH << "persistent/" << dn->getProperty() << '/' << dn->getCluster()
+                      << '/' << dn->getNamespacePortion() << '/' << dn->getEncodedLocalName();
+    executorProvider_->get()->postWork(boost::bind(&HTTPLookupService::sendHTTPRequest, shared_from_this(),
+                                                   promise, completeUrlStream.str(), Lookup));
+    return promise.getFuture();
+}
+
+Future<Result, LookupDataResultPtr> HTTPLookupService::getPartitionMetadataAsync(
+    const DestinationNamePtr &dn) {
+    LookupPromise promise;
+    std::stringstream completeUrlStream;
+    completeUrlStream << adminUrl_ << PARTITION_PATH << dn->getProperty() << '/' << dn->getCluster() << '/'
+                      << dn->getNamespacePortion() << '/' << dn->getEncodedLocalName() << '/'
+                      << PARTITION_METHOD_NAME;
+    executorProvider_->get()->postWork(boost::bind(&HTTPLookupService::sendHTTPRequest, shared_from_this(),
+                                                   promise, completeUrlStream.str(), PartitionMetaData));
+    return promise.getFuture();
+}
 
-    static size_t curlWriteCallback(void *contents, size_t size, size_t nmemb, void *responseDataPtr) {
-        ((std::string*)responseDataPtr)->append((char*)contents, size * nmemb);
-        return size * nmemb;
+static size_t curlWriteCallback(void *contents, size_t size, size_t nmemb, void *responseDataPtr) {
+    ((std::string *)responseDataPtr)->append((char *)contents, size * nmemb);
+    return size * nmemb;
+}
+
+void HTTPLookupService::sendHTTPRequest(LookupPromise promise, const std::string completeUrl,
+                                        RequestType requestType) {
+    CURL *handle;
+    CURLcode res;
+    std::string responseData;
+    std::string version = std::string("Pulsar-CPP-v") + _PULSAR_VERSION_;
+    handle = curl_easy_init();
+
+    if (!handle) {
+        LOG_ERROR("Unable to curl_easy_init for url " << completeUrl);
+        promise.setFailed(ResultLookupError);
+        // No curl_easy_cleanup required since handle not initialized
+        return;
+    }
+    // set URL
+    curl_easy_setopt(handle, CURLOPT_URL, completeUrl.c_str());
+
+    // Write callback
+    curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, curlWriteCallback);
+    curl_easy_setopt(handle, CURLOPT_WRITEDATA, &responseData);
+
+    // New connection is made for each call
+    curl_easy_setopt(handle, CURLOPT_FRESH_CONNECT, 1L);
+    curl_easy_setopt(handle, CURLOPT_FORBID_REUSE, 1L);
+
+    // Skipping signal handling - results in timeouts not honored during the DNS lookup
+    curl_easy_setopt(handle, CURLOPT_NOSIGNAL, 1L);
+
+    // Timer
+    curl_easy_setopt(handle, CURLOPT_TIMEOUT, lookupTimeoutInSeconds_);
+
+    // Set User Agent
+    curl_easy_setopt(handle, CURLOPT_USERAGENT, version.c_str());
+
+    // Redirects
+    curl_easy_setopt(handle, CURLOPT_FOLLOWLOCATION, 1L);
+    curl_easy_setopt(handle, CURLOPT_MAXREDIRS, MAX_HTTP_REDIRECTS);
+
+    // Fail if HTTP return code >=400
+    curl_easy_setopt(handle, CURLOPT_FAILONERROR, 1L);
+
+    // Authorization data
+    AuthenticationDataPtr authDataContent;
+    Result authResult = authenticationPtr_->getAuthData(authDataContent);
+    if (authResult != ResultOk) {
+        LOG_ERROR(
+            "All Authentication methods should have AuthenticationData and return true on getAuthData for "
+            "url "
+            << completeUrl);
+        promise.setFailed(authResult);
+        curl_easy_cleanup(handle);
+        return;
+    }
+    struct curl_slist *list = NULL;
+    if (authDataContent->hasDataForHttp()) {
+        list = curl_slist_append(list, authDataContent->getHttpHeaders().c_str());
     }
+    curl_easy_setopt(handle, CURLOPT_HTTPHEADER, list);
 
-    void HTTPLookupService::sendHTTPRequest(LookupPromise promise, const std::string completeUrl,
-            RequestType requestType) {
-        CURL *handle;
-        CURLcode res;
-        std::string responseData;
-        std::string version = std::string("Pulsar-CPP-v") + _PULSAR_VERSION_;
-        handle = curl_easy_init();
+    LOG_INFO("Curl Lookup Request sent for" << completeUrl);
 
-        if(!handle) {
-            LOG_ERROR("Unable to curl_easy_init for url " << completeUrl);
-            promise.setFailed(ResultLookupError);
-            // No curl_easy_cleanup required since handle not initialized
-            return;
-        }
-        // set URL
-        curl_easy_setopt(handle, CURLOPT_URL, completeUrl.c_str());
-
-        // Write callback
-        curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, curlWriteCallback);
-        curl_easy_setopt(handle, CURLOPT_WRITEDATA, &responseData);
-
-        // New connection is made for each call
-        curl_easy_setopt(handle, CURLOPT_FRESH_CONNECT, 1L);
-        curl_easy_setopt(handle, CURLOPT_FORBID_REUSE, 1L);
-
-        // Skipping signal handling - results in timeouts not honored during the DNS lookup
-        curl_easy_setopt(handle, CURLOPT_NOSIGNAL, 1L);
-
-        // Timer
-        curl_easy_setopt(handle, CURLOPT_TIMEOUT, lookupTimeoutInSeconds_);
-
-        // Set User Agent 
-        curl_easy_setopt(handle, CURLOPT_USERAGENT, version.c_str());
-
-        // Redirects
-        curl_easy_setopt(handle, CURLOPT_FOLLOWLOCATION, 1L);
-        curl_easy_setopt(handle, CURLOPT_MAXREDIRS, MAX_HTTP_REDIRECTS);
-
-        // Fail if HTTP return code >=400
-        curl_easy_setopt(handle, CURLOPT_FAILONERROR, 1L);
-
-        // Authorization data
-        AuthenticationDataPtr authDataContent;
-        Result authResult = authenticationPtr_->getAuthData(authDataContent);
-        if (authResult != ResultOk) {
-            LOG_ERROR("All Authentication methods should have AuthenticationData and return true on getAuthData for url " << completeUrl);
-            promise.setFailed(authResult);
-            curl_easy_cleanup(handle);
-            return;
-        }
-        struct curl_slist *list = NULL;
-        if (authDataContent->hasDataForHttp()) {
-            list = curl_slist_append(list, authDataContent->getHttpHeaders().c_str());
-        }
-        curl_easy_setopt(handle, CURLOPT_HTTPHEADER, list);
-
-        LOG_INFO("Curl Lookup Request sent for" << completeUrl);
-
-        // Make get call to server
-        res = curl_easy_perform(handle);
-
-        // Free header list
-        curl_slist_free_all(list);
-
-        switch(res) {
-            case CURLE_OK:
-                long response_code;
-                curl_easy_getinfo(handle, CURLINFO_RESPONSE_CODE, &response_code);
-                LOG_INFO("Response received for url " << completeUrl << " code " << response_code);
-                if (response_code == 200) {
-                    promise.setValue((requestType == PartitionMetaData) ? parsePartitionData(responseData) : parseLookupData(responseData));
-                } else {
-                    promise.setFailed(ResultLookupError);
-                }
-                break;
-            case CURLE_COULDNT_CONNECT:
-            case CURLE_COULDNT_RESOLVE_PROXY:
-            case CURLE_COULDNT_RESOLVE_HOST:
-            case CURLE_HTTP_RETURNED_ERROR:
-                LOG_ERROR("Response failed for url "<<completeUrl << ". Error Code "<<res);
-                promise.setFailed(ResultConnectError);
-                break;
-            case CURLE_READ_ERROR:
-                LOG_ERROR("Response failed for url "<<completeUrl << ". Error Code "<<res);
-                promise.setFailed(ResultReadError);
-                break;
-            case CURLE_OPERATION_TIMEDOUT:
-                LOG_ERROR("Response failed for url "<<completeUrl << ". Error Code "<<res);
-                promise.setFailed(ResultTimeout);
-                break;
-            default:
-                LOG_ERROR("Response failed for url "<<completeUrl << ". Error Code "<<res);
+    // Make get call to server
+    res = curl_easy_perform(handle);
+
+    // Free header list
+    curl_slist_free_all(list);
+
+    switch (res) {
+        case CURLE_OK:
+            long response_code;
+            curl_easy_getinfo(handle, CURLINFO_RESPONSE_CODE, &response_code);
+            LOG_INFO("Response received for url " << completeUrl << " code " << response_code);
+            if (response_code == 200) {
+                promise.setValue((requestType == PartitionMetaData) ? parsePartitionData(responseData)
+                                                                    : parseLookupData(responseData));
+            } else {
                 promise.setFailed(ResultLookupError);
-                break;
-        }
-        curl_easy_cleanup(handle);
+            }
+            break;
+        case CURLE_COULDNT_CONNECT:
+        case CURLE_COULDNT_RESOLVE_PROXY:
+        case CURLE_COULDNT_RESOLVE_HOST:
+        case CURLE_HTTP_RETURNED_ERROR:
+            LOG_ERROR("Response failed for url " << completeUrl << ". Error Code " << res);
+            promise.setFailed(ResultConnectError);
+            break;
+        case CURLE_READ_ERROR:
+            LOG_ERROR("Response failed for url " << completeUrl << ". Error Code " << res);
+            promise.setFailed(ResultReadError);
+            break;
+        case CURLE_OPERATION_TIMEDOUT:
+            LOG_ERROR("Response failed for url " << completeUrl << ". Error Code " << res);
+            promise.setFailed(ResultTimeout);
+            break;
+        default:
+            LOG_ERROR("Response failed for url " << completeUrl << ". Error Code " << res);
+            promise.setFailed(ResultLookupError);
+            break;
     }
+    curl_easy_cleanup(handle);
+}
 
-    LookupDataResultPtr HTTPLookupService::parsePartitionData(const std::string &json) {
-        Json::Value root;
-        Json::Reader reader;
-        if (!reader.parse(json, root, false)) {
-            LOG_ERROR("Failed to parse json of Partition Metadata: " << reader.getFormatedErrorMessages()
-                    << "\nInput Json = " << json);
-            return LookupDataResultPtr();
-        }
-        LookupDataResultPtr lookupDataResultPtr = boost::make_shared<LookupDataResult>();
-        lookupDataResultPtr->setPartitions(root.get("partitions", 0).asInt());
-        LOG_INFO("parsePartitionData = "<<*lookupDataResultPtr);
-        return lookupDataResultPtr;
+LookupDataResultPtr HTTPLookupService::parsePartitionData(const std::string &json) {
+    Json::Value root;
+    Json::Reader reader;
+    if (!reader.parse(json, root, false)) {
+        LOG_ERROR("Failed to parse json of Partition Metadata: " << reader.getFormatedErrorMessages()
+                                                                 << "\nInput Json = " << json);
+        return LookupDataResultPtr();
     }
+    LookupDataResultPtr lookupDataResultPtr = boost::make_shared<LookupDataResult>();
+    lookupDataResultPtr->setPartitions(root.get("partitions", 0).asInt());
+    LOG_INFO("parsePartitionData = " << *lookupDataResultPtr);
+    return lookupDataResultPtr;
+}
 
-    LookupDataResultPtr HTTPLookupService::parseLookupData(const std::string &json) {
-        Json::Value root;
-        Json::Reader reader;
-        if (!reader.parse(json, root, false)) {
-            LOG_ERROR("Failed to parse json : " << reader.getFormatedErrorMessages()
-                    << "\nInput Json = " << json);
-            return LookupDataResultPtr();
-        }
-        const std::string defaultNotFoundString = "Url Not found";
-        const std::string brokerUrl = root.get("brokerUrl", defaultNotFoundString).asString();
-        if (brokerUrl == defaultNotFoundString) {
-            LOG_ERROR("malformed json! - brokerUrl not present" << json);
-            return LookupDataResultPtr();
-        }
-
-        const std::string brokerUrlSsl = root.get("brokerUrlSsl", defaultNotFoundString).asString();
-        if (brokerUrlSsl == defaultNotFoundString) {
-            LOG_ERROR("malformed json! - brokerUrlSsl not present" << json);
-            return LookupDataResultPtr();
-        }
-
-        LookupDataResultPtr lookupDataResultPtr = boost::make_shared<LookupDataResult>();
-        lookupDataResultPtr->setBrokerUrl(brokerUrl);
-        lookupDataResultPtr->setBrokerUrlSsl(brokerUrlSsl);
-        LOG_INFO("parseLookupData = "<<*lookupDataResultPtr);
-        return lookupDataResultPtr;
+LookupDataResultPtr HTTPLookupService::parseLookupData(const std::string &json) {
+    Json::Value root;
+    Json::Reader reader;
+    if (!reader.parse(json, root, false)) {
+        LOG_ERROR("Failed to parse json : " << reader.getFormatedErrorMessages()
+                                            << "\nInput Json = " << json);
+        return LookupDataResultPtr();
+    }
+    const std::string defaultNotFoundString = "Url Not found";
+    const std::string brokerUrl = root.get("brokerUrl", defaultNotFoundString).asString();
+    if (brokerUrl == defaultNotFoundString) {
+        LOG_ERROR("malformed json! - brokerUrl not present" << json);
+        return LookupDataResultPtr();
     }
+
+    const std::string brokerUrlSsl = root.get("brokerUrlSsl", defaultNotFoundString).asString();
+    if (brokerUrlSsl == defaultNotFoundString) {
+        LOG_ERROR("malformed json! - brokerUrlSsl not present" << json);
+        return LookupDataResultPtr();
+    }
+
+    LookupDataResultPtr lookupDataResultPtr = boost::make_shared<LookupDataResult>();
+    lookupDataResultPtr->setBrokerUrl(brokerUrl);
+    lookupDataResultPtr->setBrokerUrlSsl(brokerUrlSsl);
+    LOG_INFO("parseLookupData = " << *lookupDataResultPtr);
+    return lookupDataResultPtr;
 }
+}  // namespace pulsar
diff --git a/pulsar-client-cpp/lib/HTTPLookupService.h b/pulsar-client-cpp/lib/HTTPLookupService.h
index 10bee0c..b8c06e8 100644
--- a/pulsar-client-cpp/lib/HTTPLookupService.h
+++ b/pulsar-client-cpp/lib/HTTPLookupService.h
@@ -29,36 +29,38 @@
 #include <lib/Version.h>
 
 namespace pulsar {
-    class HTTPLookupService : public LookupService, public boost::enable_shared_from_this<HTTPLookupService> {
-        class CurlInitializer {
-         public:
-            CurlInitializer() {
-                // Once per application - https://curl.haxx.se/mail/lib-2015-11/0052.html
-                curl_global_init (CURL_GLOBAL_ALL);
-            }
-            ~CurlInitializer() {
-                curl_global_cleanup();
-            }
-        };
-        static CurlInitializer curlInitializer;
-        enum RequestType {Lookup, PartitionMetaData};
-        typedef Promise<Result, LookupDataResultPtr> LookupPromise;
-        ExecutorServiceProviderPtr executorProvider_;
-        std::string adminUrl_;
-        AuthenticationPtr authenticationPtr_;
-        int lookupTimeoutInSeconds_;
+class HTTPLookupService : public LookupService, public boost::enable_shared_from_this<HTTPLookupService> {
+    class CurlInitializer {
+       public:
+        CurlInitializer() {
+            // Once per application - https://curl.haxx.se/mail/lib-2015-11/0052.html
+            curl_global_init(CURL_GLOBAL_ALL);
+        }
+        ~CurlInitializer() { curl_global_cleanup(); }
+    };
+    static CurlInitializer curlInitializer;
+    enum RequestType
+    {
+        Lookup,
+        PartitionMetaData
+    };
+    typedef Promise<Result, LookupDataResultPtr> LookupPromise;
+    ExecutorServiceProviderPtr executorProvider_;
+    std::string adminUrl_;
+    AuthenticationPtr authenticationPtr_;
+    int lookupTimeoutInSeconds_;
 
-        static LookupDataResultPtr parsePartitionData(const std::string&);
-        static LookupDataResultPtr parseLookupData(const std::string&);
-        void sendHTTPRequest(LookupPromise, const std::string, RequestType);
-     public:
-        HTTPLookupService(const std::string&, const ClientConfiguration&, const AuthenticationPtr&);
+    static LookupDataResultPtr parsePartitionData(const std::string&);
+    static LookupDataResultPtr parseLookupData(const std::string&);
+    void sendHTTPRequest(LookupPromise, const std::string, RequestType);
 
-        Future<Result, LookupDataResultPtr> lookupAsync(const std::string&);
+   public:
+    HTTPLookupService(const std::string&, const ClientConfiguration&, const AuthenticationPtr&);
 
-        Future<Result, LookupDataResultPtr> getPartitionMetadataAsync(const DestinationNamePtr&);
-    };
+    Future<Result, LookupDataResultPtr> lookupAsync(const std::string&);
 
-}
+    Future<Result, LookupDataResultPtr> getPartitionMetadataAsync(const DestinationNamePtr&);
+};
+}  // namespace pulsar
 
-#endif //PULSAR_CPP_HTTPLOOKUPSERVICE_H
+#endif  // PULSAR_CPP_HTTPLOOKUPSERVICE_H
diff --git a/pulsar-client-cpp/lib/HandlerBase.cc b/pulsar-client-cpp/lib/HandlerBase.cc
index a0a0686..8cf6d20 100644
--- a/pulsar-client-cpp/lib/HandlerBase.cc
+++ b/pulsar-client-cpp/lib/HandlerBase.cc
@@ -28,24 +28,19 @@ DECLARE_LOG_OBJECT()
 namespace pulsar {
 
 HandlerBase::HandlerBase(const ClientImplPtr& client, const std::string& topic, const Backoff& backoff)
-        : client_(client),
-          topic_(topic),
-          connection_(),
-          mutex_(),
-          creationTimestamp_(now()),
-          operationTimeut_(seconds(client->conf().getOperationTimeoutSeconds())),
-          state_(Pending),
-          backoff_(backoff),
-          timer_(client->getIOExecutorProvider()->get()->createDeadlineTimer()) {
-}
+    : client_(client),
+      topic_(topic),
+      connection_(),
+      mutex_(),
+      creationTimestamp_(now()),
+      operationTimeut_(seconds(client->conf().getOperationTimeoutSeconds())),
+      state_(Pending),
+      backoff_(backoff),
+      timer_(client->getIOExecutorProvider()->get()->createDeadlineTimer()) {}
 
-HandlerBase::~HandlerBase() {
-    timer_->cancel();
-}
+HandlerBase::~HandlerBase() { timer_->cancel(); }
 
-void HandlerBase::start() {
-    grabCnx();
-}
+void HandlerBase::start() { grabCnx(); }
 
 void HandlerBase::grabCnx() {
     Lock lock(mutex_);
@@ -58,8 +53,7 @@ void HandlerBase::grabCnx() {
     LOG_INFO(getName() << "Getting connection from pool");
     ClientImplPtr client = client_.lock();
     Future<Result, ClientConnectionWeakPtr> future = client->getConnection(topic_);
-    future.addListener(
-            boost::bind(&HandlerBase::handleNewConnection, _1, _2, get_weak_from_this()));
+    future.addListener(boost::bind(&HandlerBase::handleNewConnection, _1, _2, get_weak_from_this()));
 }
 
 void HandlerBase::handleNewConnection(Result result, ClientConnectionWeakPtr connection,
@@ -96,8 +90,8 @@ void HandlerBase::handleDisconnection(Result result, ClientConnectionWeakPtr con
 
     ClientConnectionPtr currentConnection = handler->connection_.lock();
     if (currentConnection && connection.lock().get() != currentConnection.get()) {
-        LOG_WARN(
-                handler->getName() << "Ignoring connection closed since we are already attached to a newer connection");
+        LOG_WARN(handler->getName()
+                 << "Ignoring connection closed since we are already attached to a newer connection");
         return;
     }
 
@@ -112,8 +106,8 @@ void HandlerBase::handleDisconnection(Result result, ClientConnectionWeakPtr con
         case Closing:
         case Closed:
         case Failed:
-            LOG_DEBUG(handler->getName() <<
-                    "Ignoring connection closed event since the handler is not used anymore");
+            LOG_DEBUG(handler->getName()
+                      << "Ignoring connection closed event since the handler is not used anymore");
             break;
     }
 }
@@ -131,27 +125,25 @@ void HandlerBase::scheduleReconnection(HandlerBasePtr handler) {
     if (handler->state_ == Pending || handler->state_ == Ready) {
         TimeDuration delay = handler->backoff_.next();
 
-        LOG_INFO(
-                handler->getName() << "Schedule reconnection in " << (delay.total_milliseconds() / 1000.0) << " s");
+        LOG_INFO(handler->getName() << "Schedule reconnection in " << (delay.total_milliseconds() / 1000.0)
+                                    << " s");
         handler->timer_->expires_from_now(delay);
-        //passing shared_ptr here since time_ will get destroyed, so tasks will be cancelled
-        //so we will not run into the case where grabCnx is invoked on out of scope handler
+        // passing shared_ptr here since time_ will get destroyed, so tasks will be cancelled
+        // so we will not run into the case where grabCnx is invoked on out of scope handler
         handler->timer_->async_wait(boost::bind(&HandlerBase::handleTimeout, _1, handler));
     }
 }
 
 void HandlerBase::handleTimeout(const boost::system::error_code& ec, HandlerBasePtr handler) {
     if (ec) {
-        LOG_DEBUG(handler->getName() << "Ignoring timer cancelled event, code[" << ec <<"]");
+        LOG_DEBUG(handler->getName() << "Ignoring timer cancelled event, code[" << ec << "]");
         return;
     } else {
         handler->grabCnx();
     }
 }
 
-ptime now() {
-    return microsec_clock::universal_time();
-}
+ptime now() { return microsec_clock::universal_time(); }
 
 int64_t currentTimeMillis() {
     static ptime time_t_epoch(boost::gregorian::date(1970, 1, 1));
@@ -159,5 +151,4 @@ int64_t currentTimeMillis() {
     time_duration diff = now() - time_t_epoch;
     return diff.total_milliseconds();
 }
-
-}
+}  // namespace pulsar
diff --git a/pulsar-client-cpp/lib/HandlerBase.h b/pulsar-client-cpp/lib/HandlerBase.h
index 70e2c62..4ad0800 100644
--- a/pulsar-client-cpp/lib/HandlerBase.h
+++ b/pulsar-client-cpp/lib/HandlerBase.h
@@ -40,8 +40,7 @@ typedef boost::weak_ptr<HandlerBase> HandlerBaseWeakPtr;
 typedef boost::shared_ptr<HandlerBase> HandlerBasePtr;
 
 class HandlerBase {
-
- public:
+   public:
     HandlerBase(const ClientImplPtr&, const std::string&, const Backoff&);
 
     virtual ~HandlerBase();
@@ -52,11 +51,9 @@ class HandlerBase {
      * get method for derived class to access weak ptr to connection so that they
      * have to check if they can get a shared_ptr out of it or not
      */
-    ClientConnectionWeakPtr getCnx() {
-        return connection_;
-    }
+    ClientConnectionWeakPtr getCnx() { return connection_; }
 
- protected:
+   protected:
     /*
      * tries reconnection and sets connection_ to valid object
      */
@@ -83,15 +80,13 @@ class HandlerBase {
 
     virtual const std::string& getName() const = 0;
 
- private:
-    static void handleNewConnection(Result result, ClientConnectionWeakPtr connection,
-                                    HandlerBaseWeakPtr wp);
-    static void handleDisconnection(Result result, ClientConnectionWeakPtr connection,
-                                    HandlerBaseWeakPtr wp);
+   private:
+    static void handleNewConnection(Result result, ClientConnectionWeakPtr connection, HandlerBaseWeakPtr wp);
+    static void handleDisconnection(Result result, ClientConnectionWeakPtr connection, HandlerBaseWeakPtr wp);
 
     static void handleTimeout(const boost::system::error_code& ec, HandlerBasePtr handler);
 
- protected:
+   protected:
     ClientImplWeakPtr client_;
     const std::string topic_;
     ClientConnectionWeakPtr connection_;
@@ -101,7 +96,8 @@ class HandlerBase {
     const TimeDuration operationTimeut_;
     typedef boost::unique_lock<boost::mutex> Lock;
 
-    enum State {
+    enum State
+    {
         Pending,
         Ready,
         Closing,
@@ -112,10 +108,10 @@ class HandlerBase {
     State state_;
     Backoff backoff_;
 
- private:
+   private:
     DeadlineTimerPtr timer_;
     friend class ClientConnection;
     friend class PulsarFriend;
 };
-}
+}  // namespace pulsar
 #endif  //_PULSAR_HANDLER_BASE_HEADER_
diff --git a/pulsar-client-cpp/lib/Latch.cc b/pulsar-client-cpp/lib/Latch.cc
index f183d1a..bc5b16e 100644
--- a/pulsar-client-cpp/lib/Latch.cc
+++ b/pulsar-client-cpp/lib/Latch.cc
@@ -25,19 +25,12 @@ namespace pulsar {
 struct CountIsZero {
     const int& count_;
 
-    CountIsZero(const int& count)
-            : count_(count) {
-    }
+    CountIsZero(const int& count) : count_(count) {}
 
-    bool operator()() const {
-        return count_ == 0;
-    }
+    bool operator()() const { return count_ == 0; }
 };
 
-Latch::Latch(int count)
-        : state_(boost::make_shared<InternalState>()) {
-    state_->count = count;
-}
+Latch::Latch(int count) : state_(boost::make_shared<InternalState>()) { state_->count = count; }
 
 void Latch::countdown() {
     Lock lock(state_->mutex);
@@ -53,7 +46,6 @@ int Latch::getCount() {
     Lock lock(state_->mutex);
 
     return state_->count;
-
 }
 
 void Latch::wait() {
diff --git a/pulsar-client-cpp/lib/Latch.h b/pulsar-client-cpp/lib/Latch.h
index b80a122..9665a19 100644
--- a/pulsar-client-cpp/lib/Latch.h
+++ b/pulsar-client-cpp/lib/Latch.h
@@ -28,7 +28,7 @@
 namespace pulsar {
 
 class Latch {
- public:
+   public:
     Latch(int count);
 
     void countdown();
@@ -39,7 +39,7 @@ class Latch {
 
     int getCount();
 
- private:
+   private:
     struct InternalState {
         boost::mutex mutex;
         boost::condition_variable condition;
diff --git a/pulsar-client-cpp/lib/LogUtils.cc b/pulsar-client-cpp/lib/LogUtils.cc
index 6500ff7..70507d9 100644
--- a/pulsar-client-cpp/lib/LogUtils.cc
+++ b/pulsar-client-cpp/lib/LogUtils.cc
@@ -34,7 +34,7 @@ void LogUtils::init(const std::string& logfilePath) {
                 LogManager::getLoggerRepository()->setConfigured(true);
                 LoggerPtr root = Logger::getRootLogger();
                 static const LogString TTCC_CONVERSION_PATTERN(
-                        LOG4CXX_STR("%d{HH:mm:ss.SSS} [%t] %-5p %l - %m%n"));
+                    LOG4CXX_STR("%d{HH:mm:ss.SSS} [%t] %-5p %l - %m%n"));
                 LayoutPtr layout(new PatternLayout(TTCC_CONVERSION_PATTERN));
                 AppenderPtr appender(new ConsoleAppender(layout));
                 root->setLevel(log4cxx::Level::getInfo());
@@ -44,10 +44,9 @@ void LogUtils::init(const std::string& logfilePath) {
             log4cxx::PropertyConfigurator::configure(logfilePath);
         }
     } catch (const std::exception& e) {
-        std::cerr << "exception caught while configuring log4cpp via '" << logfilePath << "': "
-                  << e.what() << std::endl;
-    } catch (...) {
-        std::cerr << "unknown exception while configuring log4cpp via '" << logfilePath << "'."
+        std::cerr << "exception caught while configuring log4cpp via '" << logfilePath << "': " << e.what()
                   << std::endl;
+    } catch (...) {
+        std::cerr << "unknown exception while configuring log4cpp via '" << logfilePath << "'." << std::endl;
     }
 }
diff --git a/pulsar-client-cpp/lib/LogUtils.h b/pulsar-client-cpp/lib/LogUtils.h
index 3ca59fc..6371efe 100644
--- a/pulsar-client-cpp/lib/LogUtils.h
+++ b/pulsar-client-cpp/lib/LogUtils.h
@@ -23,47 +23,67 @@
 #include <log4cxx/logger.h>
 #include <string>
 
-#define DECLARE_LOG_OBJECT()                                \
-    static log4cxx::LoggerPtr& logger()                     \
-    {                                                       \
-        static boost::thread_specific_ptr<log4cxx::LoggerPtr> threadSpecificLogPtr; \
-        log4cxx::LoggerPtr* ptr = threadSpecificLogPtr.get(); \
-        if (!ptr) { \
-            threadSpecificLogPtr.reset(new log4cxx::LoggerPtr(log4cxx::Logger::getLogger(LOG_CATEGORY_NAME __FILE__)));\
-            ptr = threadSpecificLogPtr.get(); \
-        } \
-        return *ptr;                                      \
+#define DECLARE_LOG_OBJECT()                                                                     \
+    static log4cxx::LoggerPtr& logger() {                                                        \
+        static boost::thread_specific_ptr<log4cxx::LoggerPtr> threadSpecificLogPtr;              \
+        log4cxx::LoggerPtr* ptr = threadSpecificLogPtr.get();                                    \
+        if (!ptr) {                                                                              \
+            threadSpecificLogPtr.reset(                                                          \
+                new log4cxx::LoggerPtr(log4cxx::Logger::getLogger(LOG_CATEGORY_NAME __FILE__))); \
+            ptr = threadSpecificLogPtr.get();                                                    \
+        }                                                                                        \
+        return *ptr;                                                                             \
     }
 
-#define LOG_DEBUG(message) { \
-        if (LOG4CXX_UNLIKELY(logger()->isDebugEnabled())) {\
-           ::log4cxx::helpers::MessageBuffer oss_; \
-           logger()->forcedLog(::log4cxx::Level::getDebug(), oss_.str(((std::ostream&)oss_) << message), LOG4CXX_LOCATION); }}
+#define LOG_DEBUG(message)                                                                                \
+    {                                                                                                     \
+        if (LOG4CXX_UNLIKELY(logger()->isDebugEnabled())) {                                               \
+            ::log4cxx::helpers::MessageBuffer oss_;                                                       \
+            logger()->forcedLog(::log4cxx::Level::getDebug(), oss_.str(((std::ostream&)oss_) << message), \
+                                LOG4CXX_LOCATION);                                                        \
+        }                                                                                                 \
+    }
 
-#define LOG_INFO(message) { \
-        if (logger()->isInfoEnabled()) {\
-           ::log4cxx::helpers::MessageBuffer oss_; \
-           logger()->forcedLog(::log4cxx::Level::getInfo(), oss_.str(((std::ostream&)oss_) << message), LOG4CXX_LOCATION); }}
+#define LOG_INFO(message)                                                                                \
+    {                                                                                                    \
+        if (logger()->isInfoEnabled()) {                                                                 \
+            ::log4cxx::helpers::MessageBuffer oss_;                                                      \
+            logger()->forcedLog(::log4cxx::Level::getInfo(), oss_.str(((std::ostream&)oss_) << message), \
+                                LOG4CXX_LOCATION);                                                       \
+        }                                                                                                \
+    }
 
-#define LOG_WARN(message) { \
-        if (logger()->isWarnEnabled()) {\
-           ::log4cxx::helpers::MessageBuffer oss_; \
-           logger()->forcedLog(::log4cxx::Level::getWarn(), oss_.str(((std::ostream&)oss_) << message), LOG4CXX_LOCATION); }}
+#define LOG_WARN(message)                                                                                \
+    {                                                                                                    \
+        if (logger()->isWarnEnabled()) {                                                                 \
+            ::log4cxx::helpers::MessageBuffer oss_;                                                      \
+            logger()->forcedLog(::log4cxx::Level::getWarn(), oss_.str(((std::ostream&)oss_) << message), \
+                                LOG4CXX_LOCATION);                                                       \
+        }                                                                                                \
+    }
 
-#define LOG_ERROR(message) { \
-        if (logger()->isErrorEnabled()) {\
-           ::log4cxx::helpers::MessageBuffer oss_; \
-           logger()->forcedLog(::log4cxx::Level::getError(), oss_.str(((std::ostream&)oss_) << message), LOG4CXX_LOCATION); }}
+#define LOG_ERROR(message)                                                                                \
+    {                                                                                                     \
+        if (logger()->isErrorEnabled()) {                                                                 \
+            ::log4cxx::helpers::MessageBuffer oss_;                                                       \
+            logger()->forcedLog(::log4cxx::Level::getError(), oss_.str(((std::ostream&)oss_) << message), \
+                                LOG4CXX_LOCATION);                                                        \
+        }                                                                                                 \
+    }
 
-#define LOG_FATAL(message) { \
-        if (logger()->isFatalEnabled()) {\
-           ::log4cxx::helpers::MessageBuffer oss_; \
-           logger()->forcedLog(::log4cxx::Level::getFatal(), oss_.str(((std::ostream&)oss_) << message), LOG4CXX_LOCATION); }}
+#define LOG_FATAL(message)                                                                                \
+    {                                                                                                     \
+        if (logger()->isFatalEnabled()) {                                                                 \
+            ::log4cxx::helpers::MessageBuffer oss_;                                                       \
+            logger()->forcedLog(::log4cxx::Level::getFatal(), oss_.str(((std::ostream&)oss_) << message), \
+                                LOG4CXX_LOCATION);                                                        \
+        }                                                                                                 \
+    }
 
 #pragma GCC visibility push(default)
 
 class LogUtils {
- public:
+   public:
     static void init(const std::string& logConfFilePath);
 };
 
diff --git a/pulsar-client-cpp/lib/LookupDataResult.h b/pulsar-client-cpp/lib/LookupDataResult.h
index ed43af9..698a21f 100644
--- a/pulsar-client-cpp/lib/LookupDataResult.h
+++ b/pulsar-client-cpp/lib/LookupDataResult.h
@@ -29,45 +29,25 @@ typedef Promise<Result, LookupDataResultPtr> LookupDataResultPromise;
 typedef boost::shared_ptr<LookupDataResultPromise> LookupDataResultPromisePtr;
 
 class LookupDataResult {
- public:
-    void setBrokerUrl(const std::string& brokerUrl) {
-        brokerUrl_ = brokerUrl;
-    }
-    void setBrokerUrlSsl(const std::string& brokerUrlSsl) {
-        brokerUrlSsl_ = brokerUrlSsl;
-    }
-    std::string getBrokerUrl() {
-        return brokerUrl_;
-    }
-    std::string getBrokerUrlSsl() {
-        return brokerUrlSsl_;
-    }
+   public:
+    void setBrokerUrl(const std::string& brokerUrl) { brokerUrl_ = brokerUrl; }
+    void setBrokerUrlSsl(const std::string& brokerUrlSsl) { brokerUrlSsl_ = brokerUrlSsl; }
+    std::string getBrokerUrl() { return brokerUrl_; }
+    std::string getBrokerUrlSsl() { return brokerUrlSsl_; }
 
-    bool isAuthoritative() const {
-        return authoritative;
-    }
+    bool isAuthoritative() const { return authoritative; }
 
-    void setAuthoritative(bool authoritative) {
-        this->authoritative = authoritative;
-    }
+    void setAuthoritative(bool authoritative) { this->authoritative = authoritative; }
 
-    int getPartitions() const {
-        return partitions;
-    }
+    int getPartitions() const { return partitions; }
 
-    void setPartitions(int partitions) {
-        this->partitions = partitions;
-    }
+    void setPartitions(int partitions) { this->partitions = partitions; }
 
-    bool isRedirect() const {
-        return redirect;
-    }
+    bool isRedirect() const { return redirect; }
 
-    void setRedirect(bool redirect) {
-        this->redirect = redirect;
-    }
+    void setRedirect(bool redirect) { this->redirect = redirect; }
 
- private:
+   private:
     friend inline std::ostream& operator<<(std::ostream& os, const LookupDataResult& b);
     std::string brokerUrl_;
     std::string brokerUrlSsl_;
@@ -77,14 +57,11 @@ class LookupDataResult {
 };
 
 std::ostream& operator<<(std::ostream& os, const LookupDataResult& b) {
-    os << "{ LookupDataResult [brokerUrl_ = " << b.brokerUrl_ << "] [brokerUrlSsl_ = "
-            << b.brokerUrlSsl_ << "] [partitions = "
-            << b.partitions << "] [authoritative = "
-            << b.authoritative << "] [redirect = " << b.redirect
-            << "]";
+    os << "{ LookupDataResult [brokerUrl_ = " << b.brokerUrl_ << "] [brokerUrlSsl_ = " << b.brokerUrlSsl_
+       << "] [partitions = " << b.partitions << "] [authoritative = " << b.authoritative
+       << "] [redirect = " << b.redirect << "]";
     return os;
 }
+}  // namespace pulsar
 
-}
-
-#endif // _PULSAR_LOOKUP_DATA_RESULT_HEADER_
+#endif  // _PULSAR_LOOKUP_DATA_RESULT_HEADER_
diff --git a/pulsar-client-cpp/lib/LookupService.h b/pulsar-client-cpp/lib/LookupService.h
index cbcd723..4e8dbe6 100644
--- a/pulsar-client-cpp/lib/LookupService.h
+++ b/pulsar-client-cpp/lib/LookupService.h
@@ -27,7 +27,7 @@
 
 namespace pulsar {
 class LookupService {
-public:
+   public:
     /*
      * @param    destinationName - topic name
      *
@@ -43,5 +43,5 @@ public:
     virtual Future<Result, LookupDataResultPtr> getPartitionMetadataAsync(const DestinationNamePtr& dn) = 0;
 };
 typedef boost::shared_ptr<LookupService> LookupServicePtr;
-}
-#endif //PULSAR_CPP_LOOKUPSERVICE_H
+}  // namespace pulsar
+#endif  // PULSAR_CPP_LOOKUPSERVICE_H
diff --git a/pulsar-client-cpp/lib/Message.cc b/pulsar-client-cpp/lib/Message.cc
index e814980..79d7ca4 100644
--- a/pulsar-client-cpp/lib/Message.cc
+++ b/pulsar-client-cpp/lib/Message.cc
@@ -36,9 +36,7 @@ namespace pulsar {
 const static std::string emptyString;
 const static BatchMessageId invalidMessageId;
 
-const Message::StringMap& Message::getProperties() const {
-    return impl_->properties();
-}
+const Message::StringMap& Message::getProperties() const { return impl_->properties(); }
 
 bool Message::hasProperty(const std::string& name) const {
     const StringMap& m = impl_->properties();
@@ -54,36 +52,26 @@ const std::string& Message::getProperty(const std::string& name) const {
     }
 }
 
-const void* Message::getData() const {
-    return impl_->payload.data();
-}
+const void* Message::getData() const { return impl_->payload.data(); }
 
-std::size_t Message::getLength() const {
-    return impl_->payload.readableBytes();
-}
+std::size_t Message::getLength() const { return impl_->payload.readableBytes(); }
 
-std::string Message::getDataAsString() const {
-    return std::string((const char*) getData(), getLength());
-}
+std::string Message::getDataAsString() const { return std::string((const char*)getData(), getLength()); }
 
-Message::Message()
-        : impl_() {
-}
+Message::Message() : impl_() {}
 
-Message::Message(MessageImplPtr& impl)
-        : impl_(impl) {
-}
+Message::Message(MessageImplPtr& impl) : impl_(impl) {}
 
-Message::Message(const proto::CommandMessage& msg, proto::MessageMetadata& metadata,
-                 SharedBuffer& payload)
-        : impl_(boost::make_shared<MessageImpl>()) {
+Message::Message(const proto::CommandMessage& msg, proto::MessageMetadata& metadata, SharedBuffer& payload)
+    : impl_(boost::make_shared<MessageImpl>()) {
     impl_->messageId = BatchMessageId(msg.message_id().ledgerid(), msg.message_id().entryid());
     impl_->metadata = metadata;
     impl_->payload = payload;
 }
 
-Message::Message(const BatchMessageId& messageID, proto::MessageMetadata& metadata, SharedBuffer& payload, proto::SingleMessageMetadata& singleMetadata)
-: impl_(boost::make_shared<MessageImpl>()) {
+Message::Message(const BatchMessageId& messageID, proto::MessageMetadata& metadata, SharedBuffer& payload,
+                 proto::SingleMessageMetadata& singleMetadata)
+    : impl_(boost::make_shared<MessageImpl>()) {
     impl_->messageId = messageID;
     impl_->metadata = metadata;
     impl_->payload = payload;
@@ -98,8 +86,8 @@ const MessageId& Message::getMessageId() const {
     }
 }
 
-bool Message::hasPartitionKey() const{
-    if(impl_) {
+bool Message::hasPartitionKey() const {
+    if (impl_) {
         return impl_->hasPartitionKey();
     }
     return false;
@@ -112,13 +100,9 @@ const std::string& Message::getPartitionKey() const {
     return impl_->getPartitionKey();
 }
 
-uint64_t Message::getPublishTimestamp() const {
-    return impl_ ? impl_->getPublishTimestamp() : 0ull;
-}
+uint64_t Message::getPublishTimestamp() const { return impl_ ? impl_->getPublishTimestamp() : 0ull; }
 
-uint64_t Message::getEventTimestamp() const {
-    return impl_ ? impl_->getEventTimestamp() : 0ull;
-}
+uint64_t Message::getEventTimestamp() const { return impl_ ? impl_->getEventTimestamp() : 0ull; }
 
 #pragma GCC visibility push(default)
 
@@ -148,13 +132,12 @@ std::ostream& operator<<(std::ostream& s, const Message& msg) {
     assert(msg.impl_.get());
     assert(msg.impl_->metadata.has_sequence_id());
     assert(msg.impl_->metadata.has_publish_time());
-    s << "Message(prod=" << msg.impl_->metadata.producer_name() << ", seq="
-      << msg.impl_->metadata.sequence_id() << ", publish_time="
-      << msg.impl_->metadata.publish_time() << ", payload_size=" << msg.getLength() << ", msg_id="
-      << msg.getMessageId() << ", props=" << msg.getProperties() << ')';
+    s << "Message(prod=" << msg.impl_->metadata.producer_name()
+      << ", seq=" << msg.impl_->metadata.sequence_id()
+      << ", publish_time=" << msg.impl_->metadata.publish_time() << ", payload_size=" << msg.getLength()
+      << ", msg_id=" << msg.getMessageId() << ", props=" << msg.getProperties() << ')';
     return s;
 }
 
 #pragma GCC visibility pop
-
-}
+}  // namespace pulsar
diff --git a/pulsar-client-cpp/lib/MessageBuilder.cc b/pulsar-client-cpp/lib/MessageBuilder.cc
index 5f232e3..4ea21b2 100644
--- a/pulsar-client-cpp/lib/MessageBuilder.cc
+++ b/pulsar-client-cpp/lib/MessageBuilder.cc
@@ -35,22 +35,16 @@ namespace pulsar {
 
 ObjectPool<MessageImpl, 100000> messagePool;
 
-boost::shared_ptr<MessageImpl> MessageBuilder::createMessageImpl() {
-    return messagePool.create();
-}
+boost::shared_ptr<MessageImpl> MessageBuilder::createMessageImpl() { return messagePool.create(); }
 
-MessageBuilder::MessageBuilder() {
-    impl_ = createMessageImpl();
-}
+MessageBuilder::MessageBuilder() { impl_ = createMessageImpl(); }
 
 MessageBuilder& MessageBuilder::create() {
     impl_ = createMessageImpl();
     return *this;
 }
 
-Message MessageBuilder::build() {
-    return Message(impl_);
-}
+Message MessageBuilder::build() { return Message(impl_); }
 
 void MessageBuilder::checkMetadata() {
     if (!impl_.get()) {
@@ -61,25 +55,25 @@ void MessageBuilder::checkMetadata() {
 
 MessageBuilder& MessageBuilder::setContent(const void* data, size_t size) {
     checkMetadata();
-    impl_->payload = SharedBuffer::copy((char *) data, size);
+    impl_->payload = SharedBuffer::copy((char*)data, size);
     return *this;
 }
 
 MessageBuilder& MessageBuilder::setAllocatedContent(void* data, size_t size) {
     checkMetadata();
-    impl_->payload = SharedBuffer::wrap((char *) data, size);
+    impl_->payload = SharedBuffer::wrap((char*)data, size);
     return *this;
 }
 
 MessageBuilder& MessageBuilder::setContent(const std::string& data) {
     checkMetadata();
-    impl_->payload = SharedBuffer::copy((char *) data.c_str(), data.length());
+    impl_->payload = SharedBuffer::copy((char*)data.c_str(), data.length());
     return *this;
 }
 
 MessageBuilder& MessageBuilder::setProperty(const std::string& name, const std::string& value) {
     checkMetadata();
-    proto::KeyValue *keyValue = proto::KeyValue().New();
+    proto::KeyValue* keyValue = proto::KeyValue().New();
     keyValue->set_key(name);
     keyValue->set_value(value);
     impl_->metadata.mutable_properties()->AddAllocated(keyValue);
@@ -131,5 +125,4 @@ MessageBuilder& MessageBuilder::disableReplication(bool flag) {
     r.Swap(impl_->metadata.mutable_replicate_to());
     return *this;
 }
-
-}
+}  // namespace pulsar
diff --git a/pulsar-client-cpp/lib/MessageId.cc b/pulsar-client-cpp/lib/MessageId.cc
index 0cb0b81..dc1ff38 100644
--- a/pulsar-client-cpp/lib/MessageId.cc
+++ b/pulsar-client-cpp/lib/MessageId.cc
@@ -30,12 +30,7 @@
 
 namespace pulsar {
 
-
-MessageId::MessageId()
-        : ledgerId_(-1),
-          entryId_(-1),
-          partition_(-1) {
-}
+MessageId::MessageId() : ledgerId_(-1), entryId_(-1), partition_(-1) {}
 
 MessageId& MessageId::operator=(const MessageId& m) {
     entryId_ = m.entryId_;
@@ -45,11 +40,9 @@ MessageId& MessageId::operator=(const MessageId& m) {
 }
 
 MessageId::MessageId(int64_t ledgerId, int64_t entryId)
-        : ledgerId_(ledgerId),
-          entryId_(entryId),
-          partition_(-1) {
-     // partition is set explicitly in consumerImpl when message is received
-     // consumer's partition is assigned to this partition
+    : ledgerId_(ledgerId), entryId_(entryId), partition_(-1) {
+    // partition is set explicitly in consumerImpl when message is received
+    // consumer's partition is assigned to this partition
 }
 
 int64_t MessageId::getBatchIndex() const {
@@ -64,8 +57,7 @@ const MessageId& MessageId::earliest() {
 
 const MessageId& MessageId::latest() {
     // For entry-id we only have 48bits
-    static const BatchMessageId _latest(std::numeric_limits<int64_t>::max(),
-                                        (int64_t)(pow(2, 47) - 1));
+    static const BatchMessageId _latest(std::numeric_limits<int64_t>::max(), (int64_t)(pow(2, 47) - 1));
     return _latest;
 }
 
@@ -89,11 +81,9 @@ boost::shared_ptr<MessageId> MessageId::deserialize(const std::string& serialize
         throw "Failed to parse serialized message id";
     }
 
-    return boost::make_shared<BatchMessageId>(idData.ledgerid(), idData.entryid(),
-                                              idData.batch_index());
+    return boost::make_shared<BatchMessageId>(idData.ledgerid(), idData.entryid(), idData.batch_index());
 }
 
-
 #pragma GCC visibility push(default)
 std::ostream& operator<<(std::ostream& s, const pulsar::MessageId& messageId) {
     s << '(' << messageId.ledgerId_ << ',' << messageId.entryId_ << ',' << messageId.partition_ << ')';
@@ -119,5 +109,4 @@ bool MessageId::operator==(const MessageId& other) const {
 }
 
 #pragma GCC visibility pop
-
-}
+}  // namespace pulsar
diff --git a/pulsar-client-cpp/lib/MessageImpl.cc b/pulsar-client-cpp/lib/MessageImpl.cc
index f86c084..569a30a 100644
--- a/pulsar-client-cpp/lib/MessageImpl.cc
+++ b/pulsar-client-cpp/lib/MessageImpl.cc
@@ -20,73 +20,62 @@
 
 namespace pulsar {
 
-    MessageImpl::MessageImpl()
-        : metadata(),
-          payload(),
-          messageId(),
-          cnx_(0) {
-    }
+MessageImpl::MessageImpl() : metadata(), payload(), messageId(), cnx_(0) {}
 
-    const Message::StringMap& MessageImpl::properties() {
-        if (properties_.size() == 0) {
-            for (int i = 0; i < metadata.properties_size(); i++) {
-                const std::string& key = metadata.properties(i).key();
-                const std::string& value = metadata.properties(i).value();
-                properties_.insert(std::make_pair(key, value));
-            }
+const Message::StringMap& MessageImpl::properties() {
+    if (properties_.size() == 0) {
+        for (int i = 0; i < metadata.properties_size(); i++) {
+            const std::string& key = metadata.properties(i).key();
+            const std::string& value = metadata.properties(i).value();
+            properties_.insert(std::make_pair(key, value));
         }
-        return properties_;
     }
+    return properties_;
+}
 
-    const std::string& MessageImpl::getPartitionKey() const {
-            return metadata.partition_key();
-    }
+const std::string& MessageImpl::getPartitionKey() const { return metadata.partition_key(); }
 
-    bool MessageImpl::hasPartitionKey() const {
-        return metadata.has_partition_key();
-    }
+bool MessageImpl::hasPartitionKey() const { return metadata.has_partition_key(); }
 
-    uint64_t MessageImpl::getPublishTimestamp() const {
-        if (metadata.has_publish_time()) {
-            return metadata.publish_time();
-        } else {
-            return 0ull;
-        }
-    }
-
-    uint64_t MessageImpl::getEventTimestamp() const {
-        if (metadata.has_event_time()) {
-            return metadata.event_time();
-        } else {
-            return 0ull;
-        }
+uint64_t MessageImpl::getPublishTimestamp() const {
+    if (metadata.has_publish_time()) {
+        return metadata.publish_time();
+    } else {
+        return 0ull;
     }
+}
 
-    void MessageImpl::setReplicationClusters(const std::vector<std::string>& clusters) {
-        google::protobuf::RepeatedPtrField<std::string> r(clusters.begin(), clusters.end());
-        r.Swap(metadata.mutable_replicate_to());
+uint64_t MessageImpl::getEventTimestamp() const {
+    if (metadata.has_event_time()) {
+        return metadata.event_time();
+    } else {
+        return 0ull;
     }
+}
 
-    void MessageImpl::disableReplication(bool flag) {
-        google::protobuf::RepeatedPtrField<std::string> r;
-        if (flag) {
-            r.AddAllocated(new std::string("__local__"));
-        }
-        r.Swap(metadata.mutable_replicate_to());
-    }
+void MessageImpl::setReplicationClusters(const std::vector<std::string>& clusters) {
+    google::protobuf::RepeatedPtrField<std::string> r(clusters.begin(), clusters.end());
+    r.Swap(metadata.mutable_replicate_to());
+}
 
-    void MessageImpl::setProperty(const std::string& name, const std::string& value) {
-        proto::KeyValue *keyValue = proto::KeyValue().New();
-        keyValue->set_key(name);
-        keyValue->set_value(value);
-        metadata.mutable_properties()->AddAllocated(keyValue);
+void MessageImpl::disableReplication(bool flag) {
+    google::protobuf::RepeatedPtrField<std::string> r;
+    if (flag) {
+        r.AddAllocated(new std::string("__local__"));
     }
+    r.Swap(metadata.mutable_replicate_to());
+}
 
-    void MessageImpl::setPartitionKey(const std::string& partitionKey) {
-        metadata.set_partition_key(partitionKey);
-    }
+void MessageImpl::setProperty(const std::string& name, const std::string& value) {
+    proto::KeyValue* keyValue = proto::KeyValue().New();
+    keyValue->set_key(name);
+    keyValue->set_value(value);
+    metadata.mutable_properties()->AddAllocated(keyValue);
+}
 
-    void MessageImpl::setEventTimestamp(uint64_t eventTimestamp) {
-        metadata.set_event_time(eventTimestamp);
-    }
+void MessageImpl::setPartitionKey(const std::string& partitionKey) {
+    metadata.set_partition_key(partitionKey);
 }
+
+void MessageImpl::setEventTimestamp(uint64_t eventTimestamp) { metadata.set_event_time(eventTimestamp); }
+}  // namespace pulsar
diff --git a/pulsar-client-cpp/lib/MessageImpl.h b/pulsar-client-cpp/lib/MessageImpl.h
index 80d29e2..23a8fcf 100644
--- a/pulsar-client-cpp/lib/MessageImpl.h
+++ b/pulsar-client-cpp/lib/MessageImpl.h
@@ -35,7 +35,7 @@ class ClientConnection;
 class BatchMessageContainer;
 
 class MessageImpl {
- public:
+   public:
     MessageImpl();
 
     const Message::StringMap& properties();
@@ -53,7 +53,8 @@ class MessageImpl {
 
     friend class PulsarWrapper;
     friend class MessageBuilder;
-private:
+
+   private:
     void setReplicationClusters(const std::vector<std::string>& clusters);
     void setProperty(const std::string& name, const std::string& value);
     void disableReplication(bool flag);
@@ -61,7 +62,6 @@ private:
     void setEventTimestamp(uint64_t eventTimestamp);
     Message::StringMap properties_;
 };
-
-}
+}  // namespace pulsar
 
 #endif /* LIB_MESSAGEIMPL_H_ */
diff --git a/pulsar-client-cpp/lib/NamedEntity.h b/pulsar-client-cpp/lib/NamedEntity.h
index 4f78cb0..4437602 100644
--- a/pulsar-client-cpp/lib/NamedEntity.h
+++ b/pulsar-client-cpp/lib/NamedEntity.h
@@ -22,9 +22,10 @@
 #include <boost/regex.hpp>
 
 class NamedEntity {
- private:
+   private:
     static const boost::regex pattern;
- public:
+
+   public:
     static bool checkName(const std::string& name);
 };
 #endif
diff --git a/pulsar-client-cpp/lib/NamespaceName.cc b/pulsar-client-cpp/lib/NamespaceName.cc
index 5f0631a..27308bb 100644
--- a/pulsar-client-cpp/lib/NamespaceName.cc
+++ b/pulsar-client-cpp/lib/NamespaceName.cc
@@ -28,8 +28,7 @@
 
 DECLARE_LOG_OBJECT()
 
-boost::shared_ptr<NamespaceName> NamespaceName::get(const std::string& property,
-                                                    const std::string& cluster,
+boost::shared_ptr<NamespaceName> NamespaceName::get(const std::string& property, const std::string& cluster,
                                                     const std::string& namespaceName) {
     if (validateNamespace(property, cluster, namespaceName)) {
         boost::shared_ptr<NamespaceName> ptr(new NamespaceName(property, cluster, namespaceName));
@@ -53,8 +52,8 @@ NamespaceName::NamespaceName(const std::string& property, const std::string& clu
 bool NamespaceName::validateNamespace(const std::string& property, const std::string& cluster,
                                       const std::string& namespaceName) {
     if (!property.empty() && !cluster.empty() && !namespaceName.empty()) {
-        return NamedEntity::checkName(property) && NamedEntity::checkName(cluster)
-                && NamedEntity::checkName(namespaceName);
+        return NamedEntity::checkName(property) && NamedEntity::checkName(cluster) &&
+               NamedEntity::checkName(namespaceName);
     } else {
         LOG_DEBUG("Empty parameters passed for validating namespace");
         return false;
@@ -65,18 +64,12 @@ boost::shared_ptr<NamespaceName> NamespaceName::getNamespaceObject() {
     return boost::shared_ptr<NamespaceName>(this);
 }
 
-bool NamespaceName::operator ==(const NamespaceName& namespaceName) {
+bool NamespaceName::operator==(const NamespaceName& namespaceName) {
     return this->namespace_.compare(namespaceName.namespace_) == 0;
 }
 
-std::string NamespaceName::getProperty() {
-    return this->property_;
-}
+std::string NamespaceName::getProperty() { return this->property_; }
 
-std::string NamespaceName::getCluster() {
-    return this->cluster_;
-}
+std::string NamespaceName::getCluster() { return this->cluster_; }
 
-std::string NamespaceName::getLocalName() {
-    return this->localName_;
-}
+std::string NamespaceName::getLocalName() { return this->localName_; }
diff --git a/pulsar-client-cpp/lib/NamespaceName.h b/pulsar-client-cpp/lib/NamespaceName.h
index 8c231d6..f0016ca 100644
--- a/pulsar-client-cpp/lib/NamespaceName.h
+++ b/pulsar-client-cpp/lib/NamespaceName.h
@@ -24,29 +24,26 @@
 #include <string>
 #include <boost/shared_ptr.hpp>
 
-
 #pragma GCC visibility push(default)
 
 class NamespaceName : public ServiceUnitId {
- public:
+   public:
     boost::shared_ptr<NamespaceName> getNamespaceObject();
     std::string getProperty();
     std::string getCluster();
     std::string getLocalName();
-    static boost::shared_ptr<NamespaceName> get(const std::string& property,
-                                                const std::string& cluster,
+    static boost::shared_ptr<NamespaceName> get(const std::string& property, const std::string& cluster,
                                                 const std::string& namespaceName);
-    bool operator ==(const NamespaceName& namespaceName);
+    bool operator==(const NamespaceName& namespaceName);
 
- private:
+   private:
     std::string namespace_;
     std::string property_;
     std::string cluster_;
     std::string localName_;
     static bool validateNamespace(const std::string& property, const std::string& cluster,
                                   const std::string& namespace_);
-    NamespaceName(const std::string& property, const std::string& cluster,
-                  const std::string& namespace_);
+    NamespaceName(const std::string& property, const std::string& cluster, const std::string& namespace_);
 };
 
 #pragma GCC visibility pop
diff --git a/pulsar-client-cpp/lib/ObjectPool.h b/pulsar-client-cpp/lib/ObjectPool.h
index 834838c..b5db0f1 100644
--- a/pulsar-client-cpp/lib/ObjectPool.h
+++ b/pulsar-client-cpp/lib/ObjectPool.h
@@ -28,12 +28,12 @@
 
 namespace pulsar {
 
-template<typename T, int MaxSize>
+template <typename T, int MaxSize>
 class Allocator {
-    public:
+   public:
     // Allocator must be stateless, so put everything in this static
     class Impl {
-        public:
+       public:
         // cheap lock to acquire
         static boost::mutex mutex_;
 
@@ -42,16 +42,16 @@ class Allocator {
             Node* next;
             explicit Node(Node* n) : next(n) {}
         };
-        Node *head_;
+        Node* head_;
         int pushSize_;
 
         struct GlobalPool {
-            Node *node_;
+            Node* node_;
             int nodeCount_;
-            GlobalPool *next_;
+            GlobalPool* next_;
             explicit GlobalPool(GlobalPool* n) : next_(n) {}
         };
-        static struct GlobalPool *globalPool_;
+        static struct GlobalPool* globalPool_;
         static int globalNodeCount_;
 
         Impl(const Impl&);
@@ -66,13 +66,12 @@ class Allocator {
                     return NULL;
                 }
 
-                GlobalPool *poolEntry = globalPool_;
+                GlobalPool* poolEntry = globalPool_;
                 head_ = globalPool_->node_;
                 pushSize_ += globalPool_->nodeCount_;
                 globalNodeCount_ -= globalPool_->nodeCount_;
                 globalPool_ = globalPool_->next_;
                 delete poolEntry;
-
             }
             void* result = head_;
             if (result) {
@@ -83,10 +82,8 @@ class Allocator {
         }
 
         bool push(void* p) {
-
             // Once thread specific entries reaches 10% of max size, push them to GlobalPool
-            if (pushSize_ >= MaxSize*0.1) {
-
+            if (pushSize_ >= MaxSize * 0.1) {
                 bool deleteList = true;
                 {
                     // Move the entries to global pool
@@ -95,7 +92,6 @@ class Allocator {
                     // If total node count reached max allowed cache limit,
                     // skip adding to global pool.
                     if ((globalNodeCount_ + pushSize_) <= MaxSize) {
-
                         deleteList = false;
 
                         globalPool_ = new GlobalPool(globalPool_);
@@ -103,18 +99,17 @@ class Allocator {
                         globalPool_->nodeCount_ = pushSize_;
                         globalNodeCount_ += pushSize_;
                     }
-
                 }
                 if (deleteList) {
                     pushSize_ = 0;
                     deleteLinkedList(head_);
                 }
-                head_ = new(p) Node(0);
+                head_ = new (p) Node(0);
                 pushSize_ = 1;
                 return true;
             }
 
-            head_ = new(p) Node(head_);
+            head_ = new (p) Node(head_);
             pushSize_++;
             return true;
         }
@@ -127,7 +122,8 @@ class Allocator {
                 ::operator delete(p);
             }
         }
-    public:
+
+       public:
         Impl() {
             pushSize_ = 0;
             head_ = 0;
@@ -159,30 +155,25 @@ class Allocator {
     typedef T* pointer;
     typedef const void* const_pointer;
 
-    Allocator() {
-    }
+    Allocator() {}
 
-    Allocator(const Allocator& /*other*/) {
-    }
+    Allocator(const Allocator& /*other*/) {}
 
-    template<typename Other, int OtherSize>
-    Allocator(const Allocator<Other, OtherSize>& /*other*/) {
-    }
+    template <typename Other, int OtherSize>
+    Allocator(const Allocator<Other, OtherSize>& /*other*/) {}
 
-    pointer allocate(size_type n, const void * /*hint*/ = 0) {
-        Impl *impl = implPtr_.get();
+    pointer allocate(size_type n, const void* /*hint*/ = 0) {
+        Impl* impl = implPtr_.get();
         if (!impl) {
             implPtr_.reset(new Impl);
             impl = implPtr_.get();
         }
-        void* p = (n == 1)
-            ? impl->allocate()
-            : operator new(n * sizeof(T));
+        void* p = (n == 1) ? impl->allocate() : operator new(n * sizeof(T));
         return static_cast<T*>(p);
     }
 
     void deallocate(pointer ptr, size_type n) {
-        Impl *impl = implPtr_.get();
+        Impl* impl = implPtr_.get();
         if (!impl) {
             implPtr_.reset(new Impl);
             impl = implPtr_.get();
@@ -193,7 +184,8 @@ class Allocator {
             ::operator delete(ptr);
     }
 
-    template<typename Other> struct rebind {
+    template <typename Other>
+    struct rebind {
         typedef Allocator<Other, MaxSize> other;
     };
 };
@@ -201,46 +193,42 @@ class Allocator {
 // typename Allocator<Type,MaxSize>::Impl is important else the compiler
 // doesn't understand that it is a type
 template <typename Type, int MaxSize>
-boost::thread_specific_ptr<typename Allocator<Type,MaxSize>::Impl> Allocator<Type,MaxSize>::implPtr_;
+boost::thread_specific_ptr<typename Allocator<Type, MaxSize>::Impl> Allocator<Type, MaxSize>::implPtr_;
 
 template <typename Type, int MaxSize>
-boost::mutex Allocator<Type,MaxSize>::Impl::mutex_;
+boost::mutex Allocator<Type, MaxSize>::Impl::mutex_;
 
 template <typename Type, int MaxSize>
-struct Allocator<Type,MaxSize>::Impl::GlobalPool *Allocator<Type,MaxSize>::Impl::globalPool_;
+struct Allocator<Type, MaxSize>::Impl::GlobalPool* Allocator<Type, MaxSize>::Impl::globalPool_;
 
 template <typename Type, int MaxSize>
-int Allocator<Type,MaxSize>::Impl::globalNodeCount_;
+int Allocator<Type, MaxSize>::Impl::globalNodeCount_;
 
-template<typename Type, int MaxSize>
+template <typename Type, int MaxSize>
 class ObjectPool {
     typedef boost::shared_ptr<Type> TypeSharedPtr;
 
     Allocator<Type, MaxSize> allocator_;
 
- public:
-    ObjectPool() {
-
-    }
+   public:
+    ObjectPool() {}
 
-    TypeSharedPtr create() {
-        return boost::allocate_shared<Type>(allocator_);
-    }
+    TypeSharedPtr create() { return boost::allocate_shared<Type>(allocator_); }
 
     ~ObjectPool() {
-
-        struct Allocator<Type,MaxSize>::Impl::GlobalPool *poolEntry = Allocator<Type,MaxSize>::Impl::globalPool_;
-        while(poolEntry) {
+        struct Allocator<Type, MaxSize>::Impl::GlobalPool* poolEntry =
+            Allocator<Type, MaxSize>::Impl::globalPool_;
+        while (poolEntry) {
             Allocator<Type, MaxSize>::Impl::deleteLinkedList(poolEntry->node_);
-            struct Allocator<Type,MaxSize>::Impl::GlobalPool *delEntry = poolEntry;
+            struct Allocator<Type, MaxSize>::Impl::GlobalPool* delEntry = poolEntry;
             poolEntry = poolEntry->next_;
             ::operator delete(delEntry);
         }
     }
- private:
+
+   private:
     ObjectPool<Type, MaxSize>(const ObjectPool<Type, MaxSize>&);
     ObjectPool<Type, MaxSize>& operator=(const ObjectPool<Type, MaxSize>&);
 };
-
-}
+}  // namespace pulsar
 #endif /* LIB_OBJECTPOOL_H_ */
diff --git a/pulsar-client-cpp/lib/PartitionedBrokerConsumerStatsImpl.cc b/pulsar-client-cpp/lib/PartitionedBrokerConsumerStatsImpl.cc
index 54da934..9d5965b 100644
--- a/pulsar-client-cpp/lib/PartitionedBrokerConsumerStatsImpl.cc
+++ b/pulsar-client-cpp/lib/PartitionedBrokerConsumerStatsImpl.cc
@@ -23,147 +23,141 @@
 
 namespace pulsar {
 
-    const std::string PartitionedBrokerConsumerStatsImpl::DELIMITER = ";";
+const std::string PartitionedBrokerConsumerStatsImpl::DELIMITER = ";";
 
-    PartitionedBrokerConsumerStatsImpl::PartitionedBrokerConsumerStatsImpl(size_t size) {
-        statsList_.resize(size);
-    }
+PartitionedBrokerConsumerStatsImpl::PartitionedBrokerConsumerStatsImpl(size_t size) {
+    statsList_.resize(size);
+}
 
-    bool PartitionedBrokerConsumerStatsImpl::isValid() const {
-        bool isValid = true;
-        for (int i = 0; i<statsList_.size(); i++) {
-            isValid &= statsList_[i].isValid();
-        }
-        return isValid;
+bool PartitionedBrokerConsumerStatsImpl::isValid() const {
+    bool isValid = true;
+    for (int i = 0; i < statsList_.size(); i++) {
+        isValid &= statsList_[i].isValid();
     }
+    return isValid;
+}
 
-    std::ostream& operator<<(std::ostream &os, const PartitionedBrokerConsumerStatsImpl& obj) {
-        os << "\nPartitionedBrokerConsumerStatsImpl ["
-           << "validTill_ = " << obj.isValid()
-           << ", msgRateOut_ = " << obj.getMsgRateOut()
-           << ", msgThroughputOut_ = " << obj.getMsgThroughputOut()
-           << ", msgRateRedeliver_ = " << obj.getMsgRateRedeliver()
-           << ", consumerName_ = " << obj.getConsumerName()
-           << ", availablePermits_ = " << obj.getAvailablePermits()
-           << ", unackedMessages_ = " << obj.getUnackedMessages()
-           << ", blockedConsumerOnUnackedMsgs_ = " << obj.isBlockedConsumerOnUnackedMsgs()
-           << ", address_ = " << obj.getAddress()
-           << ", connectedSince_ = " << obj.getConnectedSince()
-           << ", type_ = " << obj.getType()
-           << ", msgRateExpired_ = " << obj.getMsgRateExpired()
-           << ", msgBacklog_ = " << obj.getMsgBacklog()
-           << "]";
-        return os;
-    }
+std::ostream& operator<<(std::ostream& os, const PartitionedBrokerConsumerStatsImpl& obj) {
+    os << "\nPartitionedBrokerConsumerStatsImpl ["
+       << "validTill_ = " << obj.isValid() << ", msgRateOut_ = " << obj.getMsgRateOut()
+       << ", msgThroughputOut_ = " << obj.getMsgThroughputOut()
+       << ", msgRateRedeliver_ = " << obj.getMsgRateRedeliver()
+       << ", consumerName_ = " << obj.getConsumerName()
+       << ", availablePermits_ = " << obj.getAvailablePermits()
+       << ", unackedMessages_ = " << obj.getUnackedMessages()
+       << ", blockedConsumerOnUnackedMsgs_ = " << obj.isBlockedConsumerOnUnackedMsgs()
+       << ", address_ = " << obj.getAddress() << ", connectedSince_ = " << obj.getConnectedSince()
+       << ", type_ = " << obj.getType() << ", msgRateExpired_ = " << obj.getMsgRateExpired()
+       << ", msgBacklog_ = " << obj.getMsgBacklog() << "]";
+    return os;
+}
 
-    double PartitionedBrokerConsumerStatsImpl::getMsgRateOut() const {
-        double sum = 0;
-        for (int i = 0; i<statsList_.size(); i++) {
-            sum += statsList_[i].getMsgRateOut();
-        }
-        return sum;
+double PartitionedBrokerConsumerStatsImpl::getMsgRateOut() const {
+    double sum = 0;
+    for (int i = 0; i < statsList_.size(); i++) {
+        sum += statsList_[i].getMsgRateOut();
     }
+    return sum;
+}
 
-    double PartitionedBrokerConsumerStatsImpl::getMsgThroughputOut() const {
-        double sum = 0;
-        for (int i = 0; i<statsList_.size(); i++) {
-            sum += statsList_[i].getMsgThroughputOut();
-        }
-        return sum;
+double PartitionedBrokerConsumerStatsImpl::getMsgThroughputOut() const {
+    double sum = 0;
+    for (int i = 0; i < statsList_.size(); i++) {
+        sum += statsList_[i].getMsgThroughputOut();
     }
+    return sum;
+}
 
-    double PartitionedBrokerConsumerStatsImpl::getMsgRateRedeliver() const {
-        double sum = 0;
-        for (int i = 0; i<statsList_.size(); i++) {
-            sum += statsList_[i].getMsgRateRedeliver();
-        }
-        return sum;
+double PartitionedBrokerConsumerStatsImpl::getMsgRateRedeliver() const {
+    double sum = 0;
+    for (int i = 0; i < statsList_.size(); i++) {
+        sum += statsList_[i].getMsgRateRedeliver();
     }
+    return sum;
+}
 
-    const std::string PartitionedBrokerConsumerStatsImpl::getConsumerName() const {
-        std::string str;
-        for (int i = 0; i<statsList_.size(); i++) {
-            str += statsList_[i].getConsumerName() + DELIMITER;
-        }
-        return str;
+const std::string PartitionedBrokerConsumerStatsImpl::getConsumerName() const {
+    std::string str;
+    for (int i = 0; i < statsList_.size(); i++) {
+        str += statsList_[i].getConsumerName() + DELIMITER;
     }
+    return str;
+}
 
-    uint64_t PartitionedBrokerConsumerStatsImpl::getAvailablePermits() const {
-        uint64_t sum = 0;
-        for (int i = 0; i<statsList_.size(); i++) {
-            sum += statsList_[i].getAvailablePermits();
-        }
-        return sum;
+uint64_t PartitionedBrokerConsumerStatsImpl::getAvailablePermits() const {
+    uint64_t sum = 0;
+    for (int i = 0; i < statsList_.size(); i++) {
+        sum += statsList_[i].getAvailablePermits();
     }
+    return sum;
+}
 
-    uint64_t PartitionedBrokerConsumerStatsImpl::getUnackedMessages() const {
-        uint64_t sum = 0;
-        for (int i = 0; i<statsList_.size(); i++) {
-            sum += statsList_[i].getUnackedMessages();
-        }
-        return sum;
+uint64_t PartitionedBrokerConsumerStatsImpl::getUnackedMessages() const {
+    uint64_t sum = 0;
+    for (int i = 0; i < statsList_.size(); i++) {
+        sum += statsList_[i].getUnackedMessages();
     }
+    return sum;
+}
 
-    bool PartitionedBrokerConsumerStatsImpl::isBlockedConsumerOnUnackedMsgs() const {
-        if (statsList_.size() == 0) {
-            return false;
-        }
-
-        bool isValid = true;
-        for (int i = 0; i<statsList_.size(); i++) {
-            isValid &= statsList_[i].isValid();
-        }
-        return isValid;
+bool PartitionedBrokerConsumerStatsImpl::isBlockedConsumerOnUnackedMsgs() const {
+    if (statsList_.size() == 0) {
+        return false;
     }
 
-    const std::string PartitionedBrokerConsumerStatsImpl::getAddress() const {
-        std::string str;
-        for (int i = 0; i<statsList_.size(); i++) {
-            str += statsList_[i].getAddress() + DELIMITER;
-        }
-        return str;
+    bool isValid = true;
+    for (int i = 0; i < statsList_.size(); i++) {
+        isValid &= statsList_[i].isValid();
     }
+    return isValid;
+}
 
-    const std::string PartitionedBrokerConsumerStatsImpl::getConnectedSince() const {
-        std::string str;
-        for (int i = 0; i<statsList_.size(); i++) {
-            str += statsList_[i].getConnectedSince() + DELIMITER;
-        }
-        return str;
+const std::string PartitionedBrokerConsumerStatsImpl::getAddress() const {
+    std::string str;
+    for (int i = 0; i < statsList_.size(); i++) {
+        str += statsList_[i].getAddress() + DELIMITER;
     }
+    return str;
+}
 
-    const ConsumerType PartitionedBrokerConsumerStatsImpl::getType() const {
-        if (! statsList_.size()) {
-            return ConsumerExclusive;
-        }
-        return statsList_[0].getType();
+const std::string PartitionedBrokerConsumerStatsImpl::getConnectedSince() const {
+    std::string str;
+    for (int i = 0; i < statsList_.size(); i++) {
+        str += statsList_[i].getConnectedSince() + DELIMITER;
     }
+    return str;
+}
 
-    double PartitionedBrokerConsumerStatsImpl::getMsgRateExpired() const {
-        double sum = 0;
-        for (int i = 0; i<statsList_.size(); i++) {
-            sum += statsList_[i].getMsgRateExpired();
-        }
-        return sum;
+const ConsumerType PartitionedBrokerConsumerStatsImpl::getType() const {
+    if (!statsList_.size()) {
+        return ConsumerExclusive;
     }
+    return statsList_[0].getType();
+}
 
-    uint64_t PartitionedBrokerConsumerStatsImpl::getMsgBacklog() const {
-        uint64_t sum = 0;
-        for (int i = 0; i<statsList_.size(); i++) {
-            sum += statsList_[i].getMsgBacklog();
-        }
-        return sum;
+double PartitionedBrokerConsumerStatsImpl::getMsgRateExpired() const {
+    double sum = 0;
+    for (int i = 0; i < statsList_.size(); i++) {
+        sum += statsList_[i].getMsgRateExpired();
     }
+    return sum;
+}
 
-    BrokerConsumerStats PartitionedBrokerConsumerStatsImpl::getBrokerConsumerStats(int index) {
-        return statsList_[index];
+uint64_t PartitionedBrokerConsumerStatsImpl::getMsgBacklog() const {
+    uint64_t sum = 0;
+    for (int i = 0; i < statsList_.size(); i++) {
+        sum += statsList_[i].getMsgBacklog();
     }
+    return sum;
+}
 
-    void PartitionedBrokerConsumerStatsImpl::add(BrokerConsumerStats stats, int index) {
-        statsList_[index] = stats;
-    }
+BrokerConsumerStats PartitionedBrokerConsumerStatsImpl::getBrokerConsumerStats(int index) {
+    return statsList_[index];
+}
 
-    void PartitionedBrokerConsumerStatsImpl::clear() {
-        statsList_.clear();
-    }
+void PartitionedBrokerConsumerStatsImpl::add(BrokerConsumerStats stats, int index) {
+    statsList_[index] = stats;
 }
+
+void PartitionedBrokerConsumerStatsImpl::clear() { statsList_.clear(); }
+}  // namespace pulsar
diff --git a/pulsar-client-cpp/lib/PartitionedBrokerConsumerStatsImpl.h b/pulsar-client-cpp/lib/PartitionedBrokerConsumerStatsImpl.h
index 321bc69..07cb11a 100644
--- a/pulsar-client-cpp/lib/PartitionedBrokerConsumerStatsImpl.h
+++ b/pulsar-client-cpp/lib/PartitionedBrokerConsumerStatsImpl.h
@@ -31,11 +31,11 @@
 #pragma GCC visibility push(default)
 namespace pulsar {
 class PartitionedBrokerConsumerStatsImpl : public BrokerConsumerStatsImplBase {
- private:
+   private:
     std::vector<BrokerConsumerStats> statsList_;
     static const std::string DELIMITER;
- public:
 
+   public:
     PartitionedBrokerConsumerStatsImpl(size_t size);
 
     /** Returns true if the Stats are still valid **/
@@ -84,10 +84,9 @@ class PartitionedBrokerConsumerStatsImpl : public BrokerConsumerStatsImplBase {
 
     void clear();
 
-    friend std::ostream& operator<<(std::ostream &os, const PartitionedBrokerConsumerStatsImpl &obj);
+    friend std::ostream &operator<<(std::ostream &os, const PartitionedBrokerConsumerStatsImpl &obj);
 };
 typedef boost::shared_ptr<PartitionedBrokerConsumerStatsImpl> PartitionedBrokerConsumerStatsPtr;
-
-}
+}  // namespace pulsar
 #pragma GCC visibility pop
-#endif //PULSAR_CPP_BROKERCONSUMERSTATSIMPL_H
+#endif  // PULSAR_CPP_BROKERCONSUMERSTATSIMPL_H
diff --git a/pulsar-client-cpp/lib/PartitionedConsumerImpl.cc b/pulsar-client-cpp/lib/PartitionedConsumerImpl.cc
index e25fd27..52a3c46 100644
--- a/pulsar-client-cpp/lib/PartitionedConsumerImpl.cc
+++ b/pulsar-client-cpp/lib/PartitionedConsumerImpl.cc
@@ -22,393 +22,383 @@ DECLARE_LOG_OBJECT()
 
 namespace pulsar {
 
-    PartitionedConsumerImpl::PartitionedConsumerImpl(ClientImplPtr client,
-            const std::string& subscriptionName,
-            const DestinationNamePtr destinationName,
-            const unsigned int numPartitions,
-            const ConsumerConfiguration& conf)
+PartitionedConsumerImpl::PartitionedConsumerImpl(ClientImplPtr client, const std::string& subscriptionName,
+                                                 const DestinationNamePtr destinationName,
+                                                 const unsigned int numPartitions,
+                                                 const ConsumerConfiguration& conf)
     : client_(client),
-    subscriptionName_(subscriptionName),
-    destinationName_(destinationName),
-    numPartitions_(numPartitions),
-    numConsumersCreated_(0),
-    conf_(conf),
-    state_(Pending),
-    unsubscribedSoFar_(0),
-    messages_(1000),
-    listenerExecutor_(client->getListenerExecutorProvider()->get()),
-    messageListener_(conf.getMessageListener()),
-    topic_(destinationName->toString())
-    {
-        std::stringstream consumerStrStream;
-        consumerStrStream << "[Partitioned Consumer: " << topic_ << "," << subscriptionName << "," << numPartitions << "]";
-        if(conf.getUnAckedMessagesTimeoutMs() != 0) {
-            unAckedMessageTrackerPtr_.reset(new UnAckedMessageTrackerEnabled(conf.getUnAckedMessagesTimeoutMs(), client, *this));
-        } else {
-            unAckedMessageTrackerPtr_.reset(new UnAckedMessageTrackerDisabled());
-        }
+      subscriptionName_(subscriptionName),
+      destinationName_(destinationName),
+      numPartitions_(numPartitions),
+      numConsumersCreated_(0),
+      conf_(conf),
+      state_(Pending),
+      unsubscribedSoFar_(0),
+      messages_(1000),
+      listenerExecutor_(client->getListenerExecutorProvider()->get()),
+      messageListener_(conf.getMessageListener()),
+      topic_(destinationName->toString()) {
+    std::stringstream consumerStrStream;
+    consumerStrStream << "[Partitioned Consumer: " << topic_ << "," << subscriptionName << ","
+                      << numPartitions << "]";
+    if (conf.getUnAckedMessagesTimeoutMs() != 0) {
+        unAckedMessageTrackerPtr_.reset(
+            new UnAckedMessageTrackerEnabled(conf.getUnAckedMessagesTimeoutMs(), client, *this));
+    } else {
+        unAckedMessageTrackerPtr_.reset(new UnAckedMessageTrackerDisabled());
     }
+}
 
-    PartitionedConsumerImpl::~PartitionedConsumerImpl() {
-    }
+PartitionedConsumerImpl::~PartitionedConsumerImpl() {}
 
-    Future<Result, ConsumerImplBaseWeakPtr> PartitionedConsumerImpl::getConsumerCreatedFuture() {
-        return partitionedConsumerCreatedPromise_.getFuture();
-    }
-    const std::string& PartitionedConsumerImpl::getSubscriptionName() const {
-        return subscriptionName_;
-    }
+Future<Result, ConsumerImplBaseWeakPtr> PartitionedConsumerImpl::getConsumerCreatedFuture() {
+    return partitionedConsumerCreatedPromise_.getFuture();
+}
+const std::string& PartitionedConsumerImpl::getSubscriptionName() const { return subscriptionName_; }
 
-    const std::string& PartitionedConsumerImpl::getTopic() const {
-        return topic_;
+const std::string& PartitionedConsumerImpl::getTopic() const { return topic_; }
+
+Result PartitionedConsumerImpl::receive(Message& msg) {
+    Lock lock(mutex_);
+    if (state_ != Ready) {
+        lock.unlock();
+        return ResultAlreadyClosed;
     }
 
-    Result PartitionedConsumerImpl::receive(Message& msg) {
-        Lock lock(mutex_);
-        if (state_ != Ready) {
-            lock.unlock();
-            return ResultAlreadyClosed;
-        }
+    if (messageListener_) {
+        LOG_ERROR("Can not receive when a listener has been set");
+        return ResultInvalidConfiguration;
+    }
 
-        if (messageListener_) {
-            LOG_ERROR("Can not receive when a listener has been set");
-            return ResultInvalidConfiguration;
-        }
+    messages_.pop(msg);
+    unAckedMessageTrackerPtr_->add(msg.getMessageId());
+    return ResultOk;
+}
 
-        messages_.pop(msg);
-        unAckedMessageTrackerPtr_->add(msg.getMessageId());
-        return ResultOk;
+Result PartitionedConsumerImpl::receive(Message& msg, int timeout) {
+    Lock lock(mutex_);
+    if (state_ != Ready) {
+        lock.unlock();
+        return ResultAlreadyClosed;
     }
 
-    Result PartitionedConsumerImpl::receive(Message& msg, int timeout) {
-        Lock lock(mutex_);
-        if (state_ != Ready) {
-            lock.unlock();
-            return ResultAlreadyClosed;
-        }
-
-       if (messageListener_) {
-            LOG_ERROR("Can not receive when a listener has been set");
-            return ResultInvalidConfiguration;
-        }
+    if (messageListener_) {
+        LOG_ERROR("Can not receive when a listener has been set");
+        return ResultInvalidConfiguration;
+    }
 
-        if (messages_.pop(msg, milliseconds(timeout))) {
-            unAckedMessageTrackerPtr_->add(msg.getMessageId());
-            return ResultOk;
-        } else {
-            return ResultTimeout;
-        }
+    if (messages_.pop(msg, milliseconds(timeout))) {
+        unAckedMessageTrackerPtr_->add(msg.getMessageId());
+        return ResultOk;
+    } else {
+        return ResultTimeout;
     }
+}
 
-    void PartitionedConsumerImpl::unsubscribeAsync(ResultCallback callback) {
-        LOG_INFO("[" << destinationName_->toString() << "," << subscriptionName_ << "] Unsubscribing");
-        // change state to Closing, so that no Ready state operation is permitted during unsubscribe
-        setState(Closing);
-        // do not accept un subscribe until we have subscribe to all of the partitions of a topic
-        // it's a logical single topic so it should behave like a single topic, even if it's sharded
-        Lock lock(mutex_);
-        if (state_ != Ready) {
-            lock.unlock();
-            unsigned int index = 0;
-            for (ConsumerList::const_iterator consumer = consumers_.begin(); consumer != consumers_.end(); consumer++) {
-                LOG_DEBUG("Unsubcribing Consumer - " << index << " for Subscription - "
-                 << subscriptionName_ << " for Topic - " << destinationName_->toString());
-                (*consumer)->unsubscribeAsync(boost::bind(&PartitionedConsumerImpl::handleUnsubscribeAsync,
-                                                          shared_from_this(),
-                                                          _1, index++, callback));
-            }
+void PartitionedConsumerImpl::unsubscribeAsync(ResultCallback callback) {
+    LOG_INFO("[" << destinationName_->toString() << "," << subscriptionName_ << "] Unsubscribing");
+    // change state to Closing, so that no Ready state operation is permitted during unsubscribe
+    setState(Closing);
+    // do not accept un subscribe until we have subscribe to all of the partitions of a topic
+    // it's a logical single topic so it should behave like a single topic, even if it's sharded
+    Lock lock(mutex_);
+    if (state_ != Ready) {
+        lock.unlock();
+        unsigned int index = 0;
+        for (ConsumerList::const_iterator consumer = consumers_.begin(); consumer != consumers_.end();
+             consumer++) {
+            LOG_DEBUG("Unsubcribing Consumer - " << index << " for Subscription - " << subscriptionName_
+                                                 << " for Topic - " << destinationName_->toString());
+            (*consumer)->unsubscribeAsync(boost::bind(&PartitionedConsumerImpl::handleUnsubscribeAsync,
+                                                      shared_from_this(), _1, index++, callback));
         }
     }
+}
 
-    void PartitionedConsumerImpl::handleUnsubscribeAsync(Result result,
-                                                         unsigned int consumerIndex,
-                                                         ResultCallback callback) {
-
-        Lock lock(mutex_);
-        if (state_ == Failed) {
-            lock.unlock();
-            // we have already informed the client that unsubcribe has failed so, ignore this callbacks
-            // or do we still go ahead and check how many could we close successfully?
-            LOG_DEBUG("handleUnsubscribeAsync callback received in Failed State for consumerIndex - "
-                      << consumerIndex << "with Result - " << result << " for Subscription - "
-                      << subscriptionName_ << " for Topic - " << destinationName_->toString());
-            return;
-        }
+void PartitionedConsumerImpl::handleUnsubscribeAsync(Result result, unsigned int consumerIndex,
+                                                     ResultCallback callback) {
+    Lock lock(mutex_);
+    if (state_ == Failed) {
         lock.unlock();
-        if (result != ResultOk) {
-            setState(Failed);
-            LOG_ERROR("Error Closing one of the parition consumers, consumerIndex - " << consumerIndex);
-            callback(ResultUnknownError);
-            return;
-        }
-        assert (unsubscribedSoFar_ <= numPartitions_);
-        assert (consumerIndex <= numPartitions_);
-        // this means we have successfully closed this partition consumer and no unsubscribe has failed so far
-        LOG_INFO("Successfully Unsubscribed Consumer - " << consumerIndex << " for Subscription - "
-                 << subscriptionName_ << " for Topic - " << destinationName_->toString());
-        unsubscribedSoFar_++;
-        if (unsubscribedSoFar_ == numPartitions_) {
-            LOG_DEBUG("Unsubscribed all of the partition consumer for subscription - " << subscriptionName_);
-            setState(Closed);
-            callback(ResultOk);
-            return;
-        }
+        // we have already informed the client that unsubcribe has failed so, ignore this callbacks
+        // or do we still go ahead and check how many could we close successfully?
+        LOG_DEBUG("handleUnsubscribeAsync callback received in Failed State for consumerIndex - "
+                  << consumerIndex << "with Result - " << result << " for Subscription - "
+                  << subscriptionName_ << " for Topic - " << destinationName_->toString());
+        return;
+    }
+    lock.unlock();
+    if (result != ResultOk) {
+        setState(Failed);
+        LOG_ERROR("Error Closing one of the parition consumers, consumerIndex - " << consumerIndex);
+        callback(ResultUnknownError);
+        return;
+    }
+    assert(unsubscribedSoFar_ <= numPartitions_);
+    assert(consumerIndex <= numPartitions_);
+    // this means we have successfully closed this partition consumer and no unsubscribe has failed so far
+    LOG_INFO("Successfully Unsubscribed Consumer - " << consumerIndex << " for Subscription - "
+                                                     << subscriptionName_ << " for Topic - "
+                                                     << destinationName_->toString());
+    unsubscribedSoFar_++;
+    if (unsubscribedSoFar_ == numPartitions_) {
+        LOG_DEBUG("Unsubscribed all of the partition consumer for subscription - " << subscriptionName_);
+        setState(Closed);
+        callback(ResultOk);
+        return;
     }
+}
 
-    void PartitionedConsumerImpl::acknowledgeAsync(const MessageId& msgId, ResultCallback callback){
-        int partition = msgId.partition_;
-        assert (partition < numPartitions_ && partition >= 0 && consumers_.size() > partition);
-        unAckedMessageTrackerPtr_->remove(msgId);
-        consumers_[partition]->acknowledgeAsync(msgId, callback);
-    }
-
-    void PartitionedConsumerImpl::acknowledgeCumulativeAsync(const MessageId& msgId, ResultCallback callback){
-        callback(ResultOperationNotSupported);
-    }
-
-    void PartitionedConsumerImpl::start(){
-        ExecutorServicePtr internalListenerExecutor = client_->getPartitionListenerExecutorProvider()->get();
-        boost::shared_ptr<ConsumerImpl> consumer;
-        ConsumerConfiguration config;
-        // all the partitioned-consumer belonging to one partitioned topic should have same name
-        config.setConsumerName(conf_.getConsumerName());
-        config.setConsumerType(conf_.getConsumerType());
-        config.setBrokerConsumerStatsCacheTimeInMs(conf_.getBrokerConsumerStatsCacheTimeInMs());
-        config.setMessageListener(boost::bind(&PartitionedConsumerImpl::messageReceived, shared_from_this(), _1, _2));
-        // create consumer on each partition
-        for (unsigned int i = 0; i < numPartitions_; i++ ) {
-            std::string topicPartitionName = destinationName_->getTopicPartitionName(i);
-            consumer = boost::make_shared<ConsumerImpl>(client_, topicPartitionName,
-                                                        subscriptionName_, config,
-                                                        internalListenerExecutor, Partitioned);
-            consumer->getConsumerCreatedFuture().addListener(boost::bind(&PartitionedConsumerImpl::handleSinglePartitionConsumerCreated,
-                                                                         shared_from_this(), _1, _2, i));
-            consumer->setPartitionIndex(i);
-            consumers_.push_back(consumer);
-
-            LOG_DEBUG("Creating Consumer for single Partition - " << topicPartitionName << "SubName - " << subscriptionName_);
-        }
-        for (ConsumerList::const_iterator consumer = consumers_.begin(); consumer != consumers_.end(); consumer++) {
-            (*consumer)->start();
-        }
+void PartitionedConsumerImpl::acknowledgeAsync(const MessageId& msgId, ResultCallback callback) {
+    int partition = msgId.partition_;
+    assert(partition < numPartitions_ && partition >= 0 && consumers_.size() > partition);
+    unAckedMessageTrackerPtr_->remove(msgId);
+    consumers_[partition]->acknowledgeAsync(msgId, callback);
+}
+
+void PartitionedConsumerImpl::acknowledgeCumulativeAsync(const MessageId& msgId, ResultCallback callback) {
+    callback(ResultOperationNotSupported);
+}
 
+void PartitionedConsumerImpl::start() {
+    ExecutorServicePtr internalListenerExecutor = client_->getPartitionListenerExecutorProvider()->get();
+    boost::shared_ptr<ConsumerImpl> consumer;
+    ConsumerConfiguration config;
+    // all the partitioned-consumer belonging to one partitioned topic should have same name
+    config.setConsumerName(conf_.getConsumerName());
+    config.setConsumerType(conf_.getConsumerType());
+    config.setBrokerConsumerStatsCacheTimeInMs(conf_.getBrokerConsumerStatsCacheTimeInMs());
+    config.setMessageListener(
+        boost::bind(&PartitionedConsumerImpl::messageReceived, shared_from_this(), _1, _2));
+    // create consumer on each partition
+    for (unsigned int i = 0; i < numPartitions_; i++) {
+        std::string topicPartitionName = destinationName_->getTopicPartitionName(i);
+        consumer = boost::make_shared<ConsumerImpl>(client_, topicPartitionName, subscriptionName_, config,
+                                                    internalListenerExecutor, Partitioned);
+        consumer->getConsumerCreatedFuture().addListener(boost::bind(
+            &PartitionedConsumerImpl::handleSinglePartitionConsumerCreated, shared_from_this(), _1, _2, i));
+        consumer->setPartitionIndex(i);
+        consumers_.push_back(consumer);
+
+        LOG_DEBUG("Creating Consumer for single Partition - " << topicPartitionName << "SubName - "
+                                                              << subscriptionName_);
     }
+    for (ConsumerList::const_iterator consumer = consumers_.begin(); consumer != consumers_.end();
+         consumer++) {
+        (*consumer)->start();
+    }
+}
 
-    void PartitionedConsumerImpl::handleSinglePartitionConsumerCreated(Result result,
-                                                                       ConsumerImplBaseWeakPtr consumerImplBaseWeakPtr,
-                                                                       unsigned int partitionIndex) {
-        ResultCallback nullCallbackForCleanup = NULL;
-        Lock lock(mutex_);
-        if (state_ == Failed) {
-            // one of the consumer creation failed, and we are cleaning up
-            return;
-        }
-        assert (numConsumersCreated_ < numPartitions_);
-
-        if (result != ResultOk) {
-            state_ = Failed;
-            lock.unlock();
-            partitionedConsumerCreatedPromise_.setFailed(result);
-            // unsubscribed all of the successfully subscribed partitioned consumers
-            closeAsync(nullCallbackForCleanup);
-            LOG_DEBUG("Unable to create Consumer for partition - " << partitionIndex << " Error - " << result);
-            return;
-        }
+void PartitionedConsumerImpl::handleSinglePartitionConsumerCreated(
+    Result result, ConsumerImplBaseWeakPtr consumerImplBaseWeakPtr, unsigned int partitionIndex) {
+    ResultCallback nullCallbackForCleanup = NULL;
+    Lock lock(mutex_);
+    if (state_ == Failed) {
+        // one of the consumer creation failed, and we are cleaning up
+        return;
+    }
+    assert(numConsumersCreated_ < numPartitions_);
 
-        assert(partitionIndex < numPartitions_ && partitionIndex >= 0);
-        numConsumersCreated_++;
-        if(numConsumersCreated_ == numPartitions_) {
-            LOG_INFO("Successfully Subscribed to Partitioned Topic - "
-                     << destinationName_->toString() << " with - " << numPartitions_ << " Partitions.");
-            state_ = Ready;
-            lock.unlock();
-            receiveMessages();
-            partitionedConsumerCreatedPromise_.setValue(shared_from_this());
-            return;
-        }
+    if (result != ResultOk) {
+        state_ = Failed;
+        lock.unlock();
+        partitionedConsumerCreatedPromise_.setFailed(result);
+        // unsubscribed all of the successfully subscribed partitioned consumers
+        closeAsync(nullCallbackForCleanup);
+        LOG_DEBUG("Unable to create Consumer for partition - " << partitionIndex << " Error - " << result);
+        return;
+    }
 
+    assert(partitionIndex < numPartitions_ && partitionIndex >= 0);
+    numConsumersCreated_++;
+    if (numConsumersCreated_ == numPartitions_) {
+        LOG_INFO("Successfully Subscribed to Partitioned Topic - "
+                 << destinationName_->toString() << " with - " << numPartitions_ << " Partitions.");
+        state_ = Ready;
+        lock.unlock();
+        receiveMessages();
+        partitionedConsumerCreatedPromise_.setValue(shared_from_this());
+        return;
     }
+}
 
-    void PartitionedConsumerImpl::handleSinglePartitionConsumerClose (Result result, unsigned int partitionIndex, CloseCallback callback) {
-        Lock lock(mutex_);
-        if (state_ == Failed) {
-            // we should have already notified the client by callback
-            return;
-        }
-        if (result != ResultOk) {
-            state_ = Failed;
-            LOG_ERROR("Closing the consumer failed for partition - " << partitionIndex);
-            lock.unlock();
-            partitionedConsumerCreatedPromise_.setFailed(result);
-            if (!callback.empty()) {
-                callback(result);
-            }
-            return;
-        }
-        assert (partitionIndex < numPartitions_ && partitionIndex >= 0);
-        if(numConsumersCreated_ > 0) {
-            numConsumersCreated_--;
-        }
-        // closed all successfully
-        if(!numConsumersCreated_) {
-            state_ = Closed;
-            lock.unlock();
-            // set the producerCreatedPromise to failure
-            partitionedConsumerCreatedPromise_.setFailed(ResultUnknownError);
-            if (!callback.empty()) {
-                callback(result);
-            }
-            return;
+void PartitionedConsumerImpl::handleSinglePartitionConsumerClose(Result result, unsigned int partitionIndex,
+                                                                 CloseCallback callback) {
+    Lock lock(mutex_);
+    if (state_ == Failed) {
+        // we should have already notified the client by callback
+        return;
+    }
+    if (result != ResultOk) {
+        state_ = Failed;
+        LOG_ERROR("Closing the consumer failed for partition - " << partitionIndex);
+        lock.unlock();
+        partitionedConsumerCreatedPromise_.setFailed(result);
+        if (!callback.empty()) {
+            callback(result);
         }
+        return;
     }
-    void PartitionedConsumerImpl::closeAsync(ResultCallback callback) {
-        if (consumers_.empty()) {
-            notifyResult(callback);
-            return;
+    assert(partitionIndex < numPartitions_ && partitionIndex >= 0);
+    if (numConsumersCreated_ > 0) {
+        numConsumersCreated_--;
+    }
+    // closed all successfully
+    if (!numConsumersCreated_) {
+        state_ = Closed;
+        lock.unlock();
+        // set the producerCreatedPromise to failure
+        partitionedConsumerCreatedPromise_.setFailed(ResultUnknownError);
+        if (!callback.empty()) {
+            callback(result);
         }
-        setState(Closed);
-        int consumerIndex = 0;
-        unsigned int consumerAlreadyClosed = 0;
-        // close successfully subscribed consumers
-        for (ConsumerList::const_iterator i = consumers_.begin(); i != consumers_.end(); i++) {
-            ConsumerImplPtr consumer = *i;
-            if(!consumer->isClosed()) {
-                consumer->closeAsync(boost::bind(&PartitionedConsumerImpl::handleSinglePartitionConsumerClose,
+        return;
+    }
+}
+void PartitionedConsumerImpl::closeAsync(ResultCallback callback) {
+    if (consumers_.empty()) {
+        notifyResult(callback);
+        return;
+    }
+    setState(Closed);
+    int consumerIndex = 0;
+    unsigned int consumerAlreadyClosed = 0;
+    // close successfully subscribed consumers
+    for (ConsumerList::const_iterator i = consumers_.begin(); i != consumers_.end(); i++) {
+        ConsumerImplPtr consumer = *i;
+        if (!consumer->isClosed()) {
+            consumer->closeAsync(boost::bind(&PartitionedConsumerImpl::handleSinglePartitionConsumerClose,
                                              shared_from_this(), _1, consumerIndex, callback));
-            } else {
-                if(++consumerAlreadyClosed == consumers_.size()) {
-                    //everything is closed already. so we are good.
-                    notifyResult(callback);
-                    return;
-                }
+        } else {
+            if (++consumerAlreadyClosed == consumers_.size()) {
+                // everything is closed already. so we are good.
+                notifyResult(callback);
+                return;
             }
         }
     }
+}
 
-    void PartitionedConsumerImpl::notifyResult(CloseCallback closeCallback) {
-        if(closeCallback) {
-            // this means client invoked the closeAsync with a valid callback
-            setState(Closed);
-            closeCallback(ResultOk);
-        } else {
-            // consumer create failed, closeAsync called to cleanup the successfully created producers
-            setState(Failed);
-            partitionedConsumerCreatedPromise_.setFailed(ResultUnknownError);
-        }
+void PartitionedConsumerImpl::notifyResult(CloseCallback closeCallback) {
+    if (closeCallback) {
+        // this means client invoked the closeAsync with a valid callback
+        setState(Closed);
+        closeCallback(ResultOk);
+    } else {
+        // consumer create failed, closeAsync called to cleanup the successfully created producers
+        setState(Failed);
+        partitionedConsumerCreatedPromise_.setFailed(ResultUnknownError);
     }
+}
 
-    void PartitionedConsumerImpl::setState(const PartitionedConsumerState state) {
-        Lock lock(mutex_);
-        state_ = state;
-        lock.unlock();
-    }
+void PartitionedConsumerImpl::setState(const PartitionedConsumerState state) {
+    Lock lock(mutex_);
+    state_ = state;
+    lock.unlock();
+}
 
-    void PartitionedConsumerImpl::shutdown(){}
+void PartitionedConsumerImpl::shutdown() {}
 
-    bool PartitionedConsumerImpl::isClosed(){
-        return state_ == Closed;
-    }
+bool PartitionedConsumerImpl::isClosed() { return state_ == Closed; }
 
-    bool PartitionedConsumerImpl::isOpen() {
-        Lock lock(mutex_);
-        return state_ == Ready;
-    }
+bool PartitionedConsumerImpl::isOpen() {
+    Lock lock(mutex_);
+    return state_ == Ready;
+}
 
-    void PartitionedConsumerImpl::messageReceived(Consumer consumer, const Message& msg) {
-        LOG_DEBUG("Received Message from one of the partition - " << msg.impl_->messageId.partition_);
-        messages_.push(msg);
-        if (messageListener_) {
-            listenerExecutor_->postWork(boost::bind(&PartitionedConsumerImpl::internalListener, shared_from_this(), consumer));
-        }
+void PartitionedConsumerImpl::messageReceived(Consumer consumer, const Message& msg) {
+    LOG_DEBUG("Received Message from one of the partition - " << msg.impl_->messageId.partition_);
+    messages_.push(msg);
+    if (messageListener_) {
+        listenerExecutor_->postWork(
+            boost::bind(&PartitionedConsumerImpl::internalListener, shared_from_this(), consumer));
     }
+}
 
-    void PartitionedConsumerImpl::internalListener(Consumer consumer) {
-        Message m;
-        messages_.pop(m);
-        try {
-            messageListener_(Consumer(shared_from_this()), m);
-        } catch (const std::exception& e) {
-            LOG_ERROR("Exception thrown from listener of Partitioned Consumer" << e.what());
-        }
+void PartitionedConsumerImpl::internalListener(Consumer consumer) {
+    Message m;
+    messages_.pop(m);
+    try {
+        messageListener_(Consumer(shared_from_this()), m);
+    } catch (const std::exception& e) {
+        LOG_ERROR("Exception thrown from listener of Partitioned Consumer" << e.what());
     }
+}
 
-    void PartitionedConsumerImpl::receiveMessages() {
-        for (ConsumerList::const_iterator i = consumers_.begin(); i != consumers_.end(); i++) {
-            ConsumerImplPtr consumer = *i;
-            consumer->receiveMessages(consumer->getCnx().lock(), conf_.getReceiverQueueSize());
-            LOG_DEBUG("Sending FLOW command for consumer - " << consumer->getConsumerId());
-        }
+void PartitionedConsumerImpl::receiveMessages() {
+    for (ConsumerList::const_iterator i = consumers_.begin(); i != consumers_.end(); i++) {
+        ConsumerImplPtr consumer = *i;
+        consumer->receiveMessages(consumer->getCnx().lock(), conf_.getReceiverQueueSize());
+        LOG_DEBUG("Sending FLOW command for consumer - " << consumer->getConsumerId());
     }
+}
 
-
-    Result PartitionedConsumerImpl::pauseMessageListener() {
-        if (!messageListener_) {
-            return ResultInvalidConfiguration;
-        }
-        for (ConsumerList::const_iterator i = consumers_.begin(); i != consumers_.end(); i++) {
-            (*i)->pauseMessageListener();
-        }
-        return ResultOk;
+Result PartitionedConsumerImpl::pauseMessageListener() {
+    if (!messageListener_) {
+        return ResultInvalidConfiguration;
     }
-
-    Result PartitionedConsumerImpl::resumeMessageListener() {
-        if (!messageListener_) {
-            return ResultInvalidConfiguration;
-        }
-        for (ConsumerList::const_iterator i = consumers_.begin(); i != consumers_.end(); i++) {
-            (*i)->resumeMessageListener();
-        }
-        return ResultOk;
+    for (ConsumerList::const_iterator i = consumers_.begin(); i != consumers_.end(); i++) {
+        (*i)->pauseMessageListener();
     }
+    return ResultOk;
+}
 
-    void PartitionedConsumerImpl::redeliverUnacknowledgedMessages() {
-        LOG_DEBUG("Sending RedeliverUnacknowledgedMessages command for partitioned consumer.");
-        for (ConsumerList::const_iterator i = consumers_.begin(); i != consumers_.end(); i++) {
-            (*i)->redeliverUnacknowledgedMessages();
-        }
+Result PartitionedConsumerImpl::resumeMessageListener() {
+    if (!messageListener_) {
+        return ResultInvalidConfiguration;
     }
-
-    const std::string& PartitionedConsumerImpl::getName() const {
-        return partitionStr_;
+    for (ConsumerList::const_iterator i = consumers_.begin(); i != consumers_.end(); i++) {
+        (*i)->resumeMessageListener();
     }
+    return ResultOk;
+}
 
-    int PartitionedConsumerImpl::getNumOfPrefetchedMessages() const {
-        return messages_.size();
+void PartitionedConsumerImpl::redeliverUnacknowledgedMessages() {
+    LOG_DEBUG("Sending RedeliverUnacknowledgedMessages command for partitioned consumer.");
+    for (ConsumerList::const_iterator i = consumers_.begin(); i != consumers_.end(); i++) {
+        (*i)->redeliverUnacknowledgedMessages();
     }
+}
 
-    void PartitionedConsumerImpl::getBrokerConsumerStatsAsync(BrokerConsumerStatsCallback callback) {
-        Lock lock(mutex_);
-        if (state_ != Ready) {
-            lock.unlock();
-            callback(ResultConsumerNotInitialized, BrokerConsumerStats());
-            return;
-        }
-        PartitionedBrokerConsumerStatsPtr statsPtr = boost::make_shared<PartitionedBrokerConsumerStatsImpl>(numPartitions_);
-        LatchPtr latchPtr = boost::make_shared<Latch>(numPartitions_);
-        ConsumerList consumerList = consumers_;
+const std::string& PartitionedConsumerImpl::getName() const { return partitionStr_; }
+
+int PartitionedConsumerImpl::getNumOfPrefetchedMessages() const { return messages_.size(); }
+
+void PartitionedConsumerImpl::getBrokerConsumerStatsAsync(BrokerConsumerStatsCallback callback) {
+    Lock lock(mutex_);
+    if (state_ != Ready) {
         lock.unlock();
-        for (int i = 0; i<consumerList.size(); i++) {
-            consumerList[i]->getBrokerConsumerStatsAsync(boost::bind(&PartitionedConsumerImpl::handleGetConsumerStats,
-                                                               shared_from_this(), _1, _2, latchPtr,
-                                                               statsPtr, i, callback));
-        }
+        callback(ResultConsumerNotInitialized, BrokerConsumerStats());
+        return;
+    }
+    PartitionedBrokerConsumerStatsPtr statsPtr =
+        boost::make_shared<PartitionedBrokerConsumerStatsImpl>(numPartitions_);
+    LatchPtr latchPtr = boost::make_shared<Latch>(numPartitions_);
+    ConsumerList consumerList = consumers_;
+    lock.unlock();
+    for (int i = 0; i < consumerList.size(); i++) {
+        consumerList[i]->getBrokerConsumerStatsAsync(
+            boost::bind(&PartitionedConsumerImpl::handleGetConsumerStats, shared_from_this(), _1, _2,
+                        latchPtr, statsPtr, i, callback));
     }
+}
 
-    void PartitionedConsumerImpl::handleGetConsumerStats(Result res, BrokerConsumerStats brokerConsumerStats,
-                                                         LatchPtr latchPtr, PartitionedBrokerConsumerStatsPtr statsPtr,
-                                                         size_t index, BrokerConsumerStatsCallback callback) {
-        Lock lock(mutex_);
-        if (res == ResultOk) {
-            latchPtr->countdown();
-            statsPtr->add(brokerConsumerStats, index);
-        } else {
-            lock.unlock();
-            callback(res, BrokerConsumerStats());
-            return;
-        }
-        if (latchPtr->getCount() == 0) {
-            lock.unlock();
-            callback(ResultOk, BrokerConsumerStats(statsPtr));
-        }
+void PartitionedConsumerImpl::handleGetConsumerStats(Result res, BrokerConsumerStats brokerConsumerStats,
+                                                     LatchPtr latchPtr,
+                                                     PartitionedBrokerConsumerStatsPtr statsPtr, size_t index,
+                                                     BrokerConsumerStatsCallback callback) {
+    Lock lock(mutex_);
+    if (res == ResultOk) {
+        latchPtr->countdown();
+        statsPtr->add(brokerConsumerStats, index);
+    } else {
+        lock.unlock();
+        callback(res, BrokerConsumerStats());
+        return;
+    }
+    if (latchPtr->getCount() == 0) {
+        lock.unlock();
+        callback(ResultOk, BrokerConsumerStats(statsPtr));
     }
 }
+}  // namespace pulsar
diff --git a/pulsar-client-cpp/lib/PartitionedConsumerImpl.h b/pulsar-client-cpp/lib/PartitionedConsumerImpl.h
index 9270039..3d1bca1 100644
--- a/pulsar-client-cpp/lib/PartitionedConsumerImpl.h
+++ b/pulsar-client-cpp/lib/PartitionedConsumerImpl.h
@@ -31,79 +31,77 @@
 #include <lib/PartitionedBrokerConsumerStatsImpl.h>
 
 namespace pulsar {
-    class PartitionedConsumerImpl;
-    class PartitionedConsumerImpl: public ConsumerImplBase, public boost::enable_shared_from_this<PartitionedConsumerImpl> {
-    public:
-        enum PartitionedConsumerState {
-            Pending,
-            Ready,
-            Closing,
-            Closed,
-            Failed
-        };
-        PartitionedConsumerImpl(ClientImplPtr client,
-                                const std::string& subscriptionName,
-                                const DestinationNamePtr destinationName,
-                                const unsigned int numPartitions,
-                                const ConsumerConfiguration& conf);
-        virtual ~PartitionedConsumerImpl ();
-        virtual Future<Result, ConsumerImplBaseWeakPtr> getConsumerCreatedFuture();
-        virtual const std::string& getSubscriptionName() const;
-        virtual const std::string& getTopic() const;
-        virtual Result receive(Message& msg);
-        virtual Result receive(Message& msg, int timeout);
-        virtual void unsubscribeAsync(ResultCallback callback);
-        virtual void acknowledgeAsync(const MessageId& msgId, ResultCallback callback);
-        virtual void acknowledgeCumulativeAsync(const MessageId& msgId, ResultCallback callback);
-        virtual void closeAsync(ResultCallback callback);
-        virtual void start();
-        virtual void shutdown();
-        virtual bool isClosed();
-        virtual bool isOpen();
-        virtual Result pauseMessageListener();
-        virtual Result resumeMessageListener();
-        virtual void redeliverUnacknowledgedMessages();
-        virtual const std::string& getName() const;
-        virtual int getNumOfPrefetchedMessages() const ;
-        virtual void getBrokerConsumerStatsAsync(BrokerConsumerStatsCallback callback);
-        void handleGetConsumerStats(Result , BrokerConsumerStats, LatchPtr,
-                                    PartitionedBrokerConsumerStatsPtr, size_t, BrokerConsumerStatsCallback);
-
-    private:
-        const ClientImplPtr client_;
-        const std::string subscriptionName_;
-        const DestinationNamePtr destinationName_;
-        unsigned int numPartitions_;
-        unsigned int numConsumersCreated_;
-        const ConsumerConfiguration conf_;
-        typedef std::vector<ConsumerImplPtr> ConsumerList;
-        ConsumerList consumers_;
-        boost::mutex mutex_;
-        PartitionedConsumerState state_;
-        unsigned int unsubscribedSoFar_;
-        BlockingQueue<Message> messages_;
-        ExecutorServicePtr listenerExecutor_;
-        MessageListener messageListener_;
-        const std::string topic_;
-        const std::string name_;
-        const std::string partitionStr_;
-        /* methods */
-        void setState(PartitionedConsumerState state);
-        void handleUnsubscribeAsync(Result result,
-                                    unsigned int consumerIndex,
-                                    ResultCallback callback);
-        void handleSinglePartitionConsumerCreated(Result result,
-                                                  ConsumerImplBaseWeakPtr consumerImplBaseWeakPtr,
-                                                  unsigned int partitionIndex);
-        void handleSinglePartitionConsumerClose(Result result, unsigned int partitionIndex, CloseCallback callback);
-        void notifyResult(CloseCallback closeCallback);
-        void messageReceived(Consumer consumer, const Message& msg);
-        void internalListener(Consumer consumer);
-        void receiveMessages();
-        Promise<Result, ConsumerImplBaseWeakPtr> partitionedConsumerCreatedPromise_;
-        UnAckedMessageTrackerScopedPtr unAckedMessageTrackerPtr_;
+class PartitionedConsumerImpl;
+class PartitionedConsumerImpl : public ConsumerImplBase,
+                                public boost::enable_shared_from_this<PartitionedConsumerImpl> {
+   public:
+    enum PartitionedConsumerState
+    {
+        Pending,
+        Ready,
+        Closing,
+        Closed,
+        Failed
     };
-    typedef boost::weak_ptr<PartitionedConsumerImpl> PartitionedConsumerImplWeakPtr;
-    typedef boost::shared_ptr<PartitionedConsumerImpl> PartitionedConsumerImplPtr;
-}
-#endif //PULSAR_PARTITIONED_CONSUMER_HEADER
+    PartitionedConsumerImpl(ClientImplPtr client, const std::string& subscriptionName,
+                            const DestinationNamePtr destinationName, const unsigned int numPartitions,
+                            const ConsumerConfiguration& conf);
+    virtual ~PartitionedConsumerImpl();
+    virtual Future<Result, ConsumerImplBaseWeakPtr> getConsumerCreatedFuture();
+    virtual const std::string& getSubscriptionName() const;
+    virtual const std::string& getTopic() const;
+    virtual Result receive(Message& msg);
+    virtual Result receive(Message& msg, int timeout);
+    virtual void unsubscribeAsync(ResultCallback callback);
+    virtual void acknowledgeAsync(const MessageId& msgId, ResultCallback callback);
+    virtual void acknowledgeCumulativeAsync(const MessageId& msgId, ResultCallback callback);
+    virtual void closeAsync(ResultCallback callback);
+    virtual void start();
+    virtual void shutdown();
+    virtual bool isClosed();
+    virtual bool isOpen();
+    virtual Result pauseMessageListener();
+    virtual Result resumeMessageListener();
+    virtual void redeliverUnacknowledgedMessages();
+    virtual const std::string& getName() const;
+    virtual int getNumOfPrefetchedMessages() const;
+    virtual void getBrokerConsumerStatsAsync(BrokerConsumerStatsCallback callback);
+    void handleGetConsumerStats(Result, BrokerConsumerStats, LatchPtr, PartitionedBrokerConsumerStatsPtr,
+                                size_t, BrokerConsumerStatsCallback);
+
+   private:
+    const ClientImplPtr client_;
+    const std::string subscriptionName_;
+    const DestinationNamePtr destinationName_;
+    unsigned int numPartitions_;
+    unsigned int numConsumersCreated_;
+    const ConsumerConfiguration conf_;
+    typedef std::vector<ConsumerImplPtr> ConsumerList;
+    ConsumerList consumers_;
+    boost::mutex mutex_;
+    PartitionedConsumerState state_;
+    unsigned int unsubscribedSoFar_;
+    BlockingQueue<Message> messages_;
+    ExecutorServicePtr listenerExecutor_;
+    MessageListener messageListener_;
+    const std::string topic_;
+    const std::string name_;
+    const std::string partitionStr_;
+    /* methods */
+    void setState(PartitionedConsumerState state);
+    void handleUnsubscribeAsync(Result result, unsigned int consumerIndex, ResultCallback callback);
+    void handleSinglePartitionConsumerCreated(Result result, ConsumerImplBaseWeakPtr consumerImplBaseWeakPtr,
+                                              unsigned int partitionIndex);
+    void handleSinglePartitionConsumerClose(Result result, unsigned int partitionIndex,
+                                            CloseCallback callback);
+    void notifyResult(CloseCallback closeCallback);
+    void messageReceived(Consumer consumer, const Message& msg);
+    void internalListener(Consumer consumer);
+    void receiveMessages();
+    Promise<Result, ConsumerImplBaseWeakPtr> partitionedConsumerCreatedPromise_;
+    UnAckedMessageTrackerScopedPtr unAckedMessageTrackerPtr_;
+};
+typedef boost::weak_ptr<PartitionedConsumerImpl> PartitionedConsumerImplWeakPtr;
+typedef boost::shared_ptr<PartitionedConsumerImpl> PartitionedConsumerImplPtr;
+}  // namespace pulsar
+#endif  // PULSAR_PARTITIONED_CONSUMER_HEADER
diff --git a/pulsar-client-cpp/lib/PartitionedProducerImpl.cc b/pulsar-client-cpp/lib/PartitionedProducerImpl.cc
index ec919fb..6a15056 100644
--- a/pulsar-client-cpp/lib/PartitionedProducerImpl.cc
+++ b/pulsar-client-cpp/lib/PartitionedProducerImpl.cc
@@ -31,208 +31,205 @@ DECLARE_LOG_OBJECT()
 
 namespace pulsar {
 
-    const std::string PartitionedProducerImpl::PARTITION_NAME_SUFFIX = "-partition-";
-
-    PartitionedProducerImpl::PartitionedProducerImpl(ClientImplPtr client,
-                                                     const DestinationNamePtr destinationName,
-                                                     const unsigned int numPartitions,
-                                                     const ProducerConfiguration& config):client_(client),
-                                                                                          destinationName_(destinationName),
-                                                                                          topic_(destinationName_->toString()),
-                                                                                          conf_(config),
-                                                                                          state_(Pending),
-                                                                                          topicMetadata_(new TopicMetadataImpl(numPartitions))
-    {
-        numProducersCreated_ = 0;
-        cleanup_ = false;
-        routerPolicy_ = getMessageRouter();
-    }
+const std::string PartitionedProducerImpl::PARTITION_NAME_SUFFIX = "-partition-";
+
+PartitionedProducerImpl::PartitionedProducerImpl(ClientImplPtr client,
+                                                 const DestinationNamePtr destinationName,
+                                                 const unsigned int numPartitions,
+                                                 const ProducerConfiguration& config)
+    : client_(client),
+      destinationName_(destinationName),
+      topic_(destinationName_->toString()),
+      conf_(config),
+      state_(Pending),
+      topicMetadata_(new TopicMetadataImpl(numPartitions)) {
+    numProducersCreated_ = 0;
+    cleanup_ = false;
+    routerPolicy_ = getMessageRouter();
+}
 
-    MessageRoutingPolicyPtr PartitionedProducerImpl::getMessageRouter() {
-        switch (conf_.getPartitionsRoutingMode()) {
-            case ProducerConfiguration::RoundRobinDistribution:
-                return boost::make_shared<RoundRobinMessageRouter>();
-            case ProducerConfiguration::CustomPartition:
-                return conf_.getMessageRouterPtr();
-            case ProducerConfiguration::UseSinglePartition:
-            default:
-                unsigned int random = rand();
-                return boost::make_shared<SinglePartitionMessageRouter>(random % topicMetadata_->getNumPartitions());
-        }
+MessageRoutingPolicyPtr PartitionedProducerImpl::getMessageRouter() {
+    switch (conf_.getPartitionsRoutingMode()) {
+        case ProducerConfiguration::RoundRobinDistribution:
+            return boost::make_shared<RoundRobinMessageRouter>();
+        case ProducerConfiguration::CustomPartition:
+            return conf_.getMessageRouterPtr();
+        case ProducerConfiguration::UseSinglePartition:
+        default:
+            unsigned int random = rand();
+            return boost::make_shared<SinglePartitionMessageRouter>(random %
+                                                                    topicMetadata_->getNumPartitions());
     }
+}
 
-    PartitionedProducerImpl::~PartitionedProducerImpl() {
-    }
-    //override
-    const std::string& PartitionedProducerImpl::getTopic() const {
-        return topic_;
+PartitionedProducerImpl::~PartitionedProducerImpl() {}
+// override
+const std::string& PartitionedProducerImpl::getTopic() const { return topic_; }
+
+// override
+void PartitionedProducerImpl::start() {
+    boost::shared_ptr<ProducerImpl> producer;
+    // create producer per partition
+    for (unsigned int i = 0; i < topicMetadata_->getNumPartitions(); i++) {
+        std::string topicPartitionName = destinationName_->getTopicPartitionName(i);
+        producer = boost::make_shared<ProducerImpl>(client_, topicPartitionName, conf_);
+        producer->getProducerCreatedFuture().addListener(boost::bind(
+            &PartitionedProducerImpl::handleSinglePartitionProducerCreated, shared_from_this(), _1, _2, i));
+        producers_.push_back(producer);
+        LOG_DEBUG("Creating Producer for single Partition - " << topicPartitionName);
     }
 
-    //override
-    void PartitionedProducerImpl::start() {
-        boost::shared_ptr<ProducerImpl> producer;
-        // create producer per partition
-        for (unsigned int i = 0; i < topicMetadata_->getNumPartitions(); i++) {
-            std::string topicPartitionName = destinationName_->getTopicPartitionName(i);
-            producer = boost::make_shared<ProducerImpl>(client_, topicPartitionName, conf_);
-            producer->getProducerCreatedFuture().addListener(boost::bind(&PartitionedProducerImpl::handleSinglePartitionProducerCreated,
-                                                                         shared_from_this(), _1, _2, i));
-            producers_.push_back(producer);
-            LOG_DEBUG("Creating Producer for single Partition - " << topicPartitionName);
-        }
-
-        for (ProducerList::const_iterator prod = producers_.begin(); prod != producers_.end(); prod++) {
-            (*prod)->start();
-        }
+    for (ProducerList::const_iterator prod = producers_.begin(); prod != producers_.end(); prod++) {
+        (*prod)->start();
     }
+}
 
-
-    void PartitionedProducerImpl::handleSinglePartitionProducerCreated(Result result,
-                                                                       ProducerImplBaseWeakPtr producerWeakPtr,
-                                                                       unsigned int partitionIndex) {
-        // to indicate, we are doing cleanup using closeAsync after producer create
-        // has failed and the invocation of closeAsync is not from client
-        CloseCallback closeCallback = NULL;
-        Lock lock(mutex_);
-        if (state_ == Failed) {
-            // Ignore, we have already informed client that producer creation failed
-            return;
-        }
-        assert(numProducersCreated_ <= topicMetadata_->getNumPartitions());
-        if (result != ResultOk) {
-            state_ = Failed;
-            lock.unlock();
-            closeAsync(closeCallback);
-            partitionedProducerCreatedPromise_.setFailed(result);
-            LOG_DEBUG("Unable to create Producer for partition - " << partitionIndex << " Error - " << result);
-            return;
-        }
-
-        assert(partitionIndex <= topicMetadata_->getNumPartitions());
-        numProducersCreated_++;
-        if(numProducersCreated_ == topicMetadata_->getNumPartitions()) {
-            lock.unlock();
-            partitionedProducerCreatedPromise_.setValue(shared_from_this());
-        }
+void PartitionedProducerImpl::handleSinglePartitionProducerCreated(Result result,
+                                                                   ProducerImplBaseWeakPtr producerWeakPtr,
+                                                                   unsigned int partitionIndex) {
+    // to indicate, we are doing cleanup using closeAsync after producer create
+    // has failed and the invocation of closeAsync is not from client
+    CloseCallback closeCallback = NULL;
+    Lock lock(mutex_);
+    if (state_ == Failed) {
+        // Ignore, we have already informed client that producer creation failed
+        return;
     }
-
-    //override
-    void PartitionedProducerImpl::sendAsync(const Message& msg, SendCallback callback) {
-        //get partition for this message from router policy
-        short partition = (short)(routerPolicy_->getPartition(msg, *topicMetadata_));
-        if (partition >= topicMetadata_->getNumPartitions() || partition >= producers_.size()) {
-            LOG_ERROR("Got Invalid Partition for message from Router Policy, Partition - " << partition);
-            //change me: abort or notify failure in callback?
-            //          change to appropriate error if callback
-            callback(ResultUnknownError, msg);
-            return;
-        }
-        //find a producer for that partition, index should start from 0
-        ProducerImplPtr& producer = producers_[partition];
-        msg.impl_->messageId.partition_ = partition;
-        //send message on that partition
-        producer->sendAsync(msg, callback);
+    assert(numProducersCreated_ <= topicMetadata_->getNumPartitions());
+    if (result != ResultOk) {
+        state_ = Failed;
+        lock.unlock();
+        closeAsync(closeCallback);
+        partitionedProducerCreatedPromise_.setFailed(result);
+        LOG_DEBUG("Unable to create Producer for partition - " << partitionIndex << " Error - " << result);
+        return;
     }
 
-    //override
-    void PartitionedProducerImpl::shutdown() {
-        setState(Closed);
+    assert(partitionIndex <= topicMetadata_->getNumPartitions());
+    numProducersCreated_++;
+    if (numProducersCreated_ == topicMetadata_->getNumPartitions()) {
+        lock.unlock();
+        partitionedProducerCreatedPromise_.setValue(shared_from_this());
     }
+}
 
-    void PartitionedProducerImpl::setState(const PartitionedProducerState state) {
-        Lock lock(mutex_);
-        state_ = state;
-        lock.unlock();
+// override
+void PartitionedProducerImpl::sendAsync(const Message& msg, SendCallback callback) {
+    // get partition for this message from router policy
+    short partition = (short)(routerPolicy_->getPartition(msg, *topicMetadata_));
+    if (partition >= topicMetadata_->getNumPartitions() || partition >= producers_.size()) {
+        LOG_ERROR("Got Invalid Partition for message from Router Policy, Partition - " << partition);
+        // change me: abort or notify failure in callback?
+        //          change to appropriate error if callback
+        callback(ResultUnknownError, msg);
+        return;
     }
+    // find a producer for that partition, index should start from 0
+    ProducerImplPtr& producer = producers_[partition];
+    msg.impl_->messageId.partition_ = partition;
+    // send message on that partition
+    producer->sendAsync(msg, callback);
+}
+
+// override
+void PartitionedProducerImpl::shutdown() { setState(Closed); }
+
+void PartitionedProducerImpl::setState(const PartitionedProducerState state) {
+    Lock lock(mutex_);
+    state_ = state;
+    lock.unlock();
+}
+
+const std::string& PartitionedProducerImpl::getProducerName() const {
+    return producers_[0]->getProducerName();
+}
 
-    const std::string& PartitionedProducerImpl::getProducerName() const {
-        return producers_[0]->getProducerName();
+int64_t PartitionedProducerImpl::getLastSequenceId() const {
+    int64_t currentMax = -1L;
+    for (int i = 0; i < producers_.size(); i++) {
+        currentMax = std::max(currentMax, producers_[i]->getLastSequenceId());
     }
 
-    int64_t PartitionedProducerImpl::getLastSequenceId() const {
-        int64_t currentMax = -1L;
-        for (int i = 0; i < producers_.size(); i++) {
... 6781 lines suppressed ...

-- 
To stop receiving notification emails like this one, please contact
mmerli@apache.org.