You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by vo...@apache.org on 2017/09/04 06:44:35 UTC

[01/17] incubator-rocketmq-externals git commit: Polish cpp module

Repository: incubator-rocketmq-externals
Updated Branches:
  refs/heads/master 70ce5c770 -> b9bb6cfa7


http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/transport/TcpTransport.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/transport/TcpTransport.h b/rocketmq-client4cpp/src/transport/TcpTransport.h
deleted file mode 100755
index 69f1e53..0000000
--- a/rocketmq-client4cpp/src/transport/TcpTransport.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#ifndef __TCPTRANSPORT_H__
-#define __TCPTRANSPORT_H__
-
-#include <map>
-#include <string>
-#include <list>
-#include "Mutex.h"
-#include "SocketUtil.h"
-
-namespace rmq
-{
-    const int CLIENT_STATE_UNINIT = 0;
-    const int CLIENT_STATE_INITED = 1;
-    const int CLIENT_STATE_DISCONNECT = 2;
-    const int CLIENT_STATE_CONNECTED = 3;
-
-    const int CLIENT_ERROR_SUCCESS = 0;
-    const int CLIENT_ERROR_INIT = 1;
-    const int CLIENT_ERROR_INVALID_URL = 2;
-    const int CLIENT_ERROR_CONNECT = 3;
-    const int CLIENT_ERROR_OOM = 4;
-
-    class TcpTransport
-    {
-    public:
-        TcpTransport(std::map<std::string, std::string>& config);
-        ~TcpTransport();
-
-        int connect(const std::string& serverAddr, int timeoutMillis);
-        bool isConnected();
-        void close();
-
-        int sendData(const char* pBuffer, int len, int nTimeOut = -1);
-		int recvData(std::list<std::string*>& dataList);
-
-        SOCKET getSocket();
-        std::string& getServerAddr();
-		unsigned long long getLastSendRecvTime();
-
-    private:
-        int sendOneMsg(const char* pBuffer, int len, int nTimeout);
-        int recvMsg();
-		void processData(std::list<std::string*>& dataList);
-        bool resizeBuf(int nNewSize);
-        void tryShrink(int nMsgLen);
-        static int getMsgSize(const char* pBuf);
-
-    private:
-        int m_sfd;
-        int m_state;
-    	char* m_pRecvBuf;
-        int m_recvBufSize;
-        int m_recvBufUsed;
-        int m_shrinkMax;
-        int m_shrinkCheckCnt;
-        kpr::Mutex m_sendLock;
-        kpr::Mutex m_recvLock;
-        std::string m_serverAddr;
-		long long m_lastSendRecvTime;
-    };
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-cpp/README.md
----------------------------------------------------------------------
diff --git a/rocketmq-cpp/README.md b/rocketmq-cpp/README.md
index 45abce6..3bd34ff 100644
--- a/rocketmq-cpp/README.md
+++ b/rocketmq-cpp/README.md
@@ -1,55 +1,47 @@
-================build and install========================
-- linux platform:
-
-  -1. install dependency
-	- 1>. install libevent 2.0.22 dependency
-	  - <1>. dowload libevent 2.0.22
-	    - https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz
-	  - <2>. build and install libevent
+## How to build
+### Windows platform will be supported later
+### Linux platform
+#### 1. Dependency Installation
+* Install libevent 2.0.22 dependency
+	  - Download [libevent 2.0.22](https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz)
+	  - Build and install libevent
 	    - ./configure
 	    - make
 	    - make install 
-	- 2>. install JsonCPP 0.7.0 dependency
-  	  - <1> download jsoncpp 0.7.0
-	    - https://github.com/open-source-parsers/jsoncpp/archive/0.10.6.zip
-	  - <2> build and install jsoncpp
+* Install JsonCPP 0.7.0 dependency
+  	  - Download [jsoncpp 0.7.0](https://github.com/open-source-parsers/jsoncpp/archive/0.10.6.zip)
+	  - Build and install jsoncpp
 	    - cmake .
 	    - make
-	    - make install
-	- 3>. install boost 1.56.0 dependency
-	  - <1>. dowload boost 1.56.0
-	    - http://www.boost.org/users/history/version_1_56_0.html
-	  - <2>. build and install boost 1.56.0
-	    - <1>. cd path/to/boost_1_56_0
-	    - <2>. config boost:./bootstrap.sh
-	    - <3>. build boost:     
+	    - make install
+* Install boost 1.56.0 dependency
+	 -  Download [boost 1.56.0](http://www.boost.org/users/history/version_1_56_0.html)
+	 - Build and install boost
+	    - cd path/to/boost_1_56_0
+	    - config boost:./bootstrap.sh
+	    - build boost:     
 	      - build static boost lib: ./b2 link=static runtime-link=static
 	      - build dynamic boost lib: ./b2 link=shared runtime-link=shared
-	  - <3>. install boost: ./b2 install
-    
-  -2. make&install
-  	- default install path:
-		- header files: /usr/local/include
-		- lib: /usr/local/lib
-    - 1>.make&install by cmake	
-        - <1>. cmake will auto find_package, if failes, change BOOST_INCLUDEDIR/LIBEVENT_INCLUDE_DIR/JSONCPP_INCLUDE_DIR in CMakeList.txt, according to its real install path
-        - <2>. make
-        - <3>. make install
+	    -  install boost: ./b2 install
+	   
+#### 2. Make and Install
+* Default install path:
+	   - header files: /usr/local/include
+	   - lib: /usr/local/lib
+* Make and install using cmake
+	   - cmake will auto find_package, if failes, change BOOST_INCLUDEDIR/LIBEVENT_INCLUDE_DIR/JSONCPP_INCLUDE_DIR in CMakeList.txt, according to its real install path
+	   - make
+	   - make install
 	
-- Windows platform:
-  - will be supported later
-
-
-
-- check verion:
-  - strings librocketmq.so |grep VERSION
+### Check verion
+- strings librocketmq.so |grep VERSION
 
 - log path:$HOME/logs/metaq-client4cpp
 
 - Before Run:
   - export LD_LIBRARY_PATH=/xxx/rocketmq-client4cpp/bin/:$LD_LIBRARY_PATH;LD_LIBRARY_PATH=/A/lib:$LD_LIBRARY_PATH
 
-=================meaning of each parameter===================
+## Description for Important Parameters  
 - -n	: nameserver addr, if not set -n and -i ,no nameSrv will be got
 - -i	: nameserver domain name,  if not set -n and -i ,no nameSrv will be got
 - Notice: oper should only set one option from -n and -i, 
@@ -75,7 +67,7 @@
   - orderly async pushConsumer: ./OrderlyPushConsumer -g producerGroup -t topic -c msgContent -m msgCount -n nameServerAddr
   - sync pullConsumer:./PullConsumer  -g producerGroup -t topic -c msgContent -m msgCount -n nameServerAddr 
 
-==================================Notice=============================================
+## Best practice
 - producer must invoke following interface:
   - DefaultMQProducer g_producer("please_rename_unique_group_name");
   - g_producer.start();
@@ -94,5 +86,9 @@
   - g_consumer.subscribe("test_topic", "*");
   - g_consumer.registerMessageListener(listener);
   - g_consumer.start();
-  - g_consumer.shutdown();
+  - g_consumer.shutdown();
+
+  ## Acknowledgment - Alibaba
 
+
+

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-donet/.gitignore
----------------------------------------------------------------------
diff --git a/rocketmq-donet/.gitignore b/rocketmq-donet/.gitignore
deleted file mode 100644
index d4baaf0..0000000
--- a/rocketmq-donet/.gitignore
+++ /dev/null
@@ -1,9 +0,0 @@
-bin
-coverage.out
-.idea/
-*.iml
-*.swp
-*.log
-tags
-temp_parser_file
-y.output
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-donet/LICENSE
----------------------------------------------------------------------
diff --git a/rocketmq-donet/LICENSE b/rocketmq-donet/LICENSE
deleted file mode 100644
index b67d909..0000000
--- a/rocketmq-donet/LICENSE
+++ /dev/null
@@ -1,201 +0,0 @@
-Apache License
-                           Version 2.0, January 2004
-                        http://www.apache.org/licenses/
-
-   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-   1. Definitions.
-
-      "License" shall mean the terms and conditions for use, reproduction,
-      and distribution as defined by Sections 1 through 9 of this document.
-
-      "Licensor" shall mean the copyright owner or entity authorized by
-      the copyright owner that is granting the License.
-
-      "Legal Entity" shall mean the union of the acting entity and all
-      other entities that control, are controlled by, or are under common
-      control with that entity. For the purposes of this definition,
-      "control" means (i) the power, direct or indirect, to cause the
-      direction or management of such entity, whether by contract or
-      otherwise, or (ii) ownership of fifty percent (50%) or more of the
-      outstanding shares, or (iii) beneficial ownership of such entity.
-
-      "You" (or "Your") shall mean an individual or Legal Entity
-      exercising permissions granted by this License.
-
-      "Source" form shall mean the preferred form for making modifications,
-      including but not limited to software source code, documentation
-      source, and configuration files.
-
-      "Object" form shall mean any form resulting from mechanical
-      transformation or translation of a Source form, including but
-      not limited to compiled object code, generated documentation,
-      and conversions to other media types.
-
-      "Work" shall mean the work of authorship, whether in Source or
-      Object form, made available under the License, as indicated by a
-      copyright notice that is included in or attached to the work
-      (an example is provided in the Appendix below).
-
-      "Derivative Works" shall mean any work, whether in Source or Object
-      form, that is based on (or derived from) the Work and for which the
-      editorial revisions, annotations, elaborations, or other modifications
-      represent, as a whole, an original work of authorship. For the purposes
-      of this License, Derivative Works shall not include works that remain
-      separable from, or merely link (or bind by name) to the interfaces of,
-      the Work and Derivative Works thereof.
-
-      "Contribution" shall mean any work of authorship, including
-      the original version of the Work and any modifications or additions
-      to that Work or Derivative Works thereof, that is intentionally
-      submitted to Licensor for inclusion in the Work by the copyright owner
-      or by an individual or Legal Entity authorized to submit on behalf of
-      the copyright owner. For the purposes of this definition, "submitted"
-      means any form of electronic, verbal, or written communication sent
-      to the Licensor or its representatives, including but not limited to
-      communication on electronic mailing lists, source code control systems,
-      and issue tracking systems that are managed by, or on behalf of, the
-      Licensor for the purpose of discussing and improving the Work, but
-      excluding communication that is conspicuously marked or otherwise
-      designated in writing by the copyright owner as "Not a Contribution."
-
-      "Contributor" shall mean Licensor and any individual or Legal Entity
-      on behalf of whom a Contribution has been received by Licensor and
-      subsequently incorporated within the Work.
-
-   2. Grant of Copyright License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      copyright license to reproduce, prepare Derivative Works of,
-      publicly display, publicly perform, sublicense, and distribute the
-      Work and such Derivative Works in Source or Object form.
-
-   3. Grant of Patent License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      (except as stated in this section) patent license to make, have made,
-      use, offer to sell, sell, import, and otherwise transfer the Work,
-      where such license applies only to those patent claims licensable
-      by such Contributor that are necessarily infringed by their
-      Contribution(s) alone or by combination of their Contribution(s)
-      with the Work to which such Contribution(s) was submitted. If You
-      institute patent litigation against any entity (including a
-      cross-claim or counterclaim in a lawsuit) alleging that the Work
-      or a Contribution incorporated within the Work constitutes direct
-      or contributory patent infringement, then any patent licenses
-      granted to You under this License for that Work shall terminate
-      as of the date such litigation is filed.
-
-   4. Redistribution. You may reproduce and distribute copies of the
-      Work or Derivative Works thereof in any medium, with or without
-      modifications, and in Source or Object form, provided that You
-      meet the following conditions:
-
-      (a) You must give any other recipients of the Work or
-          Derivative Works a copy of this License; and
-
-      (b) You must cause any modified files to carry prominent notices
-          stating that You changed the files; and
-
-      (c) You must retain, in the Source form of any Derivative Works
-          that You distribute, all copyright, patent, trademark, and
-          attribution notices from the Source form of the Work,
-          excluding those notices that do not pertain to any part of
-          the Derivative Works; and
-
-      (d) If the Work includes a "NOTICE" text file as part of its
-          distribution, then any Derivative Works that You distribute must
-          include a readable copy of the attribution notices contained
-          within such NOTICE file, excluding those notices that do not
-          pertain to any part of the Derivative Works, in at least one
-          of the following places: within a NOTICE text file distributed
-          as part of the Derivative Works; within the Source form or
-          documentation, if provided along with the Derivative Works; or,
-          within a display generated by the Derivative Works, if and
-          wherever such third-party notices normally appear. The contents
-          of the NOTICE file are for informational purposes only and
-          do not modify the License. You may add Your own attribution
-          notices within Derivative Works that You distribute, alongside
-          or as an addendum to the NOTICE text from the Work, provided
-          that such additional attribution notices cannot be construed
-          as modifying the License.
-
-      You may add Your own copyright statement to Your modifications and
-      may provide additional or different license terms and conditions
-      for use, reproduction, or distribution of Your modifications, or
-      for any such Derivative Works as a whole, provided Your use,
-      reproduction, and distribution of the Work otherwise complies with
-      the conditions stated in this License.
-
-   5. Submission of Contributions. Unless You explicitly state otherwise,
-      any Contribution intentionally submitted for inclusion in the Work
-      by You to the Licensor shall be under the terms and conditions of
-      this License, without any additional terms or conditions.
-      Notwithstanding the above, nothing herein shall supersede or modify
-      the terms of any separate license agreement you may have executed
-      with Licensor regarding such Contributions.
-
-   6. Trademarks. This License does not grant permission to use the trade
-      names, trademarks, service marks, or product names of the Licensor,
-      except as required for reasonable and customary use in describing the
-      origin of the Work and reproducing the content of the NOTICE file.
-
-   7. Disclaimer of Warranty. Unless required by applicable law or
-      agreed to in writing, Licensor provides the Work (and each
-      Contributor provides its Contributions) on an "AS IS" BASIS,
-      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-      implied, including, without limitation, any warranties or conditions
-      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
-      PARTICULAR PURPOSE. You are solely responsible for determining the
-      appropriateness of using or redistributing the Work and assume any
-      risks associated with Your exercise of permissions under this License.
-
-   8. Limitation of Liability. In no event and under no legal theory,
-      whether in tort (including negligence), contract, or otherwise,
-      unless required by applicable law (such as deliberate and grossly
-      negligent acts) or agreed to in writing, shall any Contributor be
-      liable to You for damages, including any direct, indirect, special,
-      incidental, or consequential damages of any character arising as a
-      result of this License or out of the use or inability to use the
-      Work (including but not limited to damages for loss of goodwill,
-      work stoppage, computer failure or malfunction, or any and all
-      other commercial damages or losses), even if such Contributor
-      has been advised of the possibility of such damages.
-
-   9. Accepting Warranty or Additional Liability. While redistributing
-      the Work or Derivative Works thereof, You may choose to offer,
-      and charge a fee for, acceptance of support, warranty, indemnity,
-      or other liability obligations and/or rights consistent with this
-      License. However, in accepting such obligations, You may act only
-      on Your own behalf and on Your sole responsibility, not on behalf
-      of any other Contributor, and only if You agree to indemnify,
-      defend, and hold each Contributor harmless for any liability
-      incurred by, or claims asserted against, such Contributor by reason
-      of your accepting any such warranty or additional liability.
-
-   END OF TERMS AND CONDITIONS
-
-   APPENDIX: How to apply the Apache License to your work.
-
-      To apply the Apache License to your work, attach the following
-      boilerplate notice, with the fields enclosed by brackets "{}"
-      replaced with your own identifying information. (Don't include
-      the brackets!)  The text should be enclosed in the appropriate
-      comment syntax for the file format. We also recommend that a
-      file or class name and description of purpose be included on the
-      same "printed page" as the copyright notice for easier
-      identification within third-party archives.
-
-   Copyright {}
-
-   Licensed under the Apache License, Version 2.0 (the "License");
-   you may not use this file except in compliance with the License.
-   You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-donet/NOTICE
----------------------------------------------------------------------
diff --git a/rocketmq-donet/NOTICE b/rocketmq-donet/NOTICE
deleted file mode 100644
index 5384857..0000000
--- a/rocketmq-donet/NOTICE
+++ /dev/null
@@ -1,5 +0,0 @@
-Apache RocketMQ (incubating)
-Copyright 2016-2017 The Apache Software Foundation
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-mongodb/LICENSE
----------------------------------------------------------------------
diff --git a/rocketmq-mongodb/LICENSE b/rocketmq-mongodb/LICENSE
deleted file mode 100644
index b67d909..0000000
--- a/rocketmq-mongodb/LICENSE
+++ /dev/null
@@ -1,201 +0,0 @@
-Apache License
-                           Version 2.0, January 2004
-                        http://www.apache.org/licenses/
-
-   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-   1. Definitions.
-
-      "License" shall mean the terms and conditions for use, reproduction,
-      and distribution as defined by Sections 1 through 9 of this document.
-
-      "Licensor" shall mean the copyright owner or entity authorized by
-      the copyright owner that is granting the License.
-
-      "Legal Entity" shall mean the union of the acting entity and all
-      other entities that control, are controlled by, or are under common
-      control with that entity. For the purposes of this definition,
-      "control" means (i) the power, direct or indirect, to cause the
-      direction or management of such entity, whether by contract or
-      otherwise, or (ii) ownership of fifty percent (50%) or more of the
-      outstanding shares, or (iii) beneficial ownership of such entity.
-
-      "You" (or "Your") shall mean an individual or Legal Entity
-      exercising permissions granted by this License.
-
-      "Source" form shall mean the preferred form for making modifications,
-      including but not limited to software source code, documentation
-      source, and configuration files.
-
-      "Object" form shall mean any form resulting from mechanical
-      transformation or translation of a Source form, including but
-      not limited to compiled object code, generated documentation,
-      and conversions to other media types.
-
-      "Work" shall mean the work of authorship, whether in Source or
-      Object form, made available under the License, as indicated by a
-      copyright notice that is included in or attached to the work
-      (an example is provided in the Appendix below).
-
-      "Derivative Works" shall mean any work, whether in Source or Object
-      form, that is based on (or derived from) the Work and for which the
-      editorial revisions, annotations, elaborations, or other modifications
-      represent, as a whole, an original work of authorship. For the purposes
-      of this License, Derivative Works shall not include works that remain
-      separable from, or merely link (or bind by name) to the interfaces of,
-      the Work and Derivative Works thereof.
-
-      "Contribution" shall mean any work of authorship, including
-      the original version of the Work and any modifications or additions
-      to that Work or Derivative Works thereof, that is intentionally
-      submitted to Licensor for inclusion in the Work by the copyright owner
-      or by an individual or Legal Entity authorized to submit on behalf of
-      the copyright owner. For the purposes of this definition, "submitted"
-      means any form of electronic, verbal, or written communication sent
-      to the Licensor or its representatives, including but not limited to
-      communication on electronic mailing lists, source code control systems,
-      and issue tracking systems that are managed by, or on behalf of, the
-      Licensor for the purpose of discussing and improving the Work, but
-      excluding communication that is conspicuously marked or otherwise
-      designated in writing by the copyright owner as "Not a Contribution."
-
-      "Contributor" shall mean Licensor and any individual or Legal Entity
-      on behalf of whom a Contribution has been received by Licensor and
-      subsequently incorporated within the Work.
-
-   2. Grant of Copyright License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      copyright license to reproduce, prepare Derivative Works of,
-      publicly display, publicly perform, sublicense, and distribute the
-      Work and such Derivative Works in Source or Object form.
-
-   3. Grant of Patent License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      (except as stated in this section) patent license to make, have made,
-      use, offer to sell, sell, import, and otherwise transfer the Work,
-      where such license applies only to those patent claims licensable
-      by such Contributor that are necessarily infringed by their
-      Contribution(s) alone or by combination of their Contribution(s)
-      with the Work to which such Contribution(s) was submitted. If You
-      institute patent litigation against any entity (including a
-      cross-claim or counterclaim in a lawsuit) alleging that the Work
-      or a Contribution incorporated within the Work constitutes direct
-      or contributory patent infringement, then any patent licenses
-      granted to You under this License for that Work shall terminate
-      as of the date such litigation is filed.
-
-   4. Redistribution. You may reproduce and distribute copies of the
-      Work or Derivative Works thereof in any medium, with or without
-      modifications, and in Source or Object form, provided that You
-      meet the following conditions:
-
-      (a) You must give any other recipients of the Work or
-          Derivative Works a copy of this License; and
-
-      (b) You must cause any modified files to carry prominent notices
-          stating that You changed the files; and
-
-      (c) You must retain, in the Source form of any Derivative Works
-          that You distribute, all copyright, patent, trademark, and
-          attribution notices from the Source form of the Work,
-          excluding those notices that do not pertain to any part of
-          the Derivative Works; and
-
-      (d) If the Work includes a "NOTICE" text file as part of its
-          distribution, then any Derivative Works that You distribute must
-          include a readable copy of the attribution notices contained
-          within such NOTICE file, excluding those notices that do not
-          pertain to any part of the Derivative Works, in at least one
-          of the following places: within a NOTICE text file distributed
-          as part of the Derivative Works; within the Source form or
-          documentation, if provided along with the Derivative Works; or,
-          within a display generated by the Derivative Works, if and
-          wherever such third-party notices normally appear. The contents
-          of the NOTICE file are for informational purposes only and
-          do not modify the License. You may add Your own attribution
-          notices within Derivative Works that You distribute, alongside
-          or as an addendum to the NOTICE text from the Work, provided
-          that such additional attribution notices cannot be construed
-          as modifying the License.
-
-      You may add Your own copyright statement to Your modifications and
-      may provide additional or different license terms and conditions
-      for use, reproduction, or distribution of Your modifications, or
-      for any such Derivative Works as a whole, provided Your use,
-      reproduction, and distribution of the Work otherwise complies with
-      the conditions stated in this License.
-
-   5. Submission of Contributions. Unless You explicitly state otherwise,
-      any Contribution intentionally submitted for inclusion in the Work
-      by You to the Licensor shall be under the terms and conditions of
-      this License, without any additional terms or conditions.
-      Notwithstanding the above, nothing herein shall supersede or modify
-      the terms of any separate license agreement you may have executed
-      with Licensor regarding such Contributions.
-
-   6. Trademarks. This License does not grant permission to use the trade
-      names, trademarks, service marks, or product names of the Licensor,
-      except as required for reasonable and customary use in describing the
-      origin of the Work and reproducing the content of the NOTICE file.
-
-   7. Disclaimer of Warranty. Unless required by applicable law or
-      agreed to in writing, Licensor provides the Work (and each
-      Contributor provides its Contributions) on an "AS IS" BASIS,
-      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-      implied, including, without limitation, any warranties or conditions
-      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
-      PARTICULAR PURPOSE. You are solely responsible for determining the
-      appropriateness of using or redistributing the Work and assume any
-      risks associated with Your exercise of permissions under this License.
-
-   8. Limitation of Liability. In no event and under no legal theory,
-      whether in tort (including negligence), contract, or otherwise,
-      unless required by applicable law (such as deliberate and grossly
-      negligent acts) or agreed to in writing, shall any Contributor be
-      liable to You for damages, including any direct, indirect, special,
-      incidental, or consequential damages of any character arising as a
-      result of this License or out of the use or inability to use the
-      Work (including but not limited to damages for loss of goodwill,
-      work stoppage, computer failure or malfunction, or any and all
-      other commercial damages or losses), even if such Contributor
-      has been advised of the possibility of such damages.
-
-   9. Accepting Warranty or Additional Liability. While redistributing
-      the Work or Derivative Works thereof, You may choose to offer,
-      and charge a fee for, acceptance of support, warranty, indemnity,
-      or other liability obligations and/or rights consistent with this
-      License. However, in accepting such obligations, You may act only
-      on Your own behalf and on Your sole responsibility, not on behalf
-      of any other Contributor, and only if You agree to indemnify,
-      defend, and hold each Contributor harmless for any liability
-      incurred by, or claims asserted against, such Contributor by reason
-      of your accepting any such warranty or additional liability.
-
-   END OF TERMS AND CONDITIONS
-
-   APPENDIX: How to apply the Apache License to your work.
-
-      To apply the Apache License to your work, attach the following
-      boilerplate notice, with the fields enclosed by brackets "{}"
-      replaced with your own identifying information. (Don't include
-      the brackets!)  The text should be enclosed in the appropriate
-      comment syntax for the file format. We also recommend that a
-      file or class name and description of purpose be included on the
-      same "printed page" as the copyright notice for easier
-      identification within third-party archives.
-
-   Copyright {}
-
-   Licensed under the Apache License, Version 2.0 (the "License");
-   you may not use this file except in compliance with the License.
-   You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-mongodb/NOTICE
----------------------------------------------------------------------
diff --git a/rocketmq-mongodb/NOTICE b/rocketmq-mongodb/NOTICE
deleted file mode 100644
index 5384857..0000000
--- a/rocketmq-mongodb/NOTICE
+++ /dev/null
@@ -1,5 +0,0 @@
-Apache RocketMQ (incubating)
-Copyright 2016-2017 The Apache Software Foundation
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
\ No newline at end of file


[16/17] incubator-rocketmq-externals git commit: Polish cpp module

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/include/DefaultMQPullConsumer.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/include/DefaultMQPullConsumer.h b/rocketmq-client4cpp/include/DefaultMQPullConsumer.h
deleted file mode 100755
index d9952c5..0000000
--- a/rocketmq-client4cpp/include/DefaultMQPullConsumer.h
+++ /dev/null
@@ -1,154 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __RMQ_DEFAULTMQPULLCONSUMER_H__
-#define __RMQ_DEFAULTMQPULLCONSUMER_H__
-
-#include <list>
-#include <string>
-
-#include "RocketMQClient.h"
-#include "MQClientException.h"
-#include "MessageQueue.h"
-#include "MessageExt.h"
-#include "ClientConfig.h"
-#include "MQPullConsumer.h"
-
-namespace rmq
-{
-	class OffsetStore;
-	class DefaultMQPullConsumerImpl;
-	class AllocateMessageQueueStrategy;
-
-	/**
-	* Pull Consumer
-	*
-	*/
-	class DefaultMQPullConsumer : public ClientConfig , public MQPullConsumer
-	{
-	public:
-		DefaultMQPullConsumer();
-		DefaultMQPullConsumer(const std::string& consumerGroup);
-		~DefaultMQPullConsumer();
-
-		//MQAdmin
-		void createTopic(const std::string& key, const std::string& newTopic, int queueNum);
-		long long searchOffset(const MessageQueue& mq, long long timestamp);
-		long long maxOffset(const MessageQueue& mq);
-		long long minOffset(const MessageQueue& mq);
-		long long earliestMsgStoreTime(const MessageQueue& mq);
-		MessageExt* viewMessage(const std::string& msgId);
-		QueryResult queryMessage(const std::string& topic,
-								 const std::string&  key,
-								 int maxNum,
-								 long long begin,
-								 long long end);
-		// MQadmin end
-
-		AllocateMessageQueueStrategy* getAllocateMessageQueueStrategy();
-		void setAllocateMessageQueueStrategy(AllocateMessageQueueStrategy* pAllocateMessageQueueStrategy);
-		int getBrokerSuspendMaxTimeMillis() ;
-		void setBrokerSuspendMaxTimeMillis(int brokerSuspendMaxTimeMillis);
-		std::string getConsumerGroup();
-		void setConsumerGroup(const std::string& consumerGroup);
-		int getConsumerPullTimeoutMillis();
-		void setConsumerPullTimeoutMillis(int consumerPullTimeoutMillis);
-		int getConsumerTimeoutMillisWhenSuspend() ;
-		void setConsumerTimeoutMillisWhenSuspend(int consumerTimeoutMillisWhenSuspend);
-		MessageModel getMessageModel();
-		void setMessageModel(MessageModel messageModel);
-		MessageQueueListener* getMessageQueueListener();
-		void setMessageQueueListener(MessageQueueListener* pMessageQueueListener);
-		std::set<std::string> getRegisterTopics();
-		void setRegisterTopics( std::set<std::string> registerTopics);
-
-		//MQConsumer
-		void sendMessageBack(MessageExt& msg, int delayLevel);
-		void sendMessageBack(MessageExt& msg, int delayLevel, const std::string& brokerName);
-		std::set<MessageQueue>* fetchSubscribeMessageQueues(const std::string& topic);
-		void start();
-		void shutdown() ;
-		//MQConsumer end
-
-		//MQPullConsumer
-		void registerMessageQueueListener(const std::string& topic, MessageQueueListener* pListener);
-		PullResult* pull(MessageQueue& mq, const std::string& subExpression, long long offset,int maxNums);
-		void pull(MessageQueue& mq,
-			const std::string& subExpression,
-			long long offset,
-			int maxNums,
-			PullCallback* pPullCallback);
-
-		PullResult* pullBlockIfNotFound(MessageQueue& mq,
-			const std::string& subExpression,
-			long long offset,
-			int maxNums);
-
-		void pullBlockIfNotFound(MessageQueue& mq,
-								 const std::string& subExpression,
-								 long long offset,
-								 int maxNums,
-								 PullCallback* pPullCallback);
-
-		void updateConsumeOffset(MessageQueue& mq, long long offset);
-
-		long long fetchConsumeOffset(MessageQueue& mq, bool fromStore);
-
-		std::set<MessageQueue>* fetchMessageQueuesInBalance(const std::string& topic);
-		//MQPullConsumer end
-
-		OffsetStore* getOffsetStore();
-		void setOffsetStore(OffsetStore* offsetStore);
-
-		DefaultMQPullConsumerImpl* getDefaultMQPullConsumerImpl();
-
-		bool isUnitMode();
-		void setUnitMode(bool isUnitMode);
-
-		int getMaxReconsumeTimes();
-		void setMaxReconsumeTimes(int maxReconsumeTimes);
-
-	protected:
-		DefaultMQPullConsumerImpl* m_pDefaultMQPullConsumerImpl;
-
-	private:
-		std::string m_consumerGroup;
-		int m_brokerSuspendMaxTimeMillis ;
-
-		int m_consumerTimeoutMillisWhenSuspend;
-		int m_consumerPullTimeoutMillis;
-
-		MessageModel m_messageModel;
-		MessageQueueListener* m_pMessageQueueListener;
-
-		OffsetStore* m_pOffsetStore;
-
-		std::set<std::string> m_registerTopics;
-		AllocateMessageQueueStrategy* m_pAllocateMessageQueueStrategy;
-
-		/**
-	     * Whether the unit of subscription group
-	     */
-	    bool m_unitMode;
-
-		/**
-		 * max retry times��default is 15
-		 */
-	    int m_maxReconsumeTimes;
-	};
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/include/DefaultMQPushConsumer.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/include/DefaultMQPushConsumer.h b/rocketmq-client4cpp/include/DefaultMQPushConsumer.h
deleted file mode 100755
index 25ef4fb..0000000
--- a/rocketmq-client4cpp/include/DefaultMQPushConsumer.h
+++ /dev/null
@@ -1,181 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#ifndef __RMQ_DEFAULTMQPUSHCONSUMER_H__
-#define __RMQ_DEFAULTMQPUSHCONSUMER_H__
-
-#include <list>
-#include <string>
-
-#include "RocketMQClient.h"
-#include "MQClientException.h"
-#include "Message.h"
-#include "MessageExt.h"
-#include "MessageQueue.h"
-#include "MessageListener.h"
-#include "PullResult.h"
-#include "ClientConfig.h"
-#include "MQPushConsumer.h"
-
-namespace rmq
-{
-	class AllocateMessageQueueStrategy;
-	class DefaultMQPushConsumerImpl;
-	class OffsetStore;
-
-	/**
-	* Push Consumer
-	*
-	*/
-	class DefaultMQPushConsumer : public ClientConfig ,public MQPushConsumer
-	{
-	public:
-		DefaultMQPushConsumer();
-		DefaultMQPushConsumer(const std::string& consumerGroup);
-		~DefaultMQPushConsumer();
-
-		//MQAdmin
-		void createTopic(const std::string& key, const std::string& newTopic, int queueNum);
-		long long searchOffset(const MessageQueue& mq, long long timestamp);
-		long long maxOffset(const MessageQueue& mq);
-		long long minOffset(const MessageQueue& mq);
-		long long earliestMsgStoreTime(const MessageQueue& mq);
-		MessageExt* viewMessage(const std::string& msgId);
-		QueryResult queryMessage(const std::string& topic,
-								 const std::string&  key,
-								 int maxNum,
-								 long long begin,
-								 long long end);
-
-		// MQadmin end
-
-		AllocateMessageQueueStrategy* getAllocateMessageQueueStrategy();
-		void setAllocateMessageQueueStrategy(AllocateMessageQueueStrategy* pAllocateMessageQueueStrategy);
-
-		int getConsumeConcurrentlyMaxSpan();
-		void setConsumeConcurrentlyMaxSpan(int consumeConcurrentlyMaxSpan);
-
-		ConsumeFromWhere getConsumeFromWhere();
-		void setConsumeFromWhere(ConsumeFromWhere consumeFromWhere);
-
-		int getConsumeMessageBatchMaxSize();
-		void setConsumeMessageBatchMaxSize(int consumeMessageBatchMaxSize);
-
-		std::string getConsumerGroup();
-		void setConsumerGroup(const std::string& consumerGroup) ;
-
-		int getConsumeThreadMax() ;
-		void setConsumeThreadMax(int consumeThreadMax);
-
-		int getConsumeThreadMin();
-		void setConsumeThreadMin(int consumeThreadMin);
-
-		MessageListener* getMessageListener();
-		void setMessageListener(MessageListener* pMessageListener);
-
-		MessageModel getMessageModel();
-		void setMessageModel(MessageModel messageModel) ;
-
-		int getPullBatchSize() ;
-		void setPullBatchSize(int pullBatchSize);
-
-		long getPullInterval();
-		void setPullInterval(long pullInterval);
-
-		int getPullThresholdForQueue();
-		void setPullThresholdForQueue(int pullThresholdForQueue);
-
-		std::map<std::string, std::string>& getSubscription();
-		void setSubscription(const std::map<std::string, std::string>& subscription);
-
-		//MQConsumer
-		void sendMessageBack(MessageExt& msg, int delayLevel);
-		void sendMessageBack(MessageExt& msg, int delayLevel, const std::string brokerName);
-		std::set<MessageQueue>* fetchSubscribeMessageQueues(const std::string& topic);
-
-		void start();
-		void shutdown();
-		//MQConsumer end
-
-		//MQPushConsumer
-		void registerMessageListener(MessageListener* pMessageListener);
-
-		void subscribe(const std::string& topic, const std::string& subExpression);
-		void unsubscribe(const std::string& topic);
-
-		void updateCorePoolSize(int corePoolSize);
-
-		void suspend() ;
-		void resume();
-		//MQPushConsumer end
-
-		OffsetStore* getOffsetStore();
-		void setOffsetStore(OffsetStore* offsetStore);
-
-		std::string getConsumeTimestamp();
-	    void setConsumeTimestamp(std::string consumeTimestamp);
-
-		DefaultMQPushConsumerImpl* getDefaultMQPushConsumerImpl();
-
-		bool isPostSubscriptionWhenPull();
-		void setPostSubscriptionWhenPull(bool postSubscriptionWhenPull);
-
-		bool isUnitMode();
-		void setUnitMode(bool isUnitMode);
-
-		int getMaxReconsumeTimes();
-		void setMaxReconsumeTimes(int maxReconsumeTimes);
-
-		int getSuspendCurrentQueueTimeMillis();
-		void setSuspendCurrentQueueTimeMillis(int suspendCurrentQueueTimeMillis);
-
-		int getConsumeTimeout();
-		void setConsumeTimeout(int consumeTimeout);
-
-	protected:
-		DefaultMQPushConsumerImpl* m_pDefaultMQPushConsumerImpl;
-
-	private:
-		std::string m_consumerGroup;
-		MessageModel m_messageModel;
-		ConsumeFromWhere m_consumeFromWhere;
-		std::string m_consumeTimestamp;
-
-		AllocateMessageQueueStrategy* m_pAllocateMessageQueueStrategy ;
-		std::map<std::string /* topic */, std::string /* sub expression */> m_subscription ;
-
-		MessageListener* m_pMessageListener;
-		OffsetStore* m_pOffsetStore;
-
-		int m_consumeThreadMin;
-		int m_consumeThreadMax;
-
-		int m_consumeConcurrentlyMaxSpan;
-		int m_pullThresholdForQueue;
-		long m_pullInterval;
-
-		int m_consumeMessageBatchMaxSize;
-		int m_pullBatchSize;
-
-	    bool m_postSubscriptionWhenPull;
-	    bool m_unitMode;
-	    int m_maxReconsumeTimes;
-
-	    long m_suspendCurrentQueueTimeMillis;
-	    long m_consumeTimeout;
-	};
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/include/MQAdmin.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/include/MQAdmin.h b/rocketmq-client4cpp/include/MQAdmin.h
deleted file mode 100755
index 552a468..0000000
--- a/rocketmq-client4cpp/include/MQAdmin.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __RMQ_MQADMIN_H__
-#define __RMQ_MQADMIN_H__
-
-#include <string>
-
-#include "RocketMQClient.h"
-#include "MessageExt.h"
-
-namespace rmq
-{
-	class MQClientException;
-	class RemotingException;
-	class MQBrokerException;
-	class InterruptedException;
-	class MessageQueue;
-	class QueryResult;
-
-	/**
-	* MQ Admin
-	*
-	*/
-	class MQAdmin
-	{
-	public:
-		MQAdmin()
-		{
-		}
-
-		virtual ~MQAdmin()
-		{
-		}
-
-		virtual void createTopic(const std::string& key, const std::string& newTopic, int queueNum)=0;
-
-		virtual long long searchOffset(const MessageQueue& mq, long long timestamp)=0;
-		virtual long long maxOffset(const MessageQueue& mq)=0;
-		virtual long long minOffset(const MessageQueue& mq)=0;
-
-		virtual long long earliestMsgStoreTime(const MessageQueue& mq)=0;
-
-		virtual MessageExt* viewMessage(const std::string& msgId)=0;
-		virtual QueryResult queryMessage(const std::string& topic,
-										 const std::string&  key,
-										 int maxNum,
-										 long long begin,
-										 long long end)=0;
-	};
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/include/MQClientException.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/include/MQClientException.h b/rocketmq-client4cpp/include/MQClientException.h
deleted file mode 100755
index f1d1d04..0000000
--- a/rocketmq-client4cpp/include/MQClientException.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/**
- * Copyright (C) 2013 kangliqiang ,kangliq@163.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __RMQ_MQCLIENTEXCEPTION_H__
-#define __RMQ_MQCLIENTEXCEPTION_H__
-
-#include <string>
-#include <ostream>
-#include <sstream>
-#include <exception>
-
-#include "RocketMQClient.h"
-
-namespace rmq
-{
-	class MQException : public std::exception
-	{
-	public:
-		MQException(const std::string& msg, int error,const char* file,int line)throw()
-			: m_error(error),m_line(line),m_file(file)
-		{
-			try
-			{
-				std::stringstream ss;
-				ss << "[" << file << ":" << line <<"]|error: " << error << "|msg:" << msg;
-				m_msg = ss.str();
-			}
-			catch (...)
-			{
-			}
-		}
-
-		virtual ~MQException()throw()
-		{
-		}
-
-		const char* what() const throw()
-		{
-			return m_msg.c_str();
-		}
-
-		int GetError() const throw()
-		{
-			return m_error;
-		}
-
-		virtual const char* GetType() const throw()
-		{
-			return "MQException";
-		}
-
-	protected:
-		int m_error;
-		int m_line;
-		std::string m_msg;
-		std::string m_file;
-	};
-
-	inline std::ostream& operator<<(std::ostream& os, const MQException& e)
-	{
-		os <<"Type:"<<e.GetType() <<  e.what();
-		return os;
-	}
-
-	#define DEFINE_MQCLIENTEXCEPTION(name, parent) \
-	class name : public parent \
-	{\
-	public:\
-		name(const std::string& msg, int error,const char* file,int line) throw ()\
-		: parent(msg, error, file, line) {}\
-		virtual const char* GetType() const throw()\
-	{\
-		return #name;\
-	}\
-	};
-
-	DEFINE_MQCLIENTEXCEPTION(MQClientException, MQException)
-	DEFINE_MQCLIENTEXCEPTION(MQBrokerException, MQException)
-	DEFINE_MQCLIENTEXCEPTION(InterruptedException, MQException)
-	DEFINE_MQCLIENTEXCEPTION(UnknownHostException, MQException)
-
-	DEFINE_MQCLIENTEXCEPTION(RemotingException, MQException)
-	DEFINE_MQCLIENTEXCEPTION(RemotingCommandException, RemotingException)
-	DEFINE_MQCLIENTEXCEPTION(RemotingConnectException, RemotingException)
-	DEFINE_MQCLIENTEXCEPTION(RemotingSendRequestException, RemotingException)
-	DEFINE_MQCLIENTEXCEPTION(RemotingTimeoutException, RemotingException)
-	DEFINE_MQCLIENTEXCEPTION(RemotingTooMuchRequestException, RemotingException)
-
-	#define THROW_MQEXCEPTION(e,msg,err) throw e(msg,err,__FILE__,__LINE__)
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/include/MQConsumer.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/include/MQConsumer.h b/rocketmq-client4cpp/include/MQConsumer.h
deleted file mode 100755
index 87efe97..0000000
--- a/rocketmq-client4cpp/include/MQConsumer.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __RMQ_MQCONSUMER_H__
-#define __RMQ_MQCONSUMER_H__
-
-#include <set>
-#include <string>
-
-#include "RocketMQClient.h"
-#include "MQAdmin.h"
-#include "ConsumeType.h"
-
-
-namespace rmq
-{
-	class MessageExt;
-
-	/**
-	* Consumer interface
-	*
-	*/
-	class MQConsumer : public MQAdmin
-	{
-	public:
-		virtual ~MQConsumer(){}
-
-		virtual void  start()=0;
-		virtual void shutdown()=0;
-
-		virtual void sendMessageBack(MessageExt& msg, int delayLevel)=0;
-		virtual std::set<MessageQueue>* fetchSubscribeMessageQueues(const std::string& topic)=0;
-	};
-}
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/include/MQProducer.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/include/MQProducer.h b/rocketmq-client4cpp/include/MQProducer.h
deleted file mode 100755
index b353aba..0000000
--- a/rocketmq-client4cpp/include/MQProducer.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License")=0;
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __RMQ_MQPRODUCER_H__
-#define __RMQ_MQPRODUCER_H__
-
-#include <vector>
-#include <string>
-
-#include "RocketMQClient.h"
-#include "MQAdmin.h"
-#include "SendResult.h"
-
-namespace rmq
-{
-	class MessageQueue;
-	class SendCallback;
-	class LocalTransactionExecuter;
-	class MessageQueueSelector;
-
-	/**
-	* Producer interface
-	*
-	*/
-	class MQProducer : public MQAdmin
-	{
-	public:
-		MQProducer()
-		{
-		}
-
-		virtual ~MQProducer()
-		{
-		}
-
-		virtual void start()=0;
-		virtual void shutdown()=0;
-
-		virtual std::vector<MessageQueue>* fetchPublishMessageQueues(const std::string& topic)=0;
-
-		virtual SendResult send(Message& msg)=0;
-		virtual void send(Message& msg, SendCallback* sendCallback)=0;
-		virtual void sendOneway(Message& msg)=0;
-
-		virtual SendResult send(Message& msg, MessageQueue& mq)=0;
-		virtual void send(Message& msg, MessageQueue& mq, SendCallback* sendCallback)=0;
-		virtual void sendOneway(Message& msg, MessageQueue& mq)=0;
-
-		virtual SendResult send(Message& msg, MessageQueueSelector* selector, void* arg)=0;
-		virtual void send(Message& msg, MessageQueueSelector* selector, void* arg, SendCallback* sendCallback)=0;
-		virtual void sendOneway(Message& msg, MessageQueueSelector* selector, void* arg)=0;
-
-		virtual TransactionSendResult sendMessageInTransaction(Message& msg,
-																LocalTransactionExecuter* tranExecuter,
-																void* arg)=0;
-	};
-}
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/include/MQPullConsumer.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/include/MQPullConsumer.h b/rocketmq-client4cpp/include/MQPullConsumer.h
deleted file mode 100755
index ffb2ac5..0000000
--- a/rocketmq-client4cpp/include/MQPullConsumer.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#ifndef __RMQ_MQPULLCONSUMER_H__
-#define __RMQ_MQPULLCONSUMER_H__
-
-#include <set>
-#include <string>
-
-#include "RocketMQClient.h"
-#include "MQConsumer.h"
-#include "PullResult.h"
-
-namespace rmq
-{
-	class MessageQueueListener;
-	class MessageQueue;
-	class PullCallback;
-
-	/**
-	* Pull Consumer
-	*
-	*/
-	class MQPullConsumer : public MQConsumer
-	{
-	public:
-		virtual ~MQPullConsumer(){}
-		virtual void registerMessageQueueListener(const std::string& topic, MessageQueueListener* pListener)=0;
-
-		virtual PullResult* pull(MessageQueue& mq, const std::string& subExpression, long long offset,int maxNums)=0;
-		virtual void pull(MessageQueue& mq, const std::string& subExpression, long long offset, int maxNums, PullCallback* pPullCallback)=0;
-
-		virtual PullResult* pullBlockIfNotFound(MessageQueue& mq, const std::string& subExpression, long long offset, int maxNums)=0;
-		virtual void pullBlockIfNotFound(MessageQueue& mq, const std::string& subExpression, long long offset, int maxNums, PullCallback* pPullCallback)=0;
-
-		virtual void updateConsumeOffset(MessageQueue& mq, long long offset)=0;
-		virtual long long fetchConsumeOffset(MessageQueue& mq, bool fromStore)=0;
-
-		virtual std::set<MessageQueue>* fetchMessageQueuesInBalance(const std::string& topic)=0;
-	};
-}
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/include/MQPushConsumer.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/include/MQPushConsumer.h b/rocketmq-client4cpp/include/MQPushConsumer.h
deleted file mode 100755
index fe6d4a0..0000000
--- a/rocketmq-client4cpp/include/MQPushConsumer.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#ifndef __RMQ_MQPUSHCONSUMER_H__
-#define __RMQ_MQPUSHCONSUMER_H__
-
-#include <set>
-#include <string>
-
-#include "RocketMQClient.h"
-#include "MQConsumer.h"
-#include "PullResult.h"
-
-namespace rmq
-{
-	class MessageListener;
-
-	/**
-	* Push Consumer
-	*
-	*/
-	class MQPushConsumer : public MQConsumer
-	{
-	public:
-		virtual void registerMessageListener(MessageListener* pMessageListener)=0;
-
-
-		virtual  void subscribe(const std::string& topic, const std::string& subExpression)=0;
-		virtual void unsubscribe(const std::string& topic)=0;
-
-
-		virtual void updateCorePoolSize(int corePoolSize)=0;
-		virtual void suspend()=0;
-		virtual void resume()=0;
-	};
-}
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/include/Message.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/include/Message.h b/rocketmq-client4cpp/include/Message.h
deleted file mode 100755
index 441b4e5..0000000
--- a/rocketmq-client4cpp/include/Message.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __RMQ_MESSAGE_H__
-#define __RMQ_MESSAGE_H__
-
-#include <map>
-#include <string>
-#include <list>
-#include "RocketMQClient.h"
-
-namespace rmq
-{
-	/**
-	* Message
-	*
-	*/
-	class Message
-	{
-	public:
-		Message();
-		Message(const std::string& topic, const char* body,int len);
-		Message(const std::string& topic, const std::string& tags, const char* body,int len);
-		Message(const std::string& topic, const std::string& tags,const std::string& keys, const char* body,int len);
-		Message(const std::string& topic,
-				const std::string& tags,
-				const std::string& keys,
-				const int	flag,
-				const char* body,
-				int len,
-				bool waitStoreMsgOK);
-
-		virtual ~Message();
-		Message(const Message& other);
-		Message& operator=(const Message& other);
-
-		void clearProperty(const std::string& name);
-		void putProperty(const std::string& name, const std::string& value);
-		std::string getProperty(const std::string& name);
-
-		std::string getTopic()const;
-		void setTopic(const std::string& topic);
-
-		std::string getTags();
-		void setTags(const std::string& tags);
-
-		std::string getKeys();
-		void setKeys(const std::string& keys);
-		void setKeys(const std::list<std::string> keys);
-
-		int getDelayTimeLevel();
-		void setDelayTimeLevel(int level);
-
-		bool isWaitStoreMsgOK();
-		void setWaitStoreMsgOK(bool waitStoreMsgOK);
-
-		int getFlag();
-		void setFlag(int flag);
-
-		const char* getBody() const;
-		int getBodyLen() const;
-		void setBody(const char* body, int len);
-
-		bool tryToCompress(int compressLevel);
-		const char* getCompressBody() const;
-		int getCompressBodyLen() const;
-
-		std::map<std::string, std::string>& getProperties();
-		void setProperties(const std::map<std::string, std::string>& properties);
-
-		std::string toString() const;
-
-	protected:
-		void Init(const std::string& topic,
-				  const std::string& tags,
-				  const std::string& keys,
-				  const int	flag,
-				  const char* body,
-				  int len,
-				  bool waitStoreMsgOK);
-
-	public:
-		static const std::string PROPERTY_KEYS;
-		static const std::string PROPERTY_TAGS;
-		static const std::string PROPERTY_WAIT_STORE_MSG_OK;
-		static const std::string PROPERTY_DELAY_TIME_LEVEL;
-
-		/**
-		* for inner use
-		*/
-		static const std::string PROPERTY_RETRY_TOPIC;
-		static const std::string PROPERTY_REAL_TOPIC;
-		static const std::string PROPERTY_REAL_QUEUE_ID;
-		static const std::string PROPERTY_TRANSACTION_PREPARED;
-		static const std::string PROPERTY_PRODUCER_GROUP;
-		static const std::string PROPERTY_MIN_OFFSET;
-		static const std::string PROPERTY_MAX_OFFSET;
-		static const std::string PROPERTY_BUYER_ID;
-		static const std::string PROPERTY_ORIGIN_MESSAGE_ID;
-		static const std::string PROPERTY_TRANSFER_FLAG;
-		static const std::string PROPERTY_CORRECTION_FLAG;
-		static const std::string PROPERTY_MQ2_FLAG;
-		static const std::string PROPERTY_RECONSUME_TIME;
-		static const std::string PROPERTY_MSG_REGION;
-		static const std::string PROPERTY_UNIQ_CLIENT_MESSAGE_ID_KEYIDX;
-		static const std::string PROPERTY_MAX_RECONSUME_TIMES;
-		static const std::string PROPERTY_CONSUME_START_TIMESTAMP;
-
-		static const std::string KEY_SEPARATOR;
-	private:
-		std::string m_topic;
-		int m_flag;
-		std::map<std::string, std::string> m_properties;
-
-		char* m_body;
-		int   m_bodyLen;
-
-		char* m_compressBody;
-		int   m_compressBodyLen;
-	};
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/include/MessageExt.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/include/MessageExt.h b/rocketmq-client4cpp/include/MessageExt.h
deleted file mode 100755
index f70041c..0000000
--- a/rocketmq-client4cpp/include/MessageExt.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#ifndef __RMQ_MESSAGEEXT_H__
-#define __RMQ_MESSAGEEXT_H__
-
-#include <sys/socket.h>
-#include <string>
-#include "Message.h"
-#include "TopicFilterType.h"
-#include "RocketMQClient.h"
-
-namespace rmq
-	{
-	/**
-	* Message extend
-	*
-	*/
-	class MessageExt : public Message
-	{
-	public:
-		MessageExt();
-
-		MessageExt(int queueId,
-				   long long bornTimestamp,
-				   sockaddr bornHost,
-				   long long storeTimestamp,
-				   sockaddr storeHost,
-				   std::string msgId);
-
-		~MessageExt();
-
-		static TopicFilterType parseTopicFilterType(int sysFlag);
-
-		int getQueueId();
-		void setQueueId(int queueId);
-
-		long long getBornTimestamp();
-		void setBornTimestamp(long long bornTimestamp);
-
-		sockaddr getBornHost();
-		std::string getBornHostString();
-		std::string getBornHostNameString();
-		void setBornHost(const sockaddr& bornHost);
-
-		long long getStoreTimestamp();
-		void setStoreTimestamp(long long storeTimestamp);
-
-		sockaddr getStoreHost();
-		std::string getStoreHostString();
-		void setStoreHost(const sockaddr& storeHost);
-
-		std::string getMsgId();
-		void setMsgId(const std::string& msgId);
-
-		int getSysFlag();
-		void setSysFlag(int sysFlag);
-
-		int getBodyCRC();
-		void setBodyCRC(int bodyCRC);
-
-		long long getQueueOffset();
-		void setQueueOffset(long long queueOffset);
-
-		long long getCommitLogOffset();
-		void setCommitLogOffset(long long physicOffset);
-
-		int getStoreSize();
-		void setStoreSize(int storeSize);
-
-		int getReconsumeTimes();
-		void setReconsumeTimes(int reconsumeTimes);
-
-		long long getPreparedTransactionOffset();
-		void setPreparedTransactionOffset(long long preparedTransactionOffset);
-
-		std::string toString() const;
-
-	private:
-		long long m_queueOffset;
-		long long m_commitLogOffset;
-		long long m_bornTimestamp;
-		long long m_storeTimestamp;
-		long long m_preparedTransactionOffset;
-		int m_queueId;
-		int m_storeSize;
-		int m_sysFlag;
-		int m_bodyCRC;
-		int m_reconsumeTimes;
-		sockaddr m_bornHost;
-		sockaddr m_storeHost;
-		std::string m_msgId;
-	};
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/include/MessageListener.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/include/MessageListener.h b/rocketmq-client4cpp/include/MessageListener.h
deleted file mode 100755
index 130a219..0000000
--- a/rocketmq-client4cpp/include/MessageListener.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __RMQ_MESSAGELISTENER_H__
-#define __RMQ_MESSAGELISTENER_H__
-
-#include <limits.h>
-#include <list>
-
-#include "MessageExt.h"
-#include "MessageQueue.h"
-
-namespace rmq
-{
-	/**
-	* Message Listener
-	*
-	*/
-	class MessageListener
-	{
-	public:
-		virtual ~MessageListener(){}
-	};
-
-	enum ConsumeOrderlyStatus
-	{
-		SUCCESS,
-		ROLLBACK,
-		COMMIT,
-		SUSPEND_CURRENT_QUEUE_A_MOMENT,
-	};
-
-	typedef struct tagConsumeOrderlyContext
-	{
-		tagConsumeOrderlyContext(MessageQueue& mq)
-			:messageQueue(mq),
-			autoCommit(true),
-			suspendCurrentQueueTimeMillis(1000)
-		{
-		}
-
-		MessageQueue messageQueue;///< Ҫ���ѵ���Ϣ�����ĸ�����
-		bool autoCommit;///< ��ϢOffset�Ƿ��Զ��ύ
-		long suspendCurrentQueueTimeMillis;
-	}ConsumeOrderlyContext;
-
-	class MessageListenerOrderly : public MessageListener
-	{
-	public:
-		virtual ConsumeOrderlyStatus consumeMessage(std::list<MessageExt*>& msgs,
-													ConsumeOrderlyContext& context)=0;
-	};
-
-	enum ConsumeConcurrentlyStatus
-	{
-		CONSUME_SUCCESS,
-		RECONSUME_LATER,
-	};
-
-	struct ConsumeConcurrentlyContext
-	{
-		ConsumeConcurrentlyContext(MessageQueue& mq)
-			:messageQueue(mq),
-			delayLevelWhenNextConsume(0),
-			ackIndex(INT_MAX)
-		{
-		}
-		MessageQueue messageQueue;
-		int delayLevelWhenNextConsume;
-		int ackIndex;
-	};
-
-	class MessageListenerConcurrently : public MessageListener
-	{
-	public:
-		virtual ConsumeConcurrentlyStatus consumeMessage(std::list<MessageExt*>& msgs,
-														ConsumeConcurrentlyContext& context)=0;
-	};
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/include/MessageQueue.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/include/MessageQueue.h b/rocketmq-client4cpp/include/MessageQueue.h
deleted file mode 100755
index 89ddf58..0000000
--- a/rocketmq-client4cpp/include/MessageQueue.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __RMQ_MESSAGEQUEUE_H__
-#define __RMQ_MESSAGEQUEUE_H__
-
-#include <iostream>
-#include <string>
-#include <sstream>
-
-#include "RocketMQClient.h"
-
-namespace rmq
-{
-	/**
-	* Message Queue
-	*
-	*/
-	class MessageQueue
-	{
-	public:
-		MessageQueue();
-		~MessageQueue(){};
-
-		MessageQueue(const std::string& topic, const std::string& brokerName, int queueId);
-
-		std::string getTopic()const;
-		void setTopic(const std::string& topic);
-
-		std::string getBrokerName()const;
-		void setBrokerName(const std::string& brokerName);
-
-		int getQueueId()const;
-		void setQueueId(int queueId);
-
-		int hashCode();
-		std::string toString() const;
-		std::string toJsonString() const;
-
-		bool operator==(const MessageQueue& mq) const;
-		bool operator<(const MessageQueue& mq) const;
-		int compareTo(const MessageQueue& mq) const;
-
-	private:
-		std::string m_topic;
-		std::string m_brokerName;
-		int m_queueId;
-	};
-
-	inline std::ostream& operator<<(std::ostream& os, const MessageQueue& obj)
-	{
-	    os << obj.toString();
-	    return os;
-	}
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/include/MessageQueueListener.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/include/MessageQueueListener.h b/rocketmq-client4cpp/include/MessageQueueListener.h
deleted file mode 100755
index 9f04c3e..0000000
--- a/rocketmq-client4cpp/include/MessageQueueListener.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * Copyright (C) 2013 kangliqiang ,kangliq@163.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef __RMQ_MESSAGEQUEUELISTENER_H__
-#define __RMQ_MESSAGEQUEUELISTENER_H__
-
-#include <set>
-#include "RocketMQClient.h"
-
-namespace rmq
-{
-	/**
-	 * Message Queue Listener
-	 *
-	 */
-	class MessageQueueListener
-	{
-	public:
-		virtual ~MessageQueueListener() {}
-		virtual void messageQueueChanged(const std::string& topic,
-			std::set<MessageQueue>& mqAll,
-			std::set<MessageQueue>& mqDivided)=0;
-	};
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/include/OffsetStore.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/include/OffsetStore.h b/rocketmq-client4cpp/include/OffsetStore.h
deleted file mode 100755
index a533750..0000000
--- a/rocketmq-client4cpp/include/OffsetStore.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#ifndef __RMQ_OFFSETSTORE_H__
-#define __RMQ_OFFSETSTORE_H__
-
-#include <set>
-#include <map>
-
-#include "RocketMQClient.h"
-
-namespace rmq
-{
-	class MessageQueue;
-
-	enum ReadOffsetType
-	{
-		READ_FROM_MEMORY,
-		READ_FROM_STORE,
-		MEMORY_FIRST_THEN_STORE,
-	};
-
-	/**
-	* Consumer Offset Store
-	*
-	*/
-	class OffsetStore
-	{
-	public:
-		virtual ~OffsetStore() {}
-
-		virtual void load()=0;
-
-		virtual void updateOffset(const MessageQueue& mq, long long offset, bool increaseOnly)=0;
-		virtual long long readOffset(const MessageQueue& mq, ReadOffsetType type)=0;
-
-		virtual void persistAll(std::set<MessageQueue>& mqs)=0;
-		virtual void persist(const MessageQueue& mq)=0;
-
-		virtual void removeOffset(const MessageQueue& mq)=0;
-
-		virtual std::map<MessageQueue, long long> cloneOffsetTable(const std::string& topic) = 0;
-	};
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/include/PullCallback.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/include/PullCallback.h b/rocketmq-client4cpp/include/PullCallback.h
deleted file mode 100755
index 47ade68..0000000
--- a/rocketmq-client4cpp/include/PullCallback.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Copyright (C) 2013 kangliqiang ,kangliq@163.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef __RMQ_PULLCALLBACK_H__
-#define __RMQ_PULLCALLBACK_H__
-
-#include "RocketMQClient.h"
-#include "PullResult.h"
-
-namespace rmq
-{
-	class MQException;
-
-	/**
-	 * PullCallback
-	 *
-	 */
-	class PullCallback
-	{
-	public:
-		virtual ~PullCallback() {}
-		virtual void onSuccess(PullResult& pullResult)=0;
-		virtual void onException(MQException& e)=0;
-	};
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/include/PullResult.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/include/PullResult.h b/rocketmq-client4cpp/include/PullResult.h
deleted file mode 100755
index 42c13ca..0000000
--- a/rocketmq-client4cpp/include/PullResult.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#ifndef __RMQ_PULLRESULT_H__
-#define __RMQ_PULLRESULT_H__
-
-#include <list>
-#include <string>
-#include <sstream>
-
-#include "RocketMQClient.h"
-#include "MessageExt.h"
-
-namespace rmq
-{
-	enum PullStatus
-	{
-		FOUND,
-		NO_NEW_MSG,
-		NO_MATCHED_MSG,
-		OFFSET_ILLEGAL
-	};
-
-	/**
-	* PullResult
-	*
-	*/
-	struct PullResult
-	{
-		PullResult()
-		{
-
-		}
-
-		PullResult(PullStatus pullStatus,
-				   long long nextBeginOffset,
-				   long long minOffset,
-				   long long maxOffset,
-				   std::list<MessageExt*>& msgFoundList)
-			:pullStatus(pullStatus),
-			 nextBeginOffset(nextBeginOffset),
-			 minOffset(minOffset),
-			 maxOffset(maxOffset),
-			 msgFoundList(msgFoundList)
-		{
-
-		}
-
-		~PullResult()
-		{
-			std::list<MessageExt*>::iterator it = msgFoundList.begin();
-
-			for (;it!=msgFoundList.end();it++)
-			{
-				delete *it;
-			}
-		}
-
-		std::string toString() const
-		{
-			std::stringstream ss;
-			ss 	<< "{pullStatus=" << pullStatus
-				<< ",nextBeginOffset=" << nextBeginOffset
-				<< ",minOffset=" << nextBeginOffset
-				<< ",maxOffset=" << nextBeginOffset
-				<< ",msgFoundList.size=" << msgFoundList.size()
-				<<"}";
-			return ss.str();
-		}
-
-		PullStatus pullStatus;
-		long long nextBeginOffset;
-		long long minOffset;
-		long long maxOffset;
-		std::list<MessageExt*> msgFoundList;
-	};
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/include/QueryResult.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/include/QueryResult.h b/rocketmq-client4cpp/include/QueryResult.h
deleted file mode 100644
index 13164e4..0000000
--- a/rocketmq-client4cpp/include/QueryResult.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __RMQ_QUERYRESULT_H__
-#define  __RMQ_QUERYRESULT_H__
-
-#include <list>
-
-#include "RocketMQClient.h"
-#include "MessageExt.h"
-
-namespace rmq
-{
-	/**
-	* QueryResult
-	*
-	*/
-	class QueryResult
-	{
-	public:
-		QueryResult(long long indexLastUpdateTimestamp, const std::list<MessageExt*>& messageList)
-		{
-			m_indexLastUpdateTimestamp = indexLastUpdateTimestamp;
-			m_messageList = messageList;
-		}
-
-		long long getIndexLastUpdateTimestamp()
-		{
-			return m_indexLastUpdateTimestamp;
-		}
-
-		std::list<MessageExt*>& getMessageList()
-		{
-			return m_messageList;
-		}
-
-	private:
-		long long m_indexLastUpdateTimestamp;
-		std::list<MessageExt*> m_messageList;
-	};
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/include/RocketMQClient.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/include/RocketMQClient.h b/rocketmq-client4cpp/include/RocketMQClient.h
deleted file mode 100755
index e4c71c9..0000000
--- a/rocketmq-client4cpp/include/RocketMQClient.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#ifndef __RMQ_ROCKETMQCLIENT_H__
-#define __RMQ_ROCKETMQCLIENT_H__
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <string.h>
-#include <assert.h>
-#include <time.h>
-#include <stdarg.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <signal.h>
-#include <pthread.h>
-
-#include <sys/time.h>
-#include <sys/timeb.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/file.h>
-#include <sys/syscall.h>
-#include <linux/unistd.h>
-
-#include <cstdio>
-#include <iostream>
-#include <string>
-#include <sstream>
-#include <vector>
-#include <map>
-#include <set>
-
-
-class RocketMQUtil
-{
-public:
-	enum
-    {
-        NONE_LOG    = 0,
-        ERROR_LOG   = 1,
-        WARN_LOG    = 2,
-        INFO_LOG    = 3,
-        DEBUG_LOG   = 4,
-    };
-
-public:
-	static pid_t getPid();
-	static pid_t getTid();
-
-	static int getDiffDays(time_t tmFirst, time_t tmSecond);
-	static std::string tm2str(const time_t &t, const std::string &sFormat);
-	static std::string now2str(const std::string &sFormat);
-	static std::string now2str();
-	static int64_t getNowMs();
-	static std::string str2fmt(const char* format, ...)__attribute__((format(__printf__,1,2)));
-
-	static int initLog(const std::string& sLogPath);
-	static void setLogLevel(int logLevel);
-	static void writeLog(const char* fmt, ...) __attribute__((format(__printf__,1,2)));
-	static inline bool isNeedLog(int level)
-	{
-		return (level <= _logLevel);
-	};
-
-public:
-	static volatile int _logFd;
-	static int _logLevel;
-	static std::string _logPath;
-};
-
-#define RMQ_AUTO(name, value) typeof(value) name = value
-#define RMQ_FOR_EACH(container, it) \
-    for(typeof((container).begin()) it = (container).begin();it!=(container).end(); ++it)
-
-
-
-#define RMQ_DEBUG(fmt, args...)	do{ if(RocketMQUtil::isNeedLog(RocketMQUtil::DEBUG_LOG)) RocketMQUtil::writeLog("%d-%d|[%s][%s:%s:%d][DEBUG]|"fmt"\n", RocketMQUtil::getPid(), RocketMQUtil::getTid(), RocketMQUtil::now2str().c_str(), __FILE__, __func__,__LINE__, ##args);}while(0)
-#define RMQ_INFO(fmt, args...)	do{ if(RocketMQUtil::isNeedLog(RocketMQUtil::INFO_LOG))  RocketMQUtil::writeLog("%d-%d|[%s][%s:%s:%d][INFO]|"fmt"\n", RocketMQUtil::getPid(), RocketMQUtil::getTid(), RocketMQUtil::now2str().c_str(), __FILE__, __func__, __LINE__, ##args);}while(0)
-#define RMQ_WARN(fmt, args...)	do{ if(RocketMQUtil::isNeedLog(RocketMQUtil::WARN_LOG))  RocketMQUtil::writeLog("%d-%d|[%s][%s:%s:%d][WARN]|"fmt"\n", RocketMQUtil::getPid(), RocketMQUtil::getTid(), RocketMQUtil::now2str().c_str(), __FILE__, __func__, __LINE__, ##args);}while(0)
-#define RMQ_ERROR(fmt, args...)	do{ if(RocketMQUtil::isNeedLog(RocketMQUtil::ERROR_LOG)) RocketMQUtil::writeLog("%d-%d|[%s][%s:%s:%d][ERROR]|"fmt"\n", RocketMQUtil::getPid(), RocketMQUtil::getTid(), RocketMQUtil::now2str().c_str(), __FILE__, __func__, __LINE__, ##args);}while(0)
-
-#define RMQ_PRINT(fmt, args...)	do{ printf("%d|[%s][%s:%s:%d][DEBUG]|"fmt"\n", RocketMQUtil::getTid(), RocketMQUtil::now2str().c_str(), __FILE__, __func__,__LINE__, ##args);}while(0)
-
-
-#endif
-

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/include/SendCallback.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/include/SendCallback.h b/rocketmq-client4cpp/include/SendCallback.h
deleted file mode 100755
index 0feb5a1..0000000
--- a/rocketmq-client4cpp/include/SendCallback.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#ifndef __RMQ_SENDCALLBACK_H__
-#define __RMQ_SENDCALLBACK_H__
-
-#include "SendResult.h"
-#include "RocketMQClient.h"
-
-namespace rmq
-{
-	class MQException;
-
-	/**
-	* Send Mesage Callback
-	*
-	*/
-	class SendCallback
-	{
-	public:
-		virtual ~SendCallback() {}
-		virtual void onSuccess(SendResult& sendResult)=0;
-		virtual void onException(MQException& e)=0;
-	};
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/include/SendMessageHook.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/include/SendMessageHook.h b/rocketmq-client4cpp/include/SendMessageHook.h
deleted file mode 100644
index 9869aa6..0000000
--- a/rocketmq-client4cpp/include/SendMessageHook.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#ifndef __RMQ_SENDMESSAGEHOOK_H__
-#define __RMQ_SENDMESSAGEHOOK_H__
-
-#include <string>
-
-#include "RocketMQClient.h"
-#include "Message.h"
-#include "MQClientException.h"
-
-namespace rmq
-{
-	class SendMessageContext
-	{
-	public:
-		std::string producerGroup;
-		Message msg;
-		MessageQueue mq;
-		std::string brokerAddr;
-		CommunicationMode communicationMode;
-		SendResult sendResult;
-		MQException* pException;
-		void* pArg;
-	};
-
-	class SendMessageHook
-	{
-	public:
-		virtual ~SendMessageHook() {}
-		virtual std::string hookName()=0;
-		virtual void sendMessageBefore(const SendMessageContext& context)=0;
-		virtual void sendMessageAfter(const SendMessageContext& context)=0;
-	};
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/include/SendResult.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/include/SendResult.h b/rocketmq-client4cpp/include/SendResult.h
deleted file mode 100755
index d6a3174..0000000
--- a/rocketmq-client4cpp/include/SendResult.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#ifndef __RMQ_SENDRESULT_H__
-#define __RMQ_SENDRESULT_H__
-
-#include "RocketMQClient.h"
-#include "MessageQueue.h"
-
-namespace rmq
-{
-	enum SendStatus
-	{
-		SEND_OK,
-		FLUSH_DISK_TIMEOUT,
-		FLUSH_SLAVE_TIMEOUT,
-		SLAVE_NOT_AVAILABLE
-	};
-
-	/**
-	* Send Message Result
-	*
-	*/
-	class SendResult
-	{
-	public:
-		SendResult();
-		SendResult(const SendStatus& sendStatus,
-			const std::string&  msgId,
-			MessageQueue& messageQueue,
-			long long queueOffset,
-			std::string&  projectGroupPrefix);
-
-		const std::string&  getMsgId();
-		void setMsgId(const std::string&  msgId);
-		SendStatus getSendStatus();
-		void setSendStatus(const SendStatus& sendStatus);
-		MessageQueue& getMessageQueue();
-		void setMessageQueue(MessageQueue& messageQueue);
-		long long getQueueOffset();
-		void setQueueOffset(long long queueOffset);
-		bool hasResult();
-
-		std::string toString() const;
-		std::string toJsonString() const;
-
-	private:
-		SendStatus m_sendStatus;
-		std::string m_msgId;
-		MessageQueue m_messageQueue;
-		long long m_queueOffset;
-	};
-
-	enum LocalTransactionState
-	{
-		COMMIT_MESSAGE,
-		ROLLBACK_MESSAGE,
-		UNKNOW,
-	};
-
-	/**
-	* Send transaction message result
-	*
-	*/
-	class TransactionSendResult : public SendResult
-	{
-	public:
-		TransactionSendResult();
-		LocalTransactionState getLocalTransactionState();
-		void setLocalTransactionState(LocalTransactionState localTransactionState);
-
-	private:
-		LocalTransactionState m_localTransactionState;
-	};
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/include/TopicFilterType.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/include/TopicFilterType.h b/rocketmq-client4cpp/include/TopicFilterType.h
deleted file mode 100755
index e51ae20..0000000
--- a/rocketmq-client4cpp/include/TopicFilterType.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * Copyright (C) 2013 kangliqiang ,kangliq@163.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef __RMQ_TOPICFILTERTYPE_H__
-#define __RMQ_TOPICFILTERTYPE_H__
-
-namespace rmq
-{
-	/**
-	 * Topic filter type
-	 *
-	 */
-	enum TopicFilterType
-	{
-		SINGLE_TAG,
-		MULTI_TAG
-	};
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/rocketmq.mk
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/rocketmq.mk b/rocketmq-client4cpp/rocketmq.mk
deleted file mode 100644
index eecc458..0000000
--- a/rocketmq-client4cpp/rocketmq.mk
+++ /dev/null
@@ -1,6 +0,0 @@
-ROCKETMQ_PATH := /data/libs/rocketmq
-
-INCLUDE += -I$(ROCKETMQ_PATH)/include 
-INCLUDE_32 += -I$(ROCKETMQ_PATH)/include -march=i686
-LIB_32 += -L$(ROCKETMQ_PATH)/lib32 -lrocketmq -lz -lrt -lpthread
-LIB_64 += -L$(ROCKETMQ_PATH)/lib64 -lrocketmq -lz -lrt -lpthread

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/ClientConfig.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/ClientConfig.cpp b/rocketmq-client4cpp/src/ClientConfig.cpp
deleted file mode 100755
index 986d67d..0000000
--- a/rocketmq-client4cpp/src/ClientConfig.cpp
+++ /dev/null
@@ -1,168 +0,0 @@
-/**
- * Copyright (C) 2010-2013 kangliqiang, kangliq@163.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <stdlib.h>
-#include <sstream>
-
-#include "MQClientException.h"
-#include "SocketUtil.h"
-#include "ClientConfig.h"
-#include "UtilAll.h"
-#include "MixAll.h"
-
-namespace rmq
-{
-
-ClientConfig::ClientConfig()
-{
-    char* addr = getenv(MixAll::NAMESRV_ADDR_ENV.c_str());
-    if (addr)
-    {
-        m_namesrvAddr = addr;
-    }
-    else
-    {
-        m_namesrvAddr = "";
-    }
-
-    m_clientIP = getLocalAddress();
-    m_instanceName = "DEFAULT";
-    m_clientCallbackExecutorThreads = UtilAll::availableProcessors();
-    m_pollNameServerInterval = 1000 * 30;
-    m_heartbeatBrokerInterval = 1000 * 30;
-    m_persistConsumerOffsetInterval = 1000 * 5;
-}
-
-ClientConfig::~ClientConfig()
-{
-}
-
-std::string ClientConfig::buildMQClientId()
-{
-    return m_clientIP + "@" + m_instanceName;
-}
-
-void ClientConfig::changeInstanceNameToPID()
-{
-    if (m_instanceName == "DEFAULT")
-    {
-        m_instanceName = UtilAll::toString(UtilAll::getPid());
-    }
-}
-
-
-void ClientConfig::resetClientConfig(const ClientConfig& cc)
-{
-    m_namesrvAddr = cc.m_namesrvAddr;
-    m_clientIP = cc.m_clientIP;
-    m_instanceName = cc.m_instanceName;
-    m_clientCallbackExecutorThreads = cc.m_clientCallbackExecutorThreads;
-    m_pollNameServerInterval = cc.m_pollNameServerInterval;
-    m_heartbeatBrokerInterval = cc.m_heartbeatBrokerInterval;
-    m_persistConsumerOffsetInterval = cc.m_persistConsumerOffsetInterval;
-}
-
-ClientConfig ClientConfig::cloneClientConfig()
-{
-    return *this;
-}
-
-std::string ClientConfig::getNamesrvAddr()
-{
-    return m_namesrvAddr;
-}
-
-void ClientConfig::setNamesrvAddr(const std::string& namesrvAddr)
-{
-    m_namesrvAddr = namesrvAddr;
-}
-
-std::string ClientConfig::getClientIP()
-{
-    return m_clientIP;
-}
-
-void ClientConfig::setClientIP(const std::string& clientIP)
-{
-    m_clientIP = clientIP;
-}
-
-std::string ClientConfig::getInstanceName()
-{
-    return m_instanceName;
-}
-
-void ClientConfig::setInstanceName(const std::string& instanceName)
-{
-    m_instanceName = instanceName;
-}
-
-int ClientConfig::getClientCallbackExecutorThreads()
-{
-    return m_clientCallbackExecutorThreads;
-}
-
-void ClientConfig::setClientCallbackExecutorThreads(int clientCallbackExecutorThreads)
-{
-    m_clientCallbackExecutorThreads = clientCallbackExecutorThreads;
-}
-
-int ClientConfig::getPollNameServerInterval()
-{
-    return m_pollNameServerInterval;
-}
-
-void ClientConfig::setPollNameServerInterval(int pollNameServerInterval)
-{
-    m_pollNameServerInterval = pollNameServerInterval;
-}
-
-int ClientConfig::getHeartbeatBrokerInterval()
-{
-    return m_heartbeatBrokerInterval;
-}
-
-void ClientConfig::setHeartbeatBrokerInterval(int heartbeatBrokerInterval)
-{
-    m_heartbeatBrokerInterval = heartbeatBrokerInterval;
-}
-
-int ClientConfig:: getPersistConsumerOffsetInterval()
-{
-    return m_persistConsumerOffsetInterval;
-}
-
-void ClientConfig::setPersistConsumerOffsetInterval(int persistConsumerOffsetInterval)
-{
-    m_persistConsumerOffsetInterval = persistConsumerOffsetInterval;
-}
-
-
-std::string ClientConfig::toString() const
-{
-	std::stringstream ss;
-	ss 	<< "{namesrvAddr=" << m_namesrvAddr
-		<< ",clientIP=" << m_clientIP
-		<< ",instanceName=" << m_instanceName
-		<< ",clientCallbackExecutorThreads=" << m_clientCallbackExecutorThreads
-		<< ",pollNameServerInteval=" << m_pollNameServerInterval
-		<< ",heartbeatBrokerInterval=" << m_heartbeatBrokerInterval
-		<< ",persistConsumerOffsetInterval=" << m_persistConsumerOffsetInterval
-		<<"}";
-	return ss.str();
-}
-
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/ClientRemotingProcessor.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/ClientRemotingProcessor.cpp b/rocketmq-client4cpp/src/ClientRemotingProcessor.cpp
deleted file mode 100755
index ae88de5..0000000
--- a/rocketmq-client4cpp/src/ClientRemotingProcessor.cpp
+++ /dev/null
@@ -1,154 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#include "ClientRemotingProcessor.h"
-#include "MQProtos.h"
-#include "TcpTransport.h"
-#include "RemotingCommand.h"
-#include "MQClientFactory.h"
-#include "CommandCustomHeader.h"
-#include "ConsumerRunningInfo.h"
-
-
-
-namespace rmq
-{
-
-ClientRemotingProcessor::ClientRemotingProcessor(MQClientFactory* pMQClientFactory)
-    : m_pMQClientFactory(pMQClientFactory)
-{
-
-}
-
-RemotingCommand* ClientRemotingProcessor::processRequest(TcpTransport* pTts, RemotingCommand* pRequest)
-{
-    int code = pRequest->getCode();
-    switch (code)
-    {
-        case CHECK_TRANSACTION_STATE_VALUE:
-            return checkTransactionState(pTts, pRequest);
-        case NOTIFY_CONSUMER_IDS_CHANGED_VALUE:
-            return notifyConsumerIdsChanged(pTts, pRequest);
-        case RESET_CONSUMER_CLIENT_OFFSET_VALUE:
-            return resetOffset(pTts, pRequest);
-        case GET_CONSUMER_STATUS_FROM_CLIENT_VALUE:
-            return getConsumeStatus(pTts, pRequest);
-        case GET_CONSUMER_RUNNING_INFO_VALUE:
-            return getConsumerRunningInfo(pTts, pRequest);
-        case CONSUME_MESSAGE_DIRECTLY_VALUE:
-            return consumeMessageDirectly(pTts, pRequest);
-        default:
-            break;
-    }
-
-    return NULL;
-}
-
-RemotingCommand* ClientRemotingProcessor::checkTransactionState(TcpTransport* pTts, RemotingCommand* pRequest)
-{
-    //TODO
-    return NULL;
-}
-
-RemotingCommand* ClientRemotingProcessor::notifyConsumerIdsChanged(TcpTransport* pTts, RemotingCommand* pRequest)
-{
-    try
-    {
-        NotifyConsumerIdsChangedRequestHeader* extHeader = (NotifyConsumerIdsChangedRequestHeader*)pRequest->getCommandCustomHeader();
-        RMQ_INFO("receive broker's notification[{%s}], the consumer group: {%s} changed, rebalance immediately",
-                pTts->getServerAddr().c_str(),
-                extHeader->consumerGroup.c_str());
-        m_pMQClientFactory->rebalanceImmediately();
-    }
-    catch (std::exception& e)
-    {
-        RMQ_ERROR("notifyConsumerIdsChanged exception: %s", e.what());
-    }
-
-    return NULL;
-}
-
-RemotingCommand* ClientRemotingProcessor::resetOffset(TcpTransport* pTts, RemotingCommand* pRequest)
-{
-    //TODO
-    return NULL;
-}
-
-
-RemotingCommand* ClientRemotingProcessor::getConsumeStatus(TcpTransport* pTts, RemotingCommand* pRequest)
-{
-    //TODO
-    return NULL;
-}
-
-
-RemotingCommand* ClientRemotingProcessor::getConsumerRunningInfo(TcpTransport* pTts, RemotingCommand* pRequest)
-{
-	return NULL;
-
-	/*
-    GetConsumerRunningInfoRequestHeader* requestHeader = (GetConsumerRunningInfoRequestHeader)pRequest->getCommandCustomHeader();
-	RemotingCommand* pResponse = RemotingCommand::createResponseCommand(NULL);
-
-	pResponse = RemotingCommand::createResponseCommand(
-					REQUEST_CODE_NOT_SUPPORTED_VALUE, "request type not supported", NULL);
-	pResponse->setOpaque(pCmd->getOpaque());
-
-    ConsumerRunningInfo* consumerRunningInfo = m_pMQClientFactory->consumerRunningInfo(requestHeader->consumerGroup);
-    if (NULL != consumerRunningInfo) {
-        response.setCode(ResponseCode.SUCCESS);
-        response.setBody(consumerRunningInfo.encode());
-    } else {
-        response.setCode(ResponseCode.SYSTEM_ERROR);
-        response.setRemark(String.format("The Consumer Group <%s> not exist in this consumer",
-                requestHeader.getConsumerGroup()));
-    }
-    return pResponse;
-
-	// java
-    final RemotingCommand response = RemotingCommand.createResponseCommand(null);
-    final GetConsumerRunningInfoRequestHeader requestHeader =
-            (GetConsumerRunningInfoRequestHeader) request
-                    .decodeCommandCustomHeader(GetConsumerRunningInfoRequestHeader.class);
-
-    ConsumerRunningInfo consumerRunningInfo =
-            this.mqClientFactory.consumerRunningInfo(requestHeader.getConsumerGroup());
-    if (null != consumerRunningInfo) {
-        if (requestHeader.isJstackEnable()) {
-            String jstack = UtilAll.jstack();
-            consumerRunningInfo.setJstack(jstack);
-        }
-
-        response.setCode(ResponseCode.SUCCESS);
-        response.setBody(consumerRunningInfo.encode());
-    } else {
-        response.setCode(ResponseCode.SYSTEM_ERROR);
-        response.setRemark(String.format("The Consumer Group <%s> not exist in this consumer",
-                requestHeader.getConsumerGroup()));
-    }
-
-    return response;
-    */
-}
-
-
-RemotingCommand* ClientRemotingProcessor::consumeMessageDirectly(TcpTransport* pTts, RemotingCommand* pRequest)
-{
-    //TODO
-    return NULL;
-}
-
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/ClientRemotingProcessor.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/ClientRemotingProcessor.h b/rocketmq-client4cpp/src/ClientRemotingProcessor.h
deleted file mode 100755
index 4cd2873..0000000
--- a/rocketmq-client4cpp/src/ClientRemotingProcessor.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __CLIENTREMOTINGPROCESSOR_H__
-#define __CLIENTREMOTINGPROCESSOR_H__
-
-#include "TcpRequestProcessor.h"
-
-namespace rmq
-{
-	class MQClientFactory;
-	class RemotingCommand;
-
-	class ClientRemotingProcessor : public TcpRequestProcessor
-	{
-	public:
-	    ClientRemotingProcessor(MQClientFactory* pMQClientFactory);
-
-	    RemotingCommand* processRequest(TcpTransport* pTts, RemotingCommand* pRequest);
-	    RemotingCommand* checkTransactionState(TcpTransport* pTts, RemotingCommand* pRequest);
-	    RemotingCommand* notifyConsumerIdsChanged(TcpTransport* pTts, RemotingCommand* pRequest);
-	    RemotingCommand* resetOffset(TcpTransport* pTts, RemotingCommand* pRequest);
-	    RemotingCommand* getConsumeStatus(TcpTransport* pTts, RemotingCommand* pRequest);
-	    RemotingCommand* getConsumerRunningInfo(TcpTransport* pTts, RemotingCommand* pRequest);
-	    RemotingCommand* consumeMessageDirectly(TcpTransport* pTts, RemotingCommand* pRequest);
-
-	private:
-	    MQClientFactory* m_pMQClientFactory;
-	};
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/CommunicationMode.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/CommunicationMode.h b/rocketmq-client4cpp/src/CommunicationMode.h
deleted file mode 100755
index 43b2941..0000000
--- a/rocketmq-client4cpp/src/CommunicationMode.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * Copyright (C) 2013 kangliqiang ,kangliq@163.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __COMMUNICATIONMODE_H__
-#define __COMMUNICATIONMODE_H__
-
-namespace rmq
-{
-	/**
-	 * Communication Mode
-	 *
-	 */
-	enum CommunicationMode
-	{
-	    SYNC,
-	    ASYNC,
-	    ONEWAY
-	};
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/FindBrokerResult.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/FindBrokerResult.h b/rocketmq-client4cpp/src/FindBrokerResult.h
deleted file mode 100644
index 51a9845..0000000
--- a/rocketmq-client4cpp/src/FindBrokerResult.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#ifndef __FINDBROKERRESULT_H__
-#define __FINDBROKERRESULT_H__
-
-namespace rmq
-{
-	typedef struct
-	{
-	    std::string brokerAddr;
-	    bool slave;
-	} FindBrokerResult;
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/MQAdminImpl.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/MQAdminImpl.cpp b/rocketmq-client4cpp/src/MQAdminImpl.cpp
deleted file mode 100755
index 2a6b597..0000000
--- a/rocketmq-client4cpp/src/MQAdminImpl.cpp
+++ /dev/null
@@ -1,295 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#include <list>
-#include "SocketUtil.h"
-#include "MQAdminImpl.h"
-#include "MQClientFactory.h"
-#include "MQClientAPIImpl.h"
-#include "MQClientException.h"
-#include "TopicConfig.h"
-#include "TopicPublishInfo.h"
-#include "MessageId.h"
-#include "MessageDecoder.h"
-
-namespace rmq
-{
-
-
-MQAdminImpl::MQAdminImpl(MQClientFactory* pMQClientFactory)
-{
-    m_pMQClientFactory = pMQClientFactory;
-}
-
-MQAdminImpl::~MQAdminImpl()
-{
-
-}
-
-void MQAdminImpl::createTopic(const std::string& key, const std::string& newTopic,
-	int queueNum)
-{
-	return createTopic(key, newTopic, queueNum, 0);
-}
-
-
-void MQAdminImpl::createTopic(const std::string& key, const std::string& newTopic,
-	int queueNum, int topicSysFlag)
-{
-    try
-    {
-        MQClientAPIImpl* api = m_pMQClientFactory->getMQClientAPIImpl();
-        TopicRouteDataPtr topicRouteData = api->getTopicRouteInfoFromNameServer(key, 1000 * 3);
-
-        std::list<BrokerData> brokerDataList = topicRouteData->getBrokerDatas();
-        if (!brokerDataList.empty())
-        {
-            brokerDataList.sort();
-
-            MQClientException exception("", 0, "", 0);
-            bool hasException = false;
-
-            std::list<BrokerData>::iterator it = brokerDataList.begin();
-
-            for (; it != brokerDataList.end(); it++)
-            {
-                std::map<int, std::string>::iterator it1 = (*it).brokerAddrs.find(MixAll::MASTER_ID);
-                if (it1 != (*it).brokerAddrs.end())
-                {
-                    std::string addr = it1->second;
-
-                    TopicConfig topicConfig(newTopic);
-                    topicConfig.setReadQueueNums(queueNum);
-                    topicConfig.setWriteQueueNums(queueNum);
-                    topicConfig.setTopicSysFlag(topicSysFlag);
-
-                    try
-                    {
-                        api->createTopic(addr, key, topicConfig, 1000 * 3);
-                    }
-                    catch (MQClientException& e)
-                    {
-                        hasException = true;
-                        exception = e;
-                    }
-                }
-            }
-
-            if (hasException)
-            {
-                throw exception;
-            }
-        }
-        else
-        {
-            THROW_MQEXCEPTION(MQClientException, "Not found broker, maybe key is wrong", -1);
-        }
-    }
-    catch (MQClientException e)
-    {
-        THROW_MQEXCEPTION(MQClientException, "create new topic failed", -1);
-    }
-}
-
-std::vector<MessageQueue>* MQAdminImpl::fetchPublishMessageQueues(const std::string& topic)
-{
-    try
-    {
-        MQClientAPIImpl* api = m_pMQClientFactory->getMQClientAPIImpl();
-        TopicRouteDataPtr topicRouteData = api->getTopicRouteInfoFromNameServer(topic, 1000 * 3);
-
-        if (topicRouteData.ptr() != NULL)
-        {
-            TopicPublishInfoPtr topicPublishInfo =
-                MQClientFactory::topicRouteData2TopicPublishInfo(topic, *topicRouteData);
-            if (topicPublishInfo.ptr() != NULL && topicPublishInfo->ok())
-            {
-                std::vector<MessageQueue>* ret = new std::vector<MessageQueue>();
-                (*ret) = topicPublishInfo->getMessageQueueList();
-
-				/*
-                std::vector<MessageQueue>& mqs = ;
-                std::vector<MessageQueue>::iterator it = mqs.begin();
-                for (; it != mqs.end(); it++)
-                {
-                    ret->push_back(*it);
-                }
-                */
-
-                return ret;
-            }
-        }
-    }
-    catch (MQClientException e)
-    {
-        THROW_MQEXCEPTION(MQClientException, "Can not find Message Queue for this topic" + topic, -1);
-    }
-
-    THROW_MQEXCEPTION(MQClientException, "Unknow why, Can not find Message Queue for this topic, " + topic, -1);
-}
-
-std::set<MessageQueue>* MQAdminImpl::fetchSubscribeMessageQueues(const std::string& topic)
-{
-    try
-    {
-        TopicRouteDataPtr topicRouteData =
-            m_pMQClientFactory->getMQClientAPIImpl()->getTopicRouteInfoFromNameServer(topic, 1000 * 3);
-        if (topicRouteData.ptr() != NULL)
-        {
-            std::set<MessageQueue>* mqList =
-                MQClientFactory::topicRouteData2TopicSubscribeInfo(topic, *topicRouteData);
-            if (!mqList->empty())
-            {
-                return mqList;
-            }
-            else
-            {
-                THROW_MQEXCEPTION(MQClientException, "Can not find Message Queue for this topic" + topic, -1);
-            }
-        }
-    }
-    catch (MQClientException e)
-    {
-        THROW_MQEXCEPTION(MQClientException, "Can not find Message Queue for this topic" + topic, -1);
-    }
-
-    THROW_MQEXCEPTION(MQClientException, "Unknow why, Can not find Message Queue for this topic: " + topic, -1);
-}
-
-long long MQAdminImpl::searchOffset(const MessageQueue& mq, long long timestamp)
-{
-    std::string brokerAddr = m_pMQClientFactory->findBrokerAddressInPublish(mq.getBrokerName());
-    if (brokerAddr.empty())
-    {
-        m_pMQClientFactory->updateTopicRouteInfoFromNameServer(mq.getTopic());
-        brokerAddr = m_pMQClientFactory->findBrokerAddressInPublish(mq.getBrokerName());
-    }
-
-    if (!brokerAddr.empty())
-    {
-        try
-        {
-            return m_pMQClientFactory->getMQClientAPIImpl()->searchOffset(brokerAddr, mq.getTopic(),
-                    mq.getQueueId(), timestamp, 1000 * 3);
-        }
-        catch (MQClientException e)
-        {
-            THROW_MQEXCEPTION(MQClientException, "Invoke Broker[" + brokerAddr + "] exception", -1);
-        }
-    }
-    THROW_MQEXCEPTION(MQClientException, "The broker[" + mq.getBrokerName() + "] not exist", -1);
-}
-
-long long MQAdminImpl::maxOffset(const MessageQueue& mq)
-{
-    std::string brokerAddr = m_pMQClientFactory->findBrokerAddressInPublish(mq.getBrokerName());
-    if (brokerAddr.empty())
-    {
-        m_pMQClientFactory->updateTopicRouteInfoFromNameServer(mq.getTopic());
-        brokerAddr = m_pMQClientFactory->findBrokerAddressInPublish(mq.getBrokerName());
-    }
-
-    if (!brokerAddr.empty())
-    {
-        try
-        {
-            return m_pMQClientFactory->getMQClientAPIImpl()->getMaxOffset(brokerAddr, mq.getTopic(),
-                    mq.getQueueId(), 1000 * 3);
-        }
-        catch (MQClientException e)
-        {
-            THROW_MQEXCEPTION(MQClientException, "Invoke Broker[" + brokerAddr + "] exception", -1);
-        }
-    }
-    THROW_MQEXCEPTION(MQClientException, "The broker[" + mq.getBrokerName() + "] not exist", -1);
-}
-
-long long MQAdminImpl::minOffset(const MessageQueue& mq)
-{
-    std::string brokerAddr = m_pMQClientFactory->findBrokerAddressInPublish(mq.getBrokerName());
-    if (brokerAddr.empty())
-    {
-        m_pMQClientFactory->updateTopicRouteInfoFromNameServer(mq.getTopic());
-        brokerAddr = m_pMQClientFactory->findBrokerAddressInPublish(mq.getBrokerName());
-    }
-
-    if (!brokerAddr.empty())
-    {
-        try
-        {
-            return m_pMQClientFactory->getMQClientAPIImpl()->getMinOffset(brokerAddr, mq.getTopic(),
-                    mq.getQueueId(), 1000 * 3);
-        }
-        catch (MQClientException e)
-        {
-            THROW_MQEXCEPTION(MQClientException, "Invoke Broker[" + brokerAddr + "] exception", -1);
-        }
-    }
-
-    THROW_MQEXCEPTION(MQClientException, "The broker[" + mq.getBrokerName() + "] not exist", -1);
-}
-
-long long MQAdminImpl::earliestMsgStoreTime(const MessageQueue& mq)
-{
-    std::string brokerAddr = m_pMQClientFactory->findBrokerAddressInPublish(mq.getBrokerName());
-    if (brokerAddr.empty())
-    {
-        m_pMQClientFactory->updateTopicRouteInfoFromNameServer(mq.getTopic());
-        brokerAddr = m_pMQClientFactory->findBrokerAddressInPublish(mq.getBrokerName());
-    }
-
-    if (!brokerAddr.empty())
-    {
-        try
-        {
-            return m_pMQClientFactory->getMQClientAPIImpl()->getEarliestMsgStoretime(brokerAddr,
-                    mq.getTopic(), mq.getQueueId(), 1000 * 3);
-        }
-        catch (MQClientException e)
-        {
-            THROW_MQEXCEPTION(MQClientException, "Invoke Broker[" + brokerAddr + "] exception", -1);
-        }
-    }
-
-    THROW_MQEXCEPTION(MQClientException, "The broker[" + mq.getBrokerName() + "] not exist", -1);
-}
-
-MessageExt* MQAdminImpl::viewMessage(const std::string& msgId)
-{
-    try
-    {
-        MessageId messageId = MessageDecoder::decodeMessageId(msgId);
-        return m_pMQClientFactory->getMQClientAPIImpl()->viewMessage(
-                   socketAddress2String(messageId.getAddress()), messageId.getOffset(), 1000 * 3);
-    }
-    catch (UnknownHostException e)
-    {
-        THROW_MQEXCEPTION(MQClientException, "message id illegal", -1);
-    }
-}
-
-QueryResult MQAdminImpl::queryMessage(const std::string& topic,
-                                      const std::string& key,
-                                      int maxNum, long long begin, long long end)
-{
-    //TODO
-    std::list<MessageExt*> messageList;
-    QueryResult result(0, messageList);
-
-    return result;
-}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/MQAdminImpl.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/MQAdminImpl.h b/rocketmq-client4cpp/src/MQAdminImpl.h
deleted file mode 100755
index 907d61e..0000000
--- a/rocketmq-client4cpp/src/MQAdminImpl.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __MQADMINIMPL_H__
-#define __MQADMINIMPL_H__
-
-#include <string>
-#include <list>
-#include <set>
-#include <vector>
-
-#include "MessageExt.h"
-#include "QueryResult.h"
-
-namespace rmq
-{
-    class MQClientFactory;
-    class MessageQueue;
-
-    class MQAdminImpl
-    {
-    public:
-        MQAdminImpl(MQClientFactory* pMQClientFactory);
-        ~MQAdminImpl();
-
-        void createTopic(const std::string& key, const std::string& newTopic, int queueNum);
-		void createTopic(const std::string& key, const std::string& newTopic, int queueNum, int topicSysFlag);
-
-        std::vector<MessageQueue>* fetchPublishMessageQueues(const std::string& topic);
-        std::set<MessageQueue>* fetchSubscribeMessageQueues(const std::string& topic);
-        long long searchOffset(const MessageQueue& mq, long long timestamp);
-        long long maxOffset(const MessageQueue& mq);
-        long long minOffset(const MessageQueue& mq);
-
-        long long earliestMsgStoreTime(const MessageQueue& mq);
-
-        MessageExt* viewMessage(const std::string& msgId);
-
-        QueryResult queryMessage(const std::string& topic,
-                                 const std::string& key,
-                                 int maxNum,
-                                 long long begin,
-                                 long long end);
-
-    private:
-        MQClientFactory* m_pMQClientFactory;
-    };
-}
-
-#endif


[05/17] incubator-rocketmq-externals git commit: Polish cpp module

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/kpr/Mutex.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/kpr/Mutex.cpp b/rocketmq-client4cpp/src/kpr/Mutex.cpp
deleted file mode 100755
index f98282c..0000000
--- a/rocketmq-client4cpp/src/kpr/Mutex.cpp
+++ /dev/null
@@ -1,296 +0,0 @@
-/**
- * Copyright (C) 2013 kangliqiang ,kangliq@163.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "Mutex.h"
-
-#include <pthread.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <errno.h>
-#include <time.h>
-
-
-namespace kpr
-{
-Mutex::Mutex()
-{
-    ::pthread_mutex_init(&m_mutex,  NULL);
-}
-
-Mutex::~Mutex()
-{
-    ::pthread_mutex_destroy(&m_mutex);
-}
-
-void Mutex::Lock() const
-{
-    ::pthread_mutex_lock(&m_mutex);
-}
-
-bool Mutex::TryLock() const
-{
-    int ret = ::pthread_mutex_trylock(&m_mutex);
-    return (ret == 0);
-}
-
-bool Mutex::TryLock(int timeout) const
-{
-	struct timespec ts;
-	clock_gettime(CLOCK_REALTIME, &ts);
-	ts.tv_sec += (timeout/1000);
-	ts.tv_nsec += (timeout%1000) * 1000 * 1000;
-
-    int ret = ::pthread_mutex_timedlock(&m_mutex, &ts);
-    return (ret == 0);
-}
-
-
-void Mutex::Unlock() const
-{
-    ::pthread_mutex_unlock(&m_mutex);
-}
-
-//***********
-//RWMutex
-//***************
-RWMutex::RWMutex()
-{
-    ::pthread_rwlock_init(&m_mutex,  NULL);
-}
-
-RWMutex::~RWMutex()
-{
-    ::pthread_rwlock_destroy(&m_mutex);
-}
-
-void RWMutex::ReadLock() const
-{
-    ::pthread_rwlock_rdlock(&m_mutex);
-}
-
-void RWMutex::WriteLock() const
-{
-    ::pthread_rwlock_wrlock(&m_mutex);
-}
-
-bool RWMutex::TryReadLock() const
-{
-    int ret = ::pthread_rwlock_tryrdlock(&m_mutex);
-    return (ret == 0);
-}
-
-bool RWMutex::TryReadLock(int timeout) const
-{
-	struct timespec ts;
-	clock_gettime(CLOCK_REALTIME, &ts);
-	ts.tv_sec += (timeout/1000);
-	ts.tv_nsec += (timeout%1000) * 1000 * 1000;
-
-    int ret = ::pthread_rwlock_timedrdlock(&m_mutex, &ts);
-    return (ret == 0);
-}
-
-bool RWMutex::TryWriteLock() const
-{
-    int ret = ::pthread_rwlock_trywrlock(&m_mutex);
-    return (ret == 0);
-}
-
-bool RWMutex::TryWriteLock(int timeout) const
-{
-	struct timespec ts;
-	clock_gettime(CLOCK_REALTIME, &ts);
-	ts.tv_sec += (timeout/1000);
-	ts.tv_nsec += (timeout%1000) * 1000 * 1000;
-
-    int ret = ::pthread_rwlock_timedwrlock(&m_mutex, &ts);
-    return (ret == 0);
-}
-
-
-void RWMutex::Unlock() const
-{
-    ::pthread_rwlock_unlock(&m_mutex);
-}
-
-
-//***********
-//RecursiveMutex
-//***************
-RecursiveMutex::RecursiveMutex()
-    : m_count(0),
-      m_owner(ThreadId())
-{
-    ::pthread_mutex_init(&m_mutex,  NULL);
-}
-
-RecursiveMutex::~RecursiveMutex()
-{
-    ::pthread_mutex_destroy(&m_mutex);
-}
-
-bool RecursiveMutex::Lock()const
-{
-    return ((RecursiveMutex*)this)->lock(1);
-}
-
-bool RecursiveMutex::Unlock()const
-{
-    return ((RecursiveMutex*)this)->unlock();
-}
-
-bool RecursiveMutex::TryLock()const
-{
-    return ((RecursiveMutex*)this)->tryLock();
-}
-
-ThreadId RecursiveMutex::GetOwner()const
-{
-    m_internal.Lock();
-    ThreadId id;
-    if (m_count > 0)
-    {
-        id = m_owner;
-    }
-    m_internal.Unlock();
-
-    return id;
-}
-
-bool RecursiveMutex::lock(int count)
-{
-    bool rc = false;
-    bool obtained = false;
-
-    while (!obtained)
-    {
-        m_internal.Lock();
-
-        if (m_count == 0)
-        {
-            m_count = count;
-            m_owner = ThreadId::GetCurrentThreadId();
-            obtained = true;
-            rc = true;
-
-            try
-            {
-                ::pthread_mutex_lock(&m_mutex);
-            }
-            catch (...)
-            {
-                try
-                {
-                    m_internal.Unlock();
-                }
-                catch (...)
-                {
-                }
-                throw;
-            }
-        }
-        else if (m_owner == ThreadId::GetCurrentThreadId())
-        {
-            m_count += count;
-            obtained = true;
-        }
-
-        m_internal.Unlock();
-
-        if (!obtained)
-        {
-            ::pthread_mutex_lock(&m_mutex);
-            ::pthread_mutex_unlock(&m_mutex);
-        }
-    }
-
-    return rc;
-}
-
-bool RecursiveMutex::tryLock()
-{
-    bool obtained = false;
-
-    m_internal.Lock();
-
-    if (m_count == 0)
-    {
-        m_count = 1;
-        m_owner = ThreadId::GetCurrentThreadId();
-        obtained = true;
-
-        try
-        {
-            ::pthread_mutex_lock(&m_mutex);
-        }
-        catch (...)
-        {
-            try
-            {
-                m_internal.Unlock();
-            }
-            catch (...)
-            {
-            }
-            throw;
-        }
-    }
-    else if (m_owner == ThreadId::GetCurrentThreadId())
-    {
-        ++m_count;
-        obtained = true;
-    }
-
-    m_internal.Unlock();
-
-    return obtained;
-}
-
-bool RecursiveMutex::unlock()
-{
-    bool rc;
-    m_internal.Lock();
-
-    if (--m_count == 0)
-    {
-        m_owner = ThreadId();
-
-        ::pthread_mutex_unlock(&m_mutex);
-
-        rc = true;
-    }
-    else
-    {
-        rc = false;
-    }
-
-    m_internal.Unlock();
-
-    return rc;
-}
-
-unsigned int RecursiveMutex::reset4Condvar()
-{
-    m_internal.Lock();
-
-    unsigned int count = m_count;
-    m_count = 0;
-    m_owner = ThreadId();
-
-    m_internal.Unlock();
-
-    return count;
-}
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/kpr/Mutex.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/kpr/Mutex.h b/rocketmq-client4cpp/src/kpr/Mutex.h
deleted file mode 100755
index fc3498f..0000000
--- a/rocketmq-client4cpp/src/kpr/Mutex.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/**
- * Copyright (C) 2013 kangliqiang ,kangliq@163.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef __KPR_MUTEX_H__
-#define __KPR_MUTEX_H__
-
-#include "KPRTypes.h"
-#include <errno.h>
-
-namespace kpr
-{
-class Mutex
-{
-public:
-    Mutex();
-    ~Mutex();
-
-    void Lock()const;
-    void Unlock()const;
-    bool TryLock()const;
-	bool TryLock(int timeout) const;
-
-    ThreadId GetOwner()const;
-
-private:
-    Mutex(const Mutex&);
-    const Mutex& operator=(const Mutex&);
-
-    mutable pthread_mutex_t m_mutex;
-    friend class Condition;
-};
-
-class RWMutex
-{
-public:
-    RWMutex();
-    ~RWMutex();
-
-    void ReadLock()const;
-    void WriteLock()const;
-    bool TryReadLock()const;
-	bool TryReadLock(int timeout) const;
-    bool TryWriteLock()const;
-	bool TryWriteLock(int timeout)const;
-    void Unlock()const;
-
-    ThreadId GetOwner()const;
-
-private:
-    RWMutex(const RWMutex&);
-    const RWMutex& operator=(const RWMutex&);
-
-    mutable pthread_rwlock_t m_mutex;
-    friend class Condition;
-};
-
-class RecursiveMutex
-{
-public:
-    RecursiveMutex();
-    ~RecursiveMutex();
-
-    bool Lock()const;
-    bool Unlock()const;
-    bool TryLock()const;
-
-    ThreadId GetOwner()const;
-
-    unsigned int GetCount()const
-    {
-        return m_count;
-    }
-
-private:
-    RecursiveMutex(const RecursiveMutex&);
-
-    const RecursiveMutex& operator=(const RecursiveMutex&);
-
-    bool  lock(int count);
-    bool  tryLock();
-    bool unlock();
-
-    unsigned int reset4Condvar();
-
-private:
-    pthread_mutex_t m_mutex;
-    Mutex m_internal;
-    mutable unsigned int m_count;
-    mutable ThreadId m_owner;
-
-    friend class Condition;
-    friend class ConditionHelper;
-};
-}
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/kpr/RefHandle.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/kpr/RefHandle.h b/rocketmq-client4cpp/src/kpr/RefHandle.h
deleted file mode 100644
index fd7d741..0000000
--- a/rocketmq-client4cpp/src/kpr/RefHandle.h
+++ /dev/null
@@ -1,328 +0,0 @@
-/**
- * Copyright (C) 2013 kangliqiang ,kangliq@163.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef __KPR_REFHANDLET_H__
-#define __KPR_REFHANDLET_H__
-
-#include "KPRTypes.h"
-#include "AtomicValue.h"
-#include "Exception.h"
-
-namespace kpr
-{
-
-class RefCount
-{
-public:
-	RefCount& operator=(const RefCount&)
-	{
-    	return *this;
-	}
-
-	void incRef()
-	{
-    	m_refCount++;
-	}
-
-	void decRef()
-	{
-	    if (--m_refCount == 0 && !m_noDelete)
-	    {
-	    	m_noDelete = true;
-	        delete this;
-	    }
-	}
-
-	int getRef() const
-	{
-		return m_refCount.get();
-	}
-
-	void setNoDelete(bool b)
-	{
-		m_noDelete = b;
-	}
-
-protected:
-	RefCount()
-    	: m_refCount(0), m_noDelete(false)
-	{
-	}
-
-	RefCount(const RefCount&)
-	    : m_refCount(0), m_noDelete(false)
-	{
-	}
-
-	virtual ~RefCount()
-	{
-	}
-
-protected:
-	AtomicInteger m_refCount;
-	bool		m_noDelete;
-};
-
-
-
-template <class T>
-class RefHandleT
-{
-public:
-    RefHandleT(T* p = 0)
-    {
-		m_ptr = p;
-
-		if (m_ptr)
-		{
-			m_ptr->incRef();
-		}
-    }
-
-	template<typename Y>
-    RefHandleT(const RefHandleT<Y>& v)
-    {
-		m_ptr = v.m_ptr;
-
-		if (m_ptr)
-		{
-			m_ptr->incRef();
-		}
-    }
-
-	RefHandleT(const RefHandleT& v)
-    {
-		m_ptr = v.m_ptr;
-
-		if (m_ptr)
-		{
-			m_ptr->incRef();
-		}
-    }
-
-    ~RefHandleT()
-    {
-		if (m_ptr)
-        {
-            m_ptr->decRef();
-        }
-    }
-
-	RefHandleT<T>& operator=(T* p)
-    {
-        if (m_ptr != p)
-        {
-			if (p)
-            {
-                p->incRef();
-            }
-
-			T* ptr = m_ptr;
-            m_ptr = p;
-
-            if (ptr)
-            {
-                ptr->decRef();
-            }
-        }
-
-        return *this;
-    }
-
-	template<typename Y>
-	RefHandleT<T>& operator=(const RefHandleT<Y>& v)
-    {
-        if (m_ptr != v.m_ptr)
-        {
-			if (v.m_ptr)
-            {
-                v.m_ptr->incRef();
-            }
-
-            T* ptr = m_ptr;
-            m_ptr = v.m_ptr;
-
-            if (ptr)
-            {
-                ptr->decRef();
-            }
-        }
-
-        return *this;
-    }
-
-    RefHandleT<T>& operator=(const RefHandleT<T>& v)
-    {
-        if (m_ptr != v.m_ptr)
-        {
-			if (v.m_ptr)
-            {
-                v.m_ptr->incRef();
-            }
-
-            T* ptr = m_ptr;
-            m_ptr = v.m_ptr;
-
-            if (ptr)
-            {
-                ptr->decRef();
-            }
-        }
-
-        return *this;
-    }
-
-    T* operator->() const
-    {
-		if (!m_ptr)
-		{
-			THROW_EXCEPTION(RefHandleNullException, "autoptr null handle error", -1);
-		}
-
-        return m_ptr;
-    }
-
-    T& operator*() const
-    {
-		if (!m_ptr)
-		{
-			THROW_EXCEPTION(RefHandleNullException, "autoptr null handle error", -1);
-		}
-
-        return *m_ptr;
-    }
-
-    operator T* () const
-    {
-        return m_ptr;
-    }
-
-    T* ptr() const
-    {
-        return m_ptr;
-    }
-
-    T* retn()
-    {
-        T* p = m_ptr;
-        m_ptr = 0;
-
-        return p;
-    }
-
-    bool operator==(const RefHandleT<T>& v) const
-    {
-        return m_ptr == v.m_ptr;
-    }
-
-    bool operator==(T* p) const
-    {
-        return m_ptr == p;
-    }
-
-    bool operator!=(const RefHandleT<T>& v) const
-    {
-        return m_ptr != v.m_ptr;
-    }
-
-    bool operator!=(T* p) const
-    {
-        return m_ptr != p;
-    }
-
-    bool operator!() const
-    {
-        return m_ptr == 0;
-    }
-
-    operator bool() const
-    {
-        return m_ptr != 0;
-    }
-
-    void swap(RefHandleT& other)
-    {
-        std::swap(m_ptr, other._ptr);
-    }
-
-	template<class Y>
-    static RefHandleT dynamicCast(const RefHandleT<Y>& r)
-    {
-        return RefHandleT(dynamic_cast<T*>(r._ptr));
-    }
-
-    template<class Y>
-    static RefHandleT dynamicCast(Y* p)
-    {
-        return RefHandleT(dynamic_cast<T*>(p));
-    }
-
-public:
-    T* m_ptr;
-};
-
-
-template<typename T, typename U>
-inline bool operator==(const RefHandleT<T>& lhs, const RefHandleT<U>& rhs)
-{
-    T* l = lhs.ptr();
-    U* r = rhs.ptr();
-    if(l && r)
-    {
-        return *l == *r;
-    }
-    else
-    {
-        return !l && !r;
-    }
-}
-
-
-template<typename T, typename U>
-inline bool operator!=(const RefHandleT<T>& lhs, const RefHandleT<U>& rhs)
-{
-    T* l = lhs.ptr();
-    U* r = rhs.ptr();
-    if(l && r)
-    {
-        return *l != *r;
-    }
-    else
-    {
-        return l || r;
-    }
-}
-
-
-template<typename T, typename U>
-inline bool operator<(const RefHandleT<T>& lhs, const RefHandleT<U>& rhs)
-{
-    T* l = lhs.ptr();
-    U* r = rhs.ptr();
-    if(l && r)
-    {
-        return *l < *r;
-    }
-    else
-    {
-        return !l && r;
-    }
-}
-
-}
-
-#define DECLAREVAR(T)   typedef kpr::RefHandleT<T> T ## Ptr;
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/kpr/ScopedLock.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/kpr/ScopedLock.h b/rocketmq-client4cpp/src/kpr/ScopedLock.h
deleted file mode 100755
index 6ff9dd1..0000000
--- a/rocketmq-client4cpp/src/kpr/ScopedLock.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/**
- * Copyright (C) 2013 kangliqiang ,kangliq@163.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef __KPR_SCOPEDLOCK_H__
-#define __KPR_SCOPEDLOCK_H__
-
-namespace kpr
-{
-template <class T>
-class ScopedLock
-{
-public:
-    ScopedLock(const T& mutex)
-        : m_mutex(mutex)
-    {
-        m_mutex.Lock();
-    }
-
-    ~ScopedLock()
-    {
-        m_mutex.Unlock();
-    }
-
-private:
-    const T& m_mutex;
-};
-
-
-template <class T>
-class ScopedRLock
-{
-public:
-    ScopedRLock(const T& mutex)
-        : m_mutex(mutex)
-    {
-        m_mutex.ReadLock();
-        m_acquired = true;
-    }
-
-    ~ScopedRLock()
-    {
-        if (m_acquired)
-        {
-            m_mutex.Unlock();
-        }
-    }
-
-private:
-    const T& m_mutex;
-    mutable bool m_acquired;
-};
-
-
-template <class T>
-class ScopedWLock
-{
-public:
-    ScopedWLock(const T& mutex)
-        : m_mutex(mutex)
-    {
-        m_mutex.WriteLock();
-        m_acquired = true;
-    }
-
-    ~ScopedWLock()
-    {
-        if (m_acquired)
-        {
-            m_mutex.Unlock();
-        }
-    }
-
-private:
-    const T& m_mutex;
-    mutable bool m_acquired;
-};
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/kpr/Semaphore.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/kpr/Semaphore.cpp b/rocketmq-client4cpp/src/kpr/Semaphore.cpp
deleted file mode 100755
index 59a0eef..0000000
--- a/rocketmq-client4cpp/src/kpr/Semaphore.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
- * Copyright (C) 2013 kangliqiang ,kangliq@163.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "Semaphore.h"
-
-#include <unistd.h>
-#include <sys/time.h>
-#include "KPRUtil.h"
-
-namespace kpr
-{
-Semaphore::Semaphore(long initial_count)
-{
-    sem_init(&m_sem, 0, initial_count);
-}
-
-Semaphore::~Semaphore()
-{
-    sem_destroy(&m_sem);
-}
-
-int Semaphore::GetValue()
-{
-	int value = 0;
-	int rc = sem_getvalue(&m_sem, &value);
-	if (rc < 0)
-	{
-		return rc;
-	}
-	return value;
-}
-
-bool Semaphore::Wait()
-{
-    int rc;
-    rc = sem_wait(&m_sem);
-    return !rc;
-}
-
-bool Semaphore::Wait(long timeout)
-{
-    int rc;
-    if (timeout < 0)
-    {
-        rc = sem_wait(&m_sem);
-    }
-    else
-    {
-        struct timespec abstime = KPRUtil::CalcAbsTime(timeout);
-        rc = sem_timedwait(&m_sem, &abstime);
-    }
-
-    return !rc;
-}
-
-void Semaphore::Release(int count)
-{
-    sem_post(&m_sem);
-}
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/kpr/Semaphore.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/kpr/Semaphore.h b/rocketmq-client4cpp/src/kpr/Semaphore.h
deleted file mode 100755
index 2a1af7f..0000000
--- a/rocketmq-client4cpp/src/kpr/Semaphore.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * Copyright (C) 2013 kangliqiang ,kangliq@163.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef __KPR_SEMAPHORE_H__
-#define __KPR_SEMAPHORE_H__
-
-#include "KPRTypes.h"
-#include <errno.h>
-
-namespace kpr
-{
-
-class Semaphore
-{
-public:
-    Semaphore(long initial_count = 0);
-    ~Semaphore();
-
-	int GetValue();
-    bool Wait();
-    bool Wait(long timeout);
-
-    void Release(int count = 1);
-
-private:
-    sem_t m_sem;
-};
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/kpr/Thread.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/kpr/Thread.cpp b/rocketmq-client4cpp/src/kpr/Thread.cpp
deleted file mode 100755
index d80819b..0000000
--- a/rocketmq-client4cpp/src/kpr/Thread.cpp
+++ /dev/null
@@ -1,191 +0,0 @@
-/**
- * Copyright (C) 2013 kangliqiang ,kangliq@163.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "Thread.h"
-
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <errno.h>
-#include <assert.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <signal.h>
-
-#include "ScopedLock.h"
-#include "Exception.h"
-
-//for log
-#include "RocketMQClient.h"
-
-namespace kpr
-{
-kpr::AtomicInteger Thread::s_threadNumber = 0;
-
-void* Thread::ThreadRoute(void* pArg)
-{
-    Thread* tv = ((Thread*)pArg);
-
-    try
-    {
-        tv->Startup();
-    }
-    catch (...)
-    {
-    }
-
-    try
-    {
-        tv->Cleanup();
-    }
-    catch (...)
-    {
-    }
-
-    return 0;
-}
-
-Thread::Thread(const char* name)
-{
-    m_started = false;
-    m_threadId = ThreadId();
-    m_threadNumber = s_threadNumber++;
-
-    SetName(name);
-}
-
-Thread::~Thread()
-{
-    try
-    {
-    }
-    catch (...)
-    {
-    }
-}
-
-void Thread::SetName(const char* name)
-{
-    ScopedLock<Mutex> guard(m_mutex);
-
-    if (name == NULL)
-    {
-        snprintf(m_name, sizeof(m_name), "Thread-%u", m_threadNumber);
-    }
-    else
-    {
-        snprintf(m_name, sizeof(m_name), "%s", name);
-    }
-}
-
-const char* Thread::GetName() const
-{
-    ScopedLock<Mutex> guard(m_mutex);
-    return m_name;
-}
-
-void Thread::Start()
-{
-    ScopedLock<Mutex> guard(m_mutex);
-
-    if (m_started)
-    {
-        return;
-    }
-
-    pthread_attr_t attr;
-    int retcode = 0;
-    retcode = pthread_attr_init(&attr);
-    if (retcode != 0)
-    {
-        THROW_EXCEPTION(SystemCallException, "pthread_attr_init failed!", errno)
-    }
-
-    pthread_t id;
-    retcode = pthread_create(&id, &attr, ThreadRoute, (void*)this);
-    if (retcode != 0)
-    {
-        THROW_EXCEPTION(SystemCallException, "pthread_create error", errno)
-    }
-
-    m_threadId = id;
-    pthread_attr_destroy(&attr);
-    m_started = true;
-    RMQ_DEBUG("thread[%s][%ld] start successfully", m_name, (long)id);
-}
-
-void Thread::Run()
-{
-    //TODO support runable
-}
-
-bool Thread::IsAlive() const
-{
-    if (m_started)
-    {
-        int retcode = pthread_kill(m_threadId, 0);
-        return (retcode == ESRCH);
-    }
-
-    return false;
-}
-
-void  Thread::Join()
-{
-    if (m_started)
-    {
-        pthread_join(m_threadId, NULL);
-    }
-}
-
-void Thread::Sleep(long millis, int nanos)
-{
-    assert(millis >= 0 && nanos >= 0 && nanos < 999999);
-    struct timespec tv;
-    tv.tv_sec = millis / 1000;
-    tv.tv_nsec = (millis % 1000) * 1000000 + nanos;
-    nanosleep(&tv, 0);
-}
-
-void Thread::Yield()
-{
-    pthread_yield();
-}
-
-ThreadId Thread::GetId() const
-{
-    ScopedLock<Mutex> guard(m_mutex);
-    return m_threadId;
-}
-
-void Thread::Startup()
-{
-    try
-    {
-    	RMQ_INFO("thread[%s] started", GetName());
-        Run();
-    }
-    catch (...)
-    {
-    }
-}
-
-void Thread::Cleanup()
-{
-	RMQ_INFO("thread[%s] end", GetName());
-}
-
-}
-

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/kpr/Thread.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/kpr/Thread.h b/rocketmq-client4cpp/src/kpr/Thread.h
deleted file mode 100755
index ef2590e..0000000
--- a/rocketmq-client4cpp/src/kpr/Thread.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
- * Copyright (C) 2013 kangliqiang ,kangliq@163.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef __KPR_THREAD_H__
-#define __KPR_THREAD_H__
-
-#include "KPRTypes.h"
-#include "RefHandle.h"
-#include "Mutex.h"
-
-#ifdef Yield
-#undef Yield
-#endif
-
-namespace kpr
-{
-class Thread : public virtual kpr::RefCount
-{
-public:
-    Thread(const char* name = NULL);
-    virtual ~Thread();
-
-    virtual void Run();
-    void Start();
-    bool IsAlive() const;
-    void Join();
-    ThreadId   GetId() const;
-
-    void SetName(const char*);
-    const char* GetName() const;
-
-    void Startup();
-    void Cleanup();
-
-    static void  Sleep(long millis, int nano = 0);
-    static void  Yield();
-
-private:
-    Thread(const Thread&);
-    const Thread& operator=(const Thread&);
-    static void* ThreadRoute(void* pArg);
-
-private:
-    ThreadId m_threadId;
-    unsigned int m_threadNumber;
-    char m_name[128];
-    bool m_started;
-    Mutex m_mutex;
-
-    static kpr::AtomicInteger s_threadNumber;
-};
-typedef kpr::RefHandleT<Thread> ThreadPtr;
-
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/kpr/ThreadLocal.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/kpr/ThreadLocal.cpp b/rocketmq-client4cpp/src/kpr/ThreadLocal.cpp
deleted file mode 100755
index 32cba5b..0000000
--- a/rocketmq-client4cpp/src/kpr/ThreadLocal.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * Copyright (C) 2013 kangliqiang ,kangliq@163.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "ThreadLocal.h"
-
-#include <errno.h>
-
-#include "Exception.h"
-
-namespace kpr
-{
-ThreadLocal::ThreadLocal()
-    : m_Key(0)
-{
-    int retcode = 0;
-
-    retcode = pthread_key_create(&m_Key, 0);
-    if (retcode != 0)
-    {
-        THROW_EXCEPTION(SystemCallException, "pthread_key_create error", errno);
-    }
-}
-
-ThreadLocal::~ThreadLocal()
-{
-    pthread_key_delete(m_Key);
-}
-
-void* ThreadLocal::GetValue()
-{
-    void* v;
-    v = pthread_getspecific(m_Key);
-    return v;
-}
-
-void ThreadLocal::SetValue(void* value)
-{
-    int retcode = pthread_setspecific(m_Key, value);
-    if (retcode != 0)
-    {
-        THROW_EXCEPTION(SystemCallException, "pthread_setspecific error", errno);
-    }
-}
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/kpr/ThreadLocal.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/kpr/ThreadLocal.h b/rocketmq-client4cpp/src/kpr/ThreadLocal.h
deleted file mode 100644
index 9ec8f43..0000000
--- a/rocketmq-client4cpp/src/kpr/ThreadLocal.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * Copyright (C) 2013 kangliqiang ,kangliq@163.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef __KPR_THREADLOCAL_H__
-#define __KPR_THREADLOCAL_H__
-
-#include "KPRTypes.h"
-
-namespace kpr
-{
-class ThreadLocal
-{
-public:
-    ThreadLocal();
-    virtual ~ThreadLocal();
-
-    void* GetValue();
-    void SetValue(void* value);
-
-private:
-    ThreadKey   m_Key;
-};
-};
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/kpr/ThreadPool.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/kpr/ThreadPool.cpp b/rocketmq-client4cpp/src/kpr/ThreadPool.cpp
deleted file mode 100755
index 32557a8..0000000
--- a/rocketmq-client4cpp/src/kpr/ThreadPool.cpp
+++ /dev/null
@@ -1,418 +0,0 @@
-/**
- * Copyright (C) 2013 kangliqiang ,kangliq@163.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "ThreadPool.h"
-
-#include "RocketMQClient.h"
-#include "ScopedLock.h"
-#include "KPRUtil.h"
-
-namespace kpr
-{
-ThreadPoolWorker:: ThreadPoolWorker(ThreadPool* pThreadPool, const char* strName)
-    : kpr::Thread(strName),
-      m_pThreadPool(pThreadPool),
-      m_canWork(false),
-      m_isWaiting(false),
-      m_stop(false),
-      m_idleTime(0),
-      m_idle(true)
-{
-
-}
-
-bool ThreadPoolWorker::IsIdle()
-{
-    kpr::ScopedLock<kpr::Monitor> lock(*this);
-    return m_idle;
-}
-
-void ThreadPoolWorker:: SetIdle(bool idle)
-{
-    kpr::ScopedLock<kpr::Monitor> lock(*this);
-    m_idle = idle;
-    m_idleTime = 0;
-}
-
-int ThreadPoolWorker::IdleTime(int idleTime)
-{
-    if (m_idle)
-    {
-        m_idleTime += idleTime;
-    }
-    else
-    {
-        m_idleTime = 0;
-    }
-
-    return m_idleTime;
-}
-
-void ThreadPoolWorker::Run()
-{
-    while (!m_stop)
-    {
-        SetIdle(true);
-        {
-            kpr::ScopedLock<kpr::Monitor> lock(*this);
-            while (!m_canWork)
-            {
-                try
-                {
-                    m_isWaiting = true;
-                    Wait();
-                    m_isWaiting = false;
-                }
-                catch (...)
-                {
-                }
-            }
-
-            m_canWork = false;
-        }
-
-        while (!m_stop)
-        {
-            ThreadPoolWorkPtr request = m_pThreadPool->GetWork(this);
-            if ((ThreadPoolWork*)(NULL) == request)
-            {
-                break;
-            }
-
-            SetIdle(false);
-
-            try
-            {
-            	request->Do();
-            }
-            catch(...)
-            {
-            	RMQ_ERROR("thead[%s] doWork exception", GetName());
-            }
-
-			//delete request;
-            request = NULL;
-        }
-
-        if (m_stop || m_pThreadPool->IsDestroy())
-        {
-            break;
-        }
-    }
-
-    m_pThreadPool ->RemoveThread(this);
-    m_pThreadPool = NULL;
-}
-
-void ThreadPoolWorker::WakeUp()
-{
-    SetIdle(false);
-    kpr::ScopedLock<kpr::Monitor> lock(*this);
-    m_canWork = true;
-    Notify();
-}
-
-void ThreadPoolWorker::Stop()
-{
-    kpr::ScopedLock<kpr::Monitor> lock(*this);
-    m_canWork = true;
-    m_stop = true;
-    Notify();
-}
-
-bool ThreadPoolWorker:: IsWaiting()
-{
-    kpr::ScopedLock<kpr::Monitor> lock(*this);
-    return m_isWaiting;
-}
-
-ThreadPool::ThreadPool(const char* name,
-                        int count,
-                        int minCount,
-                        int maxCount,
-                        int step,
-                        int maxIdleTime,
-                        int checkldleThreadsInterval)
-{
-    if (name == NULL)
-    {
-        snprintf(m_name, sizeof(m_name), "ThreadPool");
-    }
-    else
-    {
-        snprintf(m_name, sizeof(m_name), "%s", name);
-    }
-
-    m_destroy = false;
-    m_minCount = minCount;
-    m_maxCount = maxCount;
-    m_maxIdleTime = maxIdleTime;
-    m_count = 0;
-    m_step = step;
-    m_index = 0;
-
-    m_lastRemoveIdleThreadsTime = KPRUtil::GetCurrentTimeMillis();
-
-    if (m_minCount <= 0)
-    {
-        m_minCount = MIN_THREAD_COUNT;
-    }
-
-    if (m_maxCount < 0)
-    {
-        m_maxCount = MAX_THREAD_COUNT;
-    }
-
-    if (m_maxIdleTime < 0)
-    {
-        m_maxIdleTime = MAX_IDLE_THREAD_TIME;
-    }
-
-    if (m_maxCount != 0 && m_maxCount < m_minCount)
-    {
-        m_minCount = MIN_THREAD_COUNT;
-    }
-
-    if ((m_maxCount != 0 && count > m_maxCount) || count < m_minCount)
-    {
-        count = m_minCount;
-    }
-
-    if (checkldleThreadsInterval < 0)
-    {
-        checkldleThreadsInterval = CHECK_IDLE_THREADS_INTERVAL;
-    }
-
-    AddThreads(count);
-
-	char manager_name[32];
-	snprintf(manager_name, sizeof(manager_name), "%s-manager", m_name);
-    m_manager = new ThreadPoolManage(manager_name, this, checkldleThreadsInterval);
-    m_manager->Start();
-}
-
-ThreadPool::~ThreadPool()
-{
-    Destroy();
-}
-
-void ThreadPool::AddThreads(int count)
-{
-    char threadName[256];
-
-    for (int i = 0; i < count; ++i)
-    {
-        snprintf(threadName, sizeof(threadName), "%s-Worker%d", m_name, m_index);
-
-        try
-        {
-            ThreadPoolWorkerPtr worker = new ThreadPoolWorker(this, threadName);
-            worker->Start();
-
-            m_workers.push_back(worker);
-            while (!worker->IsWaiting())
-            {
-                kpr::Thread::Sleep(0, 100000);
-            }
-
-            m_index++;
-            m_count++;
-        }
-        catch (...)
-        {
-			RMQ_ERROR("ThreadPool thead[%s] new exception", threadName);
-        }
-    }
-}
-
-void ThreadPool::Destroy()
-{
-    std::list<ThreadPoolWorkerPtr> workers;
-    {
-        kpr::ScopedLock<kpr::Monitor> lock(*this);
-        if (m_destroy)
-        {
-            return;
-        }
-
-        m_destroy = true;
-
-        std::list<ThreadPoolWorkerPtr>::iterator iter;
-        for (iter = m_workers.begin(); iter != m_workers.end(); iter++)
-        {
-            workers.push_back(*iter);
-            (*iter)->Stop();
-        }
-    }
-
-    m_manager->Stop();
-    m_manager->Join();
-
-    std::list<ThreadPoolWorkerPtr>::iterator itThread;
-    for (itThread = workers.begin(); itThread != workers.end(); itThread++)
-    {
-        (*itThread)->Join();
-    }
-    m_works.clear();
-}
-
-int ThreadPool::AddWork(ThreadPoolWorkPtr pWork)
-{
-    kpr::ScopedLock<kpr::Monitor> lock(*this);
-    if (m_destroy)
-    {
-        return -1;
-    }
-
-    m_works.push_back(pWork);
-
-    if (!WakeOneThread())
-    {
-        if (0 == m_maxCount || m_count < m_maxCount)
-        {
-            int step = m_step;
-
-            if (0 < m_maxCount && m_count + m_step > m_maxCount)
-            {
-                step = m_maxCount - m_count;
-            }
-
-            AddThreads(step);
-            WakeOneThread();
-        }
-    }
-
-    return 0;
-}
-
-ThreadPoolWorkPtr ThreadPool::GetWork(ThreadPoolWorker* pWorker)
-{
-    kpr::ScopedLock<kpr::Monitor> lock(*this);
-    ThreadPoolWorkPtr result = NULL;
-
-    if (!m_destroy && !m_works.empty())
-    {
-        result = m_works.front();
-        m_works.pop_front();
-    }
-
-    return result;
-}
-
-bool ThreadPool::IsDestroy()
-{
-    kpr::ScopedLock<kpr::Monitor> lock(*this);
-    return m_destroy;
-}
-
-void ThreadPool::RemoveThread(ThreadPoolWorker* workerThread)
-{
-    kpr::ScopedLock<kpr::Monitor> lock(*this);
-
-    std::list<ThreadPoolWorkerPtr>::iterator it = m_workers.begin();
-
-    for (; it != m_workers.end(); it++)
-    {
-        if ((*it) == workerThread)
-        {
-            m_workers.erase(it);
-            m_count--;
-            break;
-        }
-    }
-}
-
-void ThreadPool::RemoveIdleThreads()
-{
-    kpr::ScopedLock<kpr::Monitor> lock(*this);
-
-    if (m_maxIdleTime == 0)
-    {
-        return;
-    }
-
-    unsigned long long time = KPRUtil::GetCurrentTimeMillis();
-    int interval = (int)(time - m_lastRemoveIdleThreadsTime);
-    m_lastRemoveIdleThreadsTime = time;
-
-    std::list<ThreadPoolWorkerPtr>::iterator it = m_workers.begin();
-    int size = (int)m_workers.size();
-    while (size > m_minCount && it != m_workers.end())
-    {
-        if ((*it)->IdleTime(interval) > m_maxIdleTime)
-        {
-            (*it)->Stop();
-            size--;
-        }
-
-        it++;
-    }
-}
-
-bool ThreadPool::WakeOneThread()
-{
-    std::list<ThreadPoolWorkerPtr>::iterator it = m_workers.begin();
-    for (; it != m_workers.end(); it++)
-    {
-        if ((*it)->IsIdle())
-        {
-            (*it)->WakeUp();
-            return true;
-        }
-    }
-
-    return false;
-}
-
-ThreadPoolManage::ThreadPoolManage(const char* name, ThreadPool* pThreadPool, int checkldleThreadsInterval)
-    : kpr::Thread(name),
-      m_pThreadPool(pThreadPool),
-      m_stop(false),
-      m_checkIdleThreadsInterval(checkldleThreadsInterval)
-{
-}
-
-ThreadPoolManage::~ThreadPoolManage()
-{
-}
-
-void ThreadPoolManage::Stop()
-{
-    kpr::ScopedLock<kpr::Monitor> lock(*this);
-    m_stop = true;
-    Notify();
-}
-
-void ThreadPoolManage::Run()
-{
-    while (!m_stop)
-    {
-        {
-            kpr::ScopedLock<kpr::Monitor> lock(*this);
-            if (!m_stop)
-            {
-                Wait(m_checkIdleThreadsInterval);
-            }
-
-            if (m_stop)
-            {
-                break;
-            }
-        }
-
-        m_pThreadPool->RemoveIdleThreads();
-    }
-}
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/kpr/ThreadPool.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/kpr/ThreadPool.h b/rocketmq-client4cpp/src/kpr/ThreadPool.h
deleted file mode 100755
index 2c7e3ff..0000000
--- a/rocketmq-client4cpp/src/kpr/ThreadPool.h
+++ /dev/null
@@ -1,124 +0,0 @@
-/**
- * Copyright (C) 2013 kangliqiang ,kangliq@163.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef __KPR_THREADPOOL_H__
-#define __KPR_THREADPOOL_H__
-
-#include<time.h>
-#include <assert.h>
-#include <list>
-#include "Mutex.h"
-#include "Thread.h"
-#include "Monitor.h"
-
-#include "ThreadPoolWork.h"
-
-namespace kpr
-{
-const int MAX_THREAD_COUNT = 300;
-const int MIN_THREAD_COUNT = 1;
-//const int MAX_IDLE_THREAD_TIME = 600000;
-const int MAX_IDLE_THREAD_TIME = 0;
-const int THREAD_STEP = 10;
-const int CHECK_IDLE_THREADS_INTERVAL = 30000;
-
-class ThreadPool;
-class ThreadPoolWorker : public kpr::Thread, public kpr::Monitor
-{
-public:
-    ThreadPoolWorker(ThreadPool* pThreadPool, const char* strName);
-
-    virtual void Run();
-    void WakeUp();
-    void Stop();
-    bool IsWaiting();
-    bool IsIdle();
-    void SetIdle(bool idle);
-    int IdleTime(int idleTime);
-
-private:
-    ThreadPool* m_pThreadPool;
-    bool m_canWork;
-    bool m_isWaiting;
-    bool m_stop;
-    int m_idleTime;
-    bool m_idle;
-};
-typedef kpr::RefHandleT<ThreadPoolWorker> ThreadPoolWorkerPtr;
-
-class ThreadPoolManage : public kpr::Thread, public kpr::Monitor
-{
-public:
-    ThreadPoolManage(const char* name, ThreadPool* pThreadPool, int nCheckldleThreadsInterval);
-
-    ~ThreadPoolManage();
-    virtual void Run();
-    void Stop();
-
-private:
-    ThreadPool* m_pThreadPool;
-    bool m_stop;
-    int m_checkIdleThreadsInterval;
-};
-typedef kpr::RefHandleT<ThreadPoolManage> ThreadPoolManagePtr;
-
-
-class ThreadPool : public kpr::RefCount, public kpr::Monitor
-{
-public:
-    ThreadPool(const char* name,
-               int initCount,
-               int minCount,
-               int maxCount,
-               int step = THREAD_STEP,
-               int maxIdleTime = MAX_IDLE_THREAD_TIME,
-               int checkldleThreadsInterval = CHECK_IDLE_THREADS_INTERVAL);
-
-    ~ThreadPool();
-    void Destroy();
-
-    int AddWork(ThreadPoolWorkPtr pWork);
-    ThreadPoolWorkPtr GetWork(ThreadPoolWorker* pWorker);
-
-    void RemoveIdleThreads();
-    void RemoveThread(ThreadPoolWorker* pWorker);
-
-    bool WakeOneThread();
-    bool IsDestroy();
-
-private:
-    void AddThreads(int count);
-
-private:
-    bool m_destroy;
-    int m_minCount;
-    int m_maxCount;
-    int m_maxIdleTime;
-    int m_count;
-    int m_step;
-
-    char m_name[128];
-    unsigned int m_index;
-    unsigned long long m_lastRemoveIdleThreadsTime;
-
-    ThreadPoolManagePtr m_manager;
-    std::list<ThreadPoolWorkPtr> m_works;
-    std::list<ThreadPoolWorkerPtr> m_workers;
-};
-
-typedef kpr::RefHandleT<ThreadPool> ThreadPoolPtr;
-
-}
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/kpr/ThreadPoolWork.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/kpr/ThreadPoolWork.h b/rocketmq-client4cpp/src/kpr/ThreadPoolWork.h
deleted file mode 100644
index 30dfe6c..0000000
--- a/rocketmq-client4cpp/src/kpr/ThreadPoolWork.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#ifndef __THREADPOOLWORK_H__
-#define __THREADPOOLWORK_H__
-
-#include "RefHandle.h"
-
-namespace kpr
-{
-
-class ThreadPoolWork : public kpr::RefCount
-{
-public:
-    virtual ~ThreadPoolWork() {}
-    virtual void Do() = 0;
-};
-typedef kpr::RefHandleT<ThreadPoolWork> ThreadPoolWorkPtr;
-
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/kpr/TimerTaskManager.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/kpr/TimerTaskManager.cpp b/rocketmq-client4cpp/src/kpr/TimerTaskManager.cpp
deleted file mode 100755
index 42ef672..0000000
--- a/rocketmq-client4cpp/src/kpr/TimerTaskManager.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#include "TimerTaskManager.h"
-#include "ThreadPool.h"
-#include "ScopedLock.h"
-
-namespace kpr
-{
-TimerTaskManager::TimerTaskManager()
-{
-}
-
-TimerTaskManager::~TimerTaskManager()
-{
-}
-
-int TimerTaskManager::Init(int maxThreadCount, int checklnteval)
-{
-    try
-    {
-        m_pThreadPool = new ThreadPool("TimerThreadPool", 5, 5, maxThreadCount);
-        m_timerThread = new TimerThread("TimerThread", checklnteval);
-        m_timerThread->Start();
-    }
-    catch (...)
-    {
-        return -1;
-    }
-
-    return 0;
-}
-
-unsigned int TimerTaskManager::RegisterTimer(unsigned int initialDelay, unsigned int elapse, TimerTaskPtr pTask)
-{
-    unsigned int id = m_timerThread->RegisterTimer(initialDelay, elapse, this, true);
-
-    kpr::ScopedLock<kpr::Mutex> lock(m_mutex);
-    m_timerTasks[id] = pTask;
-
-    return id;
-}
-
-bool TimerTaskManager::UnRegisterTimer(unsigned int timerId)
-{
-    bool ret = m_timerThread->UnRegisterTimer(timerId);
-
-    kpr::ScopedLock<kpr::Mutex> lock(m_mutex);
-    m_timerTasks.erase(timerId);
-
-    return ret;
-}
-
-bool TimerTaskManager::ResetTimer(unsigned int timerId)
-{
-    return m_timerThread->ResetTimer(timerId);
-}
-
-void TimerTaskManager::OnTimeOut(unsigned int timerId)
-{
-    kpr::ScopedLock<kpr::Mutex> lock(m_mutex);
-    std::map<unsigned int, TimerTaskPtr>::iterator it = m_timerTasks.find(timerId);
-    if (it != m_timerTasks.end())
-    {
-        if (!it->second->IsProcessing())
-        {
-            it->second->SetProcessing(true);
-            m_pThreadPool->AddWork((it->second).ptr());
-        }
-    }
-}
-
-void TimerTaskManager::Stop()
-{
-    m_timerThread->Stop();
-    m_timerThread->Join();
-    m_pThreadPool->Destroy();
-}
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/kpr/TimerTaskManager.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/kpr/TimerTaskManager.h b/rocketmq-client4cpp/src/kpr/TimerTaskManager.h
deleted file mode 100755
index b9cc2e0..0000000
--- a/rocketmq-client4cpp/src/kpr/TimerTaskManager.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#ifndef __KPR_TIMERTASKMANAGER_H__
-#define __KPR_TIMERTASKMANAGER_H__
-
-#include <list>
-#include <map>
-
-#include "RocketMQClient.h"
-#include "TimerThread.h"
-#include "ThreadPool.h"
-#include "ThreadPoolWork.h"
-
-namespace kpr
-{
-
-class TimerTask : public kpr::ThreadPoolWork
-{
-public:
-    TimerTask()
-        : m_isProcessing(false)
-    {
-    }
-
-	virtual ~TimerTask()
-	{
-	}
-
-    virtual void Do()
-    {
-		try
-		{
-        	DoTask();
-		}
-		catch(...)
-		{
-			RMQ_ERROR("TimerTask exception");
-		}
-        m_isProcessing = false;
-    }
-
-    bool IsProcessing()
-    {
-        return m_isProcessing;
-    }
-
-    void SetProcessing(bool isProcessing)
-    {
-        m_isProcessing = isProcessing;
-    }
-
-    virtual void DoTask() = 0;
-
-private:
-    bool m_isProcessing;
-};
-typedef kpr::RefHandleT<TimerTask> TimerTaskPtr;
-
-
-class TimerTaskManager : public TimerHandler
-{
-public:
-    TimerTaskManager();
-    virtual ~TimerTaskManager();
-
-    int Init(int maxThreadCount, int checklnteval);
-    unsigned int RegisterTimer(unsigned int initialDelay, unsigned int elapse, TimerTaskPtr pTask);
-    bool UnRegisterTimer(unsigned int timerId);
-    bool ResetTimer(unsigned int timerId);
-    void Stop();
-
-    virtual void OnTimeOut(unsigned int timerId);
-
-private:
-    std::map<unsigned int, TimerTaskPtr> m_timerTasks;
-    kpr::Mutex m_mutex;
-    TimerThreadPtr m_timerThread;
-    kpr::ThreadPoolPtr m_pThreadPool;
-};
-
-}
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/kpr/TimerThread.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/kpr/TimerThread.cpp b/rocketmq-client4cpp/src/kpr/TimerThread.cpp
deleted file mode 100755
index b127074..0000000
--- a/rocketmq-client4cpp/src/kpr/TimerThread.cpp
+++ /dev/null
@@ -1,186 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#include "TimerThread.h"
-#include "KPRUtil.h"
-#include "ScopedLock.h"
-
-namespace kpr
-{
-unsigned int TimerThread::s_nextTimerID = 0;
-
-TimerThread::TimerThread(const char* name, unsigned int checklnterval)
-    : kpr::Thread(name), m_closed(false), m_checkInterval(checklnterval)
-{
-}
-
-TimerThread::~TimerThread()
-{
-}
-
-void TimerThread::Run()
-{
-    unsigned long long lastCheckTime = KPRUtil::GetCurrentTimeMillis();
-    unsigned long long currentCheckTime = lastCheckTime;
-
-    while (!m_closed)
-    {
-        currentCheckTime = KPRUtil::GetCurrentTimeMillis();
-        unsigned int elapse = (unsigned int)(currentCheckTime - lastCheckTime);
-
-        std::list<TimerInfo> timeList;
-
-        CheckTimeOut(elapse, timeList);
-
-        if (!timeList.empty())
-        {
-            std::list<TimerInfo>::iterator it = timeList.begin();
-            for (; it != timeList.end(); it++)
-            {
-            	try
-            	{
-                	it->pTimerHandler->OnTimeOut(it->id);
-                }
-                catch(...)
-                {
-                	RMQ_ERROR("TimerThread[%s] OnTimeOut exception", GetName());
-                }
-            }
-        }
-
-        unsigned long long checkEndTime = KPRUtil::GetCurrentTimeMillis();
-        int sleepTime = m_checkInterval - (int)(checkEndTime - currentCheckTime);
-        if (sleepTime < 0)
-        {
-            sleepTime = 0;
-        }
-
-        lastCheckTime = currentCheckTime;
-
-        try
-        {
-            kpr::ScopedLock<kpr::Monitor> lock(*this);
-            Wait(sleepTime);
-        }
-        catch (...)
-        {
-        }
-    }
-}
-
-void TimerThread::Stop()
-{
-    m_closed = true;
-    kpr::ScopedLock<kpr::Monitor> lock(*this);
-    Notify();
-}
-
-unsigned int TimerThread::RegisterTimer(unsigned int initialDelay, unsigned int elapse, TimerHandler* pHandler, bool persistent)
-{
-    TimerInfo info;
-    info.elapse = elapse;
-    info.outTime = elapse - initialDelay;
-    info.pTimerHandler = pHandler;
-    info.persistent = persistent;
-
-    kpr::ScopedLock<kpr::Mutex> lock(m_mutex);
-    info.id = GetNextTimerID();
-    m_timers[info.id] = info;
-
-    return info.id;
-}
-
-bool TimerThread::UnRegisterTimer(unsigned int timerId)
-{
-    bool result = false;
-    kpr::ScopedLock<kpr::Mutex> lock(m_mutex);
-    std::map<unsigned int, TimerInfo>::iterator it = m_timers.find(timerId);
-    if (it != m_timers.end())
-    {
-        m_timers.erase(it);
-        result = true;
-    }
-
-    return result;
-}
-
-bool TimerThread::ResetTimer(unsigned int timerId)
-{
-    bool result = false;
-    kpr::ScopedLock<kpr::Mutex> lock(m_mutex);
-    std::map<unsigned int, TimerInfo>::iterator it = m_timers.find(timerId);
-    if (it != m_timers.end())
-    {
-        if (it->second.persistent)
-        {
-            it->second.outTime = it->second.elapse;
-        }
-        else
-        {
-            it->second.outTime = 0;
-        }
-
-        result = true;
-    }
-
-    return result;
-}
-
-bool TimerThread::CheckTimeOut(unsigned int elapse, std::list<TimerInfo>& timerList)
-{
-    bool result = false;
-    timerList.clear();
-
-    kpr::ScopedLock<kpr::Mutex> lock(m_mutex);
-    if (!m_timers.empty())
-    {
-        std::map<unsigned int, TimerInfo>::iterator it = m_timers.begin();
-        while (it != m_timers.end())
-        {
-            it->second.outTime += elapse;
-
-            if (it->second.outTime >= int(it->second.elapse))
-            {
-                timerList.push_back(it->second);
-
-                if (it->second.persistent)
-                {
-                    it->second.outTime = 0;
-                    ++it;
-                }
-                else
-                {
-                    std::map<unsigned int, TimerInfo>::iterator it1 = it;
-                    ++it;
-                    m_timers.erase(it1);
-                }
-            }
-            else
-            {
-                ++it;
-            }
-        }
-
-        result = true;
-    }
-
-    return result;
-}
-
-unsigned int TimerThread::GetNextTimerID()
-{
-    return ++s_nextTimerID;
-}
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/kpr/TimerThread.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/kpr/TimerThread.h b/rocketmq-client4cpp/src/kpr/TimerThread.h
deleted file mode 100755
index 7e02a79..0000000
--- a/rocketmq-client4cpp/src/kpr/TimerThread.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
- * Copyright (C) 2013 kangliqiang ,kangliq@163.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef __KPR_TIMERTHREAD_H__
-#define __KPR_TIMERTHREAD_H__
-
-#include <list>
-#include <map>
-
-#include "RocketMQClient.h"
-#include "Thread.h"
-#include "Mutex.h"
-#include "Monitor.h"
-
-namespace kpr
-{
-class TimerHandler
-{
-public:
-    TimerHandler()
-    {
-    }
-
-    virtual ~TimerHandler()
-    {
-    }
-
-    virtual void OnTimeOut(unsigned int timerID) = 0;
-};
-
-typedef struct tagTimerlnfo
-{
-    unsigned int id;
-    unsigned int elapse;
-    int outTime;
-    bool persistent;
-    TimerHandler* pTimerHandler;
-} TimerInfo;
-
-
-class TimerThread : public kpr::Thread, public kpr::Monitor
-{
-public:
-    TimerThread(const char* name, unsigned int checklnterval);
-    virtual ~TimerThread();
-    virtual void Run();
-    virtual void Stop();
-
-    virtual unsigned int RegisterTimer(unsigned int initialDelay, unsigned int elapse, TimerHandler* pHandler, bool persistent = true);
-    virtual bool UnRegisterTimer(unsigned int timerId);
-    virtual bool ResetTimer(unsigned int timerId);
-
-private:
-    bool CheckTimeOut(unsigned int elapse, std::list<TimerInfo>& timerList);
-    static unsigned int GetNextTimerID();
-
-private:
-    static unsigned int s_nextTimerID;
-    std::map<unsigned int, TimerInfo> m_timers;
-    kpr::Mutex m_mutex;
-    bool m_closed;
-    unsigned int m_checkInterval;
-};
-typedef kpr::RefHandleT<TimerThread> TimerThreadPtr;
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/message/Message.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/message/Message.cpp b/rocketmq-client4cpp/src/message/Message.cpp
deleted file mode 100755
index db88c3e..0000000
--- a/rocketmq-client4cpp/src/message/Message.cpp
+++ /dev/null
@@ -1,379 +0,0 @@
-/**
- * Copyright (C) 2013 kangliqiang ,kangliq@163.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "Message.h"
-
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include "UtilAll.h"
-
-
-namespace rmq
-{
-
-const std::string Message::PROPERTY_KEYS = "KEYS";
-const std::string Message::PROPERTY_TAGS = "TAGS";
-const std::string Message::PROPERTY_WAIT_STORE_MSG_OK = "WAIT";
-const std::string Message::PROPERTY_DELAY_TIME_LEVEL = "DELAY";
-const std::string Message::PROPERTY_RETRY_TOPIC = "RETRY_TOPIC";
-const std::string Message::PROPERTY_REAL_TOPIC = "REAL_TOPIC";
-const std::string Message::PROPERTY_REAL_QUEUE_ID = "REAL_QID";
-const std::string Message::PROPERTY_TRANSACTION_PREPARED = "TRAN_MSG";
-const std::string Message::PROPERTY_PRODUCER_GROUP = "PGROUP";
-const std::string Message::PROPERTY_MIN_OFFSET = "MIN_OFFSET";
-const std::string Message::PROPERTY_MAX_OFFSET = "MAX_OFFSET";
-const std::string Message::PROPERTY_BUYER_ID = "BUYER_ID";
-const std::string Message::PROPERTY_ORIGIN_MESSAGE_ID = "ORIGIN_MESSAGE_ID";
-const std::string Message::PROPERTY_TRANSFER_FLAG = "TRANSFER_FLAG";
-const std::string Message::PROPERTY_CORRECTION_FLAG = "CORRECTION_FLAG";
-const std::string Message::PROPERTY_MQ2_FLAG = "MQ2_FLAG";
-const std::string Message::PROPERTY_RECONSUME_TIME = "RECONSUME_TIME";
-const std::string Message::PROPERTY_MSG_REGION = "MSG_REGION";
-const std::string Message::PROPERTY_UNIQ_CLIENT_MESSAGE_ID_KEYIDX = "UNIQ_KEY";
-const std::string Message::PROPERTY_MAX_RECONSUME_TIMES = "MAX_RECONSUME_TIMES";
-const std::string Message::PROPERTY_CONSUME_START_TIMESTAMP = "CONSUME_START_TIME";
-const std::string Message::KEY_SEPARATOR = " ";
-
-Message::Message()
-{
-    Init("", "", "", 0, NULL, 0, true);
-}
-
-Message::Message(const std::string& topic, const char* body, int len)
-{
-    Init(topic, "", "", 0, body, len, true);
-}
-
-Message::Message(const std::string& topic, const std::string& tags, const char* body, int len)
-{
-    Init(topic, tags, "", 0, body, len, true);
-}
-
-Message::Message(const std::string& topic, const std::string& tags, const std::string& keys, const char* body, int len)
-{
-    Init(topic, tags, keys, 0, body, len, true);
-}
-
-Message::Message(const std::string& topic,
-                 const std::string& tags,
-                 const std::string& keys,
-                 const int  flag,
-                 const char* body,
-                 int len,
-                 bool waitStoreMsgOK)
-{
-    Init(topic, tags, keys, flag, body, len, waitStoreMsgOK);
-}
-
-Message::~Message()
-{
-	if (m_body)
-	{
-    	free(m_body);
-    	m_body = NULL;
-    	m_bodyLen = 0;
-    }
-
-    if (m_compressBody)
-	{
-    	free(m_compressBody);
-    	m_compressBody = NULL;
-    	m_compressBodyLen = 0;
-    }
-}
-
-Message::Message(const Message& other)
-{
-    m_body = (char*)malloc(other.m_bodyLen);
-    m_bodyLen = other.m_bodyLen;
-	memcpy(m_body, other.m_body, other.m_bodyLen);
-
-    m_compressBody = NULL;
-    m_compressBodyLen = 0;
-
-    m_topic = other.m_topic;
-    m_flag = other.m_flag;
-    m_properties = other.m_properties;
-}
-
-Message& Message::operator=(const Message& other)
-{
-    if (this != &other)
-    {
-    	if (m_body)
-		{
-        	free(m_body);
-        	m_body = NULL;
-        	m_bodyLen = 0;
-        }
-
-        if (m_compressBody)
-		{
-	    	free(m_compressBody);
-	    	m_compressBody = NULL;
-	    	m_compressBodyLen = 0;
-	    }
-
-        m_body = (char*)malloc(other.m_bodyLen);;
-        m_bodyLen = other.m_bodyLen;
-        memcpy(m_body, other.m_body, other.m_bodyLen);
-
-        m_topic = other.m_topic;
-        m_flag = other.m_flag;
-        m_properties = other.m_properties;
-    }
-
-    return *this;
-}
-
-void Message::clearProperty(const std::string& name)
-{
-    m_properties.erase(name);
-}
-
-void Message::putProperty(const std::string& name, const std::string& value)
-{
-    m_properties[name] = value;
-}
-
-std::string Message::getProperty(const std::string& name)
-{
-    std::map<std::string, std::string>::const_iterator it = m_properties.find(name);
-    return (it == m_properties.end()) ? "" : it->second;
-}
-
-std::string Message::getTopic()const
-{
-    return m_topic;
-}
-
-void Message::setTopic(const std::string& topic)
-{
-    m_topic = topic;
-}
-
-std::string Message::getTags()
-{
-    return getProperty(PROPERTY_TAGS);
-}
-
-void Message::setTags(const std::string& tags)
-{
-    putProperty(PROPERTY_TAGS, tags);
-}
-
-std::string Message::getKeys()
-{
-    return getProperty(PROPERTY_KEYS);
-}
-
-void Message::setKeys(const std::string& keys)
-{
-    putProperty(PROPERTY_KEYS, keys);
-}
-
-void Message::setKeys(const std::list<std::string> keys)
-{
-    if (keys.empty())
-    {
-        return;
-    }
-
-    std::list<std::string>::const_iterator it = keys.begin();
-    std::string str;
-    str += *it;
-    it++;
-
-    for (; it != keys.end(); it++)
-    {
-        str += KEY_SEPARATOR;
-        str += *it;
-    }
-
-    setKeys(str);
-}
-
-int Message::getDelayTimeLevel()
-{
-    std::string tmp = getProperty(PROPERTY_DELAY_TIME_LEVEL);
-    if (!tmp.empty())
-    {
-        return atoi(tmp.c_str());
-    }
-
-    return 0;
-}
-
-void Message::setDelayTimeLevel(int level)
-{
-    char tmp[16];
-    snprintf(tmp, sizeof(tmp), "%d", level);
-
-    putProperty(PROPERTY_DELAY_TIME_LEVEL, tmp);
-}
-
-bool Message::isWaitStoreMsgOK()
-{
-    std::string tmp = getProperty(PROPERTY_WAIT_STORE_MSG_OK);
-    if (tmp.empty())
-    {
-        return true;
-    }
-    else
-    {
-        return (tmp == "true") ? true : false;
-    }
-}
-
-void Message::setWaitStoreMsgOK(bool waitStoreMsgOK)
-{
-    if (waitStoreMsgOK)
-    {
-        putProperty(PROPERTY_WAIT_STORE_MSG_OK, "true");
-    }
-    else
-    {
-        putProperty(PROPERTY_WAIT_STORE_MSG_OK, "false");
-    }
-}
-
-int Message::getFlag()
-{
-    return m_flag;
-}
-
-void Message::setFlag(int flag)
-{
-    m_flag = flag;
-}
-
-const char* Message::getBody()const
-{
-    return m_body;
-}
-
-int Message::getBodyLen()const
-{
-    return m_bodyLen;
-}
-
-void Message::setBody(const char* body, int len)
-{
-    if (len > 0)
-    {
-    	if (m_body)
-    	{
-    		free(m_body);
-    		m_body = NULL;
-    		m_bodyLen = 0;
-    	}
-
-        m_body = (char*)malloc(len);
-        m_bodyLen = len;
-        memcpy(m_body, body, len);
-    }
-}
-
-bool Message::tryToCompress(int compressLevel)
-{
-    if (m_body != NULL)
-    {
-    	if (m_compressBody)
-		{
-	    	free(m_compressBody);
-	    	m_compressBody = NULL;
-	    	m_compressBodyLen = 0;
-	    }
-
-        unsigned char* pOut;
-        int outLen = 0;
-        if (UtilAll::compress(m_body, m_bodyLen, &pOut, &outLen, compressLevel))
-        {
-            m_compressBody = (char*)pOut;
-            m_compressBodyLen = outLen;
-            return true;
-        }
-    }
-
-    return false;
-}
-
-
-const char* Message::getCompressBody() const
-{
-    return m_compressBody;
-}
-
-int Message::getCompressBodyLen() const
-{
-    return m_compressBodyLen;
-}
-
-
-
-std::map<std::string, std::string>& Message::getProperties()
-{
-    return m_properties;
-}
-
-void Message::setProperties(const std::map<std::string, std::string>& properties)
-{
-    m_properties = properties;
-}
-
-void Message::Init(const std::string& topic, const std::string& tags, const std::string& keys, const int flag, const char* body, int len, bool waitStoreMsgOK)
-{
-    m_topic = topic;
-    m_flag = flag;
-
-    m_body = NULL;
-    m_bodyLen = len;
-
-    m_compressBody = NULL;
-    m_compressBodyLen = 0;
-
-    if (len > 0)
-    {
-        m_body = (char*)malloc(len);
-        memcpy(m_body, body, len);
-    }
-
-    if (tags.length() > 0)
-    {
-        setTags(tags);
-    }
-
-    if (keys.length() > 0)
-    {
-        setKeys(keys);
-    }
-
-    setWaitStoreMsgOK(waitStoreMsgOK);
-}
-
-std::string Message::toString() const
-{
-	std::stringstream ss;
-    ss << "{m_topic=" << m_topic
-       << ",m_flag=" << m_flag
-       << ",properties=" << UtilAll::toString(m_properties)
-       << ",m_bodyLen=" << m_bodyLen
-       << "}";
-    return ss.str();
-}
-
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/message/MessageDecoder.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/message/MessageDecoder.cpp b/rocketmq-client4cpp/src/message/MessageDecoder.cpp
deleted file mode 100755
index 338121e..0000000
--- a/rocketmq-client4cpp/src/message/MessageDecoder.cpp
+++ /dev/null
@@ -1,366 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#include "MessageDecoder.h"
-
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sstream>
-#include "MessageExt.h"
-#include "MessageSysFlag.h"
-#include "UtilAll.h"
-
-namespace rmq
-{
-
-const char MessageDecoder::NAME_VALUE_SEPARATOR = 1;
-const char MessageDecoder::PROPERTY_SEPARATOR = 2;
-const int MessageDecoder::MSG_ID_LENGTH = 8 + 8;
-
-int MessageDecoder::MessageMagicCodePostion = 4;
-int MessageDecoder::MessageFlagPostion = 16;
-int MessageDecoder::MessagePhysicOffsetPostion = 28;
-int MessageDecoder::MessageStoreTimestampPostion = 56;
-
-std::string MessageDecoder::createMessageId(sockaddr& addr, long long offset)
-{
-    struct sockaddr_in sa;
-    memcpy(&sa, &addr, sizeof(sockaddr));
-    sa.sin_family = AF_INET;
-
-    int port = ntohs(sa.sin_port);
-    port = htonl(port);
-    int ip = sa.sin_addr.s_addr;
-
-    unsigned char* buf = new unsigned char[MSG_ID_LENGTH];
-    offset = h2nll(offset);
-    memcpy(buf, &ip, 4);
-    memcpy(buf + 4, &port, 4);
-    memcpy(buf + 8, &offset, 8);
-
-    char* str = new char[2 * MSG_ID_LENGTH + 1];
-    memset(str, 0, 2 * MSG_ID_LENGTH + 1);
-
-    for (int i = 0; i < MSG_ID_LENGTH; i++)
-    {
-        char tmp[3];
-        tmp[2] = 0;
-
-        snprintf(tmp, sizeof(tmp), "%02X", buf[i]);
-        strncat(str, tmp, sizeof(tmp));
-    }
-
-    std::string ret = str;
-
-    delete[] buf;
-    delete[] str;
-
-    return ret;
-}
-
-MessageId MessageDecoder::decodeMessageId(const std::string& msgId)
-{
-    std::string ipstr = msgId.substr(0, 8);
-    std::string portstr = msgId.substr(8, 8);
-    std::string offsetstr = msgId.substr(16);
-
-    char* end;
-    int ipint = strtoul(ipstr.c_str(), &end, 16);
-    int portint = strtoul(portstr.c_str(), &end, 16);
-
-    long long offset = UtilAll::hexstr2ull(offsetstr.c_str());
-
-    offset = n2hll(offset);
-
-    portint = ntohl(portint);
-    short port = portint;
-
-    struct sockaddr_in sa;
-    sa.sin_family = AF_INET;
-    sa.sin_port = htons(port);
-    sa.sin_addr.s_addr = ipint;
-
-    sockaddr addr;
-    memcpy(&addr, &sa, sizeof(sockaddr));
-
-    MessageId id(addr, offset);
-
-    return id;
-}
-
-MessageExt* MessageDecoder::decode(const char* pData, int len, int& offset)
-{
-    return decode(pData, len, offset, true);
-}
-
-MessageExt* MessageDecoder::decode(const char* pData, int len, int& offset, bool readBody)
-{
-	MessageExt* msgExt = NULL;
-
-    try
-    {
-        msgExt = new MessageExt();
-
-        // 1 TOTALSIZE
-        int storeSize;
-        memcpy(&storeSize, pData, 4);
-        storeSize = ntohl(storeSize);
-
-        msgExt->setStoreSize(storeSize);
-
-        // 2 MAGICCODE sizeof(int)
-
-        // 3 BODYCRC
-        int bodyCRC;
-        memcpy(&bodyCRC, pData + 2 * sizeof(int), 4);
-        bodyCRC = ntohl(bodyCRC);
-        msgExt->setBodyCRC(bodyCRC);
-
-        // 4 QUEUEID
-        int queueId;
-        memcpy(&queueId, pData + 3 * sizeof(int), 4);
-        queueId = ntohl(queueId);
-        msgExt->setQueueId(queueId);
-
-        // 5 FLAG
-        int flag ;
-
-        memcpy(&flag, pData + 4 * sizeof(int), 4);
-        flag = ntohl(flag);
-
-        msgExt->setFlag(flag);
-
-        // 6 QUEUEOFFSET
-        long long queueOffset;
-        memcpy(&queueOffset, pData + 5 * sizeof(int), 8);
-        queueOffset = n2hll(queueOffset);
-        msgExt->setQueueOffset(queueOffset);
-
-        // 7 PHYSICALOFFSET
-        long long physicOffset;
-
-        memcpy(&physicOffset, pData + 7 * sizeof(int), 8);
-        physicOffset = n2hll(physicOffset);
-        msgExt->setCommitLogOffset(physicOffset);
-
-        // 8 SYSFLAG
-        int sysFlag;
-
-        memcpy(&sysFlag, pData + 9 * sizeof(int), 4);
-        sysFlag = ntohl(sysFlag);
-        msgExt->setSysFlag(sysFlag);
-
-        // 9 BORNTIMESTAMP
-        long long bornTimeStamp;
-        memcpy(&bornTimeStamp, pData + 10 * sizeof(int), 8);
-        bornTimeStamp = n2hll(bornTimeStamp);
-
-        msgExt->setBornTimestamp(bornTimeStamp);
-
-        // 10 BORNHOST
-        int bornHost;//c0 a8 00 68  192.168.0.104 c0 a8 00 68 00 00 c4 04
-        memcpy(&bornHost, pData + 12 * sizeof(int), 4);
-
-        int port;
-        memcpy(&port, pData + 13 * sizeof(int), 4);
-        port = ntohl(port);
-
-        struct sockaddr_in sa;
-        sa.sin_family = AF_INET;
-        sa.sin_port = htons(port);
-        sa.sin_addr.s_addr = bornHost;
-
-        sockaddr bornAddr;
-        memcpy(&bornAddr, &sa, sizeof(sockaddr));
-        msgExt->setBornHost(bornAddr);
-
-        // 11 STORETIMESTAMP
-        long long storeTimestamp;
-        memcpy(&storeTimestamp, pData + 14 * sizeof(int), 8);
-        storeTimestamp = n2hll(storeTimestamp);
-        msgExt->setStoreTimestamp(storeTimestamp);
-
-        // 12 STOREHOST
-        int storeHost;
-        memcpy(&storeHost, pData + 16 * sizeof(int), 4);
-        memcpy(&port, pData + 17 * sizeof(int), 4);
-        port = ntohl(port);
-
-        sa.sin_family = AF_INET;
-        sa.sin_port = htons(port);
-        sa.sin_addr.s_addr = storeHost;
-
-        sockaddr storeAddr;
-        memcpy(&storeAddr, &sa, sizeof(sockaddr));
-
-        msgExt->setStoreHost(storeAddr);
-
-        // 13 RECONSUMETIMES
-        int reconsumeTimes;
-        memcpy(&reconsumeTimes, pData + 18 * sizeof(int), 4);
-        reconsumeTimes = ntohl(reconsumeTimes);
-        msgExt->setReconsumeTimes(reconsumeTimes);
-
-        // 14 Prepared Transaction Offset
-        long long preparedTransactionOffset;
-        memcpy(&preparedTransactionOffset, pData + 19 * sizeof(int), 8);
-        preparedTransactionOffset = n2hll(preparedTransactionOffset);
-        msgExt->setPreparedTransactionOffset(preparedTransactionOffset);
-
-        // 15 BODY
-        int bodyLen = 0;
-        memcpy(&bodyLen, pData + 21 * sizeof(int), 4);
-        bodyLen = ntohl(bodyLen);
-
-        if (bodyLen > 0)
-        {
-            if (readBody)
-            {
-                const char* body = pData + 22 * sizeof(int);
-                int newBodyLen = bodyLen;
-
-                // uncompress body
-                if ((sysFlag & MessageSysFlag::CompressedFlag) == MessageSysFlag::CompressedFlag)
-                {
-                    unsigned char* pOut;
-                    int outLen;
-
-                    if (UtilAll::decompress(body, bodyLen, &pOut, &outLen))
-                    {
-                        msgExt->setBody((char*)pOut, outLen);
-                        free(pOut);
-                    }
-                    else
-                    {
-                        msgExt->setBody(body, newBodyLen);
-                    }
-                }
-                else
-                {
-                    msgExt->setBody(body, newBodyLen);
-                }
-            }
-            else
-            {
-
-            }
-        }
-
-        // 16 TOPIC
-        int topicLen = *(pData + 22 * sizeof(int) + bodyLen);
-
-        char* tmp = new char[topicLen + 1];
-
-        memcpy(tmp, pData + 22 * sizeof(int) + bodyLen + 1, topicLen);
-        tmp[topicLen] = 0;
-        std::string topic = tmp;
-
-        delete[] tmp;
-
-        msgExt->setTopic(topic);
-
-        // 17 properties
-        short propertiesLength;
-        memcpy(&propertiesLength, pData + 22 * sizeof(int) + bodyLen + 1 + topicLen, 2);
-        propertiesLength = ntohs(propertiesLength);
-
-        if (propertiesLength > 0)
-        {
-            char* properties = new char[propertiesLength + 1];
-            memcpy(properties, pData + 22 * sizeof(int) + bodyLen + 1 + topicLen + 2, propertiesLength);
-            properties[propertiesLength] = 0;
-            std::string propertiesString = properties;
-            std::map<std::string, std::string> map;
-            string2messageProperties(map, propertiesString);
-            msgExt->setProperties(map);
-            delete[] properties;
-        }
-
-        offset = 22 * sizeof(int) + bodyLen + 1 + topicLen + 2 + propertiesLength;
-
-        // ��ϢID
-        std::string msgId =  createMessageId(storeAddr, physicOffset);
-        msgExt->setMsgId(msgId);
-
-        return msgExt;
-    }
-    catch (...)
-    {
-    	RMQ_ERROR("decode exception");
-		if (msgExt)
-		{
-			delete msgExt;
-			msgExt = NULL;
-		}
-    }
-
-    return NULL;
-}
-
-std::list<MessageExt*> MessageDecoder::decodes(const char* pData, int len)
-{
-    return decodes(pData, len, true);
-}
-
-std::list<MessageExt*> MessageDecoder::decodes(const char* pData, int len, bool readBody)
-{
-    std::list<MessageExt*> list;
-
-    int offset = 0;
-    while (offset < len)
-    {
-        int tmp;
-        MessageExt* msg = decode(pData + offset, len, tmp);
-        list.push_back(msg);
-        offset += tmp;
-    }
-
-    return list;
-}
-
-std::string MessageDecoder::messageProperties2String(const std::map<std::string, std::string>& properties)
-{
-    std::stringstream ss;
-
-    std::map<std::string, std::string>::const_iterator it = properties.begin();
-
-    for (; it != properties.end(); it++)
-    {
-        ss << it->first << NAME_VALUE_SEPARATOR << it->second << PROPERTY_SEPARATOR;
-    }
-
-    return ss.str();
-}
-
-void MessageDecoder::string2messageProperties(std::map<std::string, std::string>& properties,
-        std::string& propertiesString)
-{
-    std::vector<std::string> out;
-    UtilAll::Split(out, propertiesString, PROPERTY_SEPARATOR);
-
-    for (size_t i = 0; i < out.size(); i++)
-    {
-        std::vector<std::string> outValue;
-        UtilAll::Split(outValue, out[i], NAME_VALUE_SEPARATOR);
-
-        if (outValue.size() == 2)
-        {
-            properties[outValue[0]] = outValue[1];
-        }
-    }
-}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/message/MessageDecoder.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/message/MessageDecoder.h b/rocketmq-client4cpp/src/message/MessageDecoder.h
deleted file mode 100755
index a5f24ed..0000000
--- a/rocketmq-client4cpp/src/message/MessageDecoder.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#ifndef __MESSAGEDECODER_H__
-#define  __MESSAGEDECODER_H__
-
-#include <string>
-#include <list>
-#include <map>
-
-#include "SocketUtil.h"
-#include "MessageId.h"
-
-namespace rmq
-{
-    class MessageExt;
-    class UnknownHostException;
-
-    /**
-    * Message decoder
-    *
-    */
-    class MessageDecoder
-    {
-    public:
-        static std::string createMessageId(sockaddr& addr, long long offset);
-        static MessageId decodeMessageId(const std::string& msgId);
-
-        static MessageExt* decode(const char* pData, int len, int& offset);
-        static MessageExt* decode(const char* pData, int len, int& offset, bool readBody);
-
-        static std::list<MessageExt*> decodes(const char* pData, int len);
-        static std::list<MessageExt*> decodes(const char* pData, int len, bool readBody);
-
-        static std::string messageProperties2String(const std::map<std::string, std::string>& properties);
-        static void string2messageProperties(std::map<std::string, std::string>& properties,
-                                             std::string& propertiesString);
-
-    public:
-        static const char NAME_VALUE_SEPARATOR;
-        static const char PROPERTY_SEPARATOR;
-
-        static const int MSG_ID_LENGTH;
-
-        static int MessageMagicCodePostion;
-        static int MessageFlagPostion;
-        static int MessagePhysicOffsetPostion;
-        static int MessageStoreTimestampPostion;
-    };
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/message/MessageExt.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/message/MessageExt.cpp b/rocketmq-client4cpp/src/message/MessageExt.cpp
deleted file mode 100755
index 35479ce..0000000
--- a/rocketmq-client4cpp/src/message/MessageExt.cpp
+++ /dev/null
@@ -1,244 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#include "MessageExt.h"
-
-#include <sstream>
-#include "MessageSysFlag.h"
-#include "SocketUtil.h"
-
-namespace rmq
-{
-
-MessageExt::MessageExt()
-    : m_queueOffset(0),
-      m_commitLogOffset(0),
-      m_bornTimestamp(0),
-      m_storeTimestamp(0),
-      m_preparedTransactionOffset(0),
-      m_queueId(0),
-      m_storeSize(0),
-      m_sysFlag(0),
-      m_bodyCRC(0),
-      m_reconsumeTimes(3),
-      m_msgId("")
-{
-}
-
-MessageExt::MessageExt(int queueId,
-                       long long bornTimestamp,
-                       sockaddr bornHost,
-                       long long storeTimestamp,
-                       sockaddr storeHost,
-                       std::string msgId)
-    : m_queueOffset(0),
-      m_commitLogOffset(0),
-      m_bornTimestamp(bornTimestamp),
-      m_storeTimestamp(storeTimestamp),
-      m_preparedTransactionOffset(0),
-      m_queueId(queueId),
-      m_storeSize(0),
-      m_sysFlag(0),
-      m_bodyCRC(0),
-      m_reconsumeTimes(3),
-      m_bornHost(bornHost),
-      m_storeHost(storeHost),
-      m_msgId(msgId)
-{
-
-}
-
-MessageExt::~MessageExt()
-{
-
-}
-
-int MessageExt::getQueueId()
-{
-    return m_queueId;
-}
-
-void MessageExt::setQueueId(int queueId)
-{
-    m_queueId = queueId;
-}
-
-long long MessageExt::getBornTimestamp()
-{
-    return m_bornTimestamp;
-}
-
-void MessageExt::setBornTimestamp(long long bornTimestamp)
-{
-    m_bornTimestamp = bornTimestamp;
-}
-
-sockaddr MessageExt::getBornHost()
-{
-    return m_bornHost;
-}
-
-std::string MessageExt::getBornHostString()
-{
-    return socketAddress2String(m_bornHost);
-}
-
-std::string MessageExt::getBornHostNameString()
-{
-    return getHostName(m_bornHost);
-}
-
-void MessageExt::setBornHost(const sockaddr& bornHost)
-{
-    m_bornHost = bornHost;
-}
-
-long long MessageExt::getStoreTimestamp()
-{
-    return m_storeTimestamp;
-}
-
-void MessageExt::setStoreTimestamp(long long storeTimestamp)
-{
-    m_storeTimestamp = storeTimestamp;
-}
-
-sockaddr MessageExt::getStoreHost()
-{
-    return m_storeHost;
-}
-
-std::string MessageExt::getStoreHostString()
-{
-    return socketAddress2String(m_storeHost);
-}
-
-void MessageExt::setStoreHost(const sockaddr& storeHost)
-{
-    m_storeHost = storeHost;
-}
-
-std::string MessageExt::getMsgId()
-{
-    return m_msgId;
-}
-
-void MessageExt::setMsgId(const std::string& msgId)
-{
-    m_msgId = msgId;
-}
-
-int MessageExt::getSysFlag()
-{
-    return m_sysFlag;
-}
-
-void MessageExt::setSysFlag(int sysFlag)
-{
-    m_sysFlag = sysFlag;
-}
-
-int MessageExt::getBodyCRC()
-{
-    return m_bodyCRC;
-}
-
-void MessageExt::setBodyCRC(int bodyCRC)
-{
-    m_bodyCRC = bodyCRC;
-}
-
-long long MessageExt::getQueueOffset()
-{
-    return m_queueOffset;
-}
-
-void MessageExt::setQueueOffset(long long queueOffset)
-{
-    m_queueOffset = queueOffset;
-}
-
-long long MessageExt::getCommitLogOffset()
-{
-    return m_commitLogOffset;
-}
-
-void MessageExt::setCommitLogOffset(long long physicOffset)
-{
-    m_commitLogOffset = physicOffset;
-}
-
-int MessageExt::getStoreSize()
-{
-    return m_storeSize;
-}
-
-void MessageExt::setStoreSize(int storeSize)
-{
-    m_storeSize = storeSize;
-}
-
-TopicFilterType MessageExt::parseTopicFilterType(int sysFlag)
-{
-    if ((sysFlag & MessageSysFlag::MultiTagsFlag) == MessageSysFlag::MultiTagsFlag)
-    {
-        return MULTI_TAG;
-    }
-
-    return SINGLE_TAG;
-}
-
-int MessageExt::getReconsumeTimes()
-{
-    return m_reconsumeTimes;
-}
-
-void MessageExt::setReconsumeTimes(int reconsumeTimes)
-{
-    m_reconsumeTimes = reconsumeTimes;
-}
-
-long long MessageExt::getPreparedTransactionOffset()
-{
-    return  m_preparedTransactionOffset;
-}
-
-void MessageExt::setPreparedTransactionOffset(long long preparedTransactionOffset)
-{
-    m_preparedTransactionOffset = preparedTransactionOffset;
-}
-
-std::string MessageExt::toString() const
-{
-    std::stringstream ss;
-    ss << "{msgId=" << m_msgId
-       << ",queueId=" << m_queueId
-       << ",storeSize=" << m_storeSize
-       << ",sysFlag=" << m_sysFlag
-       << ",queueOffset=" << m_queueOffset
-       << ",commitLogOffset=" << m_commitLogOffset
-       << ",preparedTransactionOffset=" << m_preparedTransactionOffset
-       << ",bornTimestamp=" << m_bornTimestamp
-       << ",bornHost=" << socketAddress2String(m_bornHost)
-       << ",storeHost=" << socketAddress2String(m_storeHost)
-       << ",storeTimestamp=" << m_storeTimestamp
-       << ",reconsumeTimes=" << m_reconsumeTimes
-       << ",bodyCRC=" << m_bodyCRC
-       << ",Message=" << Message::toString()
-       << "}";
-    return ss.str();
-}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/message/MessageId.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/message/MessageId.h b/rocketmq-client4cpp/src/message/MessageId.h
deleted file mode 100644
index 5237f8d..0000000
--- a/rocketmq-client4cpp/src/message/MessageId.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __MESSAGEID_H__
-#define __MESSAGEID_H__
-
-#include "SocketUtil.h"
-
-namespace rmq
-{
-    class MessageId
-    {
-    public:
-        MessageId(sockaddr address, long long offset)
-            : m_address(address), m_offset(offset)
-        {
-
-        }
-
-        sockaddr getAddress()
-        {
-            return m_address;
-        }
-
-        void setAddress(sockaddr address)
-        {
-            m_address = address;
-        }
-
-        long long getOffset()
-        {
-            return m_offset;
-        }
-
-        void setOffset(long long offset)
-        {
-            m_offset = offset;
-        }
-
-    private:
-        sockaddr m_address;
-        long long m_offset;
-    };
-}
-
-#endif


[09/17] incubator-rocketmq-externals git commit: Polish cpp module

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/jsoncpp/json/config.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/jsoncpp/json/config.h b/rocketmq-client4cpp/src/jsoncpp/json/config.h
deleted file mode 100755
index 55d50d9..0000000
--- a/rocketmq-client4cpp/src/jsoncpp/json/config.h
+++ /dev/null
@@ -1,182 +0,0 @@
-// Copyright 2007-2010 Baptiste Lepilleur
-// Distributed under MIT license, or public domain if desired and
-// recognized in your jurisdiction.
-// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
-
-#ifndef JSON_CONFIG_H_INCLUDED
-#define JSON_CONFIG_H_INCLUDED
-#include <stddef.h>
-#include <string> //typedef String
-#include <stdint.h> //typedef int64_t, uint64_t
-
-/// If defined, indicates that json library is embedded in CppTL library.
-//# define JSON_IN_CPPTL 1
-
-/// If defined, indicates that json may leverage CppTL library
-//#  define JSON_USE_CPPTL 1
-/// If defined, indicates that cpptl vector based map should be used instead of
-/// std::map
-/// as Value container.
-//#  define JSON_USE_CPPTL_SMALLMAP 1
-
-// If non-zero, the library uses exceptions to report bad input instead of C
-// assertion macros. The default is to use exceptions.
-#ifndef JSON_USE_EXCEPTION
-#define JSON_USE_EXCEPTION 1
-#endif
-
-/// If defined, indicates that the source file is amalgated
-/// to prevent private header inclusion.
-/// Remarks: it is automatically defined in the generated amalgated header.
-// #define JSON_IS_AMALGAMATION
-
-#ifdef JSON_IN_CPPTL
-#include <cpptl/config.h>
-#ifndef JSON_USE_CPPTL
-#define JSON_USE_CPPTL 1
-#endif
-#endif
-
-#ifdef JSON_IN_CPPTL
-#define JSON_API CPPTL_API
-#elif defined(JSON_DLL_BUILD)
-#if defined(_MSC_VER) || defined(__MINGW32__)
-#define JSON_API __declspec(dllexport)
-#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
-#endif // if defined(_MSC_VER)
-#elif defined(JSON_DLL)
-#if defined(_MSC_VER) || defined(__MINGW32__)
-#define JSON_API __declspec(dllimport)
-#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
-#endif // if defined(_MSC_VER)
-#endif // ifdef JSON_IN_CPPTL
-#if !defined(JSON_API)
-#define JSON_API
-#endif
-
-// If JSON_NO_INT64 is defined, then Json only support C++ "int" type for
-// integer
-// Storages, and 64 bits integer support is disabled.
-// #define JSON_NO_INT64 1
-
-#if defined(_MSC_VER) // MSVC
-#  if _MSC_VER <= 1200 // MSVC 6
-    // Microsoft Visual Studio 6 only support conversion from __int64 to double
-    // (no conversion from unsigned __int64).
-#    define JSON_USE_INT64_DOUBLE_CONVERSION 1
-    // Disable warning 4786 for VS6 caused by STL (identifier was truncated to '255'
-    // characters in the debug information)
-    // All projects I've ever seen with VS6 were using this globally (not bothering
-    // with pragma push/pop).
-#    pragma warning(disable : 4786)
-#  endif // MSVC 6
-
-#  if _MSC_VER >= 1500 // MSVC 2008
-    /// Indicates that the following function is deprecated.
-#    define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
-#  endif
-
-#endif // defined(_MSC_VER)
-
-// In c++11 the override keyword allows you to explicity define that a function
-// is intended to override the base-class version.  This makes the code more
-// managable and fixes a set of common hard-to-find bugs.
-#if __cplusplus >= 201103L
-# define JSONCPP_OVERRIDE override
-#elif defined(_MSC_VER) && _MSC_VER > 1600
-# define JSONCPP_OVERRIDE override
-#else
-# define JSONCPP_OVERRIDE
-#endif
-
-#ifndef JSON_HAS_RVALUE_REFERENCES
-
-#if defined(_MSC_VER) && _MSC_VER >= 1600 // MSVC >= 2010
-#define JSON_HAS_RVALUE_REFERENCES 1
-#endif // MSVC >= 2010
-
-#ifdef __clang__
-#if __has_feature(cxx_rvalue_references)
-#define JSON_HAS_RVALUE_REFERENCES 1
-#endif  // has_feature
-
-#elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
-#if defined(__GXX_EXPERIMENTAL_CXX0X__) || (__cplusplus >= 201103L)
-#define JSON_HAS_RVALUE_REFERENCES 1
-#endif  // GXX_EXPERIMENTAL
-
-#endif // __clang__ || __GNUC__
-
-#endif // not defined JSON_HAS_RVALUE_REFERENCES
-
-#ifndef JSON_HAS_RVALUE_REFERENCES
-#define JSON_HAS_RVALUE_REFERENCES 0
-#endif
-
-#ifdef __clang__
-#elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
-#  if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
-#    define JSONCPP_DEPRECATED(message)  __attribute__ ((deprecated(message)))
-#  elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
-#    define JSONCPP_DEPRECATED(message)  __attribute__((__deprecated__))
-#  endif  // GNUC version
-#endif // __clang__ || __GNUC__
-
-#if !defined(JSONCPP_DEPRECATED)
-#define JSONCPP_DEPRECATED(message)
-#endif // if !defined(JSONCPP_DEPRECATED)
-
-#if __GNUC__ >= 6
-#  define JSON_USE_INT64_DOUBLE_CONVERSION 1
-#endif
-
-#if !defined(JSON_IS_AMALGAMATION)
-
-# include "version.h"
-
-# if JSONCPP_USING_SECURE_MEMORY
-#  include "allocator.h" //typedef Allocator
-# endif
-
-#endif // if !defined(JSON_IS_AMALGAMATION)
-
-namespace rmq {
-namespace Json {
-
-typedef int Int;
-typedef unsigned int UInt;
-#if defined(JSON_NO_INT64)
-typedef int LargestInt;
-typedef unsigned int LargestUInt;
-#undef JSON_HAS_INT64
-#else                 // if defined(JSON_NO_INT64)
-// For Microsoft Visual use specific types as long long is not supported
-#if defined(_MSC_VER) // Microsoft Visual Studio
-typedef __int64 Int64;
-typedef unsigned __int64 UInt64;
-#else                 // if defined(_MSC_VER) // Other platforms, use long long
-   typedef long long int Int64;
-   typedef unsigned long long int UInt64;
-#endif // if defined(_MSC_VER)
-typedef Int64 LargestInt;
-typedef UInt64 LargestUInt;
-#define JSON_HAS_INT64
-#endif // if defined(JSON_NO_INT64)
-#if JSONCPP_USING_SECURE_MEMORY
-#define JSONCPP_STRING        std::basic_string<char, std::char_traits<char>, rmq::Json::SecureAllocator<char> >
-#define JSONCPP_OSTRINGSTREAM std::basic_ostringstream<char, std::char_traits<char>, rmq::Json::SecureAllocator<char> >
-#define JSONCPP_OSTREAM       std::basic_ostream<char, std::char_traits<char>>
-#define JSONCPP_ISTRINGSTREAM std::basic_istringstream<char, std::char_traits<char>, rmq::Json::SecureAllocator<char> >
-#define JSONCPP_ISTREAM       std::istream
-#else
-#define JSONCPP_STRING        std::string
-#define JSONCPP_OSTRINGSTREAM std::ostringstream
-#define JSONCPP_OSTREAM       std::ostream
-#define JSONCPP_ISTRINGSTREAM std::istringstream
-#define JSONCPP_ISTREAM       std::istream
-#endif // if JSONCPP_USING_SECURE_MEMORY
-
-} // end namespace Json
-} // end namespace rmq
-
-#endif // JSON_CONFIG_H_INCLUDED

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/jsoncpp/json/features.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/jsoncpp/json/features.h b/rocketmq-client4cpp/src/jsoncpp/json/features.h
deleted file mode 100755
index d109790..0000000
--- a/rocketmq-client4cpp/src/jsoncpp/json/features.h
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright 2007-2010 Baptiste Lepilleur
-// Distributed under MIT license, or public domain if desired and
-// recognized in your jurisdiction.
-// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
-
-#ifndef CPPTL_JSON_FEATURES_H_INCLUDED
-#define CPPTL_JSON_FEATURES_H_INCLUDED
-
-#if !defined(JSON_IS_AMALGAMATION)
-#include "forwards.h"
-#endif // if !defined(JSON_IS_AMALGAMATION)
-
-namespace rmq {
-namespace Json {
-
-/** \brief Configuration passed to reader and writer.
- * This configuration object can be used to force the Reader or Writer
- * to behave in a standard conforming way.
- */
-class JSON_API Features {
-public:
-  /** \brief A configuration that allows all features and assumes all strings
-   * are UTF-8.
-   * - C & C++ comments are allowed
-   * - Root object can be any JSON value
-   * - Assumes Value strings are encoded in UTF-8
-   */
-  static Features all();
-
-  /** \brief A configuration that is strictly compatible with the JSON
-   * specification.
-   * - Comments are forbidden.
-   * - Root object must be either an array or an object value.
-   * - Assumes Value strings are encoded in UTF-8
-   */
-  static Features strictMode();
-
-  /** \brief Initialize the configuration like JsonConfig::allFeatures;
-   */
-  Features();
-
-  /// \c true if comments are allowed. Default: \c true.
-  bool allowComments_;
-
-  /// \c true if root must be either an array or an object value. Default: \c
-  /// false.
-  bool strictRoot_;
-
-  /// \c true if dropped null placeholders are allowed. Default: \c false.
-  bool allowDroppedNullPlaceholders_;
-
-  /// \c true if numeric object key are allowed. Default: \c false.
-  bool allowNumericKeys_;
-};
-
-} // namespace Json
-} // namespace rmq
-
-#endif // CPPTL_JSON_FEATURES_H_INCLUDED

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/jsoncpp/json/forwards.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/jsoncpp/json/forwards.h b/rocketmq-client4cpp/src/jsoncpp/json/forwards.h
deleted file mode 100755
index 71f59a3..0000000
--- a/rocketmq-client4cpp/src/jsoncpp/json/forwards.h
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright 2007-2010 Baptiste Lepilleur
-// Distributed under MIT license, or public domain if desired and
-// recognized in your jurisdiction.
-// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
-
-#ifndef JSON_FORWARDS_H_INCLUDED
-#define JSON_FORWARDS_H_INCLUDED
-
-#if !defined(JSON_IS_AMALGAMATION)
-#include "config.h"
-#endif // if !defined(JSON_IS_AMALGAMATION)
-
-namespace rmq {
-namespace Json {
-
-// writer.h
-class FastWriter;
-class StyledWriter;
-
-// reader.h
-class Reader;
-
-// features.h
-class Features;
-
-// value.h
-typedef unsigned int ArrayIndex;
-class StaticString;
-class Path;
-class PathArgument;
-class Value;
-class ValueIteratorBase;
-class ValueIterator;
-class ValueConstIterator;
-
-} // namespace Json
-} // namespace rmq
-
-#endif // JSON_FORWARDS_H_INCLUDED

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/jsoncpp/json/json.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/jsoncpp/json/json.h b/rocketmq-client4cpp/src/jsoncpp/json/json.h
deleted file mode 100644
index 8f10ac2..0000000
--- a/rocketmq-client4cpp/src/jsoncpp/json/json.h
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2007-2010 Baptiste Lepilleur
-// Distributed under MIT license, or public domain if desired and
-// recognized in your jurisdiction.
-// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
-
-#ifndef JSON_JSON_H_INCLUDED
-#define JSON_JSON_H_INCLUDED
-
-#include "autolink.h"
-#include "value.h"
-#include "reader.h"
-#include "writer.h"
-#include "features.h"
-
-#endif // JSON_JSON_H_INCLUDED

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/jsoncpp/json/reader.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/jsoncpp/json/reader.h b/rocketmq-client4cpp/src/jsoncpp/json/reader.h
deleted file mode 100755
index 846251b..0000000
--- a/rocketmq-client4cpp/src/jsoncpp/json/reader.h
+++ /dev/null
@@ -1,406 +0,0 @@
-// Copyright 2007-2010 Baptiste Lepilleur
-// Distributed under MIT license, or public domain if desired and
-// recognized in your jurisdiction.
-// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
-
-#ifndef CPPTL_JSON_READER_H_INCLUDED
-#define CPPTL_JSON_READER_H_INCLUDED
-
-#if !defined(JSON_IS_AMALGAMATION)
-#include "features.h"
-#include "value.h"
-#endif // if !defined(JSON_IS_AMALGAMATION)
-#include <deque>
-#include <iosfwd>
-#include <stack>
-#include <string>
-#include <istream>
-
-// Disable warning C4251: <data member>: <type> needs to have dll-interface to
-// be used by...
-#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
-#pragma warning(push)
-#pragma warning(disable : 4251)
-#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
-
-namespace rmq {
-namespace Json {
-
-/** \brief Unserialize a <a HREF="http://www.json.org">JSON</a> document into a
- *Value.
- *
- * \deprecated Use CharReader and CharReaderBuilder.
- */
-class JSON_API Reader {
-public:
-  typedef char Char;
-  typedef const Char* Location;
-
-  /** \brief An error tagged with where in the JSON text it was encountered.
-   *
-   * The offsets give the [start, limit) range of bytes within the text. Note
-   * that this is bytes, not codepoints.
-   *
-   */
-  struct StructuredError {
-    ptrdiff_t offset_start;
-    ptrdiff_t offset_limit;
-    JSONCPP_STRING message;
-  };
-
-  /** \brief Constructs a Reader allowing all features
-   * for parsing.
-   */
-  Reader();
-
-  /** \brief Constructs a Reader allowing the specified feature set
-   * for parsing.
-   */
-  Reader(const Features& features);
-
-  /** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a>
-   * document.
-   * \param document UTF-8 encoded string containing the document to read.
-   * \param root [out] Contains the root value of the document if it was
-   *             successfully parsed.
-   * \param collectComments \c true to collect comment and allow writing them
-   * back during
-   *                        serialization, \c false to discard comments.
-   *                        This parameter is ignored if
-   * Features::allowComments_
-   *                        is \c false.
-   * \return \c true if the document was successfully parsed, \c false if an
-   * error occurred.
-   */
-  bool
-  parse(const std::string& document, Value& root, bool collectComments = true);
-
-  /** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a>
-   document.
-   * \param beginDoc Pointer on the beginning of the UTF-8 encoded string of the
-   document to read.
-   * \param endDoc Pointer on the end of the UTF-8 encoded string of the
-   document to read.
-   *               Must be >= beginDoc.
-   * \param root [out] Contains the root value of the document if it was
-   *             successfully parsed.
-   * \param collectComments \c true to collect comment and allow writing them
-   back during
-   *                        serialization, \c false to discard comments.
-   *                        This parameter is ignored if
-   Features::allowComments_
-   *                        is \c false.
-   * \return \c true if the document was successfully parsed, \c false if an
-   error occurred.
-   */
-  bool parse(const char* beginDoc,
-             const char* endDoc,
-             Value& root,
-             bool collectComments = true);
-
-  /// \brief Parse from input stream.
-  /// \see Json::operator>>(std::istream&, Json::Value&).
-  bool parse(JSONCPP_ISTREAM& is, Value& root, bool collectComments = true);
-
-  /** \brief Returns a user friendly string that list errors in the parsed
-   * document.
-   * \return Formatted error message with the list of errors with their location
-   * in
-   *         the parsed document. An empty string is returned if no error
-   * occurred
-   *         during parsing.
-   * \deprecated Use getFormattedErrorMessages() instead (typo fix).
-   */
-  JSONCPP_DEPRECATED("Use getFormattedErrorMessages() instead.")
-  JSONCPP_STRING getFormatedErrorMessages() const;
-
-  /** \brief Returns a user friendly string that list errors in the parsed
-   * document.
-   * \return Formatted error message with the list of errors with their location
-   * in
-   *         the parsed document. An empty string is returned if no error
-   * occurred
-   *         during parsing.
-   */
-  JSONCPP_STRING getFormattedErrorMessages() const;
-
-  /** \brief Returns a vector of structured erros encounted while parsing.
-   * \return A (possibly empty) vector of StructuredError objects. Currently
-   *         only one error can be returned, but the caller should tolerate
-   * multiple
-   *         errors.  This can occur if the parser recovers from a non-fatal
-   *         parse error and then encounters additional errors.
-   */
-  std::vector<StructuredError> getStructuredErrors() const;
-
-  /** \brief Add a semantic error message.
-   * \param value JSON Value location associated with the error
-   * \param message The error message.
-   * \return \c true if the error was successfully added, \c false if the
-   * Value offset exceeds the document size.
-   */
-  bool pushError(const Value& value, const JSONCPP_STRING& message);
-
-  /** \brief Add a semantic error message with extra context.
-   * \param value JSON Value location associated with the error
-   * \param message The error message.
-   * \param extra Additional JSON Value location to contextualize the error
-   * \return \c true if the error was successfully added, \c false if either
-   * Value offset exceeds the document size.
-   */
-  bool pushError(const Value& value, const JSONCPP_STRING& message, const Value& extra);
-
-  /** \brief Return whether there are any errors.
-   * \return \c true if there are no errors to report \c false if
-   * errors have occurred.
-   */
-  bool good() const;
-
-private:
-  enum TokenType {
-    tokenEndOfStream = 0,
-    tokenObjectBegin,
-    tokenObjectEnd,
-    tokenArrayBegin,
-    tokenArrayEnd,
-    tokenString,
-    tokenNumber,
-    tokenTrue,
-    tokenFalse,
-    tokenNull,
-    tokenArraySeparator,
-    tokenMemberSeparator,
-    tokenComment,
-    tokenError
-  };
-
-  class Token {
-  public:
-    TokenType type_;
-    Location start_;
-    Location end_;
-  };
-
-  class ErrorInfo {
-  public:
-    Token token_;
-    JSONCPP_STRING message_;
-    Location extra_;
-  };
-
-  typedef std::deque<ErrorInfo> Errors;
-
-  bool readToken(Token& token);
-  void skipSpaces();
-  bool match(Location pattern, int patternLength);
-  bool readComment();
-  bool readCStyleComment();
-  bool readCppStyleComment();
-  bool readString();
-  void readNumber();
-  bool readValue();
-  bool readObject(Token& token);
-  bool readArray(Token& token);
-  bool decodeNumber(Token& token);
-  bool decodeNumber(Token& token, Value& decoded);
-  bool decodeString(Token& token);
-  bool decodeString(Token& token, JSONCPP_STRING& decoded);
-  bool decodeDouble(Token& token);
-  bool decodeDouble(Token& token, Value& decoded);
-  bool decodeUnicodeCodePoint(Token& token,
-                              Location& current,
-                              Location end,
-                              unsigned int& unicode);
-  bool decodeUnicodeEscapeSequence(Token& token,
-                                   Location& current,
-                                   Location end,
-                                   unsigned int& unicode);
-  bool addError(const JSONCPP_STRING& message, Token& token, Location extra = 0);
-  bool recoverFromError(TokenType skipUntilToken);
-  bool addErrorAndRecover(const JSONCPP_STRING& message,
-                          Token& token,
-                          TokenType skipUntilToken);
-  void skipUntilSpace();
-  Value& currentValue();
-  Char getNextChar();
-  void
-  getLocationLineAndColumn(Location location, int& line, int& column) const;
-  JSONCPP_STRING getLocationLineAndColumn(Location location) const;
-  void addComment(Location begin, Location end, CommentPlacement placement);
-  void skipCommentTokens(Token& token);
-
-  typedef std::stack<Value*> Nodes;
-  Nodes nodes_;
-  Errors errors_;
-  JSONCPP_STRING document_;
-  Location begin_;
-  Location end_;
-  Location current_;
-  Location lastValueEnd_;
-  Value* lastValue_;
-  JSONCPP_STRING commentsBefore_;
-  Features features_;
-  bool collectComments_;
-};  // Reader
-
-/** Interface for reading JSON from a char array.
- */
-class JSON_API CharReader {
-public:
-  virtual ~CharReader() {}
-  /** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a>
-   document.
-   * The document must be a UTF-8 encoded string containing the document to read.
-   *
-   * \param beginDoc Pointer on the beginning of the UTF-8 encoded string of the
-   document to read.
-   * \param endDoc Pointer on the end of the UTF-8 encoded string of the
-   document to read.
-   *        Must be >= beginDoc.
-   * \param root [out] Contains the root value of the document if it was
-   *             successfully parsed.
-   * \param errs [out] Formatted error messages (if not NULL)
-   *        a user friendly string that lists errors in the parsed
-   * document.
-   * \return \c true if the document was successfully parsed, \c false if an
-   error occurred.
-   */
-  virtual bool parse(
-      char const* beginDoc, char const* endDoc,
-      Value* root, JSONCPP_STRING* errs) = 0;
-
-  class JSON_API Factory {
-  public:
-    virtual ~Factory() {}
-    /** \brief Allocate a CharReader via operator new().
-     * \throw std::exception if something goes wrong (e.g. invalid settings)
-     */
-    virtual CharReader* newCharReader() const = 0;
-  };  // Factory
-};  // CharReader
-
-/** \brief Build a CharReader implementation.
-
-Usage:
-\code
-  using namespace Json;
-  CharReaderBuilder builder;
-  builder["collectComments"] = false;
-  Value value;
-  JSONCPP_STRING errs;
-  bool ok = parseFromStream(builder, std::cin, &value, &errs);
-\endcode
-*/
-class JSON_API CharReaderBuilder : public CharReader::Factory {
-public:
-  // Note: We use a Json::Value so that we can add data-members to this class
-  // without a major version bump.
-  /** Configuration of this builder.
-    These are case-sensitive.
-    Available settings (case-sensitive):
-    - `"collectComments": false or true`
-      - true to collect comment and allow writing them
-        back during serialization, false to discard comments.
-        This parameter is ignored if allowComments is false.
-    - `"allowComments": false or true`
-      - true if comments are allowed.
-    - `"strictRoot": false or true`
-      - true if root must be either an array or an object value
-    - `"allowDroppedNullPlaceholders": false or true`
-      - true if dropped null placeholders are allowed. (See StreamWriterBuilder.)
-    - `"allowNumericKeys": false or true`
-      - true if numeric object keys are allowed.
-    - `"allowSingleQuotes": false or true`
-      - true if '' are allowed for strings (both keys and values)
-    - `"stackLimit": integer`
-      - Exceeding stackLimit (recursive depth of `readValue()`) will
-        cause an exception.
-      - This is a security issue (seg-faults caused by deeply nested JSON),
-        so the default is low.
-    - `"failIfExtra": false or true`
-      - If true, `parse()` returns false when extra non-whitespace trails
-        the JSON value in the input string.
-    - `"rejectDupKeys": false or true`
-      - If true, `parse()` returns false when a key is duplicated within an object.
-    - `"allowSpecialFloats": false or true`
-      - If true, special float values (NaNs and infinities) are allowed 
-        and their values are lossfree restorable.
-
-    You can examine 'settings_` yourself
-    to see the defaults. You can also write and read them just like any
-    JSON Value.
-    \sa setDefaults()
-    */
-  Value settings_;
-
-  CharReaderBuilder();
-  ~CharReaderBuilder() JSONCPP_OVERRIDE;
-
-  CharReader* newCharReader() const JSONCPP_OVERRIDE;
-
-  /** \return true if 'settings' are legal and consistent;
-   *   otherwise, indicate bad settings via 'invalid'.
-   */
-  bool validate(Value* invalid) const;
-
-  /** A simple way to update a specific setting.
-   */
-  Value& operator[](JSONCPP_STRING key);
-
-  /** Called by ctor, but you can use this to reset settings_.
-   * \pre 'settings' != NULL (but Json::null is fine)
-   * \remark Defaults:
-   * \snippet src/lib_json/json_reader.cpp CharReaderBuilderDefaults
-   */
-  static void setDefaults(Value* settings);
-  /** Same as old Features::strictMode().
-   * \pre 'settings' != NULL (but Json::null is fine)
-   * \remark Defaults:
-   * \snippet src/lib_json/json_reader.cpp CharReaderBuilderStrictMode
-   */
-  static void strictMode(Value* settings);
-};
-
-/** Consume entire stream and use its begin/end.
-  * Someday we might have a real StreamReader, but for now this
-  * is convenient.
-  */
-bool JSON_API parseFromStream(
-    CharReader::Factory const&,
-    JSONCPP_ISTREAM&,
-    Value* root, std::string* errs);
-
-/** \brief Read from 'sin' into 'root'.
-
- Always keep comments from the input JSON.
-
- This can be used to read a file into a particular sub-object.
- For example:
- \code
- Json::Value root;
- cin >> root["dir"]["file"];
- cout << root;
- \endcode
- Result:
- \verbatim
- {
- "dir": {
-     "file": {
-     // The input stream JSON would be nested here.
-     }
- }
- }
- \endverbatim
- \throw std::exception on parse error.
- \see Json::operator<<()
-*/
-JSON_API JSONCPP_ISTREAM& operator>>(JSONCPP_ISTREAM&, Value&);
-
-} // namespace Json
-} // namespace rmq
-
-#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
-#pragma warning(pop)
-#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
-
-#endif // CPPTL_JSON_READER_H_INCLUDED

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/jsoncpp/json/value.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/jsoncpp/json/value.h b/rocketmq-client4cpp/src/jsoncpp/json/value.h
deleted file mode 100755
index 07ba7c6..0000000
--- a/rocketmq-client4cpp/src/jsoncpp/json/value.h
+++ /dev/null
@@ -1,868 +0,0 @@
-// Copyright 2007-2010 Baptiste Lepilleur
-// Distributed under MIT license, or public domain if desired and
-// recognized in your jurisdiction.
-// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
-
-#ifndef CPPTL_JSON_H_INCLUDED
-#define CPPTL_JSON_H_INCLUDED
-
-#if !defined(JSON_IS_AMALGAMATION)
-#include "forwards.h"
-#endif // if !defined(JSON_IS_AMALGAMATION)
-#include <string>
-#include <vector>
-#include <exception>
-
-#ifndef JSON_USE_CPPTL_SMALLMAP
-#include <map>
-#else
-#include <cpptl/smallmap.h>
-#endif
-#ifdef JSON_USE_CPPTL
-#include <cpptl/forwards.h>
-#endif
-
-//Conditional NORETURN attribute on the throw functions would:
-// a) suppress false positives from static code analysis 
-// b) possibly improve optimization opportunities.
-#if !defined(JSONCPP_NORETURN)
-#  if defined(_MSC_VER)
-#    define JSONCPP_NORETURN __declspec(noreturn)
-#  elif defined(__GNUC__)
-#    define JSONCPP_NORETURN __attribute__ ((__noreturn__))
-#  else
-#    define JSONCPP_NORETURN
-#  endif
-#endif
-
-// Disable warning C4251: <data member>: <type> needs to have dll-interface to
-// be used by...
-#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
-#pragma warning(push)
-#pragma warning(disable : 4251)
-#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
-
-/** \brief JSON (JavaScript Object Notation).
- */
-namespace rmq {
-namespace Json {
-
-/** Base class for all exceptions we throw.
- *
- * We use nothing but these internally. Of course, STL can throw others.
- */
-class JSON_API Exception : public std::exception {
-public:
-  Exception(JSONCPP_STRING const& msg);
-  ~Exception() throw() JSONCPP_OVERRIDE;
-  char const* what() const throw() JSONCPP_OVERRIDE;
-protected:
-  JSONCPP_STRING msg_;
-};
-
-/** Exceptions which the user cannot easily avoid.
- *
- * E.g. out-of-memory (when we use malloc), stack-overflow, malicious input
- * 
- * \remark derived from Json::Exception
- */
-class JSON_API RuntimeError : public Exception {
-public:
-  RuntimeError(JSONCPP_STRING const& msg);
-};
-
-/** Exceptions thrown by JSON_ASSERT/JSON_FAIL macros.
- *
- * These are precondition-violations (user bugs) and internal errors (our bugs).
- * 
- * \remark derived from Json::Exception
- */
-class JSON_API LogicError : public Exception {
-public:
-  LogicError(JSONCPP_STRING const& msg);
-};
-
-/// used internally
-JSONCPP_NORETURN void throwRuntimeError(JSONCPP_STRING const& msg);
-/// used internally
-JSONCPP_NORETURN void throwLogicError(JSONCPP_STRING const& msg);
-
-/** \brief Type of the value held by a Value object.
- */
-enum ValueType {
-  nullValue = 0, ///< 'null' value
-  intValue,      ///< signed integer value
-  uintValue,     ///< unsigned integer value
-  realValue,     ///< double value
-  stringValue,   ///< UTF-8 string value
-  booleanValue,  ///< bool value
-  arrayValue,    ///< array value (ordered list)
-  objectValue    ///< object value (collection of name/value pairs).
-};
-
-enum CommentPlacement {
-  commentBefore = 0,      ///< a comment placed on the line before a value
-  commentAfterOnSameLine, ///< a comment just after a value on the same line
-  commentAfter, ///< a comment on the line after a value (only make sense for
-  /// root value)
-  numberOfCommentPlacement
-};
-
-//# ifdef JSON_USE_CPPTL
-//   typedef CppTL::AnyEnumerator<const char *> EnumMemberNames;
-//   typedef CppTL::AnyEnumerator<const Value &> EnumValues;
-//# endif
-
-/** \brief Lightweight wrapper to tag static string.
- *
- * Value constructor and objectValue member assignement takes advantage of the
- * StaticString and avoid the cost of string duplication when storing the
- * string or the member name.
- *
- * Example of usage:
- * \code
- * Json::Value aValue( StaticString("some text") );
- * Json::Value object;
- * static const StaticString code("code");
- * object[code] = 1234;
- * \endcode
- */
-class JSON_API StaticString {
-public:
-  explicit StaticString(const char* czstring) : c_str_(czstring) {}
-
-  operator const char*() const { return c_str_; }
-
-  const char* c_str() const { return c_str_; }
-
-private:
-  const char* c_str_;
-};
-
-/** \brief Represents a <a HREF="http://www.json.org">JSON</a> value.
- *
- * This class is a discriminated union wrapper that can represents a:
- * - signed integer [range: Value::minInt - Value::maxInt]
- * - unsigned integer (range: 0 - Value::maxUInt)
- * - double
- * - UTF-8 string
- * - boolean
- * - 'null'
- * - an ordered list of Value
- * - collection of name/value pairs (javascript object)
- *
- * The type of the held value is represented by a #ValueType and
- * can be obtained using type().
- *
- * Values of an #objectValue or #arrayValue can be accessed using operator[]()
- * methods.
- * Non-const methods will automatically create the a #nullValue element
- * if it does not exist.
- * The sequence of an #arrayValue will be automatically resized and initialized
- * with #nullValue. resize() can be used to enlarge or truncate an #arrayValue.
- *
- * The get() methods can be used to obtain default value in the case the
- * required element does not exist.
- *
- * It is possible to iterate over the list of a #objectValue values using
- * the getMemberNames() method.
- *
- * \note #Value string-length fit in size_t, but keys must be < 2^30.
- * (The reason is an implementation detail.) A #CharReader will raise an
- * exception if a bound is exceeded to avoid security holes in your app,
- * but the Value API does *not* check bounds. That is the responsibility
- * of the caller.
- */
-class JSON_API Value {
-  friend class ValueIteratorBase;
-public:
-  typedef std::vector<JSONCPP_STRING> Members;
-  typedef ValueIterator iterator;
-  typedef ValueConstIterator const_iterator;
-  typedef rmq::Json::UInt UInt;
-  typedef rmq::Json::Int Int;
-#if defined(JSON_HAS_INT64)
-  typedef rmq::Json::UInt64 UInt64;
-  typedef rmq::Json::Int64 Int64;
-#endif // defined(JSON_HAS_INT64)
-  typedef rmq::Json::LargestInt LargestInt;
-  typedef rmq::Json::LargestUInt LargestUInt;
-  typedef rmq::Json::ArrayIndex ArrayIndex;
-
-  static const Value& null;  ///< We regret this reference to a global instance; prefer the simpler Value().
-  static const Value& nullRef;  ///< just a kludge for binary-compatibility; same as null
-  static Value const& nullSingleton(); ///< Prefer this to null or nullRef.
-
-  /// Minimum signed integer value that can be stored in a Json::Value.
-  static const LargestInt minLargestInt;
-  /// Maximum signed integer value that can be stored in a Json::Value.
-  static const LargestInt maxLargestInt;
-  /// Maximum unsigned integer value that can be stored in a Json::Value.
-  static const LargestUInt maxLargestUInt;
-
-  /// Minimum signed int value that can be stored in a Json::Value.
-  static const Int minInt;
-  /// Maximum signed int value that can be stored in a Json::Value.
-  static const Int maxInt;
-  /// Maximum unsigned int value that can be stored in a Json::Value.
-  static const UInt maxUInt;
-
-#if defined(JSON_HAS_INT64)
-  /// Minimum signed 64 bits int value that can be stored in a Json::Value.
-  static const Int64 minInt64;
-  /// Maximum signed 64 bits int value that can be stored in a Json::Value.
-  static const Int64 maxInt64;
-  /// Maximum unsigned 64 bits int value that can be stored in a Json::Value.
-  static const UInt64 maxUInt64;
-#endif // defined(JSON_HAS_INT64)
-
-private:
-#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
-  class CZString {
-  public:
-    enum DuplicationPolicy {
-      noDuplication = 0,
-      duplicate,
-      duplicateOnCopy
-    };
-    CZString(ArrayIndex index);
-    CZString(char const* str, unsigned length, DuplicationPolicy allocate);
-    CZString(CZString const& other);
-#if JSON_HAS_RVALUE_REFERENCES
-    CZString(CZString&& other);
-#endif
-    ~CZString();
-    CZString& operator=(CZString other);
-    bool operator<(CZString const& other) const;
-    bool operator==(CZString const& other) const;
-    ArrayIndex index() const;
-    //const char* c_str() const; ///< \deprecated
-    char const* data() const;
-    unsigned length() const;
-    bool isStaticString() const;
-
-  private:
-    void swap(CZString& other);
-
-    struct StringStorage {
-      unsigned policy_: 2;
-      unsigned length_: 30; // 1GB max
-    };
-
-    char const* cstr_;  // actually, a prefixed string, unless policy is noDup
-    union {
-      ArrayIndex index_;
-      StringStorage storage_;
-    };
-  };
-
-public:
-#ifndef JSON_USE_CPPTL_SMALLMAP
-  typedef std::map<CZString, Value> ObjectValues;
-#else
-  typedef CppTL::SmallMap<CZString, Value> ObjectValues;
-#endif // ifndef JSON_USE_CPPTL_SMALLMAP
-#endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
-
-public:
-  /** \brief Create a default Value of the given type.
-
-    This is a very useful constructor.
-    To create an empty array, pass arrayValue.
-    To create an empty object, pass objectValue.
-    Another Value can then be set to this one by assignment.
-This is useful since clear() and resize() will not alter types.
-
-    Examples:
-\code
-Json::Value null_value; // null
-Json::Value arr_value(Json::arrayValue); // []
-Json::Value obj_value(Json::objectValue); // {}
-\endcode
-  */
-  Value(ValueType type = nullValue);
-  Value(Int value);
-  Value(UInt value);
-#if defined(JSON_HAS_INT64)
-  Value(Int64 value);
-  Value(UInt64 value);
-#endif // if defined(JSON_HAS_INT64)
-  Value(double value);
-  Value(const char* value); ///< Copy til first 0. (NULL causes to seg-fault.)
-  Value(const char* begin, const char* end); ///< Copy all, incl zeroes.
-  /** \brief Constructs a value from a static string.
-
-   * Like other value string constructor but do not duplicate the string for
-   * internal storage. The given string must remain alive after the call to this
-   * constructor.
-   * \note This works only for null-terminated strings. (We cannot change the
-   *   size of this class, so we have nowhere to store the length,
-   *   which might be computed later for various operations.)
-   *
-   * Example of usage:
-   * \code
-   * static StaticString foo("some text");
-   * Json::Value aValue(foo);
-   * \endcode
-   */
-  Value(const StaticString& value);
-  Value(const JSONCPP_STRING& value); ///< Copy data() til size(). Embedded zeroes too.
-#ifdef JSON_USE_CPPTL
-  Value(const CppTL::ConstString& value);
-#endif
-  Value(bool value);
-  /// Deep copy.
-  Value(const Value& other);
-#if JSON_HAS_RVALUE_REFERENCES
-  /// Move constructor
-  Value(Value&& other);
-#endif
-  ~Value();
-
-  /// Deep copy, then swap(other).
-  /// \note Over-write existing comments. To preserve comments, use #swapPayload().
-  Value& operator=(Value other);
-  /// Swap everything.
-  void swap(Value& other);
-  /// Swap values but leave comments and source offsets in place.
-  void swapPayload(Value& other);
-
-  ValueType type() const;
-
-  /// Compare payload only, not comments etc.
-  bool operator<(const Value& other) const;
-  bool operator<=(const Value& other) const;
-  bool operator>=(const Value& other) const;
-  bool operator>(const Value& other) const;
-  bool operator==(const Value& other) const;
-  bool operator!=(const Value& other) const;
-  int compare(const Value& other) const;
-
-  const char* asCString() const; ///< Embedded zeroes could cause you trouble!
-#if JSONCPP_USING_SECURE_MEMORY
-  unsigned getCStringLength() const; //Allows you to understand the length of the CString
-#endif
-  JSONCPP_STRING asString() const; ///< Embedded zeroes are possible.
-  /** Get raw char* of string-value.
-   *  \return false if !string. (Seg-fault if str or end are NULL.)
-   */
-  bool getString(
-      char const** begin, char const** end) const;
-#ifdef JSON_USE_CPPTL
-  CppTL::ConstString asConstString() const;
-#endif
-  Int asInt() const;
-  UInt asUInt() const;
-#if defined(JSON_HAS_INT64)
-  Int64 asInt64() const;
-  UInt64 asUInt64() const;
-#endif // if defined(JSON_HAS_INT64)
-  LargestInt asLargestInt() const;
-  LargestUInt asLargestUInt() const;
-  float asFloat() const;
-  double asDouble() const;
-  bool asBool() const;
-
-  bool isNull() const;
-  bool isBool() const;
-  bool isInt() const;
-  bool isInt64() const;
-  bool isUInt() const;
-  bool isUInt64() const;
-  bool isIntegral() const;
-  bool isDouble() const;
-  bool isNumeric() const;
-  bool isString() const;
-  bool isArray() const;
-  bool isObject() const;
-
-  bool isConvertibleTo(ValueType other) const;
-
-  /// Number of values in array or object
-  ArrayIndex size() const;
-
-  /// \brief Return true if empty array, empty object, or null;
-  /// otherwise, false.
-  bool empty() const;
-
-  /// Return isNull()
-  bool operator!() const;
-
-  /// Remove all object members and array elements.
-  /// \pre type() is arrayValue, objectValue, or nullValue
-  /// \post type() is unchanged
-  void clear();
-
-  /// Resize the array to size elements.
-  /// New elements are initialized to null.
-  /// May only be called on nullValue or arrayValue.
-  /// \pre type() is arrayValue or nullValue
-  /// \post type() is arrayValue
-  void resize(ArrayIndex size);
-
-  /// Access an array element (zero based index ).
-  /// If the array contains less than index element, then null value are
-  /// inserted
-  /// in the array so that its size is index+1.
-  /// (You may need to say 'value[0u]' to get your compiler to distinguish
-  ///  this from the operator[] which takes a string.)
-  Value& operator[](ArrayIndex index);
-
-  /// Access an array element (zero based index ).
-  /// If the array contains less than index element, then null value are
-  /// inserted
-  /// in the array so that its size is index+1.
-  /// (You may need to say 'value[0u]' to get your compiler to distinguish
-  ///  this from the operator[] which takes a string.)
-  //Value& operator[](int index);
-
-  /// Access an array element (zero based index )
-  /// (You may need to say 'value[0u]' to get your compiler to distinguish
-  ///  this from the operator[] which takes a string.)
-  const Value& operator[](ArrayIndex index) const;
-
-  /// Access an array element (zero based index )
-  /// (You may need to say 'value[0u]' to get your compiler to distinguish
-  ///  this from the operator[] which takes a string.)
-  //const Value& operator[](int index) const;
-
-  /// If the array contains at least index+1 elements, returns the element
-  /// value,
-  /// otherwise returns defaultValue.
-  Value get(ArrayIndex index, const Value& defaultValue) const;
-  /// Return true if index < size().
-  bool isValidIndex(ArrayIndex index) const;
-  /// \brief Append value to array at the end.
-  ///
-  /// Equivalent to jsonvalue[jsonvalue.size()] = value;
-  Value& append(const Value& value);
-
-  /// Access an object value by name, create a null member if it does not exist.
-  /// \note Because of our implementation, keys are limited to 2^30 -1 chars.
-  ///  Exceeding that will cause an exception.
-  Value& operator[](const char* key);
-  /// Access an object value by name, returns null if there is no member with
-  /// that name.
-  const Value& operator[](const char* key) const;
-  /// Access an object value by name, create a null member if it does not exist.
-  /// \param key may contain embedded nulls.
-  Value& operator[](const JSONCPP_STRING& key);
-  /// Access an object value by name, returns null if there is no member with
-  /// that name.
-  /// \param key may contain embedded nulls.
-  const Value& operator[](const JSONCPP_STRING& key) const;
-  /** \brief Access an object value by name, create a null member if it does not
-   exist.
-
-   * If the object has no entry for that name, then the member name used to store
-   * the new entry is not duplicated.
-   * Example of use:
-   * \code
-   * Json::Value object;
-   * static const StaticString code("code");
-   * object[code] = 1234;
-   * \endcode
-   */
-  Value& operator[](const StaticString& key);
-#ifdef JSON_USE_CPPTL
-  /// Access an object value by name, create a null member if it does not exist.
-  Value& operator[](const CppTL::ConstString& key);
-  /// Access an object value by name, returns null if there is no member with
-  /// that name.
-  const Value& operator[](const CppTL::ConstString& key) const;
-#endif
-  /// Return the member named key if it exist, defaultValue otherwise.
-  /// \note deep copy
-  Value get(const char* key, const Value& defaultValue) const;
-  /// Return the member named key if it exist, defaultValue otherwise.
-  /// \note deep copy
-  /// \note key may contain embedded nulls.
-  Value get(const char* begin, const char* end, const Value& defaultValue) const;
-  /// Return the member named key if it exist, defaultValue otherwise.
-  /// \note deep copy
-  /// \param key may contain embedded nulls.
-  Value get(const JSONCPP_STRING& key, const Value& defaultValue) const;
-#ifdef JSON_USE_CPPTL
-  /// Return the member named key if it exist, defaultValue otherwise.
-  /// \note deep copy
-  Value get(const CppTL::ConstString& key, const Value& defaultValue) const;
-#endif
-  /// Most general and efficient version of isMember()const, get()const,
-  /// and operator[]const
-  /// \note As stated elsewhere, behavior is undefined if (end-begin) >= 2^30
-  Value const* find(char const* begin, char const* end) const;
-  /// Most general and efficient version of object-mutators.
-  /// \note As stated elsewhere, behavior is undefined if (end-begin) >= 2^30
-  /// \return non-zero, but JSON_ASSERT if this is neither object nor nullValue.
-  Value const* demand(char const* begin, char const* end);
-  /// \brief Remove and return the named member.
-  ///
-  /// Do nothing if it did not exist.
-  /// \return the removed Value, or null.
-  /// \pre type() is objectValue or nullValue
-  /// \post type() is unchanged
-  /// \deprecated
-  Value removeMember(const char* key);
-  /// Same as removeMember(const char*)
-  /// \param key may contain embedded nulls.
-  /// \deprecated
-  Value removeMember(const JSONCPP_STRING& key);
-  /// Same as removeMember(const char* begin, const char* end, Value* removed),
-  /// but 'key' is null-terminated.
-  bool removeMember(const char* key, Value* removed);
-  /** \brief Remove the named map member.
-
-      Update 'removed' iff removed.
-      \param key may contain embedded nulls.
-      \return true iff removed (no exceptions)
-  */
-  bool removeMember(JSONCPP_STRING const& key, Value* removed);
-  /// Same as removeMember(JSONCPP_STRING const& key, Value* removed)
-  bool removeMember(const char* begin, const char* end, Value* removed);
-  /** \brief Remove the indexed array element.
-
-      O(n) expensive operations.
-      Update 'removed' iff removed.
-      \return true iff removed (no exceptions)
-  */
-  bool removeIndex(ArrayIndex i, Value* removed);
-
-  /// Return true if the object has a member named key.
-  /// \note 'key' must be null-terminated.
-  bool isMember(const char* key) const;
-  /// Return true if the object has a member named key.
-  /// \param key may contain embedded nulls.
-  bool isMember(const JSONCPP_STRING& key) const;
-  /// Same as isMember(JSONCPP_STRING const& key)const
-  bool isMember(const char* begin, const char* end) const;
-#ifdef JSON_USE_CPPTL
-  /// Return true if the object has a member named key.
-  bool isMember(const CppTL::ConstString& key) const;
-#endif
-
-  /// \brief Return a list of the member names.
-  ///
-  /// If null, return an empty list.
-  /// \pre type() is objectValue or nullValue
-  /// \post if type() was nullValue, it remains nullValue
-  Members getMemberNames() const;
-
-  //# ifdef JSON_USE_CPPTL
-  //      EnumMemberNames enumMemberNames() const;
-  //      EnumValues enumValues() const;
-  //# endif
-
-  /// \deprecated Always pass len.
-  JSONCPP_DEPRECATED("Use setComment(JSONCPP_STRING const&) instead.")
-  void setComment(const char* comment, CommentPlacement placement);
-  /// Comments must be //... or /* ... */
-  void setComment(const char* comment, size_t len, CommentPlacement placement);
-  /// Comments must be //... or /* ... */
-  void setComment(const JSONCPP_STRING& comment, CommentPlacement placement);
-  bool hasComment(CommentPlacement placement) const;
-  /// Include delimiters and embedded newlines.
-  JSONCPP_STRING getComment(CommentPlacement placement) const;
-
-  JSONCPP_STRING toStyledString() const;
-
-  const_iterator begin() const;
-  const_iterator end() const;
-
-  iterator begin();
-  iterator end();
-
-  // Accessors for the [start, limit) range of bytes within the JSON text from
-  // which this value was parsed, if any.
-  void setOffsetStart(ptrdiff_t start);
-  void setOffsetLimit(ptrdiff_t limit);
-  ptrdiff_t getOffsetStart() const;
-  ptrdiff_t getOffsetLimit() const;
-
-private:
-  void initBasic(ValueType type, bool allocated = false);
-
-  Value& resolveReference(const char* key);
-  Value& resolveReference(const char* key, const char* end);
-
-  struct CommentInfo {
-    CommentInfo();
-    ~CommentInfo();
-
-    void setComment(const char* text, size_t len);
-
-    char* comment_;
-  };
-
-  // struct MemberNamesTransform
-  //{
-  //   typedef const char *result_type;
-  //   const char *operator()( const CZString &name ) const
-  //   {
-  //      return name.c_str();
-  //   }
-  //};
-
-  union ValueHolder {
-    LargestInt int_;
-    LargestUInt uint_;
-    double real_;
-    bool bool_;
-    char* string_;  // actually ptr to unsigned, followed by str, unless !allocated_
-    ObjectValues* map_;
-  } value_;
-  ValueType type_ : 8;
-  unsigned int allocated_ : 1; // Notes: if declared as bool, bitfield is useless.
-                               // If not allocated_, string_ must be null-terminated.
-  CommentInfo* comments_;
-
-  // [start, limit) byte offsets in the source JSON text from which this Value
-  // was extracted.
-  ptrdiff_t start_;
-  ptrdiff_t limit_;
-};
-
-/** \brief Experimental and untested: represents an element of the "path" to
- * access a node.
- */
-class JSON_API PathArgument {
-public:
-  friend class Path;
-
-  PathArgument();
-  PathArgument(ArrayIndex index);
-  PathArgument(const char* key);
-  PathArgument(const JSONCPP_STRING& key);
-
-private:
-  enum Kind {
-    kindNone = 0,
-    kindIndex,
-    kindKey
-  };
-  JSONCPP_STRING key_;
-  ArrayIndex index_;
-  Kind kind_;
-};
-
-/** \brief Experimental and untested: represents a "path" to access a node.
- *
- * Syntax:
- * - "." => root node
- * - ".[n]" => elements at index 'n' of root node (an array value)
- * - ".name" => member named 'name' of root node (an object value)
- * - ".name1.name2.name3"
- * - ".[0][1][2].name1[3]"
- * - ".%" => member name is provided as parameter
- * - ".[%]" => index is provied as parameter
- */
-class JSON_API Path {
-public:
-  Path(const JSONCPP_STRING& path,
-       const PathArgument& a1 = PathArgument(),
-       const PathArgument& a2 = PathArgument(),
-       const PathArgument& a3 = PathArgument(),
-       const PathArgument& a4 = PathArgument(),
-       const PathArgument& a5 = PathArgument());
-
-  const Value& resolve(const Value& root) const;
-  Value resolve(const Value& root, const Value& defaultValue) const;
-  /// Creates the "path" to access the specified node and returns a reference on
-  /// the node.
-  Value& make(Value& root) const;
-
-private:
-  typedef std::vector<const PathArgument*> InArgs;
-  typedef std::vector<PathArgument> Args;
-
-  void makePath(const JSONCPP_STRING& path, const InArgs& in);
-  void addPathInArg(const JSONCPP_STRING& path,
-                    const InArgs& in,
-                    InArgs::const_iterator& itInArg,
-                    PathArgument::Kind kind);
-  void invalidPath(const JSONCPP_STRING& path, int location);
-
-  Args args_;
-};
-
-/** \brief base class for Value iterators.
- *
- */
-class JSON_API ValueIteratorBase {
-public:
-  typedef std::bidirectional_iterator_tag iterator_category;
-  typedef unsigned int size_t;
-  typedef int difference_type;
-  typedef ValueIteratorBase SelfType;
-
-  bool operator==(const SelfType& other) const { return isEqual(other); }
-
-  bool operator!=(const SelfType& other) const { return !isEqual(other); }
-
-  difference_type operator-(const SelfType& other) const {
-    return other.computeDistance(*this);
-  }
-
-  /// Return either the index or the member name of the referenced value as a
-  /// Value.
-  Value key() const;
-
-  /// Return the index of the referenced Value, or -1 if it is not an arrayValue.
-  UInt index() const;
-
-  /// Return the member name of the referenced Value, or "" if it is not an
-  /// objectValue.
-  /// \note Avoid `c_str()` on result, as embedded zeroes are possible.
-  JSONCPP_STRING name() const;
-
-  /// Return the member name of the referenced Value. "" if it is not an
-  /// objectValue.
-  /// \deprecated This cannot be used for UTF-8 strings, since there can be embedded nulls.
-  JSONCPP_DEPRECATED("Use `key = name();` instead.")
-  char const* memberName() const;
-  /// Return the member name of the referenced Value, or NULL if it is not an
-  /// objectValue.
-  /// \note Better version than memberName(). Allows embedded nulls.
-  char const* memberName(char const** end) const;
-
-protected:
-  Value& deref() const;
-
-  void increment();
-
-  void decrement();
-
-  difference_type computeDistance(const SelfType& other) const;
-
-  bool isEqual(const SelfType& other) const;
-
-  void copy(const SelfType& other);
-
-private:
-  Value::ObjectValues::iterator current_;
-  // Indicates that iterator is for a null value.
-  bool isNull_;
-
-public:
-  // For some reason, BORLAND needs these at the end, rather
-  // than earlier. No idea why.
-  ValueIteratorBase();
-  explicit ValueIteratorBase(const Value::ObjectValues::iterator& current);
-};
-
-/** \brief const iterator for object and array value.
- *
- */
-class JSON_API ValueConstIterator : public ValueIteratorBase {
-  friend class Value;
-
-public:
-  typedef const Value value_type;
-  //typedef unsigned int size_t;
-  //typedef int difference_type;
-  typedef const Value& reference;
-  typedef const Value* pointer;
-  typedef ValueConstIterator SelfType;
-
-  ValueConstIterator();
-  ValueConstIterator(ValueIterator const& other);
-
-private:
-/*! \internal Use by Value to create an iterator.
- */
-  explicit ValueConstIterator(const Value::ObjectValues::iterator& current);
-public:
-  SelfType& operator=(const ValueIteratorBase& other);
-
-  SelfType operator++(int) {
-    SelfType temp(*this);
-    ++*this;
-    return temp;
-  }
-
-  SelfType operator--(int) {
-    SelfType temp(*this);
-    --*this;
-    return temp;
-  }
-
-  SelfType& operator--() {
-    decrement();
-    return *this;
-  }
-
-  SelfType& operator++() {
-    increment();
-    return *this;
-  }
-
-  reference operator*() const { return deref(); }
-
-  pointer operator->() const { return &deref(); }
-};
-
-/** \brief Iterator for object and array value.
- */
-class JSON_API ValueIterator : public ValueIteratorBase {
-  friend class Value;
-
-public:
-  typedef Value value_type;
-  typedef unsigned int size_t;
-  typedef int difference_type;
-  typedef Value& reference;
-  typedef Value* pointer;
-  typedef ValueIterator SelfType;
-
-  ValueIterator();
-  explicit ValueIterator(const ValueConstIterator& other);
-  ValueIterator(const ValueIterator& other);
-
-private:
-/*! \internal Use by Value to create an iterator.
- */
-  explicit ValueIterator(const Value::ObjectValues::iterator& current);
-public:
-  SelfType& operator=(const SelfType& other);
-
-  SelfType operator++(int) {
-    SelfType temp(*this);
-    ++*this;
-    return temp;
-  }
-
-  SelfType operator--(int) {
-    SelfType temp(*this);
-    --*this;
-    return temp;
-  }
-
-  SelfType& operator--() {
-    decrement();
-    return *this;
-  }
-
-  SelfType& operator++() {
-    increment();
-    return *this;
-  }
-
-  reference operator*() const { return deref(); }
-
-  pointer operator->() const { return &deref(); }
-};
-
-} // namespace Json
-} // namespace rmq
-
-namespace std {
-/// Specialize std::swap() for Json::Value.
-template<>
-inline void swap(rmq::Json::Value& a, rmq::Json::Value& b) { a.swap(b); }
-}
-
-
-#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
-#pragma warning(pop)
-#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
-
-#endif // CPPTL_JSON_H_INCLUDED

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/jsoncpp/json/version.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/jsoncpp/json/version.h b/rocketmq-client4cpp/src/jsoncpp/json/version.h
deleted file mode 100644
index 24e2b09..0000000
--- a/rocketmq-client4cpp/src/jsoncpp/json/version.h
+++ /dev/null
@@ -1,20 +0,0 @@
-// DO NOT EDIT. This file (and "version") is generated by CMake.
-// Run CMake configure step to update it.
-#ifndef JSON_VERSION_H_INCLUDED
-# define JSON_VERSION_H_INCLUDED
-
-# define JSONCPP_VERSION_STRING "1.7.7"
-# define JSONCPP_VERSION_MAJOR 1
-# define JSONCPP_VERSION_MINOR 7
-# define JSONCPP_VERSION_PATCH 7
-# define JSONCPP_VERSION_QUALIFIER
-# define JSONCPP_VERSION_HEXA ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | (JSONCPP_VERSION_PATCH << 8))
-
-#ifdef JSONCPP_USING_SECURE_MEMORY
-#undef JSONCPP_USING_SECURE_MEMORY
-#endif
-#define JSONCPP_USING_SECURE_MEMORY 0
-// If non-zero, the library zeroes any memory that it has allocated before
-// it frees its memory.
-
-#endif // JSON_VERSION_H_INCLUDED

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/jsoncpp/json/writer.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/jsoncpp/json/writer.h b/rocketmq-client4cpp/src/jsoncpp/json/writer.h
deleted file mode 100755
index c244cf4..0000000
--- a/rocketmq-client4cpp/src/jsoncpp/json/writer.h
+++ /dev/null
@@ -1,333 +0,0 @@
-// Copyright 2007-2010 Baptiste Lepilleur
-// Distributed under MIT license, or public domain if desired and
-// recognized in your jurisdiction.
-// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
-
-#ifndef JSON_WRITER_H_INCLUDED
-#define JSON_WRITER_H_INCLUDED
-
-#if !defined(JSON_IS_AMALGAMATION)
-#include "value.h"
-#endif // if !defined(JSON_IS_AMALGAMATION)
-#include <vector>
-#include <string>
-#include <ostream>
-
-// Disable warning C4251: <data member>: <type> needs to have dll-interface to
-// be used by...
-#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
-#pragma warning(push)
-#pragma warning(disable : 4251)
-#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
-
-namespace rmq {
-namespace Json {
-
-class Value;
-
-/**
-
-Usage:
-\code
-  using namespace Json;
-  void writeToStdout(StreamWriter::Factory const& factory, Value const& value) {
-    std::unique_ptr<StreamWriter> const writer(
-      factory.newStreamWriter());
-    writer->write(value, &std::cout);
-    std::cout << std::endl;  // add lf and flush
-  }
-\endcode
-*/
-class JSON_API StreamWriter {
-protected:
-  JSONCPP_OSTREAM* sout_;  // not owned; will not delete
-public:
-  StreamWriter();
-  virtual ~StreamWriter();
-  /** Write Value into document as configured in sub-class.
-      Do not take ownership of sout, but maintain a reference during function.
-      \pre sout != NULL
-      \return zero on success (For now, we always return zero, so check the stream instead.)
-      \throw std::exception possibly, depending on configuration
-   */
-  virtual int write(Value const& root, JSONCPP_OSTREAM* sout) = 0;
-
-  /** \brief A simple abstract factory.
-   */
-  class JSON_API Factory {
-  public:
-    virtual ~Factory();
-    /** \brief Allocate a CharReader via operator new().
-     * \throw std::exception if something goes wrong (e.g. invalid settings)
-     */
-    virtual StreamWriter* newStreamWriter() const = 0;
-  };  // Factory
-};  // StreamWriter
-
-/** \brief Write into stringstream, then return string, for convenience.
- * A StreamWriter will be created from the factory, used, and then deleted.
- */
-JSONCPP_STRING JSON_API writeString(StreamWriter::Factory const& factory, Value const& root);
-
-
-/** \brief Build a StreamWriter implementation.
-
-Usage:
-\code
-  using namespace Json;
-  Value value = ...;
-  StreamWriterBuilder builder;
-  builder["commentStyle"] = "None";
-  builder["indentation"] = "   ";  // or whatever you like
-  std::unique_ptr<Json::StreamWriter> writer(
-      builder.newStreamWriter());
-  writer->write(value, &std::cout);
-  std::cout << std::endl;  // add lf and flush
-\endcode
-*/
-class JSON_API StreamWriterBuilder : public StreamWriter::Factory {
-public:
-  // Note: We use a Json::Value so that we can add data-members to this class
-  // without a major version bump.
-  /** Configuration of this builder.
-    Available settings (case-sensitive):
-    - "commentStyle": "None" or "All"
-    - "indentation":  "<anything>"
-    - "enableYAMLCompatibility": false or true
-      - slightly change the whitespace around colons
-    - "dropNullPlaceholders": false or true
-      - Drop the "null" string from the writer's output for nullValues.
-        Strictly speaking, this is not valid JSON. But when the output is being
-        fed to a browser's Javascript, it makes for smaller output and the
-        browser can handle the output just fine.
-    - "useSpecialFloats": false or true
-      - If true, outputs non-finite floating point values in the following way:
-        NaN values as "NaN", positive infinity as "Infinity", and negative infinity
-        as "-Infinity".
-
-    You can examine 'settings_` yourself
-    to see the defaults. You can also write and read them just like any
-    JSON Value.
-    \sa setDefaults()
-    */
-  Value settings_;
-
-  StreamWriterBuilder();
-  ~StreamWriterBuilder() JSONCPP_OVERRIDE;
-
-  /**
-   * \throw std::exception if something goes wrong (e.g. invalid settings)
-   */
-  StreamWriter* newStreamWriter() const JSONCPP_OVERRIDE;
-
-  /** \return true if 'settings' are legal and consistent;
-   *   otherwise, indicate bad settings via 'invalid'.
-   */
-  bool validate(Value* invalid) const;
-  /** A simple way to update a specific setting.
-   */
-  Value& operator[](JSONCPP_STRING key);
-
-  /** Called by ctor, but you can use this to reset settings_.
-   * \pre 'settings' != NULL (but Json::null is fine)
-   * \remark Defaults:
-   * \snippet src/lib_json/json_writer.cpp StreamWriterBuilderDefaults
-   */
-  static void setDefaults(Value* settings);
-};
-
-/** \brief Abstract class for writers.
- * \deprecated Use StreamWriter. (And really, this is an implementation detail.)
- */
-class JSON_API Writer {
-public:
-  virtual ~Writer();
-
-  virtual JSONCPP_STRING write(const Value& root) = 0;
-};
-
-/** \brief Outputs a Value in <a HREF="http://www.json.org">JSON</a> format
- *without formatting (not human friendly).
- *
- * The JSON document is written in a single line. It is not intended for 'human'
- *consumption,
- * but may be usefull to support feature such as RPC where bandwith is limited.
- * \sa Reader, Value
- * \deprecated Use StreamWriterBuilder.
- */
-class JSON_API FastWriter : public Writer {
-
-public:
-  FastWriter();
-  ~FastWriter() JSONCPP_OVERRIDE {}
-
-  void enableYAMLCompatibility();
-
-  /** \brief Drop the "null" string from the writer's output for nullValues.
-   * Strictly speaking, this is not valid JSON. But when the output is being
-   * fed to a browser's Javascript, it makes for smaller output and the
-   * browser can handle the output just fine.
-   */
-  void dropNullPlaceholders();
-
-  void omitEndingLineFeed();
-
-public: // overridden from Writer
-  JSONCPP_STRING write(const Value& root) JSONCPP_OVERRIDE;
-
-private:
-  void writeValue(const Value& value);
-
-  JSONCPP_STRING document_;
-  bool yamlCompatiblityEnabled_;
-  bool dropNullPlaceholders_;
-  bool omitEndingLineFeed_;
-};
-
-/** \brief Writes a Value in <a HREF="http://www.json.org">JSON</a> format in a
- *human friendly way.
- *
- * The rules for line break and indent are as follow:
- * - Object value:
- *     - if empty then print {} without indent and line break
- *     - if not empty the print '{', line break & indent, print one value per
- *line
- *       and then unindent and line break and print '}'.
- * - Array value:
- *     - if empty then print [] without indent and line break
- *     - if the array contains no object value, empty array or some other value
- *types,
- *       and all the values fit on one lines, then print the array on a single
- *line.
- *     - otherwise, it the values do not fit on one line, or the array contains
- *       object or non empty array, then print one value per line.
- *
- * If the Value have comments then they are outputed according to their
- *#CommentPlacement.
- *
- * \sa Reader, Value, Value::setComment()
- * \deprecated Use StreamWriterBuilder.
- */
-class JSON_API StyledWriter : public Writer {
-public:
-  StyledWriter();
-  ~StyledWriter() JSONCPP_OVERRIDE {}
-
-public: // overridden from Writer
-  /** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format.
-   * \param root Value to serialize.
-   * \return String containing the JSON document that represents the root value.
-   */
-  JSONCPP_STRING write(const Value& root) JSONCPP_OVERRIDE;
-
-private:
-  void writeValue(const Value& value);
-  void writeArrayValue(const Value& value);
-  bool isMultineArray(const Value& value);
-  void pushValue(const JSONCPP_STRING& value);
-  void writeIndent();
-  void writeWithIndent(const JSONCPP_STRING& value);
-  void indent();
-  void unindent();
-  void writeCommentBeforeValue(const Value& root);
-  void writeCommentAfterValueOnSameLine(const Value& root);
-  bool hasCommentForValue(const Value& value);
-  static JSONCPP_STRING normalizeEOL(const JSONCPP_STRING& text);
-
-  typedef std::vector<JSONCPP_STRING> ChildValues;
-
-  ChildValues childValues_;
-  JSONCPP_STRING document_;
-  JSONCPP_STRING indentString_;
-  unsigned int rightMargin_;
-  unsigned int indentSize_;
-  bool addChildValues_;
-};
-
-/** \brief Writes a Value in <a HREF="http://www.json.org">JSON</a> format in a
- human friendly way,
-     to a stream rather than to a string.
- *
- * The rules for line break and indent are as follow:
- * - Object value:
- *     - if empty then print {} without indent and line break
- *     - if not empty the print '{', line break & indent, print one value per
- line
- *       and then unindent and line break and print '}'.
- * - Array value:
- *     - if empty then print [] without indent and line break
- *     - if the array contains no object value, empty array or some other value
- types,
- *       and all the values fit on one lines, then print the array on a single
- line.
- *     - otherwise, it the values do not fit on one line, or the array contains
- *       object or non empty array, then print one value per line.
- *
- * If the Value have comments then they are outputed according to their
- #CommentPlacement.
- *
- * \param indentation Each level will be indented by this amount extra.
- * \sa Reader, Value, Value::setComment()
- * \deprecated Use StreamWriterBuilder.
- */
-class JSON_API StyledStreamWriter {
-public:
-  StyledStreamWriter(JSONCPP_STRING indentation = "\t");
-  ~StyledStreamWriter() {}
-
-public:
-  /** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format.
-   * \param out Stream to write to. (Can be ostringstream, e.g.)
-   * \param root Value to serialize.
-   * \note There is no point in deriving from Writer, since write() should not
-   * return a value.
-   */
-  void write(JSONCPP_OSTREAM& out, const Value& root);
-
-private:
-  void writeValue(const Value& value);
-  void writeArrayValue(const Value& value);
-  bool isMultineArray(const Value& value);
-  void pushValue(const JSONCPP_STRING& value);
-  void writeIndent();
-  void writeWithIndent(const JSONCPP_STRING& value);
-  void indent();
-  void unindent();
-  void writeCommentBeforeValue(const Value& root);
-  void writeCommentAfterValueOnSameLine(const Value& root);
-  bool hasCommentForValue(const Value& value);
-  static JSONCPP_STRING normalizeEOL(const JSONCPP_STRING& text);
-
-  typedef std::vector<JSONCPP_STRING> ChildValues;
-
-  ChildValues childValues_;
-  JSONCPP_OSTREAM* document_;
-  JSONCPP_STRING indentString_;
-  unsigned int rightMargin_;
-  JSONCPP_STRING indentation_;
-  bool addChildValues_ : 1;
-  bool indented_ : 1;
-};
-
-#if defined(JSON_HAS_INT64)
-JSONCPP_STRING JSON_API valueToString(Int value);
-JSONCPP_STRING JSON_API valueToString(UInt value);
-#endif // if defined(JSON_HAS_INT64)
-JSONCPP_STRING JSON_API valueToString(LargestInt value);
-JSONCPP_STRING JSON_API valueToString(LargestUInt value);
-JSONCPP_STRING JSON_API valueToString(double value);
-JSONCPP_STRING JSON_API valueToString(bool value);
-JSONCPP_STRING JSON_API valueToQuotedString(const char* value);
-
-/// \brief Output using the StyledStreamWriter.
-/// \see Json::operator>>()
-JSON_API JSONCPP_OSTREAM& operator<<(JSONCPP_OSTREAM&, const Value& root);
-
-} // namespace Json
-} // namespace rmq
-
-#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
-#pragma warning(pop)
-#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
-
-#endif // JSON_WRITER_H_INCLUDED


[15/17] incubator-rocketmq-externals git commit: Polish cpp module

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/MQClientAPIImpl.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/MQClientAPIImpl.cpp b/rocketmq-client4cpp/src/MQClientAPIImpl.cpp
deleted file mode 100755
index fa5a2b9..0000000
--- a/rocketmq-client4cpp/src/MQClientAPIImpl.cpp
+++ /dev/null
@@ -1,1323 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#include <assert.h>
-
-#include "MQClientAPIImpl.h"
-#include "MQClientException.h"
-#include "SocketUtil.h"
-#include "UtilAll.h"
-#include "TcpRemotingClient.h"
-#include "MQProtos.h"
-#include "PullResultExt.h"
-#include "ConsumerInvokeCallback.h"
-#include "NamesrvUtil.h"
-#include "VirtualEnvUtil.h"
-#include "ClientRemotingProcessor.h"
-#include "CommandCustomHeader.h"
-#include "TopicList.h"
-#include "ProducerInvokeCallback.h"
-#include "MessageDecoder.h"
-#include "MessageSysFlag.h"
-#include "GetConsumerListByGroupResponseBody.h"
-
-
-namespace rmq
-{
-
-
-MQClientAPIImpl::MQClientAPIImpl(ClientConfig& clientConfig,
-								const RemoteClientConfig& remoteClientConfig,
-                                ClientRemotingProcessor* pClientRemotingProcessor)
-    : m_pClientRemotingProcessor(pClientRemotingProcessor)
-{
-    m_pRemotingClient = new TcpRemotingClient(remoteClientConfig);
-
-    m_pRemotingClient->registerProcessor(CHECK_TRANSACTION_STATE_VALUE, m_pClientRemotingProcessor);
-    m_pRemotingClient->registerProcessor(NOTIFY_CONSUMER_IDS_CHANGED_VALUE, m_pClientRemotingProcessor);
-    m_pRemotingClient->registerProcessor(RESET_CONSUMER_CLIENT_OFFSET_VALUE, m_pClientRemotingProcessor);
-    m_pRemotingClient->registerProcessor(GET_CONSUMER_STATUS_FROM_CLIENT_VALUE, m_pClientRemotingProcessor);
-    m_pRemotingClient->registerProcessor(GET_CONSUMER_RUNNING_INFO_VALUE, m_pClientRemotingProcessor);
-    m_pRemotingClient->registerProcessor(CONSUME_MESSAGE_DIRECTLY_VALUE, m_pClientRemotingProcessor);
-}
-
-MQClientAPIImpl::~MQClientAPIImpl()
-{
-}
-
-std::string MQClientAPIImpl::getProjectGroupPrefix()
-{
-    return m_projectGroupPrefix;
-}
-
-std::vector<std::string> MQClientAPIImpl::getNameServerAddressList()
-{
-    return m_pRemotingClient->getNameServerAddressList();
-}
-
-TcpRemotingClient* MQClientAPIImpl::getRemotingClient()
-{
-    return m_pRemotingClient;
-}
-
-std::string MQClientAPIImpl::fetchNameServerAddr()
-{
-    try
-    {
-        std::string addrs = m_topAddressing.fetchNSAddr();
-        if (!addrs.empty())
-        {
-            if (addrs != m_nameSrvAddr)
-            {
-            	RMQ_INFO("name server address changed, %s -> %s",
-            		m_nameSrvAddr.c_str(), addrs.c_str());
-                updateNameServerAddressList(addrs);
-                m_nameSrvAddr = addrs;
-                return m_nameSrvAddr;
-            }
-        }
-    }
-    catch (...)
-    {
-		RMQ_ERROR("fetchNameServerAddr Exception");
-    }
-
-    return m_nameSrvAddr;
-}
-
-void MQClientAPIImpl::updateNameServerAddressList(const std::string& addrs)
-{
-    m_nameSrvAddr = addrs;
-    std::vector<std::string> av;
-    UtilAll::Split(av, addrs, ";");
-    if (av.size() > 0)
-    {
-    	m_pRemotingClient->updateNameServerAddressList(av);
-    }
-}
-
-void MQClientAPIImpl::start()
-{
-    m_pRemotingClient->start();
-
-    try
-    {
-        std::string localAddress = getLocalAddress();
-        m_projectGroupPrefix = getProjectGroupByIp(localAddress, 3000);
-    }
-    catch (std::exception e)
-    {
-    }
-}
-
-void MQClientAPIImpl::shutdown()
-{
-    m_pRemotingClient->shutdown();
-}
-
-void MQClientAPIImpl::createSubscriptionGroup(const std::string& addr,
-        SubscriptionGroupConfig config,
-        int timeoutMillis)
-{
-    //TODO
-}
-
-
-void MQClientAPIImpl::createTopic(const std::string& addr,
-                                  const std::string& defaultTopic,
-                                  TopicConfig topicConfig,
-                                  int timeoutMillis)
-{
-    std::string topicWithProjectGroup = topicConfig.getTopicName();
-    if (!UtilAll::isBlank(m_projectGroupPrefix))
-    {
-        topicWithProjectGroup =
-            VirtualEnvUtil::buildWithProjectGroup(topicConfig.getTopicName(), m_projectGroupPrefix);
-    }
-
-    CreateTopicRequestHeader* requestHeader = new CreateTopicRequestHeader();
-    requestHeader->topic = (topicWithProjectGroup);
-    requestHeader->defaultTopic = (defaultTopic);
-    requestHeader->readQueueNums = (topicConfig.getReadQueueNums());
-    requestHeader->writeQueueNums = (topicConfig.getWriteQueueNums());
-    requestHeader->perm = (topicConfig.getPerm());
-    requestHeader->topicFilterType = (topicConfig.getTopicFilterType());
-    requestHeader->topicSysFlag = (topicConfig.getTopicSysFlag());
-    requestHeader->order = (topicConfig.isOrder());
-
-    RemotingCommandPtr request =
-        RemotingCommand::createRequestCommand(UPDATE_AND_CREATE_TOPIC_VALUE, requestHeader);
-
-    RemotingCommandPtr response = m_pRemotingClient->invokeSync(addr, request, timeoutMillis);
-    if (response)
-    {
-        switch (response->getCode())
-        {
-            case SUCCESS_VALUE:
-            {
-                return;
-            }
-            default:
-                break;
-        }
-        THROW_MQEXCEPTION(MQClientException, response->getRemark(), response->getCode());
-    }
-
-    THROW_MQEXCEPTION(MQClientException, "createTopic failed", -1);
-}
-
-SendResult MQClientAPIImpl::sendMessage(const std::string& addr,
-                                        const std::string& brokerName,
-                                        Message& msg,
-                                        SendMessageRequestHeader* pRequestHeader,
-                                        int timeoutMillis,
-                                        CommunicationMode communicationMode,
-                                        SendCallback* pSendCallback)
-{
-    if (!UtilAll::isBlank(m_projectGroupPrefix))
-    {
-        msg.setTopic(VirtualEnvUtil::buildWithProjectGroup(msg.getTopic(), m_projectGroupPrefix));
-        pRequestHeader->producerGroup = (VirtualEnvUtil::buildWithProjectGroup(pRequestHeader->producerGroup,
-                                         m_projectGroupPrefix));
-        pRequestHeader->topic = (VirtualEnvUtil::buildWithProjectGroup(pRequestHeader->topic,
-                                 m_projectGroupPrefix));
-    }
-
-	bool sendSmartMsg = true;
-	RemotingCommandPtr request = NULL;
-    if (sendSmartMsg)
-    {
-        SendMessageRequestHeaderV2* pRequestHeaderV2 = SendMessageRequestHeaderV2::createSendMessageRequestHeaderV2(pRequestHeader);
-        request = RemotingCommand::createRequestCommand(SEND_MESSAGE_V2_VALUE, pRequestHeaderV2);
-        delete pRequestHeader;
-    }
-    else
-    {
-        request = RemotingCommand::createRequestCommand(SEND_MESSAGE_VALUE, pRequestHeader);
-    }
-
-    if (msg.getCompressBody() != NULL)
-    {
-    	request->setBody((char*)msg.getCompressBody(), msg.getCompressBodyLen(), false);
-    }
-    else
-    {
-    	request->setBody((char*)msg.getBody(), msg.getBodyLen(), false);
-    }
-
-    SendResult result;
-    switch (communicationMode)
-    {
-        case ONEWAY:
-            m_pRemotingClient->invokeOneway(addr, request, timeoutMillis);
-            return result;
-        case ASYNC:
-            sendMessageAsync(addr, brokerName, msg, timeoutMillis, request, pSendCallback);
-            return result;
-        case SYNC:
-        {
-            SendResult* r = sendMessageSync(addr, brokerName, msg, timeoutMillis, request);
-            if (r)
-            {
-                result = *r;
-                delete r;
-            }
-            return result;
-        }
-        default:
-            break;
-    }
-    return result;
-}
-
-PullResult* MQClientAPIImpl::pullMessage(const std::string& addr,
-        PullMessageRequestHeader* pRequestHeader,
-        int timeoutMillis,
-        CommunicationMode communicationMode,
-        PullCallback* pPullCallback)
-{
-
-    if (!UtilAll::isBlank(m_projectGroupPrefix))
-    {
-        pRequestHeader->consumerGroup = (VirtualEnvUtil::buildWithProjectGroup(
-                                             pRequestHeader->consumerGroup, m_projectGroupPrefix));
-        pRequestHeader->topic = (VirtualEnvUtil::buildWithProjectGroup(pRequestHeader->topic,
-                                 m_projectGroupPrefix));
-    }
-
-    RemotingCommandPtr request = RemotingCommand::createRequestCommand(PULL_MESSAGE_VALUE, pRequestHeader);
-
-    PullResult* result = NULL;
-    switch (communicationMode)
-    {
-        case ONEWAY:
-            break;
-        case ASYNC:
-            pullMessageAsync(addr, request, timeoutMillis, pPullCallback);
-            break;
-        case SYNC:
-            result =  pullMessageSync(addr, request, timeoutMillis);
-            break;
-        default:
-            assert(false);
-            break;
-    }
-
-    return result;
-}
-
-MessageExt* MQClientAPIImpl::viewMessage(const std::string& addr,  long long phyoffset,  int timeoutMillis)
-{
-    ViewMessageRequestHeader* requestHeader = new ViewMessageRequestHeader();
-    requestHeader->offset = phyoffset;
-
-    RemotingCommandPtr request =
-        RemotingCommand::createRequestCommand(VIEW_MESSAGE_BY_ID_VALUE, requestHeader);
-
-    RemotingCommandPtr response = m_pRemotingClient->invokeSync(addr, request, timeoutMillis);
-    if (response)
-    {
-        switch (response->getCode())
-        {
-            case SUCCESS_VALUE:
-            {
-                if (response->getBody() != NULL)
-                {
-                	int len = 0;
-                	MessageExt* messageExt = MessageDecoder::decode((char*)response->getBody(),
-                		response->getBodyLen(), len);
-                    if (!UtilAll::isBlank(m_projectGroupPrefix))
-				    {
-				        messageExt->setTopic(VirtualEnvUtil::clearProjectGroup(messageExt->getTopic(),
-				        	m_projectGroupPrefix));
-				    }
-                    return messageExt;
-                }
-            }
-            default:
-                break;
-        }
-        THROW_MQEXCEPTION(MQClientException, response->getRemark(), response->getCode());
-    }
-
-    THROW_MQEXCEPTION(MQClientException, "viewMessage failed", -1);
-}
-
-long long MQClientAPIImpl::searchOffset(const std::string& addr,
-                                        const std::string& topic,
-                                        int queueId,
-                                        long long timestamp,
-                                        int timeoutMillis)
-{
-    std::string topicWithProjectGroup = topic;
-    if (!UtilAll::isBlank(m_projectGroupPrefix))
-    {
-        topicWithProjectGroup = VirtualEnvUtil::buildWithProjectGroup(topic, m_projectGroupPrefix);
-    }
-
-	SearchOffsetRequestHeader* pRequestHeader = new SearchOffsetRequestHeader();
-    pRequestHeader->topic = topicWithProjectGroup;
-    pRequestHeader->queueId = queueId;
-    pRequestHeader->timestamp = timestamp;
-
-    RemotingCommandPtr request =
-        RemotingCommand::createRequestCommand(SEARCH_OFFSET_BY_TIMESTAMP_VALUE, pRequestHeader);
-
-    RemotingCommandPtr response = m_pRemotingClient->invokeSync(addr, request, timeoutMillis);
-    if (response)
-    {
-	    switch (response->getCode())
-	    {
-	        case SUCCESS_VALUE:
-	        {
-	            SearchOffsetResponseHeader* ret = (SearchOffsetResponseHeader*)response->getCommandCustomHeader();
-	            return ret->offset;
-	        }
-	        default:
-	            break;
-	    }
-	    //THROW_MQEXCEPTION(MQClientException, response->getRemark(), response->getCode());
-	}
-
-    //THROW_MQEXCEPTION(MQClientException, "searchOffset failed", -1);
-    return -1;
-}
-
-long long MQClientAPIImpl::getMaxOffset(const std::string& addr,
-                                        const std::string& topic,
-                                        int queueId,
-                                        int timeoutMillis)
-{
-    std::string topicWithProjectGroup = topic;
-    if (!UtilAll::isBlank(m_projectGroupPrefix))
-    {
-        topicWithProjectGroup = VirtualEnvUtil::buildWithProjectGroup(topic, m_projectGroupPrefix);
-    }
-
-	GetMaxOffsetRequestHeader* pRequestHeader = new GetMaxOffsetRequestHeader();
-    pRequestHeader->topic = topicWithProjectGroup;
-    pRequestHeader->queueId = queueId;
-
-    RemotingCommandPtr request =
-        RemotingCommand::createRequestCommand(GET_MAX_OFFSET_VALUE, pRequestHeader);
-
-    RemotingCommandPtr response = m_pRemotingClient->invokeSync(addr, request, timeoutMillis);
-    if (response)
-    {
-	    switch (response->getCode())
-	    {
-	        case SUCCESS_VALUE:
-	        {
-	            GetMaxOffsetResponseHeader* ret = (GetMaxOffsetResponseHeader*)response->getCommandCustomHeader();
-	            return ret->offset;
-	        }
-	        default:
-	            break;
-	    }
-	    //THROW_MQEXCEPTION(MQClientException, response->getRemark(), response->getCode());
-	}
-
-    //THROW_MQEXCEPTION(MQClientException, "getMaxOffset failed", -1);
-    return -1;
-}
-
-
-std::list<std::string> MQClientAPIImpl::getConsumerIdListByGroup(const std::string& addr,
-        const std::string& consumerGroup,
-        int timeoutMillis)
-{
-    std::string consumerGroupWithProjectGroup = consumerGroup;
-    if (!UtilAll::isBlank(m_projectGroupPrefix))
-    {
-        consumerGroupWithProjectGroup =
-            VirtualEnvUtil::buildWithProjectGroup(consumerGroup, m_projectGroupPrefix);
-    }
-
-    GetConsumerListByGroupRequestHeader* requestHeader = new GetConsumerListByGroupRequestHeader();
-    requestHeader->consumerGroup = consumerGroupWithProjectGroup;
-
-    RemotingCommandPtr request =
-        RemotingCommand::createRequestCommand(GET_CONSUMER_LIST_BY_GROUP_VALUE, requestHeader);
-
-    RemotingCommandPtr response = m_pRemotingClient->invokeSync(addr, request, timeoutMillis);
-    if (response)
-    {
-        switch (response->getCode())
-        {
-            case SUCCESS_VALUE:
-            {
-                if (response->getBody() != NULL)
-                {
-                    GetConsumerListByGroupResponseBody* body =
-                        GetConsumerListByGroupResponseBody::decode((char*)response->getBody(), response->getBodyLen());
-                    std::list<std::string> ret = body->getConsumerIdList();
-                    delete body;
-                    return ret;
-                }
-            }
-            default:
-                break;
-        }
-
-        THROW_MQEXCEPTION(MQClientException, response->getRemark(), response->getCode());
-    }
-
-    THROW_MQEXCEPTION(MQClientException, "getConsumerIdListByGroup failed", -1);
-}
-
-long long MQClientAPIImpl::getMinOffset(const std::string& addr,
-                                        const std::string& topic,
-                                        int queueId,
-                                        int timeoutMillis)
-{
-    std::string topicWithProjectGroup = topic;
-    if (!UtilAll::isBlank(m_projectGroupPrefix))
-    {
-        topicWithProjectGroup = VirtualEnvUtil::buildWithProjectGroup(topic, m_projectGroupPrefix);
-    }
-
-	GetMinOffsetRequestHeader* pRequestHeader = new GetMinOffsetRequestHeader();
-    pRequestHeader->topic = topicWithProjectGroup;
-    pRequestHeader->queueId = queueId;
-
-    RemotingCommandPtr request =
-        RemotingCommand::createRequestCommand(GET_MIN_OFFSET_VALUE, pRequestHeader);
-
-    RemotingCommandPtr response = m_pRemotingClient->invokeSync(addr, request, timeoutMillis);
-    if (response)
-    {
-	    switch (response->getCode())
-	    {
-	        case SUCCESS_VALUE:
-	        {
-	            GetMinOffsetResponseHeader* ret = (GetMinOffsetResponseHeader*)response->getCommandCustomHeader();
-	            return ret->offset;
-	        }
-	        default:
-	            break;
-	    }
-	    //THROW_MQEXCEPTION(MQClientException, response->getRemark(), response->getCode());
-	}
-
-    //THROW_MQEXCEPTION(MQClientException, "getMinOffset failed", -1);
-    return -1;
-}
-
-long long MQClientAPIImpl::getEarliestMsgStoretime(const std::string& addr,
-        const std::string& topic,
-        int queueId,
-        int timeoutMillis)
-{
-    std::string topicWithProjectGroup = topic;
-    if (!UtilAll::isBlank(m_projectGroupPrefix))
-    {
-        topicWithProjectGroup = VirtualEnvUtil::buildWithProjectGroup(topic, m_projectGroupPrefix);
-    }
-
-	GetEarliestMsgStoretimeRequestHeader* pRequestHeader = new GetEarliestMsgStoretimeRequestHeader();
-    pRequestHeader->topic = topicWithProjectGroup;
-    pRequestHeader->queueId = queueId;
-
-    RemotingCommandPtr request =
-        RemotingCommand::createRequestCommand(GET_EARLIEST_MSG_STORETIME_VALUE, pRequestHeader);
-
-    RemotingCommandPtr response = m_pRemotingClient->invokeSync(addr, request, timeoutMillis);
-    if (response)
-    {
-	    switch (response->getCode())
-	    {
-	        case SUCCESS_VALUE:
-	        {
-	            GetEarliestMsgStoretimeResponseHeader* ret = (GetEarliestMsgStoretimeResponseHeader*)response->getCommandCustomHeader();
-	            return ret->timestamp;
-	        }
-	        default:
-	            break;
-	    }
-	    THROW_MQEXCEPTION(MQClientException, response->getRemark(), response->getCode());
-	}
-
-    THROW_MQEXCEPTION(MQClientException, "getEarliestMsgStoretime failed", -1);
-}
-
-long long MQClientAPIImpl::queryConsumerOffset(const std::string& addr,
-        QueryConsumerOffsetRequestHeader* pRequestHeader,
-        int timeoutMillis)
-{
-    if (!UtilAll::isBlank(m_projectGroupPrefix))
-    {
-        pRequestHeader->consumerGroup = VirtualEnvUtil::buildWithProjectGroup(
-                                            pRequestHeader->consumerGroup, m_projectGroupPrefix);
-        pRequestHeader->topic = VirtualEnvUtil::buildWithProjectGroup(pRequestHeader->topic,
-                                m_projectGroupPrefix);
-    }
-
-    RemotingCommandPtr request =
-        RemotingCommand::createRequestCommand(QUERY_CONSUMER_OFFSET_VALUE, pRequestHeader);
-
-    RemotingCommandPtr response = m_pRemotingClient->invokeSync(addr, request, timeoutMillis);
-    if (response)
-    {
-	    switch (response->getCode())
-	    {
-	        case SUCCESS_VALUE:
-	        {
-	            QueryConsumerOffsetResponseHeader* ret = (QueryConsumerOffsetResponseHeader*)response->getCommandCustomHeader();
-	            long long offset = ret->offset;
-	            return offset;
-	        }
-	        default:
-	            break;
-	    }
-	    THROW_MQEXCEPTION(MQBrokerException, response->getRemark(), response->getCode());
-	}
-
-    THROW_MQEXCEPTION(MQClientException, "queryConsumerOffset failed", -1);
-    return -1;
-}
-
-void MQClientAPIImpl::updateConsumerOffset(const std::string& addr,
-        UpdateConsumerOffsetRequestHeader* pRequestHeader,
-        int timeoutMillis)
-{
-    if (!UtilAll::isBlank(m_projectGroupPrefix))
-    {
-        pRequestHeader->consumerGroup = VirtualEnvUtil::buildWithProjectGroup(
-                                            pRequestHeader->consumerGroup, m_projectGroupPrefix);
-        pRequestHeader->topic = VirtualEnvUtil::buildWithProjectGroup(
-                                    pRequestHeader->topic, m_projectGroupPrefix);
-    }
-
-    RemotingCommandPtr request = RemotingCommand::createRequestCommand(UPDATE_CONSUMER_OFFSET_VALUE, pRequestHeader);
-
-    RemotingCommandPtr response = m_pRemotingClient->invokeSync(addr, request, timeoutMillis);
-    if (response)
-    {
-        switch (response->getCode())
-        {
-            case SUCCESS_VALUE:
-            {
-                return;
-            }
-            default:
-                break;
-        }
-
-        THROW_MQEXCEPTION(MQClientException, response->getRemark(), response->getCode());
-    }
-
-    THROW_MQEXCEPTION(MQClientException, "updateConsumerOffset failed", -1);
-}
-
-void MQClientAPIImpl::updateConsumerOffsetOneway(const std::string& addr,
-        UpdateConsumerOffsetRequestHeader* pRequestHeader,
-        int timeoutMillis)
-{
-    if (!UtilAll::isBlank(m_projectGroupPrefix))
-    {
-        pRequestHeader->consumerGroup = VirtualEnvUtil::buildWithProjectGroup(
-                                            pRequestHeader->consumerGroup, m_projectGroupPrefix);
-        pRequestHeader->topic = VirtualEnvUtil::buildWithProjectGroup(pRequestHeader->topic,
-                                m_projectGroupPrefix);
-    }
-
-    RemotingCommandPtr request =
-        RemotingCommand::createRequestCommand(UPDATE_CONSUMER_OFFSET_VALUE, pRequestHeader);
-
-    m_pRemotingClient->invokeOneway(addr, request, timeoutMillis);
-}
-
-void MQClientAPIImpl::sendHearbeat(const std::string& addr, HeartbeatData* pHeartbeatData, int timeoutMillis)
-{
-    if (!UtilAll::isBlank(m_projectGroupPrefix))
-    {
-        std::set<ConsumerData>& consumerDatas = pHeartbeatData->getConsumerDataSet();
-        std::set<ConsumerData>::iterator it = consumerDatas.begin();
-        for (; it != consumerDatas.end(); it++)
-        {
-            ConsumerData& consumerData = (ConsumerData&)(*it);
-            consumerData.groupName = VirtualEnvUtil::buildWithProjectGroup(consumerData.groupName,
-                                     m_projectGroupPrefix);
-
-            std::set<SubscriptionData>& subscriptionDatas = consumerData.subscriptionDataSet;
-            std::set<SubscriptionData>::iterator itsub = subscriptionDatas.begin();
-            for (; itsub != subscriptionDatas.end(); itsub++)
-            {
-                SubscriptionData& subscriptionData = (SubscriptionData&)(*itsub);
-                subscriptionData.setTopic(VirtualEnvUtil::buildWithProjectGroup(
-                                              subscriptionData.getTopic(), m_projectGroupPrefix));
-            }
-        }
-
-        std::set<ProducerData>& producerDatas = pHeartbeatData->getProducerDataSet();
-        std::set<ProducerData>::iterator itp = producerDatas.begin();
-        for (; itp != producerDatas.end(); itp++)
-        {
-            ProducerData& producerData = (ProducerData&)(*itp);
-            producerData.groupName = VirtualEnvUtil::buildWithProjectGroup(producerData.groupName,
-                                     m_projectGroupPrefix);
-        }
-    }
-
-    RemotingCommandPtr request = RemotingCommand::createRequestCommand(HEART_BEAT_VALUE, NULL);
-
-    std::string body;
-    pHeartbeatData->encode(body);
-    request->setBody((char*)body.data(), body.length(), true);
-
-    RemotingCommandPtr response = m_pRemotingClient->invokeSync(addr, request, timeoutMillis);
-    if (response)
-    {
-        switch (response->getCode())
-        {
-            case SUCCESS_VALUE:
-            {
-                return;
-            }
-            default:
-                break;
-        }
-
-        THROW_MQEXCEPTION(MQClientException, response->getRemark(), response->getCode());
-    }
-
-    THROW_MQEXCEPTION(MQClientException, "sendHearbeat failed", -1);
-}
-
-void MQClientAPIImpl::unregisterClient(const std::string& addr,
-                                       const std::string& clientID,
-                                       const std::string& producerGroup,
-                                       const std::string& consumerGroup,
-                                       int timeoutMillis)
-{
-    std::string producerGroupWithProjectGroup = producerGroup;
-    std::string consumerGroupWithProjectGroup = consumerGroup;
-    if (!UtilAll::isBlank(m_projectGroupPrefix))
-    {
-        producerGroupWithProjectGroup =
-            VirtualEnvUtil::buildWithProjectGroup(producerGroup, m_projectGroupPrefix);
-        consumerGroupWithProjectGroup =
-            VirtualEnvUtil::buildWithProjectGroup(consumerGroup, m_projectGroupPrefix);
-    }
-
-    UnregisterClientRequestHeader* requestHeader = new UnregisterClientRequestHeader();
-    requestHeader->clientID = (clientID);
-    requestHeader->producerGroup = (producerGroupWithProjectGroup);
-    requestHeader->consumerGroup = (consumerGroupWithProjectGroup);
-
-    RemotingCommandPtr request =
-        RemotingCommand::createRequestCommand(UNREGISTER_CLIENT_VALUE, requestHeader);
-
-    RemotingCommandPtr response = m_pRemotingClient->invokeSync(addr, request, timeoutMillis);
-    if (response)
-    {
-        switch (response->getCode())
-        {
-            case SUCCESS_VALUE:
-                return;
-            default:
-                break;
-        }
-
-        THROW_MQEXCEPTION(MQClientException, response->getRemark(), response->getCode());
-    }
-
-    THROW_MQEXCEPTION(MQClientException, "unregisterClient failed", -1);
-}
-
-void MQClientAPIImpl::endTransactionOneway(const std::string& addr,
-        EndTransactionRequestHeader* pRequestHeader,
-        const std::string& remark,
-        int timeoutMillis)
-{
-    //TODO
-}
-
-void MQClientAPIImpl::queryMessage(const std::string& addr,
-                                   QueryMessageRequestHeader* pRequestHeader,
-                                   int timeoutMillis,
-                                   InvokeCallback* pInvokeCallback)
-{
-    if (!UtilAll::isBlank(m_projectGroupPrefix))
-    {
-        pRequestHeader->topic = VirtualEnvUtil::buildWithProjectGroup(pRequestHeader->topic,
-        	m_projectGroupPrefix);
-    }
-
-    RemotingCommandPtr request =
-        RemotingCommand::createRequestCommand(QUERY_MESSAGE_VALUE, pRequestHeader);
-
-    m_pRemotingClient->invokeAsync(addr, request, timeoutMillis, pInvokeCallback);
-    return;
-}
-
-bool MQClientAPIImpl::registerClient(const std::string& addr, HeartbeatData& heartbeat, int timeoutMillis)
-{
-    if (!UtilAll::isBlank(m_projectGroupPrefix))
-    {
-        std::set<ConsumerData>& consumerDatas = heartbeat.getConsumerDataSet();
-        std::set<ConsumerData>::iterator it = consumerDatas.begin();
-
-        for (; it != consumerDatas.end(); it++)
-        {
-            ConsumerData& consumerData = (ConsumerData&)(*it);
-
-            consumerData.groupName = VirtualEnvUtil::buildWithProjectGroup(consumerData.groupName,
-                                     m_projectGroupPrefix);
-            std::set<SubscriptionData>& subscriptionDatas = consumerData.subscriptionDataSet;
-            std::set<SubscriptionData>::iterator itsub = subscriptionDatas.begin();
-
-            for (; itsub != subscriptionDatas.end(); itsub++)
-            {
-                SubscriptionData& subscriptionData = (SubscriptionData&)(*itsub);
-                subscriptionData.setTopic(VirtualEnvUtil::buildWithProjectGroup(
-                                              subscriptionData.getTopic(), m_projectGroupPrefix));
-            }
-        }
-
-        std::set<ProducerData>& producerDatas = heartbeat.getProducerDataSet();
-        std::set<ProducerData>::iterator itp = producerDatas.begin();
-        for (; itp != producerDatas.end(); itp++)
-        {
-            ProducerData& producerData = (ProducerData&)(*itp);
-            producerData.groupName = VirtualEnvUtil::buildWithProjectGroup(producerData.groupName,
-                                     m_projectGroupPrefix);
-        }
-    }
-
-    RemotingCommandPtr request = RemotingCommand::createRequestCommand(HEART_BEAT_VALUE, NULL);
-
-    std::string body;
-    heartbeat.encode(body);
-
-    request->setBody((char*)body.data(), body.length(), true);
-
-    RemotingCommandPtr response = m_pRemotingClient->invokeSync(addr, request, timeoutMillis);
-    return (response && response->getCode() == SUCCESS_VALUE);
-}
-
-void MQClientAPIImpl::consumerSendMessageBack(
-		const std::string& addr,
-		MessageExt& msg,
-        const std::string& consumerGroup,
-        int delayLevel,
-        int timeoutMillis)
-{
-    std::string consumerGroupWithProjectGroup = consumerGroup;
-    if (!UtilAll::isBlank(m_projectGroupPrefix))
-    {
-        consumerGroupWithProjectGroup =
-            VirtualEnvUtil::buildWithProjectGroup(consumerGroup, m_projectGroupPrefix);
-        msg.setTopic(VirtualEnvUtil::buildWithProjectGroup(msg.getTopic(), m_projectGroupPrefix));
-    }
-
-    ConsumerSendMsgBackRequestHeader* requestHeader = new ConsumerSendMsgBackRequestHeader();
-    requestHeader->group = consumerGroupWithProjectGroup;
-    requestHeader->offset = msg.getCommitLogOffset();
-    requestHeader->delayLevel = delayLevel;
-
-    RemotingCommandPtr request = RemotingCommand::createRequestCommand(CONSUMER_SEND_MSG_BACK_VALUE, requestHeader);
-
-	std::string brokerAddr = addr.empty() ? socketAddress2IPPort(msg.getStoreHost()) : addr;
-    RemotingCommandPtr response = m_pRemotingClient->invokeSync(brokerAddr, request, timeoutMillis);
-    if (response)
-    {
-        switch (response->getCode())
-        {
-            case SUCCESS_VALUE:
-                return;
-                break;
-            default:
-                break;
-        }
-
-        THROW_MQEXCEPTION(MQClientException, response->getRemark(), response->getCode());
-    }
-
-    THROW_MQEXCEPTION(MQClientException, "consumerSendMessageBack failed", -1);
-}
-
-std::set<MessageQueue> MQClientAPIImpl::lockBatchMQ(const std::string& addr,
-        LockBatchRequestBody* pRequestBody,
-        int timeoutMillis)
-{
-    if (!UtilAll::isBlank(m_projectGroupPrefix))
-    {
-        pRequestBody->setConsumerGroup((VirtualEnvUtil::buildWithProjectGroup(
-                                            pRequestBody->getConsumerGroup(), m_projectGroupPrefix)));
-        std::set<MessageQueue>& messageQueues = pRequestBody->getMqSet();
-        std::set<MessageQueue>::iterator it = messageQueues.begin();
-
-        for (; it != messageQueues.end(); it++)
-        {
-            MessageQueue& messageQueue = (MessageQueue&)(*it);
-            messageQueue.setTopic(VirtualEnvUtil::buildWithProjectGroup(messageQueue.getTopic(),
-                                  m_projectGroupPrefix));
-        }
-    }
-
-    RemotingCommandPtr request = RemotingCommand::createRequestCommand(LOCK_BATCH_MQ_VALUE, NULL);
-
-    std::string body;
-    pRequestBody->encode(body);
-    request->setBody((char*)body.data(), body.length(), true);
-
-    RemotingCommandPtr response = m_pRemotingClient->invokeSync(addr, request, timeoutMillis);
-    if (response)
-    {
-        switch (response->getCode())
-        {
-            case SUCCESS_VALUE:
-            {
-                LockBatchResponseBody* responseBody =
-                    LockBatchResponseBody::decode(response->getBody(), response->getBodyLen());
-                std::set<MessageQueue> messageQueues = responseBody->getLockOKMQSet();
-
-                if (!UtilAll::isBlank(m_projectGroupPrefix))
-                {
-                    std::set<MessageQueue>::iterator it = messageQueues.begin();
-
-                    for (; it != messageQueues.end(); it++)
-                    {
-                        MessageQueue& messageQueue = (MessageQueue&)(*it);
-                        messageQueue.setTopic(VirtualEnvUtil::clearProjectGroup(messageQueue.getTopic(),
-                                              m_projectGroupPrefix));
-                    }
-                }
-                return messageQueues;
-            }
-            default:
-                break;
-        }
-
-        THROW_MQEXCEPTION(MQClientException, response->getRemark(), response->getCode());
-    }
-
-    THROW_MQEXCEPTION(MQClientException, "lockBatchMQ failed", -1);
-}
-
-void MQClientAPIImpl::unlockBatchMQ(const std::string& addr,
-                                    UnlockBatchRequestBody* pRequestBody,
-                                    int timeoutMillis,
-                                    bool oneway)
-{
-    if (!UtilAll::isBlank(m_projectGroupPrefix))
-    {
-        pRequestBody->setConsumerGroup((VirtualEnvUtil::buildWithProjectGroup(
-                                            pRequestBody->getConsumerGroup(), m_projectGroupPrefix)));
-        std::set<MessageQueue>& messageQueues = pRequestBody->getMqSet();
-        std::set<MessageQueue>::iterator it = messageQueues.begin();
-
-        for (; it != messageQueues.end(); it++)
-        {
-            MessageQueue& messageQueue = (MessageQueue&)(*it);
-            messageQueue.setTopic(VirtualEnvUtil::buildWithProjectGroup(messageQueue.getTopic(),
-                                  m_projectGroupPrefix));
-        }
-    }
-
-    RemotingCommandPtr request = RemotingCommand::createRequestCommand(UNLOCK_BATCH_MQ_VALUE, NULL);
-
-    std::string body;
-    pRequestBody->encode(body);
-    request->setBody((char*)body.data(), body.length(), true);
-
-    if (oneway)
-    {
-        m_pRemotingClient->invokeOneway(addr, request, timeoutMillis);
-    }
-    else
-    {
-        RemotingCommandPtr response = m_pRemotingClient->invokeSync(addr, request, timeoutMillis);
-        if (response)
-        {
-            switch (response->getCode())
-            {
-                case SUCCESS_VALUE:
-                    return;
-                default:
-                    break;
-            }
-
-            THROW_MQEXCEPTION(MQClientException, response->getRemark(), response->getCode());
-        }
-
-        THROW_MQEXCEPTION(MQClientException, "unlockBatchMQ failed", -1);
-    }
-}
-
-TopicStatsTable MQClientAPIImpl::getTopicStatsInfo(const std::string& addr,
-        const std::string& topic,
-        int timeoutMillis)
-{
-    //TODO
-    TopicStatsTable t;
-    return t;
-}
-
-ConsumeStats MQClientAPIImpl::getConsumeStats(const std::string& addr,
-        const std::string& consumerGroup,
-        int timeoutMillis)
-{
-    //TODO
-    ConsumeStats cs;
-    return cs;
-}
-
-ProducerConnection* MQClientAPIImpl::getProducerConnectionList(const std::string& addr,
-        const std::string& producerGroup,
-        int timeoutMillis)
-{
-    //TODO
-    return NULL;
-}
-
-ConsumerConnection* MQClientAPIImpl::getConsumerConnectionList(const std::string& addr,
-        const std::string& consumerGroup,
-        int timeoutMillis)
-{
-    //TODO
-    return NULL;
-}
-
-KVTable MQClientAPIImpl::getBrokerRuntimeInfo(const std::string& addr,  int timeoutMillis)
-{
-    //TODO
-    KVTable kv;
-    return kv;
-}
-
-void MQClientAPIImpl::updateBrokerConfig(const std::string& addr,
-        const std::map<std::string, std::string>&  properties,
-        int timeoutMillis)
-{
-    //TODO
-}
-
-ClusterInfo* MQClientAPIImpl::getBrokerClusterInfo(int timeoutMillis)
-{
-   //TODO
-    return NULL;
-}
-
-TopicRouteData* MQClientAPIImpl::getDefaultTopicRouteInfoFromNameServer(const std::string& topic,
-        int timeoutMillis)
-{
-    GetRouteInfoRequestHeader* requestHeader = new GetRouteInfoRequestHeader();
-    requestHeader->topic = topic;
-
-    RemotingCommandPtr request = RemotingCommand::createRequestCommand(GET_ROUTEINTO_BY_TOPIC_VALUE, requestHeader);
-    RemotingCommandPtr response = m_pRemotingClient->invokeSync("", request, timeoutMillis);
-    if (response)
-    {
-        switch (response->getCode())
-        {
-            case TOPIC_NOT_EXIST_VALUE:
-            {
-				// TODO LOG
-                break;
-            }
-            case SUCCESS_VALUE:
-            {
-                int bodyLen = response->getBodyLen();
-                const char* body = response->getBody();
-                if (body)
-                {
-                    TopicRouteData* ret = TopicRouteData::encode(body, bodyLen);
-                    return ret;
-                }
-            }
-            default:
-                break;
-        }
-
-        THROW_MQEXCEPTION(MQClientException, response->getRemark(), response->getCode());
-    }
-
-    return NULL;
-}
-
-TopicRouteData* MQClientAPIImpl::getTopicRouteInfoFromNameServer(const std::string& topic, int timeoutMillis)
-{
-    std::string topicWithProjectGroup = topic;
-    if (!UtilAll::isBlank(m_projectGroupPrefix))
-    {
-        topicWithProjectGroup = VirtualEnvUtil::buildWithProjectGroup(topic, m_projectGroupPrefix);
-    }
-
-    GetRouteInfoRequestHeader* requestHeader = new GetRouteInfoRequestHeader();
-    requestHeader->topic = topicWithProjectGroup;
-
-    RemotingCommandPtr request = RemotingCommand::createRequestCommand(GET_ROUTEINTO_BY_TOPIC_VALUE, requestHeader);
-    RemotingCommandPtr response = m_pRemotingClient->invokeSync("", request, timeoutMillis);
-    if (response)
-    {
-        switch (response->getCode())
-        {
-            case TOPIC_NOT_EXIST_VALUE:
-            {
-            	if (topic != MixAll::DEFAULT_TOPIC)
-            	{
-            		RMQ_WARN("get Topic [{%s}] RouteInfoFromNameServer is not exist value", topic.c_str());
-            	}
-                break;
-            }
-            case SUCCESS_VALUE:
-            {
-                int bodyLen = response->getBodyLen();
-                const char* body = response->getBody();
-                if (body)
-                {
-                    TopicRouteData* ret = TopicRouteData::encode(body, bodyLen);
-                    return ret;
-                }
-            }
-            default:
-                break;
-        }
-
-        THROW_MQEXCEPTION(MQClientException, response->getRemark(), response->getCode());
-    }
-
-    return NULL;
-}
-
-TopicList* MQClientAPIImpl::getTopicListFromNameServer(int timeoutMillis)
-{
-    RemotingCommandPtr request = RemotingCommand::createRequestCommand(GET_ALL_TOPIC_LIST_FROM_NAMESERVER_VALUE, NULL);
-    RemotingCommandPtr response = m_pRemotingClient->invokeSync("", request, timeoutMillis);
-    if (response)
-    {
-        switch (response->getCode())
-        {
-            case SUCCESS_VALUE:
-            {
-                char* body = (char*)response->getBody();
-                if (body != NULL)
-                {
-                    TopicList* topicList = TopicList::decode(body, response->getBodyLen());
-
-                    if (!UtilAll::isBlank(m_projectGroupPrefix))
-                    {
-                        std::set<std::string> newTopicSet;
-
-                        const std::set<std::string>& topics = topicList->getTopicList();
-                        std::set<std::string>::const_iterator it = topics.begin();
-                        for (; it != topics.end(); it++)
-                        {
-                            std::string topic = *it;
-                            newTopicSet.insert(VirtualEnvUtil::clearProjectGroup(topic, m_projectGroupPrefix));
-                        }
-
-                        topicList->setTopicList(newTopicSet);
-                    }
-
-                    return topicList;
-                }
-            }
-            default:
-                break;
-        }
-
-        THROW_MQEXCEPTION(MQClientException, response->getRemark(), response->getCode());
-    }
-
-    return NULL;
-}
-
-int MQClientAPIImpl::wipeWritePermOfBroker(const std::string& namesrvAddr,
-        const std::string& brokerName,
-        int timeoutMillis)
-{
-    //TODO
-    return 0;
-}
-
-void MQClientAPIImpl::deleteTopicInBroker(const std::string& addr,
-        const std::string& topic,
-        int timeoutMillis)
-{
-    //TODO
-}
-
-void MQClientAPIImpl::deleteTopicInNameServer(const std::string& addr,
-        const std::string& topic,
-        int timeoutMillis)
-{
-    //TODO
-}
-
-void MQClientAPIImpl::deleteSubscriptionGroup(const std::string& addr,
-        const std::string& groupName,
-        int timeoutMillis)
-{
-    //TODO
-}
-
-std::string MQClientAPIImpl::getKVConfigValue(const std::string& projectNamespace,
-        const std::string& key,
-        int timeoutMillis)
-{
-	GetKVConfigRequestHeader* pRequestHeader = new GetKVConfigRequestHeader();
-    pRequestHeader->namespace_ = projectNamespace;
-    pRequestHeader->key = key;
-
-    RemotingCommandPtr request =
-        RemotingCommand::createRequestCommand(GET_KV_CONFIG_VALUE, pRequestHeader);
-
-    RemotingCommandPtr response = m_pRemotingClient->invokeSync("", request, timeoutMillis);
-    if (response)
-    {
-	    switch (response->getCode())
-	    {
-	        case SUCCESS_VALUE:
-	        {
-	            GetKVConfigResponseHeader* ret = (GetKVConfigResponseHeader*)response->getCommandCustomHeader();
-	            return ret->value;
-	        }
-	        default:
-	            break;
-	    }
-	    THROW_MQEXCEPTION(MQClientException, response->getRemark(), response->getCode());
-	}
-
-    THROW_MQEXCEPTION(MQClientException, "getKVConfigValue failed", -1);
-}
-
-void MQClientAPIImpl::putKVConfigValue(const std::string& projectNamespace,
-                                       const std::string& key,
-                                       const std::string& value,
-                                       int timeoutMillis)
-{
-    //TODO
-}
-
-void MQClientAPIImpl::deleteKVConfigValue(const std::string& projectNamespace,
-        const std::string& key,
-        int timeoutMillis)
-{
-    //TODO
-}
-
-std::string MQClientAPIImpl::getProjectGroupByIp(const std::string& ip,  int timeoutMillis)
-{
-    return getKVConfigValue(NamesrvUtil::NAMESPACE_PROJECT_CONFIG, ip, timeoutMillis);
-}
-
-std::string MQClientAPIImpl::getKVConfigByValue(const std::string& projectNamespace,
-        const std::string& projectGroup,
-        int timeoutMillis)
-{
-    //TODO
-    return "";
-}
-
-KVTable MQClientAPIImpl::getKVListByNamespace(const std::string& projectNamespace,  int timeoutMillis)
-{
-    //TODO
-    return KVTable();
-}
-
-void MQClientAPIImpl::deleteKVConfigByValue(const std::string& projectNamespace,
-        const std::string& projectGroup,
-        int timeoutMillis)
-{
-    //TODO
-}
-
-SendResult* MQClientAPIImpl::sendMessageSync(const std::string& addr,
-        const std::string& brokerName,
-        Message& msg,
-        int timeoutMillis,
-        RemotingCommand* request)
-{
-    RemotingCommandPtr response = m_pRemotingClient->invokeSync(addr, request, timeoutMillis);
-    return processSendResponse(brokerName, msg.getTopic(), response);
-}
-
-void MQClientAPIImpl::sendMessageAsync(const std::string& addr,
-                                       const std::string& brokerName,
-                                       Message& msg,
-                                       int timeoutMillis,
-                                       RemotingCommand* request,
-                                       SendCallback* pSendCallback)
-{
-    ProducerInvokeCallback* callback = new ProducerInvokeCallback(pSendCallback, this, msg.getTopic(), brokerName);
-    m_pRemotingClient->invokeAsync(addr, request, timeoutMillis, callback);
-}
-
-SendResult* MQClientAPIImpl::processSendResponse(const std::string& brokerName,
-        const std::string& topic,
-        RemotingCommand* pResponse)
-{
-    if (pResponse == NULL)
-    {
-        return NULL;
-    }
-
-    switch (pResponse->getCode())
-    {
-        case FLUSH_DISK_TIMEOUT_VALUE:
-        case FLUSH_SLAVE_TIMEOUT_VALUE:
-        case SLAVE_NOT_AVAILABLE_VALUE:
-        {
-            // TODO LOG
-        }
-        case SUCCESS_VALUE:
-        {
-            SendStatus sendStatus = SEND_OK;
-            switch (pResponse->getCode())
-            {
-                case FLUSH_DISK_TIMEOUT_VALUE:
-                    sendStatus = FLUSH_DISK_TIMEOUT;
-                    break;
-                case FLUSH_SLAVE_TIMEOUT_VALUE:
-                    sendStatus = FLUSH_SLAVE_TIMEOUT;
-                    break;
-                case SLAVE_NOT_AVAILABLE_VALUE:
-                    sendStatus = SLAVE_NOT_AVAILABLE;
-                    break;
-                case SUCCESS_VALUE:
-                    sendStatus = SEND_OK;
-                    break;
-                default:
-                    //assert false;
-                    break;
-            }
-
-            SendMessageResponseHeader* responseHeader = (SendMessageResponseHeader*)pResponse->getCommandCustomHeader();
-            MessageQueue messageQueue(topic, brokerName, responseHeader->queueId);
-            SendResult* ret = new SendResult(sendStatus, responseHeader->msgId, messageQueue,
-                                             responseHeader->queueOffset, m_projectGroupPrefix);
-
-            return ret;
-        }
-        default:
-            break;
-    }
-
-    THROW_MQEXCEPTION(MQClientException, pResponse->getRemark(), pResponse->getCode());
-}
-
-void MQClientAPIImpl::pullMessageAsync(const std::string& addr,
-                                       RemotingCommand* pRequest,
-                                       int timeoutMillis,
-                                       PullCallback* pPullCallback)
-{
-    ConsumerInvokeCallback* callback = new ConsumerInvokeCallback(pPullCallback, this);
-    m_pRemotingClient->invokeAsync(addr, pRequest, timeoutMillis, callback);
-}
-
-PullResult* MQClientAPIImpl::processPullResponse(RemotingCommand* pResponse)
-{
-    PullStatus pullStatus = NO_NEW_MSG;
-    switch (pResponse->getCode())
-    {
-        case SUCCESS_VALUE:
-            pullStatus = FOUND;
-            break;
-        case PULL_NOT_FOUND_VALUE:
-            pullStatus = NO_NEW_MSG;
-            break;
-        case PULL_RETRY_IMMEDIATELY_VALUE:
-            pullStatus = NO_MATCHED_MSG;
-            break;
-        case PULL_OFFSET_MOVED_VALUE:
-            pullStatus = OFFSET_ILLEGAL;
-            break;
-        default:
-            THROW_MQEXCEPTION(MQBrokerException, pResponse->getRemark(), pResponse->getCode());
-            break;
-    }
-
-    PullMessageResponseHeader* responseHeader = (PullMessageResponseHeader*) pResponse->getCommandCustomHeader();
-    std::list<MessageExt*> msgFoundList;
-    return new PullResultExt(pullStatus, responseHeader->nextBeginOffset,
-                             responseHeader->minOffset, responseHeader->maxOffset, msgFoundList,
-                             responseHeader->suggestWhichBrokerId, pResponse->getBody(), pResponse->getBodyLen());
-}
-
-PullResult* MQClientAPIImpl::pullMessageSync(const std::string& addr,
-        RemotingCommand* pRequest,
-        int timeoutMillis)
-{
-    RemotingCommandPtr response = m_pRemotingClient->invokeSync(addr, pRequest, timeoutMillis);
-    PullResult* result = processPullResponse(response);
-
-    response->setBody(NULL, 0, false);
-    return result;
-}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/MQClientAPIImpl.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/MQClientAPIImpl.h b/rocketmq-client4cpp/src/MQClientAPIImpl.h
deleted file mode 100755
index 88defb5..0000000
--- a/rocketmq-client4cpp/src/MQClientAPIImpl.h
+++ /dev/null
@@ -1,280 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __MQCLIENTAPIIMPL_H__
-#define __MQCLIENTAPIIMPL_H__
-
-#include <string>
-#include <map>
-#include <list>
-#include <set>
-
-#include "ClientConfig.h"
-#include "RemoteClientConfig.h"
-#include "SubscriptionGroupConfig.h"
-#include "TopicConfig.h"
-#include "ConsumeStats.h"
-#include "TopicStatsTable.h"
-#include "KVTable.h"
-#include "TopicRouteData.h"
-#include "SendResult.h"
-#include "PullResult.h"
-#include "MessageExt.h"
-#include "CommunicationMode.h"
-#include "TopAddressing.h"
-#include "HeartbeatData.h"
-#include "LockBatchBody.h"
-
-namespace rmq
-{
-class ClientConfig;
-class TcpRemotingClient;
-class QueryConsumerOffsetRequestHeader;
-class UpdateConsumerOffsetRequestHeader;
-class EndTransactionRequestHeader;
-class SendMessageRequestHeader;
-class PullMessageRequestHeader;
-class QueryMessageRequestHeader;
-class ProducerConnection;
-class ConsumerConnection;
-class ClusterInfo;
-class TopicList;
-class InvokeCallback;
-class RemotingCommand;
-class PullCallback;
-class SendCallback;
-class ClientRemotingProcessor;
-
-class MQClientAPIImpl
-{
-  public:
-      MQClientAPIImpl(ClientConfig& clientConfig,
-	  				  const RemoteClientConfig& remoteClientConfig,
-                      ClientRemotingProcessor* pClientRemotingProcessor);
-      ~MQClientAPIImpl();
-
-      void start();
-      void shutdown();
-
-      std::string getProjectGroupPrefix();
-      std::vector<std::string> getNameServerAddressList();
-      void updateNameServerAddressList(const std::string& addrs);
-      std::string fetchNameServerAddr();
-
-      void createSubscriptionGroup(const std::string& addr,
-                                   SubscriptionGroupConfig config,
-                                   int timeoutMillis);
-
-      void createTopic(const std::string& addr,
-                       const std::string& defaultTopic,
-                       TopicConfig topicConfig,
-                       int timeoutMillis);
-
-      SendResult sendMessage(const std::string& addr,
-                             const std::string& brokerName,
-                             Message& msg,
-                             SendMessageRequestHeader* pRequestHeader,
-                             int timeoutMillis,
-                             CommunicationMode communicationMode,
-                             SendCallback* pSendCallback);
-
-      PullResult* pullMessage(const std::string& addr,
-                              PullMessageRequestHeader* pRequestHeader,
-                              int timeoutMillis,
-                              CommunicationMode communicationMode,
-                              PullCallback* pPullCallback);
-
-      MessageExt* viewMessage(const std::string& addr, long long phyoffset, int timeoutMillis);
-
-
-      long long searchOffset(const std::string& addr,
-                             const std::string& topic,
-                             int queueId,
-                             long long timestamp,
-                             int timeoutMillis);
-
-      long long getMaxOffset(const std::string& addr,
-                             const std::string& topic,
-                             int queueId,
-                             int timeoutMillis);
-
-      std::list<std::string> getConsumerIdListByGroup(const std::string& addr,
-              const std::string& consumerGroup,
-              int timeoutMillis);
-
-      long long getMinOffset(const std::string& addr,
-                             const std::string& topic,
-                             int queueId,
-                             int timeoutMillis);
-
-      long long getEarliestMsgStoretime(const std::string& addr,
-                                        const std::string& topic,
-                                        int queueId,
-                                        int timeoutMillis);
-
-      long long queryConsumerOffset(const std::string& addr,
-                                    QueryConsumerOffsetRequestHeader* pRequestHeader,
-                                    int timeoutMillis);
-
-      void updateConsumerOffset(const std::string& addr,
-                                UpdateConsumerOffsetRequestHeader* pRequestHeader,
-                                int timeoutMillis);
-
-      void updateConsumerOffsetOneway(const std::string& addr,
-                                      UpdateConsumerOffsetRequestHeader* pRequestHeader,
-                                      int timeoutMillis);
-
-      void sendHearbeat(const std::string& addr, HeartbeatData* pHeartbeatData, int timeoutMillis);
-
-      void unregisterClient(const std::string& addr,
-                            const std::string& clientID,
-                            const std::string& producerGroup,
-                            const std::string& consumerGroup,
-                            int timeoutMillis);
-
-      void endTransactionOneway(const std::string& addr,
-                                EndTransactionRequestHeader* pRequestHeader,
-                                const std::string& remark,
-                                int timeoutMillis);
-
-      void queryMessage(const std::string& addr,
-                        QueryMessageRequestHeader* pRequestHeader,
-                        int timeoutMillis,
-                        InvokeCallback* pInvokeCallback);
-
-      bool registerClient(const std::string& addr,
-                          HeartbeatData& heartbeat,
-                          int timeoutMillis);
-
-      void consumerSendMessageBack(const std::string& addr,
-      							   MessageExt& msg,
-                                   const std::string& consumerGroup,
-                                   int delayLevel,
-                                   int timeoutMillis);
-
-      std::set<MessageQueue> lockBatchMQ(const std::string& addr,
-                                         LockBatchRequestBody* pRequestBody,
-                                         int timeoutMillis);
-
-      void unlockBatchMQ(const std::string& addr,
-                         UnlockBatchRequestBody* pRequestBody,
-                         int timeoutMillis,
-                         bool oneway);
-
-      TopicStatsTable getTopicStatsInfo(const std::string& addr,
-                                        const std::string& topic,
-                                        int timeoutMillis);
-
-      ConsumeStats getConsumeStats(const std::string& addr,
-                                   const std::string& consumerGroup,
-                                   int timeoutMillis);
-
-      ProducerConnection* getProducerConnectionList(const std::string& addr,
-              const std::string& producerGroup,
-              int timeoutMillis);
-
-      ConsumerConnection* getConsumerConnectionList(const std::string& addr,
-              const std::string& consumerGroup,
-              int timeoutMillis);
-
-      KVTable getBrokerRuntimeInfo(const std::string& addr,  int timeoutMillis);
-
-      void updateBrokerConfig(const std::string& addr,
-                              const std::map<std::string, std::string>& properties,
-                              int timeoutMillis);
-
-      ClusterInfo* getBrokerClusterInfo(int timeoutMillis);
-
-      TopicRouteData* getDefaultTopicRouteInfoFromNameServer(const std::string& topic, int timeoutMillis);
-
-      TopicRouteData* getTopicRouteInfoFromNameServer(const std::string& topic, int timeoutMillis);
-
-      TopicList* getTopicListFromNameServer(int timeoutMillis);
-
-      int wipeWritePermOfBroker(const std::string& namesrvAddr,
-                                const std::string& brokerName,
-                                int timeoutMillis);
-
-      void deleteTopicInBroker(const std::string& addr, const std::string& topic, int timeoutMillis);
-      void deleteTopicInNameServer(const std::string& addr, const std::string& topic, int timeoutMillis);
-      void deleteSubscriptionGroup(const std::string& addr,
-                                   const std::string& groupName,
-                                   int timeoutMillis);
-
-      std::string getKVConfigValue(const std::string& projectNamespace,
-                                   const std::string& key,
-                                   int timeoutMillis);
-
-      void putKVConfigValue(const std::string& projectNamespace,
-                            const std::string& key,
-                            const std::string& value,
-                            int timeoutMillis);
-
-      void deleteKVConfigValue(const std::string& projectNamespace, const std::string& key, int timeoutMillis);
-
-      std::string getProjectGroupByIp(const std::string& ip,  int timeoutMillis);
-
-      std::string getKVConfigByValue(const std::string& projectNamespace,
-                                     const std::string& projectGroup,
-                                     int timeoutMillis);
-
-      KVTable getKVListByNamespace(const std::string& projectNamespace,  int timeoutMillis);
-
-      void deleteKVConfigByValue(const std::string& projectNamespace,
-                                 const std::string& projectGroup,
-                                 int timeoutMillis);
-
-      TcpRemotingClient* getRemotingClient();
-
-      SendResult* processSendResponse(const std::string& brokerName,
-                                      const std::string& topic,
-                                      RemotingCommand* pResponse);
-
-      PullResult* processPullResponse(RemotingCommand* pResponse);
-
-  private:
-      SendResult* sendMessageSync(const std::string& addr,
-                                  const std::string& brokerName,
-                                  Message& msg,
-                                  int timeoutMillis,
-                                  RemotingCommand* request);
-
-      void sendMessageAsync(const std::string& addr,
-                            const std::string& brokerName,
-                            Message& msg,
-                            int timeoutMillis,
-                            RemotingCommand* request,
-                            SendCallback* pSendCallback);
-
-      void pullMessageAsync(const std::string& addr,
-                            RemotingCommand* pRequest,
-                            int timeoutMillis,
-                            PullCallback* pPullCallback);
-
-      PullResult* pullMessageSync(const std::string& addr,
-                                  RemotingCommand* pRequest,
-                                  int timeoutMillis);
-
-  private:
-      TcpRemotingClient* m_pRemotingClient;
-      TopAddressing m_topAddressing;
-      ClientRemotingProcessor* m_pClientRemotingProcessor;
-      std::string m_nameSrvAddr;
-      std::string m_projectGroupPrefix;
-  };
-}
-
-#endif


[14/17] incubator-rocketmq-externals git commit: Polish cpp module

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/MQClientFactory.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/MQClientFactory.cpp b/rocketmq-client4cpp/src/MQClientFactory.cpp
deleted file mode 100755
index 2b8208b..0000000
--- a/rocketmq-client4cpp/src/MQClientFactory.cpp
+++ /dev/null
@@ -1,1258 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#include <math.h>
-#include <set>
-#include <string>
-#include <iostream>
-#include <vector>
-
-#include "MQClientFactory.h"
-#include "RemoteClientConfig.h"
-#include "ClientRemotingProcessor.h"
-#include "MQClientAPIImpl.h"
-#include "MQAdminImpl.h"
-#include "DefaultMQProducer.h"
-#include "PullMessageService.h"
-#include "RebalanceService.h"
-#include "ScopedLock.h"
-#include "KPRUtil.h"
-#include "DefaultMQProducerImpl.h"
-#include "DefaultMQPushConsumerImpl.h"
-#include "MQClientException.h"
-#include "MQConsumerInner.h"
-#include "MQProducerInner.h"
-#include "UtilAll.h"
-#include "PermName.h"
-#include "MQClientManager.h"
-#include "ConsumerStatManage.h"
-#include "TopicPublishInfo.h"
-#include "MQVersion.h"
-
-namespace rmq
-{
-
-
-long MQClientFactory::LockTimeoutMillis = 3000;
-
-MQClientFactory::MQClientFactory(ClientConfig& clientConfig, int factoryIndex, const std::string& clientId)
-{
-    m_clientConfig = clientConfig;
-    m_factoryIndex = factoryIndex;
-    m_pRemoteClientConfig = new RemoteClientConfig();
-    m_pRemoteClientConfig->clientCallbackExecutorThreads = clientConfig.getClientCallbackExecutorThreads();
-    m_pClientRemotingProcessor = new ClientRemotingProcessor(this);
-    m_pMQClientAPIImpl = new MQClientAPIImpl(m_clientConfig, *m_pRemoteClientConfig, m_pClientRemotingProcessor);
-
-    if (!m_clientConfig.getNamesrvAddr().empty())
-    {
-        m_pMQClientAPIImpl->updateNameServerAddressList(m_clientConfig.getNamesrvAddr());
-        RMQ_INFO("user specified name server address: {%s}", m_clientConfig.getNamesrvAddr().c_str());
-    }
-
-    m_clientId = clientId;
-
-    m_pMQAdminImpl = new MQAdminImpl(this);
-    m_pPullMessageService = new PullMessageService(this);
-    m_pRebalanceService = new RebalanceService(this);
-    m_pDefaultMQProducer = new DefaultMQProducer(MixAll::CLIENT_INNER_PRODUCER_GROUP);
-    m_pDefaultMQProducer->resetClientConfig(clientConfig);
-    m_bootTimestamp = KPRUtil::GetCurrentTimeMillis();
-
-    m_pFetchNameServerAddrTask = new ScheduledTask(this, &MQClientFactory::fetchNameServerAddr);
-    m_pUpdateTopicRouteInfoFromNameServerTask = new ScheduledTask(this, &MQClientFactory::updateTopicRouteInfoFromNameServerTask);
-    m_pCleanBrokerTask = new ScheduledTask(this, &MQClientFactory::cleanBroker);
-    m_pPersistAllConsumerOffsetTask = new ScheduledTask(this, &MQClientFactory::persistAllConsumerOffsetTask);
-    m_pRecordSnapshotPeriodicallyTask = new ScheduledTask(this, &MQClientFactory::recordSnapshotPeriodicallyTask);
-    m_pLogStatsPeriodicallyTask = new ScheduledTask(this, &MQClientFactory::logStatsPeriodicallyTask);
-
-    m_serviceState = CREATE_JUST;
-
-    RMQ_INFO("created a new client Instance, FactoryIndex: {%d} ClinetID: {%s} Config: {%s} Version: {%s}",
-                m_factoryIndex,
-                m_clientId.c_str(),
-                m_clientConfig.toString().c_str(),
-                MQVersion::getVersionDesc(MQVersion::s_CurrentVersion));
-}
-
-MQClientFactory::~MQClientFactory()
-{
-    delete m_pRemoteClientConfig;
-    delete m_pClientRemotingProcessor;
-    delete m_pMQClientAPIImpl;
-    delete m_pMQAdminImpl;
-    delete m_pPullMessageService;
-    delete m_pRebalanceService;
-    delete m_pDefaultMQProducer;
-}
-
-void MQClientFactory::start()
-{
-    RMQ_DEBUG("MQClientFactory::start()");
-    kpr::ScopedLock<kpr::Mutex> lock(m_mutex);
-    switch (m_serviceState)
-    {
-        case CREATE_JUST:
-            makesureInstanceNameIsOnly(m_clientConfig.getInstanceName());
-
-            m_serviceState = START_FAILED;
-            if (m_clientConfig.getNamesrvAddr().empty())
-            {
-                m_clientConfig.setNamesrvAddr(m_pMQClientAPIImpl->fetchNameServerAddr());
-            }
-
-            m_pMQClientAPIImpl->start();
-            m_timerTaskManager.Init(5, 1000);
-            startScheduledTask();
-            m_pPullMessageService->Start();
-            m_pRebalanceService->Start();
-            m_pDefaultMQProducer->getDefaultMQProducerImpl()->start(false);
-
-			RMQ_INFO("the client factory [%s] start OK", m_clientId.c_str());
-            m_serviceState = RUNNING;
-            break;
-        case RUNNING:
-            RMQ_WARN("MQClientFactory is already running.");
-            break;
-        case SHUTDOWN_ALREADY:
-            RMQ_ERROR("MQClientFactory should have already been shutted down");
-            break;
-        case START_FAILED:
-            RMQ_ERROR("MQClientFactory started failed.");
-            THROW_MQEXCEPTION(MQClientException, "The Factory object start failed", -1);
-        default:
-            break;
-    }
-}
-
-
-void MQClientFactory::shutdown()
-{
-    RMQ_DEBUG("MQClientFactory::shutdown()");
-    // Consumer
-    if (!m_consumerTable.empty())
-    {
-        return;
-    }
-
-    // AdminExt
-    if (!m_adminExtTable.empty())
-    {
-        return;
-    }
-
-    // Producer
-    if (m_producerTable.size() > 1)
-    {
-        return;
-    }
-
-    RMQ_DEBUG("MQClientFactory::shutdown_begin");
-    {
-        kpr::ScopedLock<kpr::Mutex> lock(m_mutex);
-        switch (m_serviceState)
-        {
-            case CREATE_JUST:
-                break;
-            case RUNNING:
-                m_pDefaultMQProducer->getDefaultMQProducerImpl()->shutdown(false);
-
-                for (int i = 0; i < 6; i++)
-                {
-                    m_timerTaskManager.UnRegisterTimer(m_scheduledTaskIds[i]);
-                }
-
-                m_timerTaskManager.Stop();
-
-                m_pPullMessageService->stop();
-                m_pPullMessageService->Join();
-
-                m_pMQClientAPIImpl->shutdown();
-                m_pRebalanceService->stop();
-                m_pRebalanceService->Join();
-
-                //closesocket(m_datagramSocket);
-
-                MQClientManager::getInstance()->removeClientFactory(m_clientId);
-                m_serviceState = SHUTDOWN_ALREADY;
-                break;
-            case SHUTDOWN_ALREADY:
-                break;
-            default:
-                break;
-        }
-    }
-}
-
-
-void MQClientFactory::sendHeartbeatToAllBrokerWithLock()
-{
-	RMQ_DEBUG("TryLock m_lockHeartbeat: %p", &m_lockHeartbeat);
-    if (m_lockHeartbeat.TryLock())
-    {
-        try
-        {
-            RMQ_DEBUG("TryLock m_lockHeartbeat ok");
-            sendHeartbeatToAllBroker();
-        }
-        catch (...)
-        {
-            RMQ_ERROR("sendHeartbeatToAllBroker exception");
-        }
-        m_lockHeartbeat.Unlock();
-    }
-    else
-    {
-        RMQ_WARN("TryLock heartBeat fail");
-    }
-}
-
-void MQClientFactory::updateTopicRouteInfoFromNameServer()
-{
-    std::set<std::string> topicList;
-
-    // Consumer
-    {
-    	kpr::ScopedRLock<kpr::RWMutex> lock(m_consumerTableLock);
-        std::map<std::string, MQConsumerInner*>::iterator it = m_consumerTable.begin();
-        for (; it != m_consumerTable.end(); it++)
-        {
-            MQConsumerInner* inner = it->second;
-            std::set<SubscriptionData> subList = inner->subscriptions();
-            std::set<SubscriptionData>::iterator it1 = subList.begin();
-            for (; it1 != subList.end(); it1++)
-            {
-                topicList.insert((*it1).getTopic());
-            }
-        }
-    }
-
-    // Producer
-    {
-    	kpr::ScopedRLock<kpr::RWMutex> lock(m_producerTableLock);
-        std::map<std::string, MQProducerInner*>::iterator it = m_producerTable.begin();
-        for (; it != m_producerTable.end(); it++)
-        {
-            MQProducerInner* inner = it->second;
-            std::set<std::string> pubList = inner->getPublishTopicList();
-            topicList.insert(pubList.begin(), pubList.end());
-        }
-    }
-
-    std::set<std::string>::iterator it2 = topicList.begin();
-    for (; it2 != topicList.end(); it2++)
-    {
-        updateTopicRouteInfoFromNameServer(*it2);
-    }
-}
-
-bool MQClientFactory::updateTopicRouteInfoFromNameServer(const std::string& topic)
-{
-    return updateTopicRouteInfoFromNameServer(topic, false, NULL);
-}
-
-bool MQClientFactory::updateTopicRouteInfoFromNameServer(const std::string& topic,
-        bool isDefault,
-        DefaultMQProducer* pDefaultMQProducer)
-{
-    RMQ_DEBUG("TryLock m_lockNamesrv: 0x%p, topic: [%s]", &m_lockNamesrv, topic.c_str());
-    if (m_lockNamesrv.TryLock(MQClientFactory::LockTimeoutMillis))
-    {
-        RMQ_DEBUG("TryLock m_lockNamesrv ok");
-        TopicRouteDataPtr topicRouteData = NULL;
-        try
-        {
-            if (isDefault && pDefaultMQProducer != NULL)
-            {
-                topicRouteData =
-                    m_pMQClientAPIImpl->getDefaultTopicRouteInfoFromNameServer(
-                        pDefaultMQProducer->getCreateTopicKey(), 1000 * 3);
-                if (topicRouteData.ptr() != NULL)
-                {
-                    std::list<QueueData> dataList = topicRouteData->getQueueDatas();
-
-                    std::list<QueueData>::iterator it = dataList.begin();
-                    for (; it != dataList.end(); it++)
-                    {
-                        QueueData data = *it;
-
-                        int queueNums =
-                            std::min<int>(pDefaultMQProducer->getDefaultTopicQueueNums(),
-                                          data.readQueueNums);
-                        data.readQueueNums = (queueNums);
-                        data.writeQueueNums = (queueNums);
-                    }
-                }
-            }
-            else
-            {
-                topicRouteData =
-                    m_pMQClientAPIImpl->getTopicRouteInfoFromNameServer(topic, 1000 * 3);
-            }
-
-            if (topicRouteData.ptr() != NULL)
-            {
-                kpr::ScopedWLock<kpr::RWMutex> lock(m_topicRouteTableLock);
-                std::map<std::string, TopicRouteData>::iterator it = m_topicRouteTable.find(topic);
-                bool changed = false;
-
-                if (it != m_topicRouteTable.end())
-                {
-                    changed = topicRouteDataIsChange(it->second, *topicRouteData);
-                    if (!changed)
-                    {
-                        changed = isNeedUpdateTopicRouteInfo(topic);
-						if (changed)
-						{
-                        	RMQ_INFO("the topic[{%s}] route info changed, old[{%s}] ,new[{%s}]",
-                                 topic.c_str(), it->second.toString().c_str(),
-                                 topicRouteData->toString().c_str());
-                        }
-                    }
-                }
-                else
-                {
-                    changed = true;
-                }
-
-                if (changed)
-                {
-                    TopicRouteData cloneTopicRouteData = *topicRouteData;
-
-                    std::list<BrokerData> dataList = topicRouteData->getBrokerDatas();
-
-                    std::list<BrokerData>::iterator it = dataList.begin();
-                    for (; it != dataList.end(); it++)
-                    {
-                        kpr::ScopedWLock<kpr::RWMutex> lock(m_brokerAddrTableLock);
-                        m_brokerAddrTable[(*it).brokerName] = (*it).brokerAddrs;
-                    }
-
-                    {
-                        TopicPublishInfoPtr publishInfo =
-                            topicRouteData2TopicPublishInfo(topic, *topicRouteData);
-                        publishInfo->setHaveTopicRouterInfo(true);
-
-                        kpr::ScopedRLock<kpr::RWMutex> lock(m_producerTableLock);
-                        std::map<std::string, MQProducerInner*>::iterator it = m_producerTable.begin();
-                        for (; it != m_producerTable.end(); it++)
-                        {
-                            MQProducerInner* impl = it->second;
-                            if (impl)
-                            {
-                                impl->updateTopicPublishInfo(topic, *publishInfo);
-                            }
-                        }
-                    }
-
-                    {
-                        std::set<MessageQueue>* subscribeInfo =
-                            topicRouteData2TopicSubscribeInfo(topic, *topicRouteData);
-
-                        kpr::ScopedRLock<kpr::RWMutex> lock(m_consumerTableLock);
-                        std::map<std::string, MQConsumerInner*>::iterator it = m_consumerTable.begin();
-                        for (; it != m_consumerTable.end(); it++)
-                        {
-                            MQConsumerInner* impl = it->second;
-                            if (impl)
-                            {
-                                impl->updateTopicSubscribeInfo(topic, *subscribeInfo);
-                            }
-                        }
-                        delete subscribeInfo;
-                    }
-
-                    m_topicRouteTable[topic] = cloneTopicRouteData;
-                    m_lockNamesrv.Unlock();
-                    RMQ_DEBUG("UnLock m_lockNamesrv ok");
-
-                    RMQ_INFO("topicRouteTable.put[%s] = TopicRouteData[%s]",
-                    	topic.c_str(), cloneTopicRouteData.toString().c_str());
-                    return true;
-                }
-            }
-            else
-            {
-                //TODO log?
-                RMQ_WARN("updateTopicRouteInfoFromNameServer, getTopicRouteInfoFromNameServer return null, Topic: {%s}",
-                         topic.c_str());
-            }
-        }
-        catch (const std::exception& e)
-        {
-        	if (!(topic.find(MixAll::RETRY_GROUP_TOPIC_PREFIX) == 0) && topic != MixAll::DEFAULT_TOPIC)
-        	{
-            	RMQ_WARN("updateTopicRouteInfoFromNameServer Exception: %s", e.what());
-            }
-        }
-        catch (...)
-        {
-            RMQ_WARN("updateTopicRouteInfoFromNameServer unknow Exception");
-        }
-
-        m_lockNamesrv.Unlock();
-        RMQ_DEBUG("UnLock m_lockNamesrv ok");
-    }
-    else
-    {
-        RMQ_WARN("TryLock m_lockNamesrv timeout %ldms", MQClientFactory::LockTimeoutMillis);
-    }
-
-    return false;
-}
-
-TopicPublishInfo*  MQClientFactory::topicRouteData2TopicPublishInfo(const std::string& topic,
-        TopicRouteData& route)
-{
-    TopicPublishInfo* info = new TopicPublishInfo();
-    if (!route.getOrderTopicConf().empty())
-    {
-        std::vector<std::string> brokers;
-        UtilAll::Split(brokers, route.getOrderTopicConf(), ";");
-        for (size_t i = 0; i < brokers.size(); i++)
-        {
-            std::vector<std::string> item;
-            UtilAll::Split(item, brokers[i], ":");
-            int nums = atoi(item[1].c_str());
-            for (int i = 0; i < nums; i++)
-            {
-                MessageQueue mq(topic, item[0], i);
-                info->getMessageQueueList().push_back(mq);
-            }
-        }
-
-        info->setOrderTopic(true);
-    }
-    else
-    {
-        std::list<QueueData> qds = route.getQueueDatas();
-        qds.sort();
-        std::list<QueueData>::iterator it = qds.begin();
-        for (; it != qds.end(); it++)
-        {
-            QueueData& qd = (*it);
-            if (PermName::isWriteable(qd.perm))
-            {
-                bool find = false;
-                BrokerData brokerData;
-                std::list<BrokerData> bds = route.getBrokerDatas();
-                std::list<BrokerData>::iterator it1 = bds.begin();
-
-                for (; it1 != bds.end(); it1++)
-                {
-                    BrokerData& bd = (*it1);
-                    if (bd.brokerName == qd.brokerName)
-                    {
-                        brokerData = bd;
-                        find = true;
-                        break;
-                    }
-                }
-
-                if (!find)
-                {
-                    continue;
-                }
-
-                if (brokerData.brokerAddrs.find(MixAll::MASTER_ID) == brokerData.brokerAddrs.end())
-                {
-                    continue;
-                }
-
-                for (int i = 0; i < qd.writeQueueNums; i++)
-                {
-                    MessageQueue mq(topic, qd.brokerName, i);
-                    info->getMessageQueueList().push_back(mq);
-                }
-            }
-        }
-
-        info->setOrderTopic(false);
-    }
-
-    return info;
-}
-
-std::set<MessageQueue>* MQClientFactory::topicRouteData2TopicSubscribeInfo(const std::string& topic,
-        TopicRouteData& route)
-{
-    std::set<MessageQueue>* mqList = new std::set<MessageQueue>();
-    std::list<QueueData> qds = route.getQueueDatas();
-    std::list<QueueData>::iterator it = qds.begin();
-    for (; it != qds.end(); it++)
-    {
-        QueueData& qd = (*it);
-        if (PermName::isReadable(qd.perm))
-        {
-            for (int i = 0; i < qd.readQueueNums; i++)
-            {
-                MessageQueue mq(topic, qd.brokerName, i);
-                mqList->insert(mq);
-            }
-        }
-    }
-
-    return mqList;
-}
-
-bool MQClientFactory::registerConsumer(const std::string& group, MQConsumerInner* pConsumer)
-{
-    if (group.empty() || pConsumer == NULL)
-    {
-        return false;
-    }
-
-	kpr::ScopedWLock<kpr::RWMutex> lock(m_consumerTableLock);
-    if (m_consumerTable.find(group) != m_consumerTable.end())
-    {
-        return false;
-    }
-    m_consumerTable[group] = pConsumer;
-
-    return true;
-}
-
-void MQClientFactory::unregisterConsumer(const std::string& group)
-{
-	{
-		kpr::ScopedWLock<kpr::RWMutex> lock(m_consumerTableLock);
-	    m_consumerTable.erase(group);
-    }
-    unregisterClientWithLock("", group);
-}
-
-bool MQClientFactory::registerProducer(const std::string& group, DefaultMQProducerImpl* pProducer)
-{
-    if (group.empty() || pProducer == NULL)
-    {
-        return false;
-    }
-
-	kpr::ScopedWLock<kpr::RWMutex> lock(m_producerTableLock);
-    if (m_producerTable.find(group) != m_producerTable.end())
-    {
-        return false;
-    }
-    m_producerTable[group] = pProducer;
-
-    return true;
-}
-
-void MQClientFactory::unregisterProducer(const std::string& group)
-{
-	{
-		kpr::ScopedWLock<kpr::RWMutex> lock(m_producerTableLock);
-	    m_producerTable.erase(group);
-    }
-    unregisterClientWithLock(group, "");
-}
-
-bool MQClientFactory::registerAdminExt(const std::string& group, MQAdminExtInner* pAdmin)
-{
-    if (group.empty() || pAdmin == NULL)
-    {
-        return false;
-    }
-
-	kpr::ScopedWLock<kpr::RWMutex> lock(m_adminExtTableLock);
-    if (m_adminExtTable.find(group) != m_adminExtTable.end())
-    {
-        return false;
-    }
-    m_adminExtTable[group] = pAdmin;
-
-    return true;
-}
-
-void MQClientFactory::unregisterAdminExt(const std::string& group)
-{
-	kpr::ScopedWLock<kpr::RWMutex> lock(m_adminExtTableLock);
-    m_adminExtTable.erase(group);
-}
-
-void MQClientFactory::rebalanceImmediately()
-{
-    m_pRebalanceService->wakeup();
-}
-
-void MQClientFactory::doRebalance()
-{
-	kpr::ScopedRLock<kpr::RWMutex> lock(m_consumerTableLock);
-    std::map<std::string, MQConsumerInner*>::iterator it = m_consumerTable.begin();
-    for (; it != m_consumerTable.end(); it++)
-    {
-        MQConsumerInner* impl = it->second;
-        if (impl != NULL)
-        {
-            try
-            {
-                impl->doRebalance();
-            }
-            catch (std::exception& e)
-            {
-                RMQ_ERROR("doRebalance exception, %s", e.what());
-            }
-            catch (...)
-            {
-                RMQ_ERROR("doRebalance unknow exception");
-            }
-        }
-    }
-}
-
-MQProducerInner* MQClientFactory::selectProducer(const std::string& group)
-{
-	kpr::ScopedRLock<kpr::RWMutex> lock(m_producerTableLock);
-    std::map<std::string, MQProducerInner*>::iterator it = m_producerTable.find(group);
-    if (it != m_producerTable.end())
-    {
-        return it->second;
-    }
-
-    return NULL;
-}
-
-MQConsumerInner* MQClientFactory::selectConsumer(const std::string& group)
-{
-	kpr::ScopedRLock<kpr::RWMutex> lock(m_consumerTableLock);
-    std::map<std::string, MQConsumerInner*>::iterator it = m_consumerTable.find(group);
-    if (it != m_consumerTable.end())
-    {
-        return it->second;
-    }
-
-    return NULL;
-}
-
-FindBrokerResult MQClientFactory::findBrokerAddressInAdmin(const std::string& brokerName)
-{
-    //TODO
-    FindBrokerResult result;
-    std::string brokerAddr;
-    bool slave = false;
-    bool found = false;
-
-    kpr::ScopedRLock<kpr::RWMutex> lock(m_brokerAddrTableLock);
-    typeof(m_brokerAddrTable.begin()) it = m_brokerAddrTable.find(brokerName);
-    if (it != m_brokerAddrTable.end())
-    {
-        // TODO more slave
-        typeof(it->second.begin()) it1 = it->second.begin();
-        for (; it1 != it->second.end(); it1++)
-        {
-            int brockerId = it1->first;
-            brokerAddr = it1->second;
-            if (!brokerAddr.empty())
-            {
-                found = true;
-                if (MixAll::MASTER_ID == brockerId)
-                {
-                    slave = false;
-                }
-                else
-                {
-                    slave = true;
-                }
-                break;
-            }
-        }
-    }
-
-    if (found)
-    {
-        result.brokerAddr = brokerAddr;
-        result.slave = slave;
-    }
-
-    return result;
-}
-
-std::string MQClientFactory::findBrokerAddressInPublish(const std::string& brokerName)
-{
-    kpr::ScopedRLock<kpr::RWMutex> lock(m_brokerAddrTableLock);
-    std::map<std::string, std::map<int, std::string> >::iterator it = m_brokerAddrTable.find(brokerName);
-    if (it != m_brokerAddrTable.end())
-    {
-        std::map<int, std::string>::iterator it1 = it->second.find(MixAll::MASTER_ID);
-        if (it1 != it->second.end())
-        {
-            return it1->second;
-        }
-    }
-
-    return "";
-}
-
-FindBrokerResult MQClientFactory::findBrokerAddressInSubscribe(const std::string& brokerName,
-        long brokerId,
-        bool onlyThisBroker)
-{
-    std::string brokerAddr = "";
-    bool slave = false;
-    bool found = false;
-
-    kpr::ScopedRLock<kpr::RWMutex> lock(m_brokerAddrTableLock);
-    std::map<std::string, std::map<int, std::string> >::iterator it = m_brokerAddrTable.find(brokerName);
-    if (it != m_brokerAddrTable.end())
-    {
-        std::map<int, std::string>::iterator it1 = it->second.find(brokerId);
-        if (it1 != it->second.end())
-        {
-            brokerAddr = it1->second;
-            slave = (brokerId != MixAll::MASTER_ID);
-            found = true;
-        }
-        else
-        {
-            it1 = it->second.begin();
-            brokerAddr = it1->second;
-            slave = (brokerId != MixAll::MASTER_ID);
-            found = true;
-        }
-    }
-
-    FindBrokerResult result;
-    result.brokerAddr = brokerAddr;
-    result.slave = slave;
-
-    return result;
-}
-
-std::list<std::string> MQClientFactory::findConsumerIdList(const std::string& topic, const std::string& group)
-{
-    std::string brokerAddr = findBrokerAddrByTopic(topic);
-
-    if (brokerAddr.empty())
-    {
-        updateTopicRouteInfoFromNameServer(topic);
-        brokerAddr = findBrokerAddrByTopic(topic);
-    }
-
-    if (!brokerAddr.empty())
-    {
-        try
-        {
-            return m_pMQClientAPIImpl->getConsumerIdListByGroup(brokerAddr, group, 3000);
-        }
-        catch (...)
-        {
-			RMQ_WARN("getConsumerIdListByGroup exception, %s, %s", brokerAddr.c_str(), group.c_str());
-        }
-    }
-
-    std::list<std::string> ids;
-
-    return ids;
-}
-
-std::string MQClientFactory::findBrokerAddrByTopic(const std::string& topic)
-{
-    kpr::ScopedRLock<kpr::RWMutex> lock(m_topicRouteTableLock);
-
-    std::map<std::string, TopicRouteData>::iterator it = m_topicRouteTable.find(topic);
-    if (it != m_topicRouteTable.end())
-    {
-        const std::list<BrokerData>& brokers = it->second.getBrokerDatas();
-
-        if (!brokers.empty())
-        {
-            BrokerData bd = brokers.front();
-            return TopicRouteData::selectBrokerAddr(bd);
-        }
-    }
-
-    return "";
-}
-
-TopicRouteData MQClientFactory::getAnExistTopicRouteData(const std::string& topic)
-{
-    kpr::ScopedRLock<kpr::RWMutex> lock(m_topicRouteTableLock);
-
-    std::map<std::string, TopicRouteData>::iterator it = m_topicRouteTable.find(topic);
-    if (it != m_topicRouteTable.end())
-    {
-        return it->second;
-    }
-
-    TopicRouteData data;
-    return data;
-}
-
-MQClientAPIImpl* MQClientFactory::getMQClientAPIImpl()
-{
-    return m_pMQClientAPIImpl;
-}
-
-MQAdminImpl* MQClientFactory::getMQAdminImpl()
-{
-    return m_pMQAdminImpl;
-}
-
-std::string MQClientFactory::getClientId()
-{
-    return m_clientId;
-}
-
-long long MQClientFactory::getBootTimestamp()
-{
-    return m_bootTimestamp;
-}
-
-PullMessageService* MQClientFactory::getPullMessageService()
-{
-    return m_pPullMessageService;
-}
-
-
-DefaultMQProducer* MQClientFactory::getDefaultMQProducer()
-{
-    return m_pDefaultMQProducer;
-}
-
-void MQClientFactory::sendHeartbeatToAllBroker()
-{
-    RMQ_DEBUG("sendHeartbeatToAllBroker begin");
-
-    HeartbeatData heartbeatData;
-    this->prepareHeartbeatData(heartbeatData);
-
-    bool producerEmpty = heartbeatData.getProducerDataSet().empty();
-    bool consumerEmpty = heartbeatData.getConsumerDataSet().empty();
-    if (producerEmpty && consumerEmpty)
-    {
-        RMQ_ERROR("sending hearbeat, but no consumer and no producer");
-        return;
-    }
-
-    RMQ_DEBUG("clientId=%s, m_brokerAddrTable=%u", heartbeatData.getClientID().c_str(), (unsigned)m_brokerAddrTable.size());
-
-    kpr::ScopedRLock<kpr::RWMutex> lock(m_brokerAddrTableLock);
-    std::map<std::string, std::map<int, std::string> >::iterator it = m_brokerAddrTable.begin();
-    for (; it != m_brokerAddrTable.end(); it++)
-    {
-        std::map<int, std::string>::iterator it1 = it->second.begin();
-        for (; it1 != it->second.end(); it1++)
-        {
-            std::string& addr = it1->second;
-            if (!addr.empty())
-            {
-                if (consumerEmpty)
-                {
-                    if (it1->first != MixAll::MASTER_ID)
-                    {
-                        continue;
-                    }
-                }
-
-                try
-                {
-                    m_pMQClientAPIImpl->sendHearbeat(addr, &heartbeatData, 3000);
-                    RMQ_INFO("send heartbeat to broker[{%s} {%d} {%s}] success",
-                    	it->first.c_str(), it1->first, addr.c_str());
-                    RMQ_INFO("HeartbeatData %s", heartbeatData.toString().c_str());
-                }
-                catch (...)
-                {
-                    RMQ_ERROR("send heart beat to broker exception");
-                }
-            }
-        }
-    }
-
-    RMQ_DEBUG("sendHeartbeatToAllBroker end");
-}
-
-void MQClientFactory::prepareHeartbeatData(HeartbeatData& heartbeatData)
-{
-    // clientID
-    heartbeatData.setClientID(m_clientId);
-
-    // Consumer
-    {
-    	kpr::ScopedRLock<kpr::RWMutex> lock(m_consumerTableLock);
-        std::map<std::string, MQConsumerInner*>::iterator it = m_consumerTable.begin();
-        for (; it != m_consumerTable.end(); it++)
-        {
-            MQConsumerInner* inner = it->second;
-            if (inner)
-            {
-                ConsumerData consumerData;
-                consumerData.groupName = inner->groupName();
-                consumerData.consumeType = inner->consumeType();
-                consumerData.messageModel = inner->messageModel();
-                consumerData.consumeFromWhere = inner->consumeFromWhere();
-                consumerData.subscriptionDataSet = inner->subscriptions();
-
-                heartbeatData.getConsumerDataSet().insert(consumerData);
-            }
-        }
-    }
-
-    // Producer
-    {
-    	kpr::ScopedRLock<kpr::RWMutex> lock(m_producerTableLock);
-        std::map<std::string, MQProducerInner*>::iterator it = m_producerTable.begin();
-        for (; it != m_producerTable.end(); it++)
-        {
-            MQProducerInner* inner = it->second;
-            if (inner)
-            {
-                ProducerData producerData;
-                producerData.groupName = (it->first);
-
-                heartbeatData.getProducerDataSet().insert(producerData);
-            }
-        }
-    }
-
-    return;
-}
-
-void MQClientFactory::makesureInstanceNameIsOnly(const std::string& instanceName)
-{
-    //TODO
-}
-
-
-void MQClientFactory::fetchNameServerAddr()
-{
-    //1000 * 10, 1000 * 60 * 2
-    try
-    {
-        RMQ_DEBUG("Task: fetchNameServerAddr");
-        m_pMQClientAPIImpl->fetchNameServerAddr();
-    }
-    catch (...)
-    {
-    	RMQ_ERROR("Task: fetchNameServerAddr exception");
-    }
-}
-
-void MQClientFactory::updateTopicRouteInfoFromNameServerTask()
-{
-    //10, 1000 * 30, m_clientConfig.getPollNameServerInteval()
-    try
-    {
-        RMQ_DEBUG("Task: updateTopicRouteInfoFromNameServerTask");
-        updateTopicRouteInfoFromNameServer();
-    }
-    catch (...)
-    {
-		RMQ_ERROR("Task: fetchNameServerAddr exception");
-    }
-}
-
-void MQClientFactory::cleanBroker()
-{
-    //1000, 1000 * 30, m_clientConfig.getHeartbeatBrokerInterval()
-    try
-    {
-        RMQ_DEBUG("Task: cleanBroker");
-        cleanOfflineBroker();
-        sendHeartbeatToAllBrokerWithLock();
-    }
-    catch (...)
-    {
-		RMQ_ERROR("Task: cleanBroker exception");
-    }
-}
-
-void MQClientFactory::persistAllConsumerOffsetTask()
-{
-    //1000 * 10, 1000 * 5, m_clientConfig.getPersistConsumerOffsetInterval()
-    try
-    {
-        RMQ_DEBUG("Task: persistAllConsumerOffsetTask");
-        persistAllConsumerOffset();
-    }
-    catch (...)
-    {
-		RMQ_ERROR("Task: persistAllConsumerOffsetTask exception");
-    }
-}
-
-void MQClientFactory::recordSnapshotPeriodicallyTask()
-{
-    // 1000 * 10, 1000,
-    try
-    {
-        //RMQ_DEBUG("Task: recordSnapshotPeriodicallyTask");
-        recordSnapshotPeriodically();
-    }
-    catch (...)
-    {
-		RMQ_ERROR("Task: recordSnapshotPeriodically exception");
-    }
-}
-
-void MQClientFactory::logStatsPeriodicallyTask()
-{
-    //  1000 * 10, 1000 * 60
-    try
-    {
-        RMQ_DEBUG("Task: logStatsPeriodicallyTask");
-        logStatsPeriodically();
-    }
-    catch (...)
-    {
-		RMQ_ERROR("Task: logStatsPeriodicallyTask exception");
-    }
-}
-
-void MQClientFactory::startScheduledTask()
-{
-    m_scheduledTaskIds[0] = m_timerTaskManager.RegisterTimer(1000 * 10, 1000 * 60 * 2, m_pFetchNameServerAddrTask);
-
-    m_scheduledTaskIds[1] = m_timerTaskManager.RegisterTimer(10, m_clientConfig.getPollNameServerInterval(), m_pUpdateTopicRouteInfoFromNameServerTask);
-
-    m_scheduledTaskIds[2] = m_timerTaskManager.RegisterTimer(1000, m_clientConfig.getHeartbeatBrokerInterval(), m_pCleanBrokerTask);
-
-    m_scheduledTaskIds[3] = m_timerTaskManager.RegisterTimer(1000 * 10, m_clientConfig.getPersistConsumerOffsetInterval(), m_pPersistAllConsumerOffsetTask);
-
-    m_scheduledTaskIds[4] = m_timerTaskManager.RegisterTimer(1000 * 10, 1000, m_pRecordSnapshotPeriodicallyTask);
-    m_scheduledTaskIds[5] = m_timerTaskManager.RegisterTimer(1000 * 10, 1000 * 60, m_pLogStatsPeriodicallyTask);
-}
-
-void MQClientFactory::cleanOfflineBroker()
-{
-    RMQ_DEBUG("TryLock m_lockNamesrv: 0x%p", &m_lockNamesrv);
-    if (m_lockNamesrv.TryLock(MQClientFactory::LockTimeoutMillis))
-    {
-        RMQ_DEBUG("TryLock m_lockNamesrv ok");
-        std::map<std::string, std::map<int, std::string> > updatedTable;
-        {
-            kpr::ScopedRLock<kpr::RWMutex> lock(m_brokerAddrTableLock);
-            std::map<std::string, std::map<int, std::string> >::iterator it = m_brokerAddrTable.begin();
-
-            for (; it != m_brokerAddrTable.end(); it++)
-            {
-                std::map<int, std::string> cloneTable = it->second;
-
-                std::map<int, std::string>::iterator it1 = cloneTable.begin();
-
-                for (; it1 != cloneTable.end();)
-                {
-                    std::string& addr = it1->second;
-                    if (!isBrokerAddrExistInTopicRouteTable(addr))
-                    {
-                        std::map<int, std::string>::iterator itTmp = it1;
-                        it1++;
-                        cloneTable.erase(itTmp);
-                        continue;
-                    }
-
-                    it1++;
-                }
-
-                if (!cloneTable.empty())
-                {
-                    updatedTable[it->first] = cloneTable;
-                }
-            }
-        }
-
-        {
-            kpr::ScopedWLock<kpr::RWMutex> lock(m_brokerAddrTableLock);
-            m_brokerAddrTable.clear();
-            m_brokerAddrTable = updatedTable;
-        }
-
-        m_lockNamesrv.Unlock();
-        RMQ_DEBUG("UnLock m_lockNamesrv ok");
-    }
-    else
-    {
-        RMQ_DEBUG("TryLock m_lockNamesrv fail");
-    }
-}
-
-bool MQClientFactory::isBrokerAddrExistInTopicRouteTable(const std::string& addr)
-{
-    kpr::ScopedRLock<kpr::RWMutex> lock(m_topicRouteTableLock);
-
-    std::map<std::string, TopicRouteData>::iterator it = m_topicRouteTable.begin();
-    for (; it != m_topicRouteTable.end(); it++)
-    {
-        const std::list<BrokerData>& brokers = it->second.getBrokerDatas();
-        std::list<BrokerData>::const_iterator it1 = brokers.begin();
-
-        for (; it1 != brokers.end(); it1++)
-        {
-            std::map<int, std::string>::const_iterator it2 = (*it1).brokerAddrs.begin();
-            for (; it2 != (*it1).brokerAddrs.end(); it2++)
-            {
-                if (it2->second.find(addr) != std::string::npos)
-                {
-                    return true;
-                }
-            }
-        }
-    }
-
-    return false;
-}
-
-void MQClientFactory::recordSnapshotPeriodically()
-{
-	kpr::ScopedRLock<kpr::RWMutex> lock(m_consumerTableLock);
-    std::map<std::string, MQConsumerInner*>::iterator it = m_consumerTable.begin();
-    for (; it != m_consumerTable.end(); it++)
-    {
-        MQConsumerInner* inner = it->second;
-        if (inner)
-        {
-            DefaultMQPushConsumerImpl* consumer = dynamic_cast<DefaultMQPushConsumerImpl*>(inner);
-            if (consumer)
-            {
-                consumer->getConsumerStatManager()->recordSnapshotPeriodically();
-            }
-        }
-    }
-}
-
-void MQClientFactory::logStatsPeriodically()
-{
-	kpr::ScopedRLock<kpr::RWMutex> lock(m_consumerTableLock);
-    std::map<std::string, MQConsumerInner*>::iterator it = m_consumerTable.begin();
-    for (; it != m_consumerTable.end(); it++)
-    {
-        MQConsumerInner* inner = it->second;
-        if (inner)
-        {
-            DefaultMQPushConsumerImpl* consumer = dynamic_cast<DefaultMQPushConsumerImpl*>(inner);
-            if (consumer)
-            {
-                std::string group = it->first;
-                consumer->getConsumerStatManager()->logStatsPeriodically(group, m_clientId);
-            }
-        }
-    }
-}
-
-void MQClientFactory::persistAllConsumerOffset()
-{
-    kpr::ScopedRLock<kpr::RWMutex> lock(m_consumerTableLock);
-    RMQ_DEBUG("persistAllConsumerOffset, m_consumerTable.size=%u", (unsigned)m_consumerTable.size());
-    std::map<std::string, MQConsumerInner*>::iterator it = m_consumerTable.begin();
-    for (; it != m_consumerTable.end(); it++)
-    {
-        MQConsumerInner* inner = it->second;
-        if (inner)
-        {
-            inner->persistConsumerOffset();
-        }
-    }
-}
-
-bool MQClientFactory::topicRouteDataIsChange(TopicRouteData& olddata, TopicRouteData& nowdata)
-{
-    TopicRouteData old = olddata;
-    TopicRouteData now = nowdata;
-
-    old.getQueueDatas().sort();
-    old.getBrokerDatas().sort();
-    now.getQueueDatas().sort();
-    now.getBrokerDatas().sort();
-
-    return !(old == now);
-
-}
-
-bool MQClientFactory::isNeedUpdateTopicRouteInfo(const std::string& topic)
-{
-    bool result = false;
-    {
-    	kpr::ScopedRLock<kpr::RWMutex> lock(m_producerTableLock);
-        std::map<std::string, MQProducerInner*>::iterator it = m_producerTable.begin();
-        for (; it != m_producerTable.end(); it++)
-        {
-            MQProducerInner* inner = it->second;
-            if (inner)
-            {
-                result = inner->isPublishTopicNeedUpdate(topic);
-            }
-        }
-    }
-
-    {
-    	kpr::ScopedRLock<kpr::RWMutex> lock(m_consumerTableLock);
-        std::map<std::string, MQConsumerInner*>::iterator it = m_consumerTable.begin();
-        for (; it != m_consumerTable.end(); it++)
-        {
-            MQConsumerInner* inner = it->second;
-            if (inner)
-            {
-                result = inner->isSubscribeTopicNeedUpdate(topic);
-            }
-        }
-    }
-
-    return result;
-}
-
-void MQClientFactory::unregisterClientWithLock(const std::string& producerGroup, const std::string& consumerGroup)
-{
-    RMQ_DEBUG("TryLock m_lockHeartbeat: 0x%p", &m_lockHeartbeat);
-    if (m_lockHeartbeat.TryLock(MQClientFactory::LockTimeoutMillis))
-    {
-        try
-        {
-            RMQ_DEBUG("TryLock m_lockHeartbeat ok");
-            unregisterClient(producerGroup, consumerGroup);
-        }
-        catch (...)
-        {
-            RMQ_ERROR("unregisterClientWithLock exception, %s %s",
-                      producerGroup.c_str(), consumerGroup.c_str());
-        }
-        m_lockHeartbeat.Unlock();
-        RMQ_DEBUG("Unlock m_lockHeartbeat ok");
-    }
-    else
-    {
-        RMQ_WARN("TryLock m_lockHeartbeat fail");
-    }
-}
-
-void MQClientFactory::unregisterClient(const std::string& producerGroup, const std::string& consumerGroup)
-{
-    kpr::ScopedRLock<kpr::RWMutex> lock(m_brokerAddrTableLock);
-    std::map<std::string, std::map<int, std::string> >::iterator it = m_brokerAddrTable.begin();
-    for (; it != m_brokerAddrTable.end(); it++)
-    {
-        std::map<int, std::string>::iterator it1 = it->second.begin();
-
-        for (; it1 != it->second.end(); it1++)
-        {
-            std::string& addr = it1->second;
-
-            if (!addr.empty())
-            {
-                try
-                {
-                    m_pMQClientAPIImpl->unregisterClient(addr, m_clientId, producerGroup,
-                                                         consumerGroup, 3000);
-                }
-                catch (...)
-                {
-                    RMQ_ERROR("unregister client exception from broker: %s", addr.c_str());
-                }
-            }
-        }
-    }
-}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/MQClientFactory.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/MQClientFactory.h b/rocketmq-client4cpp/src/MQClientFactory.h
deleted file mode 100755
index 8f56a27..0000000
--- a/rocketmq-client4cpp/src/MQClientFactory.h
+++ /dev/null
@@ -1,214 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __MQCLIENTFACTORY_H__
-#define __MQCLIENTFACTORY_H__
-
-#include <set>
-#include <string>
-#include <list>
-
-#include "SocketUtil.h"
-#include "TopicRouteData.h"
-#include "FindBrokerResult.h"
-#include "ClientConfig.h"
-#include "Mutex.h"
-#include "ServiceState.h"
-#include "TimerTaskManager.h"
-
-namespace rmq
-{
-    class ClientConfig;
-    class MessageQueue;
-    class MQAdminExtInner;
-    class MQClientAPIImpl;
-    class MQAdminImpl;
-    class PullMessageService;
-    class HeartbeatData;
-    class RemoteClientConfig;
-    class ClientRemotingProcessor;
-    class RebalanceService;
-    class DefaultMQProducer;
-    class TopicPublishInfo;
-    class MQProducerInner;
-    class MQConsumerInner;
-    class DefaultMQProducerImpl;
-
-    class MQClientFactory
-    {
-    public:
-        MQClientFactory(ClientConfig& clientConfig, int factoryIndex, const std::string& clientId);
-        ~MQClientFactory();
-
-        void start();
-        void shutdown();
-        void sendHeartbeatToAllBrokerWithLock();
-        void updateTopicRouteInfoFromNameServer();
-        bool updateTopicRouteInfoFromNameServer(const std::string& topic);
-
-        bool updateTopicRouteInfoFromNameServer(const std::string& topic, bool isDefault,
-                                                DefaultMQProducer* pDefaultMQProducer);
-
-        static TopicPublishInfo* topicRouteData2TopicPublishInfo(const std::string& topic,
-                TopicRouteData& route);
-
-        static std::set<MessageQueue>* topicRouteData2TopicSubscribeInfo(const std::string& topic,
-                TopicRouteData& route);
-
-        bool registerConsumer(const std::string& group, MQConsumerInner* pConsumer);
-        void unregisterConsumer(const std::string& group);
-
-        bool registerProducer(const std::string& group, DefaultMQProducerImpl* pProducer);
-        void unregisterProducer(const std::string& group);
-
-        bool registerAdminExt(const std::string& group, MQAdminExtInner* pAdmin);
-        void unregisterAdminExt(const std::string& group);
-
-        void rebalanceImmediately();
-        void doRebalance();
-
-        MQProducerInner* selectProducer(const std::string& group);
-        MQConsumerInner* selectConsumer(const std::string& group);
-
-        FindBrokerResult findBrokerAddressInAdmin(const std::string& brokerName);
-        std::string findBrokerAddressInPublish(const std::string& brokerName);
-        FindBrokerResult findBrokerAddressInSubscribe(//
-            const std::string& brokerName,//
-            long brokerId,//
-            bool onlyThisBroker);
-
-        std::list<std::string> findConsumerIdList(const std::string& topic, const std::string& group);
-        std::string findBrokerAddrByTopic(const std::string& topic);
-        TopicRouteData getAnExistTopicRouteData(const std::string& topic);
-        MQClientAPIImpl* getMQClientAPIImpl();
-        MQAdminImpl* getMQAdminImpl();
-        std::string getClientId();
-        long long getBootTimestamp();
-        PullMessageService* getPullMessageService();
-        DefaultMQProducer* getDefaultMQProducer();
-
-    private:
-        void sendHeartbeatToAllBroker();
-        //HeartbeatData* prepareHeartbeatData();
-        void prepareHeartbeatData(HeartbeatData& heartbeatData);
-
-        void makesureInstanceNameIsOnly(const std::string& instanceName);
-        void startScheduledTask();
-
-
-        void cleanOfflineBroker();
-        bool isBrokerAddrExistInTopicRouteTable(const std::string& addr);
-        void recordSnapshotPeriodically();
-        void logStatsPeriodically();
-        void persistAllConsumerOffset();
-        bool topicRouteDataIsChange(TopicRouteData& olddata, TopicRouteData& nowdata);
-        bool isNeedUpdateTopicRouteInfo(const std::string& topic);
-        void unregisterClientWithLock(const std::string& producerGroup, const std::string& consumerGroup);
-        void unregisterClient(const std::string& producerGroup, const std::string& consumerGroup);
-
-        typedef void (MQClientFactory::*pScheduledFunc)();
-
-        class ScheduledTask : public kpr::TimerTask
-        {
-        public:
-            ScheduledTask(MQClientFactory* pMQClientFactory, pScheduledFunc pScheduled)
-                : m_pMQClientFactory(pMQClientFactory), m_pScheduled(pScheduled)
-            {
-            }
-
-            virtual void DoTask()
-            {
-                (m_pMQClientFactory->*m_pScheduled)();
-            }
-
-        private:
-            MQClientFactory* m_pMQClientFactory;
-            pScheduledFunc m_pScheduled;
-        };
-		typedef kpr::RefHandleT<ScheduledTask> ScheduledTaskPtr;
-
-        // schedule task
-        void fetchNameServerAddr();
-        void updateTopicRouteInfoFromNameServerTask();
-        void cleanBroker();
-        void persistAllConsumerOffsetTask();
-        void recordSnapshotPeriodicallyTask();
-        void logStatsPeriodicallyTask();
-
-    private:
-        static long LockTimeoutMillis;
-        ClientConfig m_clientConfig;
-        int m_factoryIndex;
-        std::string m_clientId;
-        long long m_bootTimestamp;
-
-        // Producer
-        //group --> MQProducerInner
-        std::map<std::string, MQProducerInner*> m_producerTable;
-        kpr::RWMutex m_producerTableLock;
-
-        // Consumer
-        //group --> MQConsumerInner
-        std::map<std::string, MQConsumerInner*> m_consumerTable;
-        kpr::RWMutex m_consumerTableLock;
-
-        // AdminExt
-        // group --> MQAdminExtInner
-        std::map<std::string, MQAdminExtInner*> m_adminExtTable;
-        kpr::RWMutex m_adminExtTableLock;
-
-        RemoteClientConfig* m_pRemoteClientConfig;
-
-        MQClientAPIImpl* m_pMQClientAPIImpl;
-        MQAdminImpl* m_pMQAdminImpl;
-
-        /// Topic---> TopicRouteData
-        std::map<std::string, TopicRouteData> m_topicRouteTable;
-        kpr::RWMutex m_topicRouteTableLock;
-
-        kpr::Mutex m_mutex;
-        kpr::Mutex m_lockNamesrv;
-
-        kpr::Mutex m_lockHeartbeat;
-
-        //-----brokerName
-        //     ------brokerid  addr
-        //     ------brokerid  addr
-        std::map<std::string, std::map<int, std::string> > m_brokerAddrTable;
-        kpr::RWMutex m_brokerAddrTableLock;
-
-        // ��ʱ�߳�
-        kpr::TimerTaskManager m_timerTaskManager;
-        ScheduledTaskPtr m_pFetchNameServerAddrTask;
-        ScheduledTaskPtr m_pUpdateTopicRouteInfoFromNameServerTask;
-        ScheduledTaskPtr m_pCleanBrokerTask;
-        ScheduledTaskPtr m_pPersistAllConsumerOffsetTask;
-        ScheduledTaskPtr m_pRecordSnapshotPeriodicallyTask;
-        ScheduledTaskPtr m_pLogStatsPeriodicallyTask;
-
-        int m_scheduledTaskIds[6];
-
-        ClientRemotingProcessor* m_pClientRemotingProcessor;
-        PullMessageService* m_pPullMessageService;
-        RebalanceService* m_pRebalanceService;
-        DefaultMQProducer* m_pDefaultMQProducer;
-        ServiceState m_serviceState;
-
-        //SOCKET m_datagramSocket;
-    };
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/MQClientManager.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/MQClientManager.cpp b/rocketmq-client4cpp/src/MQClientManager.cpp
deleted file mode 100755
index b3041fc..0000000
--- a/rocketmq-client4cpp/src/MQClientManager.cpp
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#include "MQClientManager.h"
-#include "ScopedLock.h"
-#include "MQClientFactory.h"
-#include "ClientConfig.h"
-
-namespace rmq
-{
-
-
-MQClientManager* MQClientManager::s_instance = new MQClientManager();
-
-MQClientManager::MQClientManager()
-{
-
-}
-
-MQClientManager::~MQClientManager()
-{
-
-}
-
-MQClientManager* MQClientManager::getInstance()
-{
-    return s_instance;
-}
-
-MQClientFactory* MQClientManager::getAndCreateMQClientFactory(ClientConfig& clientConfig)
-{
-    std::string clientId = clientConfig.buildMQClientId();
-    kpr::ScopedLock<kpr::Mutex> lock(m_mutex);
-    std::map<std::string, MQClientFactory*>::iterator it = m_factoryTable.find(clientId);
-
-    if (it != m_factoryTable.end())
-    {
-        return it->second;
-    }
-    else
-    {
-        MQClientFactory* factory = new MQClientFactory(clientConfig, m_factoryIndexGenerator++, clientId);
-
-        m_factoryTable[clientId] = factory;
-
-        return factory;
-    }
-}
-
-void MQClientManager::removeClientFactory(const std::string&  clientId)
-{
-    kpr::ScopedLock<kpr::Mutex> lock(m_mutex);
-    std::map<std::string, MQClientFactory*>::iterator it = m_factoryTable.find(clientId);
-
-    if (it != m_factoryTable.end())
-    {
-        //delete it->second;
-        m_factoryTable.erase(it);
-    }
-}
-
-}
-

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/MQClientManager.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/MQClientManager.h b/rocketmq-client4cpp/src/MQClientManager.h
deleted file mode 100755
index 742f8bb..0000000
--- a/rocketmq-client4cpp/src/MQClientManager.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __MQCLIENTMANAGER_H__
-#define __MQCLIENTMANAGER_H__
-
-#include <string>
-#include <map>
-#include "Mutex.h"
-#include "AtomicValue.h"
-
-namespace rmq
-{
-	class MQClientFactory;
-	class ClientConfig;
-
-	class MQClientManager
-	{
-	public:
-	    ~MQClientManager();
-	    static MQClientManager* getInstance();
-	    MQClientFactory* getAndCreateMQClientFactory(ClientConfig& clientConfig);
-	    void removeClientFactory(const std::string&  clientId);
-
-	private:
-	    MQClientManager();
-
-	private:
-	    static MQClientManager* s_instance;
-	    kpr::AtomicInteger m_factoryIndexGenerator;
-	    std::map<std::string, MQClientFactory*> m_factoryTable;
-	    kpr::Mutex m_mutex;
-	};
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/Makefile
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/Makefile b/rocketmq-client4cpp/src/Makefile
deleted file mode 100644
index 5d5f43b..0000000
--- a/rocketmq-client4cpp/src/Makefile
+++ /dev/null
@@ -1,26 +0,0 @@
-#-----------------------------------------------------------------------
-TARGET          := librocketmq.a
-CONFIG          :=
-STRIP_FLAG      := N
-MFLAGS      	:= ${BIT}
-CFLAGS          += -g -fPIC -Wno-deprecated -fno-strict-aliasing -fno-omit-frame-pointer
-CFLAGS_32       += -march=i686
-INCLUDE         += -I../include -I./common -I./kpr -I./protocol -I./message -I./transport -I./producer -I./consumer \
-				   -I./jsoncpp 
-LIB             += -lz -lrt -lpthread
-LIB32           += 
-LIB64           += 
-#-----------------------------------------------------------------------
-
-LOCAL_SRC += $(wildcard jsoncpp/*.cpp)
-LOCAL_SRC += $(wildcard kpr/*.cpp)
-LOCAL_SRC += $(wildcard common/*.cpp)
-LOCAL_SRC += $(wildcard protocol/*.cpp)
-LOCAL_SRC += $(wildcard message/*.cpp)
-LOCAL_SRC += $(wildcard transport/*.cpp)
-LOCAL_SRC += $(wildcard producer/*.cpp)
-LOCAL_SRC += $(wildcard consumer/*.cpp)
-
-include ./Makefile.std
-#-----------------------------------------------------------------------
-

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/Makefile.std
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/Makefile.std b/rocketmq-client4cpp/src/Makefile.std
deleted file mode 100755
index b23f260..0000000
--- a/rocketmq-client4cpp/src/Makefile.std
+++ /dev/null
@@ -1,127 +0,0 @@
-#-------------------------------------------------------------------------------
-CC          = gcc
-CXX         = g++
-CFLAGS      += -g -fPIC -Wno-deprecated -Wall -pipe -fno-ident -fno-strict-aliasing -MMD -D_GNU_SOURCE -D_REENTRANT
-
-#-------------------------------------------------------------------------------
-INCLUDE     += -I./
-LIB_32      += -L./
-LIB_64      += -L./
-
-LOCAL_SRC   += $(sort $(wildcard *.cpp *.cc *.c))
-LOCAL_OBJ += $(patsubst %.cpp,%.o, $(patsubst %.cc,%.o, $(patsubst %.c,%.o, $(LOCAL_SRC))))
-DEP_FILE    := $(foreach obj, $(LOCAL_OBJ), $(dir $(obj))$(basename $(notdir $(obj))).d)
-
-#-----------------------------------------------------------------------------
-PLATFORM := $(strip $(shell echo `uname -m`))
-ifneq ($(MFLAGS),64)
-	  ifneq ($(MFLAGS),32)
-			ifeq ($(PLATFORM),x86_64)
-		MFLAGS := 64
-			else
-				MFLAGS := 32
-			endif
-	  endif
-endif
-
-ifeq ($(MFLAGS),64)
-	 ifneq ($(PLATFORM),x86_64)
-		   MFLAGS := 32
-	 endif
-endif
-
-ifeq ($(MFLAGS),32)
-	CFLAGS += -D_SYS_EPOLL_ $(CFLAGS_32)
-else
-	CFLAGS += $(CFLAGS_64)
-endif
-
-#-----------------------------------------------------------------------------
-ifneq ($(PLATFORM),x86_64)
-	MFLAGS  := 32
-	LIB     := $(LIB) $(LIB_32)
-else
-	DEP_FILE_32     := $(foreach obj, $(DEP_FILE),$(patsubst %.d,%.32.d, $(obj)))
-	DEP_FILE_64     := $(foreach obj, $(DEP_FILE),$(patsubst %.d,%.64.d, $(obj)))
-
-	LOCAL_OBJ_32    := $(foreach obj, $(LOCAL_OBJ),$(patsubst %.o,%.32.o,$(obj)))
-	LOCAL_OBJ_64    := $(foreach obj, $(LOCAL_OBJ),$(patsubst %.o,%.64.o,$(obj)))
-
-	LOCAL_MOCK_OBJ_32  += $(filter-out %Server.32.o, $(LOCAL_OBJ_32))  UnitTest.32.o
-	LOCAL_MOCK_OBJ_64  += $(filter-out %Server.64.o, $(LOCAL_OBJ_64))  UnitTest.64.o
-
-	CLEANFILE       := $(LOCAL_OBJ_32) $(LOCAL_OBJ_64)
-
-	ifeq ($(MFLAGS),64)
-		DEP_FILE    := $(DEP_FILE_64)
-		LOCAL_OBJ   := $(LOCAL_OBJ_64)
-		LIB         := $(LIB) $(LIB_64)
-		LOCAL_MOCK_OBJ   := $(LOCAL_MOCK_OBJ_64)
-	else
-		DEP_FILE    := $(DEP_FILE_32)
-		LOCAL_OBJ   := $(LOCAL_OBJ_32)
-		LIB         := $(LIB) $(LIB_32)
-		LOCAL_MOCK_OBJ   := $(LOCAL_MOCK_OBJ_32)
-	endif
-endif
-
-#-------------------------------------------------------------------------------
-all : $(LOCAL_OBJ) $(TARGET) $(TARGETS)
-
-$(filter %.a,$(TARGET)) : $(LOCAL_OBJ)
-	ar r $@ $(LOCAL_OBJ)
-
-$(filter %.so,$(TARGET)) : $(LOCAL_OBJ)
-	$(CXX) -m$(MFLAGS) $(CFLAGS) -shared -o $@ $^ $(INCLUDE) $(LIB)
-
-$(filter-out %.so %.a,$(TARGET)) : $(LOCAL_OBJ)
-	$(CXX) -m$(MFLAGS) $(CFLAGS) -o $@ $^ $(INCLUDE) $(LIB)
-
-$(filter-out %.so %.a %.y,$(TARGETS)) : % : %.$(MFLAGS).o
-	$(CXX) -m$(MFLAGS) $(CFLAGS) -o $@ $^ $(INCLUDE) $(LIB)
-
-utest : $(LOCAL_MOCK_OBJ)
-	$(CXX) -m$(MFLAGS) $(CFLAGS) -o UnitTest $^ $(INCLUDE) $(LIB)
-
-#----------------------------------------------------------------------------------
-uclean:
-	rm -vf $(LOCAL_MOCK_OBJ) $(TARGET) $(TARGETS) ${CLEANFILE} *.d.tmp gmon.out UnitTest
-
-clean:
-	rm -vf $(LOCAL_OBJ) $(TARGET) $(TARGETS) ${CLEANFILE} *.d.tmp gmon.out UnitTest
-
-cleanall:
-	rm -vf $(LOCAL_OBJ) $(TARGET) $(TARGETS) $(DEP_FILE) ${CLEANFILE} *.o *.d.tmp *.d gmon.out UnitTest
-
-ifneq ($(DEP_FILE),)
--include $(DEP_FILE)
-endif
-
-#-------------------------------------------------------------------------------
-%.32.o: %.cpp
-	$(CXX) -m32 $(CFLAGS) $(INCLUDE) -o $@ -c $<
-
-%.32.o: %.cc
-	$(CXX) -m32 $(CFLAGS) $(INCLUDE) -o $@ -c $<
-
-%.32.o: %.c
-	$(CC) -m32 $(CFLAGS) $(INCLUDE) -o $@ -c $<
-#-------------------------------------------------------------------------------
-%.64.o: %.cpp
-	$(CXX) -m64 $(CFLAGS) $(INCLUDE) -o $@ -c $<
-
-%.64.o: %.cc
-	$(CXX) -m64 $(CFLAGS) $(INCLUDE) -o $@ -c $<
-
-%.64.o: %.c
-	$(CC) -m64 $(CFLAGS) $(INCLUDE) -o $@ -c $<
-#----------------------------------------------------------------------------------
-%.o: %.cpp
-	$(CXX) -m$(MFLAGS) $(CFLAGS) $(INCLUDE) -o $@ -c $<
-
-%.o: %.cc
-	$(CXX) -m$(MFLAGS) $(CFLAGS) $(INCLUDE) -o $@ -c $<
-
-%.o: %.c
-	$(CC) -m$(MFLAGS) $(CFLAGS) $(INCLUDE) -o $@ -c $<
-#----------------------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/RocketMQClient.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/RocketMQClient.cpp b/rocketmq-client4cpp/src/RocketMQClient.cpp
deleted file mode 100755
index ec377b3..0000000
--- a/rocketmq-client4cpp/src/RocketMQClient.cpp
+++ /dev/null
@@ -1,186 +0,0 @@
-#include "RocketMQClient.h"
-#include "AtomicValue.h"
-#include "FileUtil.h"
-
-volatile int RocketMQUtil::_logFd = -1;
-int RocketMQUtil::_logLevel = 0;
-std::string RocketMQUtil::_logPath = "";
-
-pid_t RocketMQUtil::getPid()
-{
-    static __thread pid_t pid = 0;
-    if (!pid)
-    {
-        pid = getpid();
-    }
-    return pid;
-}
-
-pid_t RocketMQUtil::getTid()
-{
-    static __thread pid_t pid = 0;
-    static __thread pid_t tid = 0;
-    if (!pid || !tid || pid != getpid())
-    {
-        pid = getpid();
-        tid = syscall(__NR_gettid);
-    }
-    return tid;
-}
-
-int RocketMQUtil::getDiffDays(time_t tmFirst, time_t tmSecond)
-{
-    static struct timeb g_tb;
-    static bool g_tbInit = false;
-
-    if(!g_tbInit)
-    {
-        ftime(&g_tb);
-        g_tbInit = true;
-    }
-
-    return (tmSecond - g_tb.timezone*60)/86400 - (tmFirst - g_tb.timezone*60)/86400;
-};
-
-
-std::string RocketMQUtil::tm2str(const time_t& t, const std::string& sFormat)
-{
-    struct tm stTm;
-    localtime_r(&t, &stTm);
-
-    char sTimeString[255] = "\0";
-    strftime(sTimeString, sizeof(sTimeString), sFormat.c_str(), &stTm);
-
-    return std::string(sTimeString);
-}
-
-std::string RocketMQUtil::now2str(const std::string& sFormat)
-{
-    time_t t = time(NULL);
-    return tm2str(t, sFormat.c_str());
-}
-
-std::string RocketMQUtil::now2str()
-{
-    return now2str("%Y-%m-%d %H:%M:%S");
-}
-
-int64_t RocketMQUtil::getNowMs()
-{
-    struct timeval tv;
-    gettimeofday(&tv, NULL);
-    return tv.tv_sec * (int64_t)1000 + tv.tv_usec / 1000;
-}
-
-
-std::string RocketMQUtil::str2fmt(const char* format, ...)
-{
-    int dataLen = 0;
-    va_list args;
-    char buffer[8092];
-    buffer[0] = buffer[sizeof(buffer) - 1] = '\0';
-
-    va_start( args, format );
-    dataLen = ::vsnprintf(buffer, sizeof(buffer), format, args);
-    va_end(args);
-
-    return std::string(buffer);
-};
-
-
-int RocketMQUtil::initLog(const std::string& sLogPath)
-{
-	if (sLogPath.empty())
-	{
-		return 0;
-	}
-
-	const char *pLogLevel = getenv("ROCKETMQ_LOGLEVEL");
-	if (pLogLevel != NULL)
-	{
-		int logLevel = atoi(pLogLevel);
-    	_logLevel = logLevel;
-		_logPath = sLogPath;
-	}
-	else
-	{
-		_logLevel = WARN_LOG;
-		_logPath = sLogPath;
-	}
-
-	std::string logDir = kpr::FileUtil::extractFilePath(_logPath);
-	if (!kpr::FileUtil::isFileExist(logDir, S_IFDIR))
-	{
-		kpr::FileUtil::makeDirRecursive(logDir);
-	}
-
-    return 0;
-}
-
-void RocketMQUtil::setLogLevel(int logLevel)
-{
-	_logLevel = logLevel;
-}
-
-
-void RocketMQUtil::writeLog(const char* fmt, ...)
-{
-    if (_logPath.empty())
-    {
-        return;
-    }
-
-    static volatile time_t last_time = 0;
-	static std::string last_time_str = "";
-	time_t old = last_time;
-	time_t now = time(NULL);
-
-	if (now - last_time >= 5)
-	{
-		if (__sync_bool_compare_and_swap(&last_time, old, now))
-		{
-			std::string time_str = tm2str(now, "%Y%m%d");
-	    	if (_logFd < 0 || time_str != last_time_str)
-	    	{
-	    		int oldFd = _logFd;
-				std::string logFullPath = _logPath + "." + time_str;
-	    		_logFd = open(logFullPath.c_str(), O_CREAT | O_RDWR | O_APPEND, 0666);
-	    		if (_logFd > 0)
-	    		{
-					last_time_str = time_str;
-				}
-
-				if (oldFd > 0)
-	    		{
-	    			close(oldFd);
-	    		}
-	    	}
-		}
-	}
-
-    char buf[1024*128];
-    buf[0] = buf[sizeof(buf) - 1] = '\0';
-
-    va_list ap;
-    va_start(ap, fmt);
-    int size = vsnprintf(buf, sizeof(buf), fmt, ap);
-    va_end(ap);
-
-	int logFd = _logFd;
-    if (logFd > 0 && (size > 0 && size < (int)sizeof(buf)))
-    {
-        int ret = write(logFd, buf, size);
-        if (ret < 0)
-        {
-        	if (errno == EBADF)
-        	{
-        		write(_logFd, buf, size);
-        	}
-        }
-    }
-
-    return;
-}
-
-
-

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/common/ConsumeStats.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/common/ConsumeStats.h b/rocketmq-client4cpp/src/common/ConsumeStats.h
deleted file mode 100755
index 34ea817..0000000
--- a/rocketmq-client4cpp/src/common/ConsumeStats.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __CONSUMESTATS_H__
-#define __CONSUMESTATS_H__
-
-#include <map>
-#include "MessageQueue.h"
-
-namespace rmq
-{
-    typedef struct
-    {
-        long long brokerOffset;
-        long long consumerOffset;
-        long long lastTimestamp;
-    } OffsetWrapper;
-
-    /**
-    * Consumer progress
-    *
-    * @author kangliqiang<ka...@163.com>
-    */
-    class ConsumeStats
-    {
-    public:
-        ConsumeStats()
-            : m_consumeTps(0)
-        {
-        }
-
-        ~ConsumeStats()
-        {
-        }
-
-        long long computeTotalDiff()
-        {
-
-            long long diffTotal = 0L;
-
-            //Iterator<Entry<MessageQueue, OffsetWrapper>> it = m_offsetTable.entrySet().iterator();
-            //while (it.hasNext()) {
-            //  Entry<MessageQueue, OffsetWrapper> next = it.next();
-            //  long long diff = next.getValue().getBrokerOffset() - next.getValue().getConsumerOffset();
-            //  diffTotal += diff;
-            //}
-
-            return diffTotal;
-        }
-
-
-        std::map<MessageQueue*, OffsetWrapper> getOffsetTable()
-        {
-            return m_offsetTable;
-        }
-
-
-        void setOffsetTable(const std::map<MessageQueue*, OffsetWrapper> offsetTable)
-        {
-            m_offsetTable = offsetTable;
-        }
-
-
-        long long getConsumeTps()
-        {
-            return m_consumeTps;
-        }
-
-
-        void setConsumeTps(long long consumeTps)
-        {
-            m_consumeTps = consumeTps;
-        }
-
-    private:
-
-        std::map<MessageQueue*, OffsetWrapper> m_offsetTable;
-        long long m_consumeTps;
-    };
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/common/FilterAPI.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/common/FilterAPI.h b/rocketmq-client4cpp/src/common/FilterAPI.h
deleted file mode 100755
index 3d87306..0000000
--- a/rocketmq-client4cpp/src/common/FilterAPI.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __FILTERAPI_H__
-#define __FILTERAPI_H__
-
-#include <string>
-#include "SubscriptionData.h"
-#include "UtilAll.h"
-#include "MQClientException.h"
-
-namespace rmq
-{
-    class FilterAPI
-    {
-    public:
-        static SubscriptionData* buildSubscriptionData(const std::string topic, const std::string& subString)
-        {
-            SubscriptionData* subscriptionData = new SubscriptionData();
-            subscriptionData->setTopic(topic);
-            subscriptionData->setSubString(subString);
-
-            if (subString.empty() || subString == SubscriptionData::SUB_ALL)
-            {
-                subscriptionData->setSubString(SubscriptionData::SUB_ALL);
-            }
-            else
-            {
-                std::vector<std::string> out;
-
-                UtilAll::Split(out, subString, "||");
-
-                if (out.empty())
-                {
-                    THROW_MQEXCEPTION(MQClientException, "FilterAPI subString split error", -1);
-                }
-
-                for (size_t i = 0; i < out.size(); i++)
-                {
-                    std::string tag = out[i];
-                    if (!tag.empty())
-                    {
-                        std::string trimString = UtilAll::Trim(tag);
-
-                        if (!trimString.empty())
-                        {
-                            subscriptionData->getTagsSet().insert(trimString);
-                            subscriptionData->getCodeSet().insert(UtilAll::hashCode(trimString));
-                        }
-                    }
-                }
-            }
-
-            return subscriptionData;
-        }
-    };
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/common/MQVersion.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/common/MQVersion.cpp b/rocketmq-client4cpp/src/common/MQVersion.cpp
deleted file mode 100755
index 1a03fa6..0000000
--- a/rocketmq-client4cpp/src/common/MQVersion.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#include "MQVersion.h"
-
-namespace rmq
-{
-
-int MQVersion::s_CurrentVersion = MQVersion::V3_2_6;
-
-const char* MQVersion::getVersionDesc(int value)
-{
-    switch (value)
-    {
-        case V3_0_0_BETA9_SNAPSHOT:
-            return "V3_0_0_BETA9_SNAPSHOT";
-        case V3_0_0_BETA9:
-            return "V3_0_0_BETA9";
-        case V3_0_0_FINAL:
-            return "V3_0_0_FINAL";
-        case V3_0_1_SNAPSHOT:
-            return "V3_0_1_SNAPSHOT";
-        case V3_0_1:
-            return "V3_0_1";
-        case V3_0_2_SNAPSHOT:
-            return "V3_0_2_SNAPSHOT";
-        case V3_0_2:
-            return "V3_0_2";
-        case V3_0_3:
-            return "V3_0_3";
-        case V3_0_4_SNAPSHOT:
-            return "V3_0_4_SNAPSHOT";
-        case V3_0_4:
-            return "V3_0_4";
-        case V3_0_5_SNAPSHOT:
-            return "V3_0_5_SNAPSHOT";
-        case V3_0_5:
-            return "V3_0_5";
-        case V3_0_6_SNAPSHOT:
-            return "V3_0_6_SNAPSHOT";
-        case V3_0_6:
-            return "V3_0_6";
-        case V3_0_7_SNAPSHOT:
-            return "V3_0_7_SNAPSHOT";
-        case V3_0_7:
-            return "V3_0_7";
-
-		case V3_2_6_SNAPSHOT:
-            return "V3_2_6_SNAPSHOT";
-        case V3_2_6:
-            return "V3_2_6";
-		case V3_2_7_SNAPSHOT:
-            return "V3_2_7_SNAPSHOT";
-        case V3_2_7:
-            return "V3_2_7";
-		case V3_2_8_SNAPSHOT:
-            return "V3_2_8_SNAPSHOT";
-        case V3_2_8:
-            return "V3_2_8";
-		case V3_5_8_SNAPSHOT:
-            return "V3_5_8_SNAPSHOT";
-        case V3_5_8:
-            return "V3_5_8";
-    }
-
-    return "";
-}
-
-
-MQVersion::Version MQVersion::value2Version(int value)
-{
-    return (MQVersion::Version)value;
-}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/common/MQVersion.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/common/MQVersion.h b/rocketmq-client4cpp/src/common/MQVersion.h
deleted file mode 100755
index d92957c..0000000
--- a/rocketmq-client4cpp/src/common/MQVersion.h
+++ /dev/null
@@ -1,184 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __MQVERSION_H__
-#define __MQVERSION_H__
-
-#include <string>
-
-namespace rmq
-{
-    /**
-    * Version Info
-    *
-    */
-    class MQVersion
-    {
-    public:
-        enum Version
-        {
-            V3_0_0_SNAPSHOT,
-            V3_0_0_ALPHA1,
-            V3_0_0_BETA1,
-            V3_0_0_BETA2,
-            V3_0_0_BETA3,
-            V3_0_0_BETA4,
-            V3_0_0_BETA5,
-            V3_0_0_BETA6_SNAPSHOT,
-            V3_0_0_BETA6,
-            V3_0_0_BETA7_SNAPSHOT,
-            V3_0_0_BETA7,
-            V3_0_0_BETA8_SNAPSHOT,
-            V3_0_0_BETA8,
-            V3_0_0_BETA9_SNAPSHOT,
-            V3_0_0_BETA9,
-            V3_0_0_FINAL,
-            V3_0_1_SNAPSHOT,
-            V3_0_1,
-            V3_0_2_SNAPSHOT,
-            V3_0_2,
-
-            V3_0_3_SNAPSHOT,
-            V3_0_3,
-            V3_0_4_SNAPSHOT,
-            V3_0_4,
-            V3_0_5_SNAPSHOT,
-            V3_0_5,
-            V3_0_6_SNAPSHOT,
-            V3_0_6,
-            V3_0_7_SNAPSHOT,
-            V3_0_7,
-            V3_0_8_SNAPSHOT,
-            V3_0_8,
-            V3_0_9_SNAPSHOT,
-            V3_0_9,
-            V3_0_10_SNAPSHOT,
-            V3_0_10,
-            V3_0_11_SNAPSHOT,
-            V3_0_11,
-            V3_0_12_SNAPSHOT,
-            V3_0_12,
-            V3_0_13_SNAPSHOT,
-            V3_0_13,
-            V3_0_14_SNAPSHOT,
-            V3_0_14,
-            V3_0_15_SNAPSHOT,
-            V3_0_15,
-            V3_1_0_SNAPSHOT,
-            V3_1_0,
-            V3_1_1_SNAPSHOT,
-            V3_1_1,
-            V3_1_2_SNAPSHOT,
-            V3_1_2,
-            V3_1_3_SNAPSHOT,
-            V3_1_3,
-            V3_1_4_SNAPSHOT,
-            V3_1_4,
-            V3_1_5_SNAPSHOT,
-            V3_1_5,
-            V3_1_6_SNAPSHOT,
-            V3_1_6,
-            V3_1_7_SNAPSHOT,
-            V3_1_7,
-            V3_1_8_SNAPSHOT,
-            V3_1_8,
-            V3_1_9_SNAPSHOT,
-            V3_1_9,
-            V3_2_0_SNAPSHOT,
-            V3_2_0,
-            V3_2_1_SNAPSHOT,
-            V3_2_1,
-            V3_2_2_SNAPSHOT,
-            V3_2_2,
-            V3_2_3_SNAPSHOT,
-            V3_2_3,
-            V3_2_4_SNAPSHOT,
-            V3_2_4,
-            V3_2_5_SNAPSHOT,
-            V3_2_5,
-            V3_2_6_SNAPSHOT,
-            V3_2_6,
-            V3_2_7_SNAPSHOT,
-            V3_2_7,
-            V3_2_8_SNAPSHOT,
-            V3_2_8,
-            V3_2_9_SNAPSHOT,
-            V3_2_9,
-            V3_3_1_SNAPSHOT,
-            V3_3_1,
-            V3_3_2_SNAPSHOT,
-            V3_3_2,
-            V3_3_3_SNAPSHOT,
-            V3_3_3,
-            V3_3_4_SNAPSHOT,
-            V3_3_4,
-            V3_3_5_SNAPSHOT,
-            V3_3_5,
-            V3_3_6_SNAPSHOT,
-            V3_3_6,
-            V3_3_7_SNAPSHOT,
-            V3_3_7,
-            V3_3_8_SNAPSHOT,
-            V3_3_8,
-            V3_3_9_SNAPSHOT,
-            V3_3_9,
-            V3_4_1_SNAPSHOT,
-            V3_4_1,
-            V3_4_2_SNAPSHOT,
-            V3_4_2,
-            V3_4_3_SNAPSHOT,
-            V3_4_3,
-            V3_4_4_SNAPSHOT,
-            V3_4_4,
-            V3_4_5_SNAPSHOT,
-            V3_4_5,
-            V3_4_6_SNAPSHOT,
-            V3_4_6,
-            V3_4_7_SNAPSHOT,
-            V3_4_7,
-            V3_4_8_SNAPSHOT,
-            V3_4_8,
-            V3_4_9_SNAPSHOT,
-            V3_4_9,
-            V3_5_1_SNAPSHOT,
-            V3_5_1,
-            V3_5_2_SNAPSHOT,
-            V3_5_2,
-            V3_5_3_SNAPSHOT,
-            V3_5_3,
-            V3_5_4_SNAPSHOT,
-            V3_5_4,
-            V3_5_5_SNAPSHOT,
-            V3_5_5,
-            V3_5_6_SNAPSHOT,
-            V3_5_6,
-            V3_5_7_SNAPSHOT,
-            V3_5_7,
-            V3_5_8_SNAPSHOT,
-            V3_5_8,
-            V3_5_9_SNAPSHOT,
-            V3_5_9,
-        };
-
-        static const char* getVersionDesc(int value);
-        static Version value2Version(int value);
-
-    public:
-        static int s_CurrentVersion;
-    };
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/common/MessageSysFlag.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/common/MessageSysFlag.cpp b/rocketmq-client4cpp/src/common/MessageSysFlag.cpp
deleted file mode 100755
index 329b71b..0000000
--- a/rocketmq-client4cpp/src/common/MessageSysFlag.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#include "MessageSysFlag.h"
-
-namespace rmq
-{
-
-/**
-* SysFlag
-*/
-int MessageSysFlag::CompressedFlag = (0x1 << 0);
-int MessageSysFlag::MultiTagsFlag = (0x1 << 1);
-
-/**
-* 7 6 5 4 3 2 1 0<br>
-* SysFlag for transaction
-*/
-int MessageSysFlag::TransactionNotType = (0x0 << 2);
-int MessageSysFlag::TransactionPreparedType = (0x1 << 2);
-int MessageSysFlag::TransactionCommitType = (0x2 << 2);
-int MessageSysFlag::TransactionRollbackType = (0x3 << 2);
-
-int MessageSysFlag::getTransactionValue(int flag)
-{
-    return flag & TransactionRollbackType;
-}
-
-int MessageSysFlag::resetTransactionValue(int flag, int type)
-{
-    return (flag & (~TransactionRollbackType)) | type;
-}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/common/MessageSysFlag.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/common/MessageSysFlag.h b/rocketmq-client4cpp/src/common/MessageSysFlag.h
deleted file mode 100755
index 3950564..0000000
--- a/rocketmq-client4cpp/src/common/MessageSysFlag.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __MESSAGESYSFLAG_H__
-#define __MESSAGESYSFLAG_H__
-
-namespace rmq
-{
-    class MessageSysFlag
-    {
-    public:
-        static int getTransactionValue(int flag);
-        static int resetTransactionValue(int flag, int type);
-
-    public:
-        /**
-        * SysFlag
-        */
-        static int CompressedFlag;
-        static int MultiTagsFlag;
-
-        /**
-        * 7 6 5 4 3 2 1 0<br>
-        * SysFlag for transaction
-        */
-        static int TransactionNotType;
-        static int TransactionPreparedType;
-        static int TransactionCommitType;
-        static int TransactionRollbackType;
-    };
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/common/MixAll.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/common/MixAll.cpp b/rocketmq-client4cpp/src/common/MixAll.cpp
deleted file mode 100755
index 417a5e5..0000000
--- a/rocketmq-client4cpp/src/common/MixAll.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
- * Copyright (C) 2013 kangliqiang ,kangliq@163.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "MixAll.h"
-#include "FileUtil.h"
-
-namespace rmq
-{
-
-const std::string MixAll::DEFAULT_TOPIC = "TBW102";
-const std::string MixAll::BENCHMARK_TOPIC = "BenchmarkTest";
-const std::string MixAll::DEFAULT_PRODUCER_GROUP = "DEFAULT_PRODUCER";
-const std::string MixAll::DEFAULT_CONSUMER_GROUP = "DEFAULT_CONSUMER";
-const std::string MixAll::TOOLS_CONSUMER_GROUP = "TOOLS_CONSUMER";
-const std::string MixAll::CLIENT_INNER_PRODUCER_GROUP = "CLIENT_INNER_PRODUCER";
-const std::string MixAll::SELF_TEST_TOPIC = "SELF_TEST_TOPIC";
-const std::string MixAll::RETRY_GROUP_TOPIC_PREFIX = "%RETRY%";
-const std::string MixAll::DLQ_GROUP_TOPIC_PREFIX = "%DLQ%";
-const std::string MixAll::NAMESRV_ADDR_ENV = "NAMESRV_ADDR";
-const std::string MixAll::ROCKETMQ_HOME_ENV = "ROCKETMQ_HOME";
-const std::string MixAll::ROCKETMQ_HOME_PROPERTY = "rocketmq.home.dir";
-const std::string MixAll::MESSAGE_COMPRESS_LEVEL = "rocketmq.message.compressLevel";
-const std::string MixAll::ROCKETMQ_NAMESRV_DOMAIN = "172.30.30.125";
-
-std::string MixAll::getRetryTopic(const std::string& consumerGroup)
-{
-    return RETRY_GROUP_TOPIC_PREFIX + consumerGroup;
-}
-
-bool MixAll::compareAndIncreaseOnly(kpr::AtomicLong& target, long long value)
-{
-    long long current = target.get();
-    while (value > current)
-    {
-        long long tmp = target.getAndSet(current, value);
-
-        if (tmp == current)
-        {
-            return true;
-        }
-
-        current = target.get();
-    }
-
-    return false;
-}
-
-
-std::string MixAll::file2String(const std::string& fileName)
-{
-    return kpr::FileUtil::load2str(fileName);
-}
-
-void MixAll::string2File(const std::string& fileName, const std::string& fileData)
-{
-    // write tmp file
-    std::string tmpFile = fileName + ".tmp";
-    kpr::FileUtil::save2file(tmpFile, fileData);
-
-    // backup old file
-    std::string bakFile = fileName + ".bak";
-    std::string oldFileData = kpr::FileUtil::load2str(fileName);
-    if (!oldFileData.empty())
-    {
-        kpr::FileUtil::save2file(bakFile, oldFileData);
-    }
-
-    // delete old file
-    std::remove(fileName.c_str());
-
-    // rename file
-    std::rename(tmpFile.c_str(), fileName.c_str());
-}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/common/MixAll.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/common/MixAll.h b/rocketmq-client4cpp/src/common/MixAll.h
deleted file mode 100755
index 797a0ae..0000000
--- a/rocketmq-client4cpp/src/common/MixAll.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- * Copyright (C) 2013 kangliqiang ,kangliq@163.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __MIXALL_H__
-#define __MIXALL_H__
-
-#include <string>
-#include <vector>
-#include <iostream>
-#include <fstream>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <dirent.h>
-#include <fnmatch.h>
-#include <arpa/inet.h>
-#include <ifaddrs.h>
-
-#include "AtomicValue.h"
-
-namespace rmq
-{
-    class MixAll
-    {
-    public:
-        static const long MASTER_ID = 0L;
-        static const std::string DEFAULT_TOPIC;
-        static const std::string BENCHMARK_TOPIC;
-        static const std::string DEFAULT_PRODUCER_GROUP;
-        static const std::string DEFAULT_CONSUMER_GROUP;
-        static const std::string TOOLS_CONSUMER_GROUP;
-        static const std::string CLIENT_INNER_PRODUCER_GROUP;
-        static const std::string SELF_TEST_TOPIC;
-        static const std::string RETRY_GROUP_TOPIC_PREFIX;
-        static const std::string DLQ_GROUP_TOPIC_PREFIX;
-        static const std::string NAMESRV_ADDR_ENV;
-        static const std::string ROCKETMQ_HOME_ENV;
-        static const std::string  ROCKETMQ_HOME_PROPERTY;
-        static const std::string MESSAGE_COMPRESS_LEVEL;
-        static const std::string ROCKETMQ_NAMESRV_DOMAIN;
-
-        static std::string getRetryTopic(const std::string& consumerGroup);
-        static bool compareAndIncreaseOnly(kpr::AtomicLong& target, long long value);
-        static std::string file2String(const std::string& fileName);
-        static void string2File(const std::string& fileName, const std::string& fileData);
-    };
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/common/NamesrvConfig.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/common/NamesrvConfig.h b/rocketmq-client4cpp/src/common/NamesrvConfig.h
deleted file mode 100755
index 608a4d9..0000000
--- a/rocketmq-client4cpp/src/common/NamesrvConfig.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang, kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#ifndef __NAMESRVCONFIG_H__
-#define __NAMESRVCONFIG_H__
-
-#include <stdlib.h>
-#include <string>
-
-namespace rmq
-{
-/**
- * Name server Config
- *
- */
-class NamesrvConfig
-{
-public:
-    NamesrvConfig()
-    {
-        m_kvConfigPath = "";
-
-        char* home = getenv(MixAll::ROCKETMQ_HOME_ENV.c_str());
-        if (home)
-        {
-            m_rocketmqHome = home;
-        }
-        else
-        {
-            m_rocketmqHome = "";
-        }
-    }
-
-    const std::string& getRocketmqHome()
-    {
-        return m_rocketmqHome;
-    }
-
-    void setRocketmqHome(const std::string& rocketmqHome)
-    {
-        m_rocketmqHome = rocketmqHome;
-    }
-
-    const std::string& getKvConfigPath()
-    {
-        return m_kvConfigPath;
-    }
-
-    void setKvConfigPath(const std::string& kvConfigPath)
-    {
-        m_kvConfigPath = kvConfigPath;
-    }
-
-private:
-    std::string m_rocketmqHome;
-    std::string m_kvConfigPath;
-};
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/common/NamesrvUtil.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/common/NamesrvUtil.h b/rocketmq-client4cpp/src/common/NamesrvUtil.h
deleted file mode 100755
index 4f3639c..0000000
--- a/rocketmq-client4cpp/src/common/NamesrvUtil.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang, kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __NAMESRVUTIL_H__
-#define __NAMESRVUTIL_H__
-
-namespace rmq
-{
-	namespace NamesrvUtil
-	{
-		const char* NAMESPACE_ORDER_TOPIC_CONFIG = "ORDER_TOPIC_CONFIG";
-		const char*  NAMESPACE_PROJECT_CONFIG = "PROJECT_CONFIG";
-	};
-}
-
-#endif



[06/17] incubator-rocketmq-externals git commit: Polish cpp module

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/jsoncpp/json_writer.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/jsoncpp/json_writer.cpp b/rocketmq-client4cpp/src/jsoncpp/json_writer.cpp
deleted file mode 100755
index 9d9e0cc..0000000
--- a/rocketmq-client4cpp/src/jsoncpp/json_writer.cpp
+++ /dev/null
@@ -1,1220 +0,0 @@
-// Copyright 2011 Baptiste Lepilleur
-// Distributed under MIT license, or public domain if desired and
-// recognized in your jurisdiction.
-// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
-
-#if !defined(JSON_IS_AMALGAMATION)
-#include <json/writer.h>
-#include "json_tool.h"
-#endif // if !defined(JSON_IS_AMALGAMATION)
-#include <iomanip>
-#include <memory>
-#include <sstream>
-#include <utility>
-#include <set>
-#include <cassert>
-#include <cstring>
-#include <cstdio>
-
-#if defined(_MSC_VER) && _MSC_VER >= 1200 && _MSC_VER < 1800 // Between VC++ 6.0 and VC++ 11.0
-#include <float.h>
-#define isfinite _finite
-#elif defined(__sun) && defined(__SVR4) //Solaris
-#if !defined(isfinite)
-#include <ieeefp.h>
-#define isfinite finite
-#endif
-#elif defined(_AIX)
-#if !defined(isfinite)
-#include <math.h>
-#define isfinite finite
-#endif
-#elif defined(__hpux)
-#if !defined(isfinite)
-#if defined(__ia64) && !defined(finite)
-#define isfinite(x) ((sizeof(x) == sizeof(float) ? \
-                     _Isfinitef(x) : _IsFinite(x)))
-#else
-#include <math.h>
-#define isfinite finite
-#endif
-#endif
-#else
-#include <cmath>
-#if !(defined(__QNXNTO__)) // QNX already defines isfinite
-#define isfinite std::isfinite
-#endif
-#endif
-
-#if defined(_MSC_VER)
-#if !defined(WINCE) && defined(__STDC_SECURE_LIB__) && _MSC_VER >= 1500 // VC++ 9.0 and above
-#define snprintf sprintf_s
-#elif _MSC_VER >= 1900 // VC++ 14.0 and above
-#define snprintf std::snprintf
-#else
-#define snprintf _snprintf
-#endif
-#elif defined(__ANDROID__) || defined(__QNXNTO__)
-#define snprintf snprintf
-#elif __cplusplus >= 201103L
-#if !defined(__MINGW32__) && !defined(__CYGWIN__)
-#define snprintf std::snprintf
-#endif
-#endif
-
-#if defined(__BORLANDC__)
-#include <float.h>
-#define isfinite _finite
-#define snprintf _snprintf
-#endif
-
-#if defined(_MSC_VER) && _MSC_VER >= 1400 // VC++ 8.0
-// Disable warning about strdup being deprecated.
-#pragma warning(disable : 4996)
-#endif
-
-namespace rmq {
-namespace Json {
-
-#if __cplusplus >= 201103L || (defined(_CPPLIB_VER) && _CPPLIB_VER >= 520)
-typedef std::unique_ptr<StreamWriter> StreamWriterPtr;
-#else
-typedef std::auto_ptr<StreamWriter>   StreamWriterPtr;
-#endif
-
-static bool containsControlCharacter(const char* str) {
-  while (*str) {
-    if (isControlCharacter(*(str++)))
-      return true;
-  }
-  return false;
-}
-
-static bool containsControlCharacter0(const char* str, unsigned len) {
-  char const* end = str + len;
-  while (end != str) {
-    if (isControlCharacter(*str) || 0==*str)
-      return true;
-    ++str;
-  }
-  return false;
-}
-
-JSONCPP_STRING valueToString(LargestInt value) {
-  UIntToStringBuffer buffer;
-  char* current = buffer + sizeof(buffer);
-  if (value == Value::minLargestInt) {
-    uintToString(LargestUInt(Value::maxLargestInt) + 1, current);
-    *--current = '-';
-  } else if (value < 0) {
-    uintToString(LargestUInt(-value), current);
-    *--current = '-';
-  } else {
-    uintToString(LargestUInt(value), current);
-  }
-  assert(current >= buffer);
-  return current;
-}
-
-JSONCPP_STRING valueToString(LargestUInt value) {
-  UIntToStringBuffer buffer;
-  char* current = buffer + sizeof(buffer);
-  uintToString(value, current);
-  assert(current >= buffer);
-  return current;
-}
-
-#if defined(JSON_HAS_INT64)
-
-JSONCPP_STRING valueToString(Int value) {
-  return valueToString(LargestInt(value));
-}
-
-JSONCPP_STRING valueToString(UInt value) {
-  return valueToString(LargestUInt(value));
-}
-
-#endif // # if defined(JSON_HAS_INT64)
-
-namespace {
-JSONCPP_STRING valueToString(double value, bool useSpecialFloats, unsigned int precision) {
-  // Allocate a buffer that is more than large enough to store the 16 digits of
-  // precision requested below.
-  char buffer[32];
-  int len = -1;
-
-  char formatString[10];
-  snprintf(formatString, sizeof(formatString), "%%.%dg", precision);
-
-  // Print into the buffer. We need not request the alternative representation
-  // that always has a decimal point because JSON doesn't distingish the
-  // concepts of reals and integers.
-  if (isfinite(value)) {
-    len = snprintf(buffer, sizeof(buffer), formatString, value);
-  } else {
-    // IEEE standard states that NaN values will not compare to themselves
-    if (value != value) {
-      len = snprintf(buffer, sizeof(buffer), useSpecialFloats ? "NaN" : "null");
-    } else if (value < 0) {
-      len = snprintf(buffer, sizeof(buffer), useSpecialFloats ? "-Infinity" : "-1e+9999");
-    } else {
-      len = snprintf(buffer, sizeof(buffer), useSpecialFloats ? "Infinity" : "1e+9999");
-    }
-    // For those, we do not need to call fixNumLoc, but it is fast.
-  }
-  assert(len >= 0);
-  fixNumericLocale(buffer, buffer + len);
-  return buffer;
-}
-}
-
-JSONCPP_STRING valueToString(double value) { return valueToString(value, false, 17); }
-
-JSONCPP_STRING valueToString(bool value) { return value ? "true" : "false"; }
-
-JSONCPP_STRING valueToQuotedString(const char* value) {
-  if (value == NULL)
-    return "";
-  // Not sure how to handle unicode...
-  if (strpbrk(value, "\"\\\b\f\n\r\t") == NULL &&
-      !containsControlCharacter(value))
-    return JSONCPP_STRING("\"") + value + "\"";
-  // We have to walk value and escape any special characters.
-  // Appending to JSONCPP_STRING is not efficient, but this should be rare.
-  // (Note: forward slashes are *not* rare, but I am not escaping them.)
-  JSONCPP_STRING::size_type maxsize =
-      strlen(value) * 2 + 3; // allescaped+quotes+NULL
-  JSONCPP_STRING result;
-  result.reserve(maxsize); // to avoid lots of mallocs
-  result += "\"";
-  for (const char* c = value; *c != 0; ++c) {
-    switch (*c) {
-    case '\"':
-      result += "\\\"";
-      break;
-    case '\\':
-      result += "\\\\";
-      break;
-    case '\b':
-      result += "\\b";
-      break;
-    case '\f':
-      result += "\\f";
-      break;
-    case '\n':
-      result += "\\n";
-      break;
-    case '\r':
-      result += "\\r";
-      break;
-    case '\t':
-      result += "\\t";
-      break;
-    // case '/':
-    // Even though \/ is considered a legal escape in JSON, a bare
-    // slash is also legal, so I see no reason to escape it.
-    // (I hope I am not misunderstanding something.
-    // blep notes: actually escaping \/ may be useful in javascript to avoid </
-    // sequence.
-    // Should add a flag to allow this compatibility mode and prevent this
-    // sequence from occurring.
-    default:
-      if (isControlCharacter(*c)) {
-        JSONCPP_OSTRINGSTREAM oss;
-        oss << "\\u" << std::hex << std::uppercase << std::setfill('0')
-            << std::setw(4) << static_cast<int>(*c);
-        result += oss.str();
-      } else {
-        result += *c;
-      }
-      break;
-    }
-  }
-  result += "\"";
-  return result;
-}
-
-// https://github.com/upcaste/upcaste/blob/master/src/upcore/src/cstring/strnpbrk.cpp
-static char const* strnpbrk(char const* s, char const* accept, size_t n) {
-  assert((s || !n) && accept);
-
-  char const* const end = s + n;
-  for (char const* cur = s; cur < end; ++cur) {
-    int const c = *cur;
-    for (char const* a = accept; *a; ++a) {
-      if (*a == c) {
-        return cur;
-      }
-    }
-  }
-  return NULL;
-}
-static JSONCPP_STRING valueToQuotedStringN(const char* value, unsigned length) {
-  if (value == NULL)
-    return "";
-  // Not sure how to handle unicode...
-  if (strnpbrk(value, "\"\\\b\f\n\r\t", length) == NULL &&
-      !containsControlCharacter0(value, length))
-    return JSONCPP_STRING("\"") + value + "\"";
-  // We have to walk value and escape any special characters.
-  // Appending to JSONCPP_STRING is not efficient, but this should be rare.
-  // (Note: forward slashes are *not* rare, but I am not escaping them.)
-  JSONCPP_STRING::size_type maxsize =
-      length * 2 + 3; // allescaped+quotes+NULL
-  JSONCPP_STRING result;
-  result.reserve(maxsize); // to avoid lots of mallocs
-  result += "\"";
-  char const* end = value + length;
-  for (const char* c = value; c != end; ++c) {
-    switch (*c) {
-    case '\"':
-      result += "\\\"";
-      break;
-    case '\\':
-      result += "\\\\";
-      break;
-    case '\b':
-      result += "\\b";
-      break;
-    case '\f':
-      result += "\\f";
-      break;
-    case '\n':
-      result += "\\n";
-      break;
-    case '\r':
-      result += "\\r";
-      break;
-    case '\t':
-      result += "\\t";
-      break;
-    // case '/':
-    // Even though \/ is considered a legal escape in JSON, a bare
-    // slash is also legal, so I see no reason to escape it.
-    // (I hope I am not misunderstanding something.)
-    // blep notes: actually escaping \/ may be useful in javascript to avoid </
-    // sequence.
-    // Should add a flag to allow this compatibility mode and prevent this
-    // sequence from occurring.
-    default:
-      if ((isControlCharacter(*c)) || (*c == 0)) {
-        JSONCPP_OSTRINGSTREAM oss;
-        oss << "\\u" << std::hex << std::uppercase << std::setfill('0')
-            << std::setw(4) << static_cast<int>(*c);
-        result += oss.str();
-      } else {
-        result += *c;
-      }
-      break;
-    }
-  }
-  result += "\"";
-  return result;
-}
-
-// Class Writer
-// //////////////////////////////////////////////////////////////////
-Writer::~Writer() {}
-
-// Class FastWriter
-// //////////////////////////////////////////////////////////////////
-
-FastWriter::FastWriter()
-    : yamlCompatiblityEnabled_(false), dropNullPlaceholders_(false),
-      omitEndingLineFeed_(false) {}
-
-void FastWriter::enableYAMLCompatibility() { yamlCompatiblityEnabled_ = true; }
-
-void FastWriter::dropNullPlaceholders() { dropNullPlaceholders_ = true; }
-
-void FastWriter::omitEndingLineFeed() { omitEndingLineFeed_ = true; }
-
-JSONCPP_STRING FastWriter::write(const Value& root) {
-  document_ = "";
-  writeValue(root);
-  if (!omitEndingLineFeed_)
-    document_ += "\n";
-  return document_;
-}
-
-void FastWriter::writeValue(const Value& value) {
-  switch (value.type()) {
-  case nullValue:
-    if (!dropNullPlaceholders_)
-      document_ += "null";
-    break;
-  case intValue:
-    document_ += valueToString(value.asLargestInt());
-    break;
-  case uintValue:
-    document_ += valueToString(value.asLargestUInt());
-    break;
-  case realValue:
-    document_ += valueToString(value.asDouble());
-    break;
-  case stringValue:
-  {
-    // Is NULL possible for value.string_? No.
-    char const* str;
-    char const* end;
-    bool ok = value.getString(&str, &end);
-    if (ok) document_ += valueToQuotedStringN(str, static_cast<unsigned>(end-str));
-    break;
-  }
-  case booleanValue:
-    document_ += valueToString(value.asBool());
-    break;
-  case arrayValue: {
-    document_ += '[';
-    ArrayIndex size = value.size();
-    for (ArrayIndex index = 0; index < size; ++index) {
-      if (index > 0)
-        document_ += ',';
-      writeValue(value[index]);
-    }
-    document_ += ']';
-  } break;
-  case objectValue: {
-    Value::Members members(value.getMemberNames());
-    document_ += '{';
-    for (Value::Members::iterator it = members.begin(); it != members.end();
-         ++it) {
-      const JSONCPP_STRING& name = *it;
-      if (it != members.begin())
-        document_ += ',';
-      document_ += valueToQuotedStringN(name.data(), static_cast<unsigned>(name.length()));
-      document_ += yamlCompatiblityEnabled_ ? ": " : ":";
-      writeValue(value[name]);
-    }
-    document_ += '}';
-  } break;
-  }
-}
-
-// Class StyledWriter
-// //////////////////////////////////////////////////////////////////
-
-StyledWriter::StyledWriter()
-    : rightMargin_(74), indentSize_(3), addChildValues_() {}
-
-JSONCPP_STRING StyledWriter::write(const Value& root) {
-  document_ = "";
-  addChildValues_ = false;
-  indentString_ = "";
-  writeCommentBeforeValue(root);
-  writeValue(root);
-  writeCommentAfterValueOnSameLine(root);
-  document_ += "\n";
-  return document_;
-}
-
-void StyledWriter::writeValue(const Value& value) {
-  switch (value.type()) {
-  case nullValue:
-    pushValue("null");
-    break;
-  case intValue:
-    pushValue(valueToString(value.asLargestInt()));
-    break;
-  case uintValue:
-    pushValue(valueToString(value.asLargestUInt()));
-    break;
-  case realValue:
-    pushValue(valueToString(value.asDouble()));
-    break;
-  case stringValue:
-  {
-    // Is NULL possible for value.string_? No.
-    char const* str;
-    char const* end;
-    bool ok = value.getString(&str, &end);
-    if (ok) pushValue(valueToQuotedStringN(str, static_cast<unsigned>(end-str)));
-    else pushValue("");
-    break;
-  }
-  case booleanValue:
-    pushValue(valueToString(value.asBool()));
-    break;
-  case arrayValue:
-    writeArrayValue(value);
-    break;
-  case objectValue: {
-    Value::Members members(value.getMemberNames());
-    if (members.empty())
-      pushValue("{}");
-    else {
-      writeWithIndent("{");
-      indent();
-      Value::Members::iterator it = members.begin();
-      for (;;) {
-        const JSONCPP_STRING& name = *it;
-        const Value& childValue = value[name];
-        writeCommentBeforeValue(childValue);
-        writeWithIndent(valueToQuotedString(name.c_str()));
-        document_ += " : ";
-        writeValue(childValue);
-        if (++it == members.end()) {
-          writeCommentAfterValueOnSameLine(childValue);
-          break;
-        }
-        document_ += ',';
-        writeCommentAfterValueOnSameLine(childValue);
-      }
-      unindent();
-      writeWithIndent("}");
-    }
-  } break;
-  }
-}
-
-void StyledWriter::writeArrayValue(const Value& value) {
-  unsigned size = value.size();
-  if (size == 0)
-    pushValue("[]");
-  else {
-    bool isArrayMultiLine = isMultineArray(value);
-    if (isArrayMultiLine) {
-      writeWithIndent("[");
-      indent();
-      bool hasChildValue = !childValues_.empty();
-      unsigned index = 0;
-      for (;;) {
-        const Value& childValue = value[index];
-        writeCommentBeforeValue(childValue);
-        if (hasChildValue)
-          writeWithIndent(childValues_[index]);
-        else {
-          writeIndent();
-          writeValue(childValue);
-        }
-        if (++index == size) {
-          writeCommentAfterValueOnSameLine(childValue);
-          break;
-        }
-        document_ += ',';
-        writeCommentAfterValueOnSameLine(childValue);
-      }
-      unindent();
-      writeWithIndent("]");
-    } else // output on a single line
-    {
-      assert(childValues_.size() == size);
-      document_ += "[ ";
-      for (unsigned index = 0; index < size; ++index) {
-        if (index > 0)
-          document_ += ", ";
-        document_ += childValues_[index];
-      }
-      document_ += " ]";
-    }
-  }
-}
-
-bool StyledWriter::isMultineArray(const Value& value) {
-  ArrayIndex const size = value.size();
-  bool isMultiLine = size * 3 >= rightMargin_;
-  childValues_.clear();
-  for (ArrayIndex index = 0; index < size && !isMultiLine; ++index) {
-    const Value& childValue = value[index];
-    isMultiLine = ((childValue.isArray() || childValue.isObject()) &&
-                        childValue.size() > 0);
-  }
-  if (!isMultiLine) // check if line length > max line length
-  {
-    childValues_.reserve(size);
-    addChildValues_ = true;
-    ArrayIndex lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]'
-    for (ArrayIndex index = 0; index < size; ++index) {
-      if (hasCommentForValue(value[index])) {
-        isMultiLine = true;
-      }
-      writeValue(value[index]);
-      lineLength += static_cast<ArrayIndex>(childValues_[index].length());
-    }
-    addChildValues_ = false;
-    isMultiLine = isMultiLine || lineLength >= rightMargin_;
-  }
-  return isMultiLine;
-}
-
-void StyledWriter::pushValue(const JSONCPP_STRING& value) {
-  if (addChildValues_)
-    childValues_.push_back(value);
-  else
-    document_ += value;
-}
-
-void StyledWriter::writeIndent() {
-  if (!document_.empty()) {
-    char last = document_[document_.length() - 1];
-    if (last == ' ') // already indented
-      return;
-    if (last != '\n') // Comments may add new-line
-      document_ += '\n';
-  }
-  document_ += indentString_;
-}
-
-void StyledWriter::writeWithIndent(const JSONCPP_STRING& value) {
-  writeIndent();
-  document_ += value;
-}
-
-void StyledWriter::indent() { indentString_ += JSONCPP_STRING(indentSize_, ' '); }
-
-void StyledWriter::unindent() {
-  assert(indentString_.size() >= indentSize_);
-  indentString_.resize(indentString_.size() - indentSize_);
-}
-
-void StyledWriter::writeCommentBeforeValue(const Value& root) {
-  if (!root.hasComment(commentBefore))
-    return;
-
-  document_ += "\n";
-  writeIndent();
-  const JSONCPP_STRING& comment = root.getComment(commentBefore);
-  JSONCPP_STRING::const_iterator iter = comment.begin();
-  while (iter != comment.end()) {
-    document_ += *iter;
-    if (*iter == '\n' &&
-       (iter != comment.end() && *(iter + 1) == '/'))
-      writeIndent();
-    ++iter;
-  }
-
-  // Comments are stripped of trailing newlines, so add one here
-  document_ += "\n";
-}
-
-void StyledWriter::writeCommentAfterValueOnSameLine(const Value& root) {
-  if (root.hasComment(commentAfterOnSameLine))
-    document_ += " " + root.getComment(commentAfterOnSameLine);
-
-  if (root.hasComment(commentAfter)) {
-    document_ += "\n";
-    document_ += root.getComment(commentAfter);
-    document_ += "\n";
-  }
-}
-
-bool StyledWriter::hasCommentForValue(const Value& value) {
-  return value.hasComment(commentBefore) ||
-         value.hasComment(commentAfterOnSameLine) ||
-         value.hasComment(commentAfter);
-}
-
-// Class StyledStreamWriter
-// //////////////////////////////////////////////////////////////////
-
-StyledStreamWriter::StyledStreamWriter(JSONCPP_STRING indentation)
-    : document_(NULL), rightMargin_(74), indentation_(indentation),
-      addChildValues_() {}
-
-void StyledStreamWriter::write(JSONCPP_OSTREAM& out, const Value& root) {
-  document_ = &out;
-  addChildValues_ = false;
-  indentString_ = "";
-  indented_ = true;
-  writeCommentBeforeValue(root);
-  if (!indented_) writeIndent();
-  indented_ = true;
-  writeValue(root);
-  writeCommentAfterValueOnSameLine(root);
-  *document_ << "\n";
-  document_ = NULL; // Forget the stream, for safety.
-}
-
-void StyledStreamWriter::writeValue(const Value& value) {
-  switch (value.type()) {
-  case nullValue:
-    pushValue("null");
-    break;
-  case intValue:
-    pushValue(valueToString(value.asLargestInt()));
-    break;
-  case uintValue:
-    pushValue(valueToString(value.asLargestUInt()));
-    break;
-  case realValue:
-    pushValue(valueToString(value.asDouble()));
-    break;
-  case stringValue:
-  {
-    // Is NULL possible for value.string_? No.
-    char const* str;
-    char const* end;
-    bool ok = value.getString(&str, &end);
-    if (ok) pushValue(valueToQuotedStringN(str, static_cast<unsigned>(end-str)));
-    else pushValue("");
-    break;
-  }
-  case booleanValue:
-    pushValue(valueToString(value.asBool()));
-    break;
-  case arrayValue:
-    writeArrayValue(value);
-    break;
-  case objectValue: {
-    Value::Members members(value.getMemberNames());
-    if (members.empty())
-      pushValue("{}");
-    else {
-      writeWithIndent("{");
-      indent();
-      Value::Members::iterator it = members.begin();
-      for (;;) {
-        const JSONCPP_STRING& name = *it;
-        const Value& childValue = value[name];
-        writeCommentBeforeValue(childValue);
-        writeWithIndent(valueToQuotedString(name.c_str()));
-        *document_ << " : ";
-        writeValue(childValue);
-        if (++it == members.end()) {
-          writeCommentAfterValueOnSameLine(childValue);
-          break;
-        }
-        *document_ << ",";
-        writeCommentAfterValueOnSameLine(childValue);
-      }
-      unindent();
-      writeWithIndent("}");
-    }
-  } break;
-  }
-}
-
-void StyledStreamWriter::writeArrayValue(const Value& value) {
-  unsigned size = value.size();
-  if (size == 0)
-    pushValue("[]");
-  else {
-    bool isArrayMultiLine = isMultineArray(value);
-    if (isArrayMultiLine) {
-      writeWithIndent("[");
-      indent();
-      bool hasChildValue = !childValues_.empty();
-      unsigned index = 0;
-      for (;;) {
-        const Value& childValue = value[index];
-        writeCommentBeforeValue(childValue);
-        if (hasChildValue)
-          writeWithIndent(childValues_[index]);
-        else {
-          if (!indented_) writeIndent();
-          indented_ = true;
-          writeValue(childValue);
-          indented_ = false;
-        }
-        if (++index == size) {
-          writeCommentAfterValueOnSameLine(childValue);
-          break;
-        }
-        *document_ << ",";
-        writeCommentAfterValueOnSameLine(childValue);
-      }
-      unindent();
-      writeWithIndent("]");
-    } else // output on a single line
-    {
-      assert(childValues_.size() == size);
-      *document_ << "[ ";
-      for (unsigned index = 0; index < size; ++index) {
-        if (index > 0)
-          *document_ << ", ";
-        *document_ << childValues_[index];
-      }
-      *document_ << " ]";
-    }
-  }
-}
-
-bool StyledStreamWriter::isMultineArray(const Value& value) {
-  ArrayIndex const size = value.size();
-  bool isMultiLine = size * 3 >= rightMargin_;
-  childValues_.clear();
-  for (ArrayIndex index = 0; index < size && !isMultiLine; ++index) {
-    const Value& childValue = value[index];
-    isMultiLine = ((childValue.isArray() || childValue.isObject()) &&
-                        childValue.size() > 0);
-  }
-  if (!isMultiLine) // check if line length > max line length
-  {
-    childValues_.reserve(size);
-    addChildValues_ = true;
-    ArrayIndex lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]'
-    for (ArrayIndex index = 0; index < size; ++index) {
-      if (hasCommentForValue(value[index])) {
-        isMultiLine = true;
-      }
-      writeValue(value[index]);
-      lineLength += static_cast<ArrayIndex>(childValues_[index].length());
-    }
-    addChildValues_ = false;
-    isMultiLine = isMultiLine || lineLength >= rightMargin_;
-  }
-  return isMultiLine;
-}
-
-void StyledStreamWriter::pushValue(const JSONCPP_STRING& value) {
-  if (addChildValues_)
-    childValues_.push_back(value);
-  else
-    *document_ << value;
-}
-
-void StyledStreamWriter::writeIndent() {
-  // blep intended this to look at the so-far-written string
-  // to determine whether we are already indented, but
-  // with a stream we cannot do that. So we rely on some saved state.
-  // The caller checks indented_.
-  *document_ << '\n' << indentString_;
-}
-
-void StyledStreamWriter::writeWithIndent(const JSONCPP_STRING& value) {
-  if (!indented_) writeIndent();
-  *document_ << value;
-  indented_ = false;
-}
-
-void StyledStreamWriter::indent() { indentString_ += indentation_; }
-
-void StyledStreamWriter::unindent() {
-  assert(indentString_.size() >= indentation_.size());
-  indentString_.resize(indentString_.size() - indentation_.size());
-}
-
-void StyledStreamWriter::writeCommentBeforeValue(const Value& root) {
-  if (!root.hasComment(commentBefore))
-    return;
-
-  if (!indented_) writeIndent();
-  const JSONCPP_STRING& comment = root.getComment(commentBefore);
-  JSONCPP_STRING::const_iterator iter = comment.begin();
-  while (iter != comment.end()) {
-    *document_ << *iter;
-    if (*iter == '\n' &&
-       (iter != comment.end() && *(iter + 1) == '/'))
-      // writeIndent();  // would include newline
-      *document_ << indentString_;
-    ++iter;
-  }
-  indented_ = false;
-}
-
-void StyledStreamWriter::writeCommentAfterValueOnSameLine(const Value& root) {
-  if (root.hasComment(commentAfterOnSameLine))
-    *document_ << ' ' << root.getComment(commentAfterOnSameLine);
-
-  if (root.hasComment(commentAfter)) {
-    writeIndent();
-    *document_ << root.getComment(commentAfter);
-  }
-  indented_ = false;
-}
-
-bool StyledStreamWriter::hasCommentForValue(const Value& value) {
-  return value.hasComment(commentBefore) ||
-         value.hasComment(commentAfterOnSameLine) ||
-         value.hasComment(commentAfter);
-}
-
-//////////////////////////
-// BuiltStyledStreamWriter
-
-/// Scoped enums are not available until C++11.
-struct CommentStyle {
-  /// Decide whether to write comments.
-  enum Enum {
-    None,  ///< Drop all comments.
-    Most,  ///< Recover odd behavior of previous versions (not implemented yet).
-    All  ///< Keep all comments.
-  };
-};
-
-struct BuiltStyledStreamWriter : public StreamWriter
-{
-  BuiltStyledStreamWriter(
-      JSONCPP_STRING const& indentation,
-      CommentStyle::Enum cs,
-      JSONCPP_STRING const& colonSymbol,
-      JSONCPP_STRING const& nullSymbol,
-      JSONCPP_STRING const& endingLineFeedSymbol,
-      bool useSpecialFloats,
-      unsigned int precision);
-  int write(Value const& root, JSONCPP_OSTREAM* sout) JSONCPP_OVERRIDE;
-private:
-  void writeValue(Value const& value);
-  void writeArrayValue(Value const& value);
-  bool isMultineArray(Value const& value);
-  void pushValue(JSONCPP_STRING const& value);
-  void writeIndent();
-  void writeWithIndent(JSONCPP_STRING const& value);
-  void indent();
-  void unindent();
-  void writeCommentBeforeValue(Value const& root);
-  void writeCommentAfterValueOnSameLine(Value const& root);
-  static bool hasCommentForValue(const Value& value);
-
-  typedef std::vector<JSONCPP_STRING> ChildValues;
-
-  ChildValues childValues_;
-  JSONCPP_STRING indentString_;
-  unsigned int rightMargin_;
-  JSONCPP_STRING indentation_;
-  CommentStyle::Enum cs_;
-  JSONCPP_STRING colonSymbol_;
-  JSONCPP_STRING nullSymbol_;
-  JSONCPP_STRING endingLineFeedSymbol_;
-  bool addChildValues_ : 1;
-  bool indented_ : 1;
-  bool useSpecialFloats_ : 1;
-  unsigned int precision_;
-};
-BuiltStyledStreamWriter::BuiltStyledStreamWriter(
-      JSONCPP_STRING const& indentation,
-      CommentStyle::Enum cs,
-      JSONCPP_STRING const& colonSymbol,
-      JSONCPP_STRING const& nullSymbol,
-      JSONCPP_STRING const& endingLineFeedSymbol,
-      bool useSpecialFloats,
-      unsigned int precision)
-  : rightMargin_(74)
-  , indentation_(indentation)
-  , cs_(cs)
-  , colonSymbol_(colonSymbol)
-  , nullSymbol_(nullSymbol)
-  , endingLineFeedSymbol_(endingLineFeedSymbol)
-  , addChildValues_(false)
-  , indented_(false)
-  , useSpecialFloats_(useSpecialFloats)
-  , precision_(precision)
-{
-}
-int BuiltStyledStreamWriter::write(Value const& root, JSONCPP_OSTREAM* sout)
-{
-  sout_ = sout;
-  addChildValues_ = false;
-  indented_ = true;
-  indentString_ = "";
-  writeCommentBeforeValue(root);
-  if (!indented_) writeIndent();
-  indented_ = true;
-  writeValue(root);
-  writeCommentAfterValueOnSameLine(root);
-  *sout_ << endingLineFeedSymbol_;
-  sout_ = NULL;
-  return 0;
-}
-void BuiltStyledStreamWriter::writeValue(Value const& value) {
-  switch (value.type()) {
-  case nullValue:
-    pushValue(nullSymbol_);
-    break;
-  case intValue:
-    pushValue(valueToString(value.asLargestInt()));
-    break;
-  case uintValue:
-    pushValue(valueToString(value.asLargestUInt()));
-    break;
-  case realValue:
-    pushValue(valueToString(value.asDouble(), useSpecialFloats_, precision_));
-    break;
-  case stringValue:
-  {
-    // Is NULL is possible for value.string_? No.
-    char const* str;
-    char const* end;
-    bool ok = value.getString(&str, &end);
-    if (ok) pushValue(valueToQuotedStringN(str, static_cast<unsigned>(end-str)));
-    else pushValue("");
-    break;
-  }
-  case booleanValue:
-    pushValue(valueToString(value.asBool()));
-    break;
-  case arrayValue:
-    writeArrayValue(value);
-    break;
-  case objectValue: {
-    Value::Members members(value.getMemberNames());
-    if (members.empty())
-      pushValue("{}");
-    else {
-      writeWithIndent("{");
-      indent();
-      Value::Members::iterator it = members.begin();
-      for (;;) {
-        JSONCPP_STRING const& name = *it;
-        Value const& childValue = value[name];
-        writeCommentBeforeValue(childValue);
-        writeWithIndent(valueToQuotedStringN(name.data(), static_cast<unsigned>(name.length())));
-        *sout_ << colonSymbol_;
-        writeValue(childValue);
-        if (++it == members.end()) {
-          writeCommentAfterValueOnSameLine(childValue);
-          break;
-        }
-        *sout_ << ",";
-        writeCommentAfterValueOnSameLine(childValue);
-      }
-      unindent();
-      writeWithIndent("}");
-    }
-  } break;
-  }
-}
-
-void BuiltStyledStreamWriter::writeArrayValue(Value const& value) {
-  unsigned size = value.size();
-  if (size == 0)
-    pushValue("[]");
-  else {
-    bool isMultiLine = (cs_ == CommentStyle::All) || isMultineArray(value);
-    if (isMultiLine) {
-      writeWithIndent("[");
-      indent();
-      bool hasChildValue = !childValues_.empty();
-      unsigned index = 0;
-      for (;;) {
-        Value const& childValue = value[index];
-        writeCommentBeforeValue(childValue);
-        if (hasChildValue)
-          writeWithIndent(childValues_[index]);
-        else {
-          if (!indented_) writeIndent();
-          indented_ = true;
-          writeValue(childValue);
-          indented_ = false;
-        }
-        if (++index == size) {
-          writeCommentAfterValueOnSameLine(childValue);
-          break;
-        }
-        *sout_ << ",";
-        writeCommentAfterValueOnSameLine(childValue);
-      }
-      unindent();
-      writeWithIndent("]");
-    } else // output on a single line
-    {
-      assert(childValues_.size() == size);
-      *sout_ << "[";
-      if (!indentation_.empty()) *sout_ << " ";
-      for (unsigned index = 0; index < size; ++index) {
-        if (index > 0)
-          *sout_ << ((!indentation_.empty()) ? ", " : ",");
-        *sout_ << childValues_[index];
-      }
-      if (!indentation_.empty()) *sout_ << " ";
-      *sout_ << "]";
-    }
-  }
-}
-
-bool BuiltStyledStreamWriter::isMultineArray(Value const& value) {
-  ArrayIndex const size = value.size();
-  bool isMultiLine = size * 3 >= rightMargin_;
-  childValues_.clear();
-  for (ArrayIndex index = 0; index < size && !isMultiLine; ++index) {
-    Value const& childValue = value[index];
-    isMultiLine = ((childValue.isArray() || childValue.isObject()) &&
-                        childValue.size() > 0);
-  }
-  if (!isMultiLine) // check if line length > max line length
-  {
-    childValues_.reserve(size);
-    addChildValues_ = true;
-    ArrayIndex lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]'
-    for (ArrayIndex index = 0; index < size; ++index) {
-      if (hasCommentForValue(value[index])) {
-        isMultiLine = true;
-      }
-      writeValue(value[index]);
-      lineLength += static_cast<ArrayIndex>(childValues_[index].length());
-    }
-    addChildValues_ = false;
-    isMultiLine = isMultiLine || lineLength >= rightMargin_;
-  }
-  return isMultiLine;
-}
-
-void BuiltStyledStreamWriter::pushValue(JSONCPP_STRING const& value) {
-  if (addChildValues_)
-    childValues_.push_back(value);
-  else
-    *sout_ << value;
-}
-
-void BuiltStyledStreamWriter::writeIndent() {
-  // blep intended this to look at the so-far-written string
-  // to determine whether we are already indented, but
-  // with a stream we cannot do that. So we rely on some saved state.
-  // The caller checks indented_.
-
-  if (!indentation_.empty()) {
-    // In this case, drop newlines too.
-    *sout_ << '\n' << indentString_;
-  }
-}
-
-void BuiltStyledStreamWriter::writeWithIndent(JSONCPP_STRING const& value) {
-  if (!indented_) writeIndent();
-  *sout_ << value;
-  indented_ = false;
-}
-
-void BuiltStyledStreamWriter::indent() { indentString_ += indentation_; }
-
-void BuiltStyledStreamWriter::unindent() {
-  assert(indentString_.size() >= indentation_.size());
-  indentString_.resize(indentString_.size() - indentation_.size());
-}
-
-void BuiltStyledStreamWriter::writeCommentBeforeValue(Value const& root) {
-  if (cs_ == CommentStyle::None) return;
-  if (!root.hasComment(commentBefore))
-    return;
-
-  if (!indented_) writeIndent();
-  const JSONCPP_STRING& comment = root.getComment(commentBefore);
-  JSONCPP_STRING::const_iterator iter = comment.begin();
-  while (iter != comment.end()) {
-    *sout_ << *iter;
-    if (*iter == '\n' &&
-       (iter != comment.end() && *(iter + 1) == '/'))
-      // writeIndent();  // would write extra newline
-      *sout_ << indentString_;
-    ++iter;
-  }
-  indented_ = false;
-}
-
-void BuiltStyledStreamWriter::writeCommentAfterValueOnSameLine(Value const& root) {
-  if (cs_ == CommentStyle::None) return;
-  if (root.hasComment(commentAfterOnSameLine))
-    *sout_ << " " + root.getComment(commentAfterOnSameLine);
-
-  if (root.hasComment(commentAfter)) {
-    writeIndent();
-    *sout_ << root.getComment(commentAfter);
-  }
-}
-
-// static
-bool BuiltStyledStreamWriter::hasCommentForValue(const Value& value) {
-  return value.hasComment(commentBefore) ||
-         value.hasComment(commentAfterOnSameLine) ||
-         value.hasComment(commentAfter);
-}
-
-///////////////
-// StreamWriter
-
-StreamWriter::StreamWriter()
-    : sout_(NULL)
-{
-}
-StreamWriter::~StreamWriter()
-{
-}
-StreamWriter::Factory::~Factory()
-{}
-StreamWriterBuilder::StreamWriterBuilder()
-{
-  setDefaults(&settings_);
-}
-StreamWriterBuilder::~StreamWriterBuilder()
-{}
-StreamWriter* StreamWriterBuilder::newStreamWriter() const
-{
-  JSONCPP_STRING indentation = settings_["indentation"].asString();
-  JSONCPP_STRING cs_str = settings_["commentStyle"].asString();
-  bool eyc = settings_["enableYAMLCompatibility"].asBool();
-  bool dnp = settings_["dropNullPlaceholders"].asBool();
-  bool usf = settings_["useSpecialFloats"].asBool();
-  unsigned int pre = settings_["precision"].asUInt();
-  CommentStyle::Enum cs = CommentStyle::All;
-  if (cs_str == "All") {
-    cs = CommentStyle::All;
-  } else if (cs_str == "None") {
-    cs = CommentStyle::None;
-  } else {
-    throwRuntimeError("commentStyle must be 'All' or 'None'");
-  }
-  JSONCPP_STRING colonSymbol = " : ";
-  if (eyc) {
-    colonSymbol = ": ";
-  } else if (indentation.empty()) {
-    colonSymbol = ":";
-  }
-  JSONCPP_STRING nullSymbol = "null";
-  if (dnp) {
-    nullSymbol = "";
-  }
-  if (pre > 17) pre = 17;
-  JSONCPP_STRING endingLineFeedSymbol = "";
-  return new BuiltStyledStreamWriter(
-      indentation, cs,
-      colonSymbol, nullSymbol, endingLineFeedSymbol, usf, pre);
-}
-static void getValidWriterKeys(std::set<JSONCPP_STRING>* valid_keys)
-{
-  valid_keys->clear();
-  valid_keys->insert("indentation");
-  valid_keys->insert("commentStyle");
-  valid_keys->insert("enableYAMLCompatibility");
-  valid_keys->insert("dropNullPlaceholders");
-  valid_keys->insert("useSpecialFloats");
-  valid_keys->insert("precision");
-}
-bool StreamWriterBuilder::validate(Value* invalid) const
-{
-  Value my_invalid;
-  if (!invalid) invalid = &my_invalid;  // so we do not need to test for NULL
-  Value& inv = *invalid;
-  std::set<JSONCPP_STRING> valid_keys;
-  getValidWriterKeys(&valid_keys);
-  Value::Members keys = settings_.getMemberNames();
-  size_t n = keys.size();
-  for (size_t i = 0; i < n; ++i) {
-    JSONCPP_STRING const& key = keys[i];
-    if (valid_keys.find(key) == valid_keys.end()) {
-      inv[key] = settings_[key];
-    }
-  }
-  return 0u == inv.size();
-}
-Value& StreamWriterBuilder::operator[](JSONCPP_STRING key)
-{
-  return settings_[key];
-}
-// static
-void StreamWriterBuilder::setDefaults(Value* settings)
-{
-  //! [StreamWriterBuilderDefaults]
-  (*settings)["commentStyle"] = "All";
-  (*settings)["indentation"] = "\t";
-  (*settings)["enableYAMLCompatibility"] = false;
-  (*settings)["dropNullPlaceholders"] = false;
-  (*settings)["useSpecialFloats"] = false;
-  (*settings)["precision"] = 17;
-  //! [StreamWriterBuilderDefaults]
-}
-
-JSONCPP_STRING writeString(StreamWriter::Factory const& builder, Value const& root) {
-  JSONCPP_OSTRINGSTREAM sout;
-  StreamWriterPtr const writer(builder.newStreamWriter());
-  writer->write(root, &sout);
-  return sout.str();
-}
-
-JSONCPP_OSTREAM& operator<<(JSONCPP_OSTREAM& sout, Value const& root) {
-  StreamWriterBuilder builder;
-  StreamWriterPtr const writer(builder.newStreamWriter());
-  writer->write(root, &sout);
-  return sout;
-}
-
-} // namespace Json
-} // namespace rmq

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/jsoncpp/version
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/jsoncpp/version b/rocketmq-client4cpp/src/jsoncpp/version
deleted file mode 100755
index 73c8b4f..0000000
--- a/rocketmq-client4cpp/src/jsoncpp/version
+++ /dev/null
@@ -1 +0,0 @@
-1.7.7
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/kpr/AtomicValue.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/kpr/AtomicValue.cpp b/rocketmq-client4cpp/src/kpr/AtomicValue.cpp
deleted file mode 100755
index 30777f9..0000000
--- a/rocketmq-client4cpp/src/kpr/AtomicValue.cpp
+++ /dev/null
@@ -1,146 +0,0 @@
-/**
- * Copyright (C) 2013 kangliqiang ,kangliq@163.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "AtomicValue.h"
-
-#if !defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8)
-
-#include "Mutex.h"
-
-namespace kpr
-{
-static const size_t kSwapLockCount = 64;
-static Mutex s_swapLocks[kSwapLockCount];
-
-static inline Mutex& getSwapLock(const volatile int64_t* addr)
-{
-    return s_swapLocks[(reinterpret_cast<intptr_t>(addr) >> 3U) % kSwapLockCount];
-}
-
-static int64_t atomicAddAndFetch(int64_t volatile* ptr, int64_t step)
-{
-    Mutex& mutex = getSwapLock(ptr);
-
-    mutex.Lock();
-    int64_t value = *ptr + step;
-    *ptr = value;
-    mutex.Unlock();
-
-    return value;
-}
-
-static int64_t atomicFetchAndAdd(int64_t volatile* ptr, int64_t step)
-{
-    Mutex& mutex = getSwapLock(ptr);
-
-    mutex.Lock();
-    int64_t value = *ptr;
-    *ptr += step;
-    mutex.Unlock();
-
-    return value;
-}
-
-static bool atomicBoolCompareAndSwap(int64_t volatile* ptr, int64_t oldval, int64_t newval)
-{
-    Mutex& mutex = getSwapLock(ptr);
-
-    mutex.Lock();
-    if (*ptr == oldval)
-    {
-    	*ptr = newval;
-    	mutex.Unlock();
-    	return true;
-    }
-
-    mutex.Unlock();
-    return false;
-}
-
-static int64_t atomicValCompareAndSwap(int64_t volatile* ptr, int64_t oldval, int64_t newval)
-{
-    Mutex& mutex = getSwapLock(ptr);
-
-    mutex.Lock();
-    int64_t value = *ptr;
-    if (value == oldval)
-    {
-    	*ptr = newval;
-    	mutex.Unlock();
-    	return value;
-    }
-
-    mutex.Unlock();
-    return value;
-}
-
-
-static int64_t atomicTestAndSet(int64_t volatile* ptr, int64_t val)
-{
-    Mutex& mutex = getSwapLock(ptr);
-
-    mutex.Lock();
-    int64_t value = *ptr;
-    *ptr = val;
-    mutex.Unlock();
-
-    return value;
-}
-
-
-
-extern "C" {
-int64_t __sync_add_and_fetch_8(int64_t volatile* ptr, int64_t value)
-{
-    return atomicAddAndFetch(ptr, value);
-}
-
-int64_t __sync_sub_and_fetch_8(int64_t volatile* ptr, int64_t value)
-{
-    return atomicAddAndFetch(ptr, -value);
-}
-
-int64_t __sync_fetch_and_add_8(int64_t volatile* ptr, int64_t value)
-{
-    return atomicFetchAndAdd(ptr, -value);
-}
-
-int64_t __sync_fetch_and_sub_8(int64_t volatile* ptr, int64_t value)
-{
-    return atomicFetchAndAdd(ptr, -value);
-}
-
-bool __sync_bool_compare_and_swap_8(volatile int64_t* ptr, int64_t oldval, int64_t newval)
-{
-    return atomicBoolCompareAndSwap(ptr, oldval, newval);
-}
-
-int64_t __sync_val_compare_and_swap_8(volatile int64_t* ptr, int64_t oldval, int64_t newval)
-{
-    return atomicValCompareAndSwap(ptr, oldval, newval);
-}
-
-bool __sync_lock_test_and_set_8(int64_t volatile* ptr, int64_t value)
-{
-    return atomicTestAndSet(ptr, value);
-}
-
-
-} // extern "C"
-
-} // namespace kpr
-#endif
-
-

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/kpr/AtomicValue.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/kpr/AtomicValue.h b/rocketmq-client4cpp/src/kpr/AtomicValue.h
deleted file mode 100755
index 50d198e..0000000
--- a/rocketmq-client4cpp/src/kpr/AtomicValue.h
+++ /dev/null
@@ -1,200 +0,0 @@
-/**
- * Copyright (C) 2013 kangliqiang ,kangliq@163.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef __KPR_ATOMICVALUE_H__
-#define __KPR_ATOMICVALUE_H__
-
-#include "KPRTypes.h"
-
-namespace kpr
-{
-
-template <class T>
-class AtomicValue
-{
-public:
-	AtomicValue()
-		: value(0)
-	{
-	}
-
-    AtomicValue(T init)
-		: value(init)
-	{
-	}
-
-    AtomicValue<T>& operator=(T newValue)
-    {
-        set(newValue);
-        return *this;
-    }
-
-    AtomicValue<T>& operator=(const AtomicValue<T>& v)
-    {
-        set(v.get());
-
-        return *this;
-    }
-
-    inline T operator+=(T n)
-    {
-        return __sync_add_and_fetch(&value, n);
-    }
-
-    inline T operator-=(T n)
-    {
-        return __sync_sub_and_fetch(&value, n);
-    }
-
-    inline T operator++()
-    {
-        return *this += 1;
-    }
-
-    inline T operator--()
-    {
-        return *this -= 1;
-    }
-
-    inline T fetchAndAdd(T n)
-    {
-        return __sync_fetch_and_add(&value, n);
-    }
-
-    inline T fetchAndSub(T n)
-    {
-        return __sync_fetch_and_sub(&value, n);
-    }
-
-    inline T operator++(int)
-    {
-        return fetchAndAdd(1);
-    }
-
-    inline T operator--(int)
-    {
-        return fetchAndSub(1);
-    }
-
-    operator T() const
-    {
-        return get();
-    }
-
-    T get() const
-    {
-        return const_cast<AtomicValue<T>*>(this)->fetchAndAdd(static_cast<T>(0));
-    }
-
-    void set(T n)
-    {
-        __sync_lock_test_and_set((T*)&value, n);
-    }
-
-    inline T getAndSet(T comparand, T exchange)
-    {
-        return __sync_val_compare_and_swap((T*)&value, comparand, exchange);
-    }
-
-	inline bool compareAndSet(T comparand, T exchange)
-    {
-        return __sync_bool_compare_and_swap((T*)&value, comparand, exchange);
-    }
-
-private:
-    volatile T value;
-};
-
-
-template <class T>
-class AtomicReference
-{
-public:
-	AtomicReference() : value(NULL) {}
-    AtomicReference(T* init) : value(init) {}
-
-    AtomicReference<T>& operator=(T* newValue)
-    {
-        set(newValue);
-        return *this;
-    }
-
-    AtomicReference<T>& operator=(const AtomicReference<T>& v)
-    {
-        set(v.get());
-
-        return *this;
-    }
-
-	T* operator->() const
-    {
-        return get();
-    }
-
-    T& operator*()
-    {
-        return *get();
-    }
-
-    operator T*() const
-    {
-        return get();
-    }
-
-    T* get() const
-    {
-		if (value == NULL)
-		{
-			return NULL;
-		}
-		else
-		{
-        	return (T*)(__sync_fetch_and_add((uintptr_t*)&value, 0));
-		}
-    }
-
-    void set(T* n)
-    {
-		if (value == NULL)
-		{
-			value = n;
-		}
-		else
-		{
-			__sync_lock_test_and_set((uintptr_t*)&value, n);
-		}
-    }
-
-    inline T getAndSet(T* comparand, T* exchange)
-    {
-        return __sync_val_compare_and_swap((uintptr_t*)&value, comparand, exchange);
-    }
-
-	inline bool compareAndSet(T* comparand, T* exchange)
-    {
-        return __sync_bool_compare_and_swap((uintptr_t*)&value, comparand, exchange);
-    }
-
-private:
-    volatile T* value;
-};
-
-
-typedef AtomicValue<bool> AtomicBoolean;
-typedef AtomicValue<int> AtomicInteger;
-typedef AtomicValue<long long> AtomicLong;
-
-}
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/kpr/Condition.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/kpr/Condition.cpp b/rocketmq-client4cpp/src/kpr/Condition.cpp
deleted file mode 100755
index c81765e..0000000
--- a/rocketmq-client4cpp/src/kpr/Condition.cpp
+++ /dev/null
@@ -1,158 +0,0 @@
-/**
- * Copyright (C) 2013 kangliqiang ,kangliq@163.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "Condition.h"
-
-#include <errno.h>
-#include <assert.h>
-
-#include "Mutex.h"
-#include "ScopedLock.h"
-#include "Semaphore.h"
-#include "KPRUtil.h"
-#include "Exception.h"
-
-namespace kpr
-{
-class ConditionHelper
-{
-    RecursiveMutex& m_mutex;
-    int m_count;
-
-public:
-
-    ConditionHelper(RecursiveMutex& mutex, int count)
-        : m_mutex(mutex),
-          m_count(count)
-    {
-    }
-
-    ~ConditionHelper()
-    {
-        pthread_mutex_unlock(&m_mutex.m_mutex);
-        m_mutex.lock(m_count);
-    }
-};
-
-
-Condition::Condition()
-{
-    pthread_cond_init(&m_cond, 0);
-}
-
-Condition::~Condition()
-{
-    pthread_cond_destroy(&m_cond);
-}
-
-void Condition::Wait(Mutex& mutex)
-{
-    wait(mutex, -1);
-}
-
-bool Condition::Wait(Mutex& mutex, long timeout)
-{
-    assert(timeout >= 0 && "timeout value is negative");
-
-    return wait(mutex, timeout);
-}
-
-void Condition::Wait(RecursiveMutex& mutex)
-{
-    wait(mutex, -1);
-}
-
-bool Condition::Wait(RecursiveMutex& mutex, long timeout)
-{
-    assert(timeout >= 0 && "timeout value is negative");
-
-    return wait(mutex, timeout);
-}
-
-void Condition::Notify()
-{
-    pthread_cond_signal(&m_cond);
-}
-
-void Condition::NotifyAll()
-{
-    pthread_cond_broadcast(&m_cond);
-}
-
-bool Condition::wait(Mutex& mutex, long timeout)
-{
-    int ret = 0;
-    if (timeout < 0)
-    {
-        ret = pthread_cond_wait(&m_cond, &mutex.m_mutex);
-    }
-    else
-    {
-        struct timespec abstime = KPRUtil::CalcAbsTime(timeout);
-        ret = pthread_cond_timedwait(&m_cond, &mutex.m_mutex, &abstime);
-    }
-    if (ret == 0)
-    {
-        return true;
-    }
-    else
-    {
-        if (errno == EINTR)
-        {
-            THROW_EXCEPTION(InterruptedException, "pthread_cond_timedwait failed", errno);
-        }
-        else if (errno == ETIMEDOUT && timeout >= 0)
-        {
-            return false;
-        }
-    }
-    return true;
-}
-
-bool Condition::wait(RecursiveMutex& mutex, long timeout)
-{
-    unsigned int count = mutex.reset4Condvar();
-    ConditionHelper unlock(mutex, count);
-
-    int ret = 0;
-    if (timeout < 0)
-    {
-        ret = pthread_cond_wait(&m_cond, &mutex.m_mutex);
-    }
-    else
-    {
-        struct timespec abstime = KPRUtil::CalcAbsTime(timeout);
-        ret = pthread_cond_timedwait(&m_cond, &mutex.m_mutex, &abstime);
-    }
-
-    if (ret == 0)
-    {
-        return true;
-    }
-    else
-    {
-        if (errno == EINTR)
-        {
-            THROW_EXCEPTION(InterruptedException, "pthread_cond_timedwait failed", errno);
-        }
-        else if (errno == ETIMEDOUT && timeout >= 0)
-        {
-            return false;
-        }
-    }
-
-    return true;
-}
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/kpr/Condition.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/kpr/Condition.h b/rocketmq-client4cpp/src/kpr/Condition.h
deleted file mode 100755
index 901e66c..0000000
--- a/rocketmq-client4cpp/src/kpr/Condition.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * Copyright (C) 2013 kangliqiang ,kangliq@163.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef __KPR_CONDITION_H__
-#define __KPR_CONDITION_H__
-
-#include "KPRTypes.h"
-
-namespace kpr
-{
-class Mutex;
-class RWMutex;
-class RecursiveMutex;
-
-class Condition
-{
-public:
-    Condition();
-    ~Condition();
-    void Wait(Mutex& mutex);
-
-    bool Wait(Mutex& mutex, long timeout);
-
-    void Wait(RecursiveMutex& mutex);
-
-    bool Wait(RecursiveMutex& mutex, long timeout);
-
-    void Notify();
-
-    void NotifyAll();
-
-private:
-    bool  wait(Mutex&, long timeout);
-    bool  wait(RecursiveMutex&, long timeout);
-
-    Condition(const Condition&);
-    void operator=(const Condition&);
-
-    pthread_cond_t m_cond;
-};
-}
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/kpr/Epoller.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/kpr/Epoller.cpp b/rocketmq-client4cpp/src/kpr/Epoller.cpp
deleted file mode 100755
index 3c4ddf3..0000000
--- a/rocketmq-client4cpp/src/kpr/Epoller.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-/**
-* Copyright (C) 2013 suwenkuang ,hooligan_520@qq.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#include "Epoller.h"
-#include <unistd.h>
-
-namespace kpr
-{
-Epoller::Epoller(bool bEt)
-{
-    _iEpollfd   = -1;
-    _pevs       = NULL;
-    _et         = bEt;
-    _max_connections = 1024;
-}
-
-Epoller::~Epoller()
-{
-    if (_pevs != NULL)
-    {
-        delete[] _pevs;
-        _pevs = NULL;
-    }
-
-    if (_iEpollfd > 0)
-    {
-        close(_iEpollfd);
-    }
-}
-
-void Epoller::ctrl(int fd, long long data, __uint32_t events, int op)
-{
-    struct epoll_event ev;
-    ev.data.u64 = data;
-    if (_et)
-    {
-        ev.events   = events | EPOLLET;
-    }
-    else
-    {
-        ev.events   = events;
-    }
-
-    epoll_ctl(_iEpollfd, op, fd, &ev);
-}
-
-void Epoller::create(int max_connections)
-{
-    _max_connections = max_connections;
-
-    _iEpollfd = epoll_create(_max_connections + 1);
-
-    if (_pevs != NULL)
-    {
-        delete[] _pevs;
-    }
-
-    _pevs = new epoll_event[_max_connections + 1];
-}
-
-void Epoller::add(int fd, long long data, __uint32_t event)
-{
-    ctrl(fd, data, event, EPOLL_CTL_ADD);
-}
-
-void Epoller::mod(int fd, long long data, __uint32_t event)
-{
-    ctrl(fd, data, event, EPOLL_CTL_MOD);
-}
-
-void Epoller::del(int fd, long long data, __uint32_t event)
-{
-    ctrl(fd, data, event, EPOLL_CTL_DEL);
-}
-
-int Epoller::wait(int millsecond)
-{
-    return epoll_wait(_iEpollfd, _pevs, _max_connections + 1, millsecond);
-}
-
-}
-
-

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/kpr/Epoller.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/kpr/Epoller.h b/rocketmq-client4cpp/src/kpr/Epoller.h
deleted file mode 100755
index d3d161b..0000000
--- a/rocketmq-client4cpp/src/kpr/Epoller.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
-* Copyright (C) 2013 suwenkuang ,hooligan_520@qq.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __KPR_EPOLLER_H_
-#define __KPR_EPOLLER_H_
-
-#include <unistd.h>
-#include <sys/epoll.h>
-#include <cassert>
-
-namespace kpr
-{
-
-
-class Epoller
-{
-public:
-    Epoller(bool bEt = true);
-    ~Epoller();
-
-
-    void create(int max_connections);
-
-    void add(int fd, long long data, __uint32_t event);
-    void mod(int fd, long long data, __uint32_t event);
-    void del(int fd, long long data, __uint32_t event);
-
-    int wait(int millsecond);
-
-    struct epoll_event& get(int i)
-    {
-        assert(_pevs != 0);
-        return _pevs[i];
-    }
-
-protected:
-    void ctrl(int fd, long long data, __uint32_t events, int op);
-
-protected:
-    int _iEpollfd;
-    int _max_connections;
-    struct epoll_event* _pevs;
-    bool _et;
-};
-
-}
-#endif
-
-

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/kpr/Exception.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/kpr/Exception.h b/rocketmq-client4cpp/src/kpr/Exception.h
deleted file mode 100755
index 524af84..0000000
--- a/rocketmq-client4cpp/src/kpr/Exception.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/**
- * Copyright (C) 2013 kangliqiang ,kangliq@163.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef __KPR_EXCEPTION_H
-#define __KPR_EXCEPTION_H
-
-#include "KPRTypes.h"
-#include <exception>
-#include <string>
-#include <sstream>
-
-namespace kpr
-{
-class Exception : public std::exception
-{
-public:
-    Exception(const char* msg, int error, const char* file, int line)throw()
-        : m_error(error), m_line(line), m_msg(msg), m_file(file)
-    {
-        try
-        {
-            std::stringstream ss;
-            ss << "[" << file << ":" << line << "]|error: " << error << "|msg:" << msg;
-            m_msg = ss.str();
-        }
-        catch (...)
-        {
-        }
-    }
-
-    virtual ~Exception()throw()
-    {
-    }
-
-    const char* what() const throw()
-    {
-        return m_msg.c_str();
-    }
-
-    int GetError() const throw()
-    {
-        return m_error;
-    }
-
-    virtual const char* GetType() const throw()
-    {
-        return "Exception";
-    }
-
-protected:
-    int m_error;
-    int m_line;
-    std::string m_msg;
-    std::string m_file;
-};
-}
-
-inline std::ostream& operator<<(std::ostream& os, const kpr::Exception& e)
-{
-    os << "Type:" << e.GetType() <<  e.what();
-    return os;
-}
-
-#define DEFINE_EXCEPTION(name) \
-    class name : public kpr::Exception \
-    {\
-    public:\
-        name(const char* msg, int error,const char* file,int line) throw ()\
-            : Exception(msg,error,file,line) {}\
-        virtual const char* GetType() const throw()\
-        {\
-            return #name;\
-        }\
-    };
-
-namespace kpr
-{
-DEFINE_EXCEPTION(SystemCallException);
-DEFINE_EXCEPTION(NotImplementException);
-DEFINE_EXCEPTION(InterruptedException);
-DEFINE_EXCEPTION(FileUtilException);
-DEFINE_EXCEPTION(RefHandleNullException);
-
-};
-
-#define THROW_EXCEPTION(e,msg,err) throw e(msg,err,__FILE__,__LINE__);
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/kpr/FileUtil.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/kpr/FileUtil.cpp b/rocketmq-client4cpp/src/kpr/FileUtil.cpp
deleted file mode 100755
index aa239e4..0000000
--- a/rocketmq-client4cpp/src/kpr/FileUtil.cpp
+++ /dev/null
@@ -1,523 +0,0 @@
-/**
-* Copyright (C) 2013 suwenkuang ,hooligan_520@qq.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#include <string.h>
-#include <time.h>
-#include <errno.h>
-#include <unistd.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <stdarg.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <cassert>
-#include <cstdio>
-#include <string>
-#include <iostream>
-#include <sstream>
-#include <stdexcept>
-#include <algorithm>
-#include <map>
-#include <stack>
-#include <vector>
-
-#include "FileUtil.h"
-#include "KPRUtil.h"
-#include "Exception.h"
-
-
-namespace kpr
-{
-
-std::ifstream::pos_type FileUtil::getFileSize(const std::string& sFullFileName)
-{
-    std::ifstream ifs(sFullFileName.c_str());
-    ifs.seekg(0, std::ios_base::end);
-    return ifs.tellg();
-}
-
-bool FileUtil::isAbsolute(const std::string& sFullFileName)
-{
-    if (sFullFileName.empty())
-    {
-        return false;
-    }
-
-    unsigned i = 0;
-    while (isspace(sFullFileName[i]))
-    {
-        ++i;
-    }
-
-    return sFullFileName[i] == '/';
-}
-
-bool FileUtil::isFileExist(const std::string& sFullFileName, mode_t iFileType)
-{
-    struct stat f_stat;
-
-    if (lstat(sFullFileName.c_str(), &f_stat) == -1)
-    {
-        return false;
-    }
-
-    if (!(f_stat.st_mode & iFileType))
-    {
-        return false;
-    }
-
-    return true;
-}
-
-bool FileUtil::isFileExistEx(const std::string& sFullFileName, mode_t iFileType)
-{
-    struct stat f_stat;
-
-    if (stat(sFullFileName.c_str(), &f_stat) == -1)
-    {
-        return false;
-    }
-
-    if (!(f_stat.st_mode & iFileType))
-    {
-        return false;
-    }
-
-    return true;
-}
-
-bool FileUtil::makeDir(const std::string& sDirectoryPath, mode_t iFlag)
-{
-    int iRetCode = mkdir(sDirectoryPath.c_str(), iFlag);
-    if (iRetCode < 0 && errno == EEXIST)
-    {
-        return isFileExistEx(sDirectoryPath, S_IFDIR);
-    }
-
-    return iRetCode == 0;
-}
-
-bool FileUtil::makeDirRecursive(const std::string& sDirectoryPath, mode_t iFlag)
-{
-    std::string simple = simplifyDirectory(sDirectoryPath);
-
-    std::string::size_type pos = 0;
-    for (; pos != std::string::npos;)
-    {
-        pos = simple.find("/", pos + 1);
-        std::string s;
-        if (pos == std::string::npos)
-        {
-            s = simple.substr(0, simple.size());
-            return makeDir(s.c_str(), iFlag);
-        }
-        else
-        {
-            s = simple.substr(0, pos);
-            if (!makeDir(s.c_str(), iFlag))
-            {
-                return false;
-            }
-        }
-    }
-    return true;
-}
-
-int FileUtil::setExecutable(const std::string& sFullFileName, bool canExecutable)
-{
-    struct stat f_stat;
-
-    if (stat(sFullFileName.c_str(), &f_stat) == -1)
-    {
-        return -1;
-    }
-
-    return chmod(sFullFileName.c_str(), canExecutable ? f_stat.st_mode | S_IXUSR : f_stat.st_mode & ~S_IXUSR);
-}
-
-bool FileUtil::canExecutable(const std::string& sFullFileName)
-{
-    struct stat f_stat;
-
-    if (stat(sFullFileName.c_str(), &f_stat) == -1)
-    {
-        return false;
-    }
-
-    return f_stat.st_mode & S_IXUSR;
-}
-
-int FileUtil::removeFile(const std::string& sFullFileName, bool bRecursive)
-{
-    std::string path = simplifyDirectory(sFullFileName);
-
-    if (isFileExist(path, S_IFDIR))
-    {
-        if (bRecursive)
-        {
-            std::vector<std::string> files;
-            listDirectory(path, files, false);
-            for (size_t i = 0; i < files.size(); i++)
-            {
-                removeFile(files[i], bRecursive);
-            }
-
-            if (path != "/")
-            {
-                if (::rmdir(path.c_str()) == -1)
-                {
-                    return -1;
-                }
-                return 0;
-            }
-        }
-        else
-        {
-            if (::rmdir(path.c_str()) == -1)
-            {
-                return -1;
-            }
-        }
-    }
-    else
-    {
-        if (::remove(path.c_str()) == -1)
-        {
-            return -1;
-        }
-    }
-
-    return 0;
-}
-
-std::string FileUtil::simplifyDirectory(const std::string& path)
-{
-    std::string result = path;
-
-    std::string::size_type pos;
-
-    pos = 0;
-    while ((pos = result.find("//", pos)) != std::string::npos)
-    {
-        result.erase(pos, 1);
-    }
-
-    pos = 0;
-    while ((pos = result.find("/./", pos)) != std::string::npos)
-    {
-        result.erase(pos, 2);
-    }
-
-    while (result.substr(0, 4) == "/../")
-    {
-        result.erase(0, 3);
-    }
-
-    if (result == "/.")
-    {
-        return result.substr(0, result.size() - 1);
-    }
-
-    if (result.size() >= 2 && result.substr(result.size() - 2, 2) == "/.")
-    {
-        result.erase(result.size() - 2, 2);
-    }
-
-    if (result == "/")
-    {
-        return result;
-    }
-
-    if (result.size() >= 1 && result[result.size() - 1] == '/')
-    {
-        result.erase(result.size() - 1);
-    }
-
-    if (result == "/..")
-    {
-        result = "/";
-    }
-
-    return result;
-}
-
-std::string FileUtil::load2str(const std::string& sFullFileName)
-{
-    std::ifstream ifs(sFullFileName.c_str());
-    if (!ifs)
-    {
-        return "";
-    }
-    return std::string(std::istreambuf_iterator<char>(ifs), std::istreambuf_iterator<char>());
-}
-
-void FileUtil::save2file(const std::string& sFullFileName, const std::string& sFileData)
-{
-    std::ofstream ofs((sFullFileName).c_str());
-    ofs << sFileData;
-    ofs.close();
-}
-
-int FileUtil::save2file(const std::string& sFullFileName, const char* sFileData, size_t length)
-{
-    FILE* fp = fopen(sFullFileName.c_str(), "wb");
-    if (fp == NULL)
-    {
-        return -1;
-    }
-
-    size_t ret = fwrite((void*)sFileData, 1, length, fp);
-    fclose(fp);
-
-    if (ret == length)
-    {
-        return 0;
-    }
-    return -1;
-}
-
-std::string FileUtil::getExePath()
-{
-    std::string proc = "/proc/self/exe";
-    char buf[2048] = "\0";
-
-    int bufsize = sizeof(buf) / sizeof(char);
-
-    int count = readlink(proc.c_str(), buf, bufsize);
-
-    if (count < 0)
-    {
-        THROW_EXCEPTION(FileUtilException, "could not get exe path error", errno);
-    }
-
-    count = (count >= bufsize) ? (bufsize - 1) : count;
-
-    buf[count] = '\0';
-    return buf;
-}
-
-std::string FileUtil::extractFileName(const std::string& sFullFileName)
-{
-    if (sFullFileName.length() <= 0)
-    {
-        return "";
-    }
-
-    std::string::size_type pos = sFullFileName.rfind('/');
-    if (pos == std::string::npos)
-    {
-        return sFullFileName;
-    }
-
-    return sFullFileName.substr(pos + 1);
-}
-
-std::string FileUtil::extractFilePath(const std::string& sFullFileName)
-{
-    if (sFullFileName.length() <= 0)
-    {
-        return "./";
-    }
-
-    std::string::size_type pos = 0;
-
-    for (pos = sFullFileName.length(); pos != 0 ; --pos)
-    {
-        if (sFullFileName[pos - 1] == '/')
-        {
-            return sFullFileName.substr(0, pos);
-        }
-    }
-
-    return "./";
-}
-
-std::string FileUtil::extractFileExt(const std::string& sFullFileName)
-{
-    std::string::size_type pos;
-    if ((pos = sFullFileName.rfind('.')) == std::string::npos)
-    {
-        return std::string("");
-    }
-
-    return sFullFileName.substr(pos + 1);
-}
-
-std::string FileUtil::excludeFileExt(const std::string& sFullFileName)
-{
-    std::string::size_type pos;
-    if ((pos = sFullFileName.rfind('.')) == std::string::npos)
-    {
-        return sFullFileName;
-    }
-
-    return sFullFileName.substr(0, pos);
-}
-
-std::string FileUtil::replaceFileExt(const std::string& sFullFileName, const std::string& sExt)
-{
-    return excludeFileExt(sFullFileName) + "." + sExt;
-}
-
-std::string FileUtil::extractUrlFilePath(const std::string& sUrl)
-{
-    std::string sLowerUrl = KPRUtil::lower(sUrl);
-    std::string::size_type pos = sLowerUrl.find("http://");
-
-    if (pos == 0)
-    {
-        pos += strlen("http://");
-    }
-    else if (pos == std::string::npos)
-    {
-        pos = 0;
-    }
-
-    for (; pos < sUrl.length(); ++pos)
-    {
-        if (sUrl[pos] == '/')
-        {
-            if (pos < sUrl.length() - 1)
-            {
-                pos++;
-                break;
-            }
-            else
-            {
-                return "";
-            }
-        }
-    }
-
-    if (pos == std::string::npos || pos == sUrl.length())
-    {
-        pos = 0;
-    }
-
-    return sUrl.substr(pos);
-}
-
-size_t FileUtil::scanDir(const std::string& sFilePath, std::vector<std::string>& vtMatchFiles, FILE_SELECT f, int iMaxSize)
-{
-    vtMatchFiles.clear();
-
-    struct dirent** namelist;
-    int n = scandir(sFilePath.c_str(), &namelist, f, alphasort);
-
-    if (n < 0)
-    {
-        return 0;
-    }
-    else
-    {
-        while (n--)
-        {
-            if (iMaxSize > 0 && vtMatchFiles.size() >= (size_t)iMaxSize)
-            {
-                free(namelist[n]);
-                break;
-            }
-            else
-            {
-                vtMatchFiles.push_back(namelist[n]->d_name);
-                free(namelist[n]);
-            }
-        }
-        free(namelist);
-    }
-
-    return vtMatchFiles.size();
-}
-
-void FileUtil::listDirectory(const std::string& path, std::vector<std::string>& files, bool bRecursive)
-{
-    std::vector<std::string> tf;
-    scanDir(path, tf, 0, 0);
-
-    for (size_t i = 0; i < tf.size(); i++)
-    {
-        if (tf[i] == "." || tf[i] == "..")
-        {
-            continue;
-        }
-
-        std::string s = path + "/" + tf[i];
-
-        if (isFileExist(s, S_IFDIR))
-        {
-            files.push_back(simplifyDirectory(s));
-            if (bRecursive)
-            {
-                listDirectory(s, files, bRecursive);
-            }
-        }
-        else
-        {
-            files.push_back(simplifyDirectory(s));
-        }
-    }
-}
-
-void FileUtil::copyFile(const std::string& sExistFile, const std::string& sNewFile, bool bRemove)
-{
-    if (FileUtil::isFileExist(sExistFile, S_IFDIR))
-    {
-        FileUtil::makeDir(sNewFile);
-        std::vector<std::string> tf;
-        FileUtil::scanDir(sExistFile, tf, 0, 0);
-        for (size_t i = 0; i < tf.size(); i++)
-        {
-            if (tf[i] == "." || tf[i] == "..")
-            {
-                continue;
-            }
-            std::string s = sExistFile + "/" + tf[i];
-            std::string d = sNewFile + "/" + tf[i];
-            copyFile(s, d, bRemove);
-        }
-    }
-    else
-    {
-        if (bRemove)
-        {
-            std::remove(sNewFile.c_str());
-        }
-        std::ifstream fin(sExistFile.c_str());
-        if (!fin)
-        {
-            THROW_EXCEPTION(FileUtilException, "[FileUtil::copyFile] infile open fail", errno);
-        }
-        std::ofstream fout(sNewFile.c_str());
-        if (!fout)
-        {
-            THROW_EXCEPTION(FileUtilException, "[FileUtil::copyFile] newfile open fail", errno);
-        }
-        struct stat f_stat;
-        if (stat(sExistFile.c_str(), &f_stat) == -1)
-        {
-            THROW_EXCEPTION(FileUtilException, "[FileUtil::copyFile] infile stat fail", errno);
-        }
-        chmod(sNewFile.c_str(), f_stat.st_mode);
-        fout << fin.rdbuf();
-        fin.close();
-        fout.close();
-
-    }
-}
-
-}
-

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/kpr/FileUtil.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/kpr/FileUtil.h b/rocketmq-client4cpp/src/kpr/FileUtil.h
deleted file mode 100755
index c1e8518..0000000
--- a/rocketmq-client4cpp/src/kpr/FileUtil.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/**
-* Copyright (C) 2013 suwenkuang ,hooligan_520@qq.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __KPR_FILEUTIL_H_
-#define __KPR_FILEUTIL_H_
-
-#include <iostream>
-#include <fstream>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <dirent.h>
-#include <fnmatch.h>
-
-
-#include <string>
-#include <vector>
-
-
-namespace kpr
-{
-
-class FileUtil
-{
-public:
-
-    static std::ifstream::pos_type getFileSize(const std::string& sFullFileName);
-
-    static bool isAbsolute(const std::string& sFullFileName);
-
-    static bool isFileExist(const std::string& sFullFileName, mode_t iFileType = S_IFREG);
-
-    static bool isFileExistEx(const std::string& sFullFileName, mode_t iFileType = S_IFREG);
-
-    static std::string simplifyDirectory(const std::string& path);
-
-    static bool makeDir(const std::string& sDirectoryPath, mode_t iFlag = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH |  S_IXOTH);
-
-    static bool makeDirRecursive(const std::string& sDirectoryPath, mode_t iFlag = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH |  S_IXOTH);
-
-    static int setExecutable(const std::string& sFullFileName, bool canExecutable);
-
-    static bool canExecutable(const std::string& sFullFileName);
-
-    static int removeFile(const std::string& sFullFileName, bool bRecursive);
-
-    static std::string load2str(const std::string& sFullFileName);
-
-    static void save2file(const std::string& sFullFileName, const std::string& sFileData);
-
-    static int save2file(const std::string& sFullFileName, const char* sFileData, size_t length);
-
-    static std::string getExePath();
-
-    static std::string extractFileName(const std::string& sFullFileName);
-
-    static std::string extractFilePath(const std::string& sFullFileName);
-
-    static std::string extractFileExt(const std::string& sFullFileName);
-
-    static std::string excludeFileExt(const std::string& sFullFileName);
-
-    static std::string replaceFileExt(const std::string& sFullFileName, const std::string& sExt);
-
-    static std::string extractUrlFilePath(const std::string& sUrl);
-
-    typedef int (*FILE_SELECT)(const dirent*);
-
-    static size_t scanDir(const std::string& sFilePath, std::vector<std::string>& vtMatchFiles, FILE_SELECT f = NULL, int iMaxSize = 0);
-
-    static void listDirectory(const std::string& path, std::vector<std::string>& files, bool bRecursive);
-
-    static void copyFile(const std::string& sExistFile, const std::string& sNewFile, bool bRemove = false);
-};
-
-}
-#endif // __FILE_UTIL_H_

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/kpr/KPRTypes.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/kpr/KPRTypes.h b/rocketmq-client4cpp/src/kpr/KPRTypes.h
deleted file mode 100755
index 0a54123..0000000
--- a/rocketmq-client4cpp/src/kpr/KPRTypes.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * Copyright (C) 2013 kangliqiang ,kangliq@163.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef __KPR_TYPES_H__
-#define __KPR_TYPES_H__
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <unistd.h>
-#include <sys/time.h>
-#include <pthread.h>
-#include <semaphore.h>
-
-
-typedef pthread_key_t ThreadKey;
-
-
-namespace kpr
-{
-class ThreadId
-{
-public:
-    ThreadId(pthread_t id = 0)
-        : m_threadId(id)
-    {
-    }
-
-    bool operator==(const ThreadId& id) const
-    {
-        return m_threadId == id.m_threadId;
-    }
-
-    bool operator!=(const ThreadId& id) const
-    {
-        return !(*this == id);
-    }
-
-    operator pthread_t() const
-    {
-        return m_threadId;
-    }
-
-    static ThreadId GetCurrentThreadId()
-    {
-        return ThreadId(pthread_self());
-    }
-
-    pthread_t m_threadId;
-};
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/kpr/KPRUtil.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/kpr/KPRUtil.cpp b/rocketmq-client4cpp/src/kpr/KPRUtil.cpp
deleted file mode 100755
index fe2cdd2..0000000
--- a/rocketmq-client4cpp/src/kpr/KPRUtil.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- * Copyright (C) 2013 kangliqiang ,kangliq@163.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "KPRUtil.h"
-#include <assert.h>
-
-
-
-unsigned long long KPRUtil::GetCurrentTimeMillis()
-{
-    struct timeval tv;
-    gettimeofday(&tv, 0);
-    return tv.tv_sec * 1000ULL + tv.tv_usec / 1000;
-}
-
-struct timespec KPRUtil::CalcAbsTime(long timeout)
-{
-    assert(timeout >= 0);
-    struct timeval tv;
-    gettimeofday(&tv, 0);
-
-    struct timespec abstime;
-    abstime.tv_sec = tv.tv_sec + (timeout / 1000);
-    abstime.tv_nsec = (tv.tv_usec * 1000) + ((timeout % 1000) * 1000000);
-    if (abstime.tv_nsec >= 1000000000)
-    {
-        ++abstime.tv_sec;
-        abstime.tv_nsec -= 1000000000;
-    }
-
-    return abstime;
-}
-
-long long KPRUtil::str2ll(const char* str)
-{
-    return atoll(str);
-}
-
-
-std::string KPRUtil::lower(const std::string& s)
-{
-    std::string sString = s;
-    for (std::string::iterator iter = sString.begin(); iter != sString.end(); ++iter)
-    {
-        *iter = tolower(*iter);
-    }
-
-    return sString;
-}
-
-std::string KPRUtil::upper(const std::string& s)
-{
-    std::string sString = s;
-
-    for (std::string::iterator iter = sString.begin(); iter != sString.end(); ++iter)
-    {
-        *iter = toupper(*iter);
-    }
-
-    return sString;
-}
-
-
-

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/kpr/KPRUtil.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/kpr/KPRUtil.h b/rocketmq-client4cpp/src/kpr/KPRUtil.h
deleted file mode 100755
index ae2c529..0000000
--- a/rocketmq-client4cpp/src/kpr/KPRUtil.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * Copyright (C) 2013 kangliqiang ,kangliq@163.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef __KPR_UTIL_H__
-#define __KPR_UTIL_H__
-
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <stdlib.h>
-#include <string>
-
-
-class KPRUtil
-{
-public:
-	static struct timespec CalcAbsTime(long timeout);
-	static unsigned long long GetCurrentTimeMillis();
-	static long long str2ll(const char* str);
-    static std::string lower(const std::string& s);
-    static std::string upper(const std::string& s);
-};
-
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/kpr/Monitor.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/kpr/Monitor.cpp b/rocketmq-client4cpp/src/kpr/Monitor.cpp
deleted file mode 100644
index d715f55..0000000
--- a/rocketmq-client4cpp/src/kpr/Monitor.cpp
+++ /dev/null
@@ -1,125 +0,0 @@
-/**
- * Copyright (C) 2013 kangliqiang ,kangliq@163.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "Monitor.h"
-#include <assert.h>
-
-namespace kpr
-{
-Monitor::Monitor()
-    : m_notifyCount(0)
-{
-}
-
-Monitor::~Monitor()
-{
-}
-
-void Monitor::Wait()
-{
-    validateOwner(m_mutex.GetOwner(), "wait()");
-
-    notify(m_notifyCount);
-
-    try
-    {
-        m_condition.Wait(m_mutex);
-    }
-    catch (...)
-    {
-        m_notifyCount = 0;
-        throw;
-    }
-    m_notifyCount = 0;
-}
-
-void Monitor::Wait(long timeout)
-{
-    validateOwner(m_mutex.GetOwner(), "wait(long)");
-
-    notify(m_notifyCount);
-    try
-    {
-        m_condition.Wait(m_mutex, timeout);
-    }
-    catch (...)
-    {
-        m_notifyCount = 0;
-        throw;
-    }
-
-    m_notifyCount = 0;
-}
-
-void Monitor::Notify()
-{
-    validateOwner(m_mutex.GetOwner(), "notify");
-
-    if (m_notifyCount != -1)
-    {
-        ++m_notifyCount;
-    }
-}
-
-void Monitor::NotifyAll()
-{
-    validateOwner(m_mutex.GetOwner(), "notifyAll");
-
-    m_notifyCount = -1;
-}
-
-void Monitor::Lock() const
-{
-    if (m_mutex.Lock())
-    {
-        m_notifyCount = 0;
-    }
-}
-
-void Monitor::Unlock() const
-{
-    if (m_mutex.GetCount() == 1)
-    {
-        ((Monitor*)this)->notify(m_notifyCount);
-    }
-
-    m_mutex.Unlock();
-}
-
-void Monitor::notify(int nnotify)
-{
-    if (nnotify != 0)
-    {
-        if (nnotify == -1)
-        {
-            m_condition.NotifyAll();
-            return;
-        }
-        else
-        {
-            while (nnotify > 0)
-            {
-                m_condition.Notify();
-                --nnotify;
-            }
-        }
-    }
-}
-
-void Monitor::validateOwner(const ThreadId& id, const char* caller) const
-{
-    assert(id == ThreadId::GetCurrentThreadId());
-}
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/kpr/Monitor.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/kpr/Monitor.h b/rocketmq-client4cpp/src/kpr/Monitor.h
deleted file mode 100644
index 345f736..0000000
--- a/rocketmq-client4cpp/src/kpr/Monitor.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * Copyright (C) 2013 kangliqiang ,kangliq@163.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef __KPR_MONITOR_H__
-#define __KPR_MONITOR_H__
-
-#include "KPRTypes.h"
-#include "Condition.h"
-#include "Mutex.h"
-namespace kpr
-{
-class Monitor
-{
-public:
-    Monitor();
-    virtual ~Monitor();
-
-    void Wait();
-    void Wait(long msec);
-
-    void Notify();
-    void NotifyAll();
-
-    void Lock() const;
-    void Unlock() const;
-
-private:
-    void notify(int times);
-    void validateOwner(const ThreadId& id, const char* caller) const;
-
-    RecursiveMutex m_mutex;
-    Condition m_condition;
-    mutable int m_notifyCount;
-};
-}
-#endif


[10/17] incubator-rocketmq-externals git commit: Polish cpp module

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/consumer/PullRequest.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/consumer/PullRequest.cpp b/rocketmq-client4cpp/src/consumer/PullRequest.cpp
deleted file mode 100755
index b8650c6..0000000
--- a/rocketmq-client4cpp/src/consumer/PullRequest.cpp
+++ /dev/null
@@ -1,108 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#include "PullRequest.h"
-#include "UtilAll.h"
-
-namespace rmq
-{
-
-PullRequest::~PullRequest()
-{
-
-}
-
-std::string PullRequest::getConsumerGroup()
-{
-    return m_consumerGroup;
-}
-
-void PullRequest::setConsumerGroup(const std::string& consumerGroup)
-{
-    m_consumerGroup = consumerGroup;
-}
-
-MessageQueue& PullRequest::getMessageQueue()
-{
-    return m_messageQueue;
-}
-
-void PullRequest::setMessageQueue(const MessageQueue& messageQueue)
-{
-    m_messageQueue = messageQueue;
-}
-
-long long PullRequest::getNextOffset()
-{
-    return m_nextOffset;
-}
-
-void PullRequest::setNextOffset(long long nextOffset)
-{
-    m_nextOffset = nextOffset;
-}
-
-int PullRequest::hashCode()
-{
-    /*
-    final int prime = 31;
-    int result = 1;
-    result = prime * result + ((consumerGroup == null) ? 0 : consumerGroup.hashCode());
-    result = prime * result + ((messageQueue == null) ? 0 : messageQueue.hashCode());
-    return result;
-    */
-    std::stringstream ss;
-    ss  << m_consumerGroup
-        << m_messageQueue.hashCode();
-    return UtilAll::hashCode(ss.str());
-}
-
-std::string PullRequest::toString() const
-{
-    std::stringstream ss;
-    ss << "{consumerGroup=" << m_consumerGroup
-       << ",messageQueue=" << m_messageQueue.toString()
-       << ",nextOffset=" << m_nextOffset << "}";
-    return ss.str();
-}
-
-
-bool PullRequest::operator==(const PullRequest& other)
-{
-    if (m_consumerGroup != other.m_consumerGroup)
-    {
-        return false;
-    }
-
-    if (!(m_messageQueue == other.m_messageQueue))
-    {
-        return false;
-    }
-
-    return true;
-}
-
-ProcessQueue* PullRequest::getProcessQueue()
-{
-    return m_pProcessQueue;
-}
-
-void PullRequest::setProcessQueue(ProcessQueue* pProcessQueue)
-{
-    m_pProcessQueue = pProcessQueue;
-}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/consumer/PullRequest.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/consumer/PullRequest.h b/rocketmq-client4cpp/src/consumer/PullRequest.h
deleted file mode 100755
index 3fb8367..0000000
--- a/rocketmq-client4cpp/src/consumer/PullRequest.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __PULLREQUEST_H__
-#define __PULLREQUEST_H__
-
-#include <string>
-#include <sstream>
-
-#include "MessageQueue.h"
-#include "ProcessQueue.h"
-
-namespace rmq
-{
-    class PullRequest
-    {
-    public:
-        virtual ~PullRequest();
-
-        std::string getConsumerGroup();
-        void setConsumerGroup(const std::string& consumerGroup);
-
-        MessageQueue& getMessageQueue();
-        void setMessageQueue(const MessageQueue& messageQueue);
-
-        long long getNextOffset();
-        void setNextOffset(long long nextOffset);
-
-        int hashCode();
-        std::string toString() const;
-
-        bool operator==(const PullRequest& other);
-
-        ProcessQueue* getProcessQueue();
-        void setProcessQueue(ProcessQueue* pProcessQueue);
-
-    private:
-        std::string m_consumerGroup;
-        MessageQueue m_messageQueue;
-
-        ProcessQueue* m_pProcessQueue;
-        long long m_nextOffset;
-    };
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/consumer/PullResultExt.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/consumer/PullResultExt.h b/rocketmq-client4cpp/src/consumer/PullResultExt.h
deleted file mode 100755
index 24235b2..0000000
--- a/rocketmq-client4cpp/src/consumer/PullResultExt.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __PULLRESULTEXT_H__
-#define __PULLRESULTEXT_H__
-
-#include "PullResult.h"
-
-namespace rmq
-{
-
-  struct PullResultExt : public PullResult
-  {
-      PullResultExt(PullStatus pullStatus,
-                    long long nextBeginOffset,
-                    long long minOffset,
-                    long long maxOffset,
-                    std::list<MessageExt*>& msgFoundList,
-                    long suggestWhichBrokerId,
-                    const char* messageBinary,
-                    int messageBinaryLen)
-          : PullResult(pullStatus,
-                       nextBeginOffset,
-                       minOffset,
-                       maxOffset,
-                       msgFoundList),
-          suggestWhichBrokerId(suggestWhichBrokerId),
-          messageBinary(messageBinary),
-          messageBinaryLen(messageBinaryLen)
-      {
-
-      }
-
-      long suggestWhichBrokerId;
-      const char* messageBinary;
-      int messageBinaryLen;
-  };
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/consumer/RebalanceImpl.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/consumer/RebalanceImpl.cpp b/rocketmq-client4cpp/src/consumer/RebalanceImpl.cpp
deleted file mode 100755
index efdc1cc..0000000
--- a/rocketmq-client4cpp/src/consumer/RebalanceImpl.cpp
+++ /dev/null
@@ -1,613 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#include "RebalanceImpl.h"
-#include "AllocateMessageQueueStrategy.h"
-#include "MQClientFactory.h"
-#include "MixAll.h"
-#include "LockBatchBody.h"
-#include "MQClientAPIImpl.h"
-#include "KPRUtil.h"
-#include "ScopedLock.h"
-
-namespace rmq
-{
-
-RebalanceImpl::RebalanceImpl(const std::string& consumerGroup,
-                             MessageModel messageModel,
-                             AllocateMessageQueueStrategy* pAllocateMessageQueueStrategy,
-                             MQClientFactory* pMQClientFactory)
-    : m_consumerGroup(consumerGroup),
-      m_messageModel(messageModel),
-      m_pAllocateMessageQueueStrategy(pAllocateMessageQueueStrategy),
-      m_pMQClientFactory(pMQClientFactory)
-{
-
-}
-
-RebalanceImpl::~RebalanceImpl()
-{
-}
-
-void RebalanceImpl::unlock(MessageQueue& mq, bool oneway)
-{
-    FindBrokerResult findBrokerResult =
-        m_pMQClientFactory->findBrokerAddressInSubscribe(mq.getBrokerName(), MixAll::MASTER_ID, true);
-    if (!findBrokerResult.brokerAddr.empty())
-    {
-        UnlockBatchRequestBody* requestBody = new UnlockBatchRequestBody();
-        requestBody->setConsumerGroup(m_consumerGroup);
-        requestBody->setClientId(m_pMQClientFactory->getClientId());
-        requestBody->getMqSet().insert(mq);
-
-        try
-        {
-            m_pMQClientFactory->getMQClientAPIImpl()->unlockBatchMQ(findBrokerResult.brokerAddr,
-                    requestBody, 1000, oneway);
-        }
-        catch (...)
-        {
-            RMQ_ERROR("unlockBatchMQ exception, MQ: {%s}" , mq.toString().c_str());
-        }
-    }
-}
-
-void RebalanceImpl::unlockAll(bool oneway)
-{
-    std::map<std::string, std::set<MessageQueue> > brokerMqs = buildProcessQueueTableByBrokerName();
-    std::map<std::string, std::set<MessageQueue> >::iterator it = brokerMqs.begin();
-
-    for (; it != brokerMqs.end(); it++)
-    {
-        std::string brokerName = it->first;
-        std::set<MessageQueue> mqs = it->second;
-
-        if (mqs.empty())
-        {
-            continue;
-        }
-
-        FindBrokerResult findBrokerResult =
-            m_pMQClientFactory->findBrokerAddressInSubscribe(brokerName, MixAll::MASTER_ID, true);
-
-        if (!findBrokerResult.brokerAddr.empty())
-        {
-            UnlockBatchRequestBody* requestBody = new UnlockBatchRequestBody();
-            requestBody->setConsumerGroup(m_consumerGroup);
-            requestBody->setClientId(m_pMQClientFactory->getClientId());
-            requestBody->setMqSet(mqs);
-
-            try
-            {
-                m_pMQClientFactory->getMQClientAPIImpl()->unlockBatchMQ(findBrokerResult.brokerAddr,
-                        requestBody, 1000, oneway);
-
-                kpr::ScopedRLock<kpr::RWMutex> lock(m_processQueueTableLock);
-                std::set<MessageQueue>::iterator itm = mqs.begin();
-                for (; itm != mqs.end(); itm++)
-                {
-                    std::map<MessageQueue, ProcessQueue*>::iterator itp = m_processQueueTable.find(*itm);
-                    if (itp != m_processQueueTable.end())
-                    {
-                        itp->second->setLocked(false);
-                        RMQ_INFO("the message queue unlock OK, Group: {%s}, MQ: {%s}",
-                                 m_consumerGroup.c_str(), (*itm).toString().c_str());
-                    }
-                }
-            }
-            catch (...)
-            {
-                RMQ_ERROR("unlockBatchMQ exception, mqs.size: {%u} ", (unsigned)mqs.size());
-            }
-        }
-    }
-}
-
-bool RebalanceImpl::lock(MessageQueue& mq)
-{
-    FindBrokerResult findBrokerResult =
-        m_pMQClientFactory->findBrokerAddressInSubscribe(mq.getBrokerName(), MixAll::MASTER_ID, true);
-    if (!findBrokerResult.brokerAddr.empty())
-    {
-        LockBatchRequestBody* requestBody = new LockBatchRequestBody();
-        requestBody->setConsumerGroup(m_consumerGroup);
-        requestBody->setClientId(m_pMQClientFactory->getClientId());
-        requestBody->getMqSet().insert(mq);
-
-        try
-        {
-            std::set<MessageQueue> lockedMq =
-                m_pMQClientFactory->getMQClientAPIImpl()->lockBatchMQ(
-                    findBrokerResult.brokerAddr, requestBody, 1000);
-
-            std::set<MessageQueue>::iterator it = lockedMq.begin();
-            for (; it != lockedMq.end(); it++)
-            {
-                kpr::ScopedRLock<kpr::RWMutex> lock(m_processQueueTableLock);
-                MessageQueue mmqq = *it;
-                std::map<MessageQueue, ProcessQueue*>::iterator itt = m_processQueueTable.find(mmqq);
-                if (itt != m_processQueueTable.end())
-                {
-                    itt->second->setLocked(true);
-                    itt->second->setLastLockTimestamp(KPRUtil::GetCurrentTimeMillis());
-                }
-            }
-
-            it = lockedMq.find(mq);
-            bool lockOK = (it != lockedMq.end());
-
-            RMQ_INFO("the message queue lock {%s}, {%s}, {%s}",//
-                     (lockOK ? "OK" : "Failed"), //
-                     m_consumerGroup.c_str(), //
-                     mq.toString().c_str());
-            return lockOK;
-        }
-        catch (...)
-        {
-            RMQ_ERROR("lockBatchMQ exception, MQ: {%s}", mq.toString().c_str());
-        }
-    }
-
-    return false;
-}
-
-void RebalanceImpl::lockAll()
-{
-    std::map<std::string, std::set<MessageQueue> > brokerMqs = buildProcessQueueTableByBrokerName();
-
-    std::map<std::string, std::set<MessageQueue> >::iterator it = brokerMqs.begin();
-    for (; it != brokerMqs.end(); it++)
-    {
-        std::string brokerName = it->first;
-        std::set<MessageQueue> mqs = it->second;
-
-        if (mqs.empty())
-        {
-            continue;
-        }
-
-        FindBrokerResult findBrokerResult =
-            m_pMQClientFactory->findBrokerAddressInSubscribe(brokerName, MixAll::MASTER_ID, true);
-        if (!findBrokerResult.brokerAddr.empty())
-        {
-            LockBatchRequestBody* requestBody = new LockBatchRequestBody();
-            requestBody->setConsumerGroup(m_consumerGroup);
-            requestBody->setClientId(m_pMQClientFactory->getClientId());
-            requestBody->setMqSet(mqs);
-
-            try
-            {
-                std::set<MessageQueue> lockOKMQSet =
-                    m_pMQClientFactory->getMQClientAPIImpl()->lockBatchMQ(
-                        findBrokerResult.brokerAddr, requestBody, 1000);
-
-                std::set<MessageQueue>::iterator its = lockOKMQSet.begin();
-                for (; its != lockOKMQSet.end(); its++)
-                {
-                    kpr::ScopedRLock<kpr::RWMutex> lock(m_processQueueTableLock);
-                    MessageQueue mq = *its;
-                    std::map<MessageQueue, ProcessQueue*>::iterator itt = m_processQueueTable.find(mq);
-                    if (itt != m_processQueueTable.end())
-                    {
-                        ProcessQueue* processQueue = itt->second;
-                        if (!processQueue->isLocked())
-                        {
-                            RMQ_INFO("the message queue locked OK, Group: {%s}, MQ: %s",
-                            	m_consumerGroup.c_str(),
-                            	mq.toString().c_str());
-                        }
-
-                        processQueue->setLocked(true);
-                        processQueue->setLastLockTimestamp(KPRUtil::GetCurrentTimeMillis());
-                    }
-                }
-
-                its = mqs.begin();
-                for (; its != mqs.end(); its++)
-                {
-                    MessageQueue mq = *its;
-                    std::set<MessageQueue>::iterator itf = lockOKMQSet.find(mq);
-                    if (itf == lockOKMQSet.end())
-                    {
-                        kpr::ScopedRLock<kpr::RWMutex> lock(m_processQueueTableLock);
-                        std::map<MessageQueue, ProcessQueue*>::iterator itt = m_processQueueTable.find(mq);
-                        if (itt != m_processQueueTable.end())
-                        {
-                            itt->second->setLocked(false);
-                            RMQ_WARN("the message queue locked Failed, Group: {%s}, MQ: %s",
-                            	m_consumerGroup.c_str(),
-                            	mq.toString().c_str());
-                        }
-                    }
-                }
-            }
-            catch (std::exception& e)
-            {
-                RMQ_ERROR("lockBatchMQ exception: %s", e.what());
-            }
-        }
-    }
-}
-
-void RebalanceImpl::doRebalance()
-{
-    std::map<std::string, SubscriptionData> subTable = getSubscriptionInner();
-    std::map<std::string, SubscriptionData>::iterator it = subTable.begin();
-    for (; it != subTable.end(); it++)
-    {
-        std::string topic = it->first;
-        try
-        {
-            rebalanceByTopic(topic);
-        }
-        catch (std::exception& e)
-        {
-            if (topic.find(MixAll::RETRY_GROUP_TOPIC_PREFIX) != 0)
-            {
-                RMQ_WARN("rebalanceByTopic Exception: %s", e.what());
-            }
-        }
-    }
-
-    truncateMessageQueueNotMyTopic();
-}
-
-std::map<std::string, SubscriptionData>& RebalanceImpl::getSubscriptionInner()
-{
-    return m_subscriptionInner;
-}
-
-std::map<MessageQueue, ProcessQueue*>& RebalanceImpl::getProcessQueueTable()
-{
-    return m_processQueueTable;
-}
-
-
-kpr::RWMutex& RebalanceImpl::getProcessQueueTableLock()
-{
-	return m_processQueueTableLock;
-}
-
-
-std::map<std::string, std::set<MessageQueue> >& RebalanceImpl::getTopicSubscribeInfoTable()
-{
-    return m_topicSubscribeInfoTable;
-}
-
-std::string& RebalanceImpl::getConsumerGroup()
-{
-    return m_consumerGroup;
-}
-
-void RebalanceImpl::setConsumerGroup(const std::string& consumerGroup)
-{
-    m_consumerGroup = consumerGroup;
-}
-
-MessageModel RebalanceImpl::getMessageModel()
-{
-    return m_messageModel;
-}
-
-void RebalanceImpl::setMessageModel(MessageModel messageModel)
-{
-    m_messageModel = messageModel;
-}
-
-AllocateMessageQueueStrategy* RebalanceImpl::getAllocateMessageQueueStrategy()
-{
-    return m_pAllocateMessageQueueStrategy;
-}
-
-void RebalanceImpl::setAllocateMessageQueueStrategy(AllocateMessageQueueStrategy* pAllocateMessageQueueStrategy)
-{
-    m_pAllocateMessageQueueStrategy = pAllocateMessageQueueStrategy;
-}
-
-MQClientFactory* RebalanceImpl::getmQClientFactory()
-{
-    return m_pMQClientFactory;
-}
-
-void RebalanceImpl::setmQClientFactory(MQClientFactory* pMQClientFactory)
-{
-    m_pMQClientFactory = pMQClientFactory;
-}
-
-std::map<std::string, std::set<MessageQueue> > RebalanceImpl::buildProcessQueueTableByBrokerName()
-{
-	std::map<std::string, std::set<MessageQueue> > result ;
-    kpr::ScopedRLock<kpr::RWMutex> lock(m_processQueueTableLock);
-    std::map<MessageQueue, ProcessQueue*>::iterator it = m_processQueueTable.begin();
-    for (; it != m_processQueueTable.end();)
-    {
-        MessageQueue mq = it->first;
-        std::map<std::string, std::set<MessageQueue> >::iterator itm = result.find(mq.getBrokerName());
-        if (itm == result.end())
-        {
-            std::set<MessageQueue> mqs ;
-            mqs.insert(mq);
-            result[mq.getBrokerName()] = mqs;
-        }
-        else
-        {
-            itm->second.insert(mq);
-        }
-    }
-
-    return result;
-}
-
-void RebalanceImpl::rebalanceByTopic(const std::string& topic)
-{
-	RMQ_DEBUG("rebalanceByTopic begin, topic={%s}", topic.c_str());
-    switch (m_messageModel)
-    {
-        case BROADCASTING:
-        {
-            //kpr::ScopedLock<kpr::Mutex> lock(m_topicSubscribeInfoTableLock);
-            std::map<std::string, std::set<MessageQueue> >::iterator it = m_topicSubscribeInfoTable.find(topic);
-            if (it != m_topicSubscribeInfoTable.end())
-            {
-                std::set<MessageQueue> mqSet = it->second;
-                bool changed = updateProcessQueueTableInRebalance(topic, mqSet);
-                if (changed)
-                {
-                    messageQueueChanged(topic, mqSet, mqSet);
-                    RMQ_INFO("messageQueueChanged {%s} {%s} {%s} {%s}",
-                             m_consumerGroup.c_str(),
-                             topic.c_str(),
-                             UtilAll::toString(mqSet).c_str(),
-                             UtilAll::toString(mqSet).c_str());
-                }
-            }
-            else
-            {
-                RMQ_WARN("doRebalance, {%s}, but the topic[%s] not exist.", m_consumerGroup.c_str(), topic.c_str());
-            }
-            break;
-        }
-        case CLUSTERING:
-        {
-            //kpr::ScopedLock<kpr::Mutex> lock(m_topicSubscribeInfoTableLock);
-            std::map<std::string, std::set<MessageQueue> >::iterator it = m_topicSubscribeInfoTable.find(topic);
-            if (it == m_topicSubscribeInfoTable.end())
-            {
-                if (topic.find(MixAll::RETRY_GROUP_TOPIC_PREFIX) != 0)
-                {
-                    RMQ_WARN("doRebalance, %s, but the topic[%s] not exist.", m_consumerGroup.c_str(), topic.c_str());
-                }
-            }
-
-            std::list<std::string> cidAll = m_pMQClientFactory->findConsumerIdList(topic, m_consumerGroup);
-            if (cidAll.empty())
-            {
-                RMQ_WARN("doRebalance, %s:%s, get consumer id list failed.", m_consumerGroup.c_str(), topic.c_str());
-            }
-
-            if (it != m_topicSubscribeInfoTable.end() && !cidAll.empty())
-            {
-                std::vector<MessageQueue> mqAll;
-                std::set<MessageQueue> mqSet = it->second;
-                std::set<MessageQueue>::iterator its = mqSet.begin();
-
-                for (; its != mqSet.end(); its++)
-                {
-                    mqAll.push_back(*its);
-                }
-
-                cidAll.sort();
-
-                AllocateMessageQueueStrategy* strategy = m_pAllocateMessageQueueStrategy;
-
-                std::vector<MessageQueue>* allocateResult = NULL;
-                try
-                {
-                    allocateResult = strategy->allocate(m_consumerGroup,
-                    	m_pMQClientFactory->getClientId(), mqAll, cidAll);
-                }
-                catch (std::exception& e)
-                {
-                    RMQ_ERROR("AllocateMessageQueueStrategy.allocate Exception, allocateMessageQueueStrategyName={%s}, mqAll={%s}, cidAll={%s}, %s",
-                    	strategy->getName().c_str(), UtilAll::toString(mqAll).c_str(), UtilAll::toString(cidAll).c_str(), e.what());
-                    return;
-                }
-
-                std::set<MessageQueue> allocateResultSet;
-                if (allocateResult != NULL)
-                {
-                    for (size_t i = 0; i < allocateResult->size(); i++)
-                    {
-                        allocateResultSet.insert(allocateResult->at(i));
-                    }
-
-                    delete allocateResult;
-                }
-
-                bool changed = updateProcessQueueTableInRebalance(topic, allocateResultSet);
-                if (changed)
-                {
-                    RMQ_INFO("rebalanced result changed. allocateMessageQueueStrategyName={%s}, group={%s}, topic={%s}, ConsumerId={%s}, "
-                             "rebalanceSize={%u}, rebalanceMqSet={%s}, mqAllSize={%u}, cidAllSize={%u}, mqAll={%s}, cidAll={%s}",
-                             strategy->getName().c_str(), m_consumerGroup.c_str(), topic.c_str(), m_pMQClientFactory->getClientId().c_str(),
-                             (unsigned)allocateResultSet.size(), UtilAll::toString(allocateResultSet).c_str(),
-                             (unsigned)mqAll.size(), (unsigned)cidAll.size(), UtilAll::toString(mqAll).c_str(), UtilAll::toString(cidAll).c_str()
-                            );
-
-                    messageQueueChanged(topic, mqSet, allocateResultSet);
-                }
-            }
-        }
-        break;
-        default:
-            break;
-    }
-    RMQ_DEBUG("rebalanceByTopic end");
-}
-
-
-void RebalanceImpl::removeProcessQueue(const MessageQueue& mq)
-{
-	kpr::ScopedRLock<kpr::RWMutex> lock(m_processQueueTableLock);
-	std::map<MessageQueue, ProcessQueue*>::iterator it = m_processQueueTable.find(mq);
-	if (it != m_processQueueTable.end())
-	{
-		MessageQueue mq = it->first;
-        ProcessQueue* pq = it->second;
-        bool isDroped = pq->isDropped();
-
-        this->removeUnnecessaryMessageQueue(mq, *pq);
-        RMQ_INFO("Fix Offset, {%s}, remove unnecessary mq, {%s} Droped: {%d}",
-        	m_consumerGroup.c_str(), mq.toString().c_str(), isDroped);
-	}
-}
-
-
-bool RebalanceImpl::updateProcessQueueTableInRebalance(const std::string& topic, std::set<MessageQueue>& mqSet)
-{
-	RMQ_DEBUG("updateProcessQueueTableInRebalance begin, topic={%s}", topic.c_str());
-    bool changed = false;
-
-    {
-        kpr::ScopedWLock<kpr::RWMutex> lock(m_processQueueTableLock);
-        std::map<MessageQueue, ProcessQueue*>::iterator it = m_processQueueTable.begin();
-        for (; it != m_processQueueTable.end();)
-        {
-        	std::map<MessageQueue, ProcessQueue*>::iterator itCur = it++;
-            MessageQueue mq = itCur->first;
-            ProcessQueue* pq = itCur->second;
-            if (mq.getTopic() == topic)
-            {
-                std::set<MessageQueue>::iterator itMq = mqSet.find(mq);
-                if (itMq == mqSet.end())
-                {
-                    pq->setDropped(true);
-        			if (this->removeUnnecessaryMessageQueue(mq, *pq))
-        			{
-        				changed = true;
-        				m_processQueueTable.erase(itCur);
-
-        				RMQ_WARN("doRebalance, {%s}, remove unnecessary mq, {%s}",
-        					m_consumerGroup.c_str(), mq.toString().c_str());
-        			}
-                }
-                else if (pq->isPullExpired())
-                {
-                	switch(this->consumeType())
-                	{
-                		case CONSUME_ACTIVELY:
-                            break;
-                        case CONSUME_PASSIVELY:
-                        	pq->setDropped(true);
-        					if (this->removeUnnecessaryMessageQueue(mq, *pq))
-        					{
-        						changed = true;
-                            	m_processQueueTable.erase(itCur);
-
-                            	RMQ_ERROR("[BUG]doRebalance, {%s}, remove unnecessary mq, {%s}, because pull is pause, so try to fixed it",
-                                    m_consumerGroup.c_str(), mq.toString().c_str());
-        					}
-                            break;
-                        default:
-                            break;
-                	}
-                }
-            }
-        }
-    }
-
-    std::list<PullRequest*> pullRequestList;
-    std::set<MessageQueue>::iterator its = mqSet.begin();
-    for (; its != mqSet.end(); its++)
-    {
-        MessageQueue mq = *its;
-        bool find = false;
-        {
-            kpr::ScopedRLock<kpr::RWMutex> lock(m_processQueueTableLock);
-            std::map<MessageQueue, ProcessQueue*>::iterator itm = m_processQueueTable.find(mq);
-            if (itm != m_processQueueTable.end())
-            {
-                find = true;
-            }
-        }
-
-        if (!find)
-        {
-        	//todo: memleak
-            PullRequest* pullRequest = new PullRequest();
-            pullRequest->setConsumerGroup(m_consumerGroup);
-            pullRequest->setMessageQueue(mq);
-            pullRequest->setProcessQueue(new ProcessQueue());//todo: memleak
-
-            long long nextOffset = computePullFromWhere(mq);
-            if (nextOffset >= 0)
-            {
-                pullRequest->setNextOffset(nextOffset);
-                pullRequestList.push_back(pullRequest);
-                changed = true;
-
-				{
-	                kpr::ScopedWLock<kpr::RWMutex> lock(m_processQueueTableLock);
-	                m_processQueueTable[mq] = pullRequest->getProcessQueue();
-	                RMQ_INFO("doRebalance, {%s}, add a new mq, {%s}, pullRequst: %s",
-	                	m_consumerGroup.c_str(), mq.toString().c_str(), pullRequest->toString().c_str());
-                }
-            }
-            else
-            {
-                RMQ_WARN("doRebalance, {%s}, add new mq failed, {%s}",
-                	m_consumerGroup.c_str(), mq.toString().c_str());
-            }
-        }
-    }
-
-    //todo memleak
-    dispatchPullRequest(pullRequestList);
-    RMQ_DEBUG("updateProcessQueueTableInRebalance end");
-
-    return changed;
-}
-
-void RebalanceImpl::truncateMessageQueueNotMyTopic()
-{
-    std::map<std::string, SubscriptionData> subTable = getSubscriptionInner();
-
-    kpr::ScopedWLock<kpr::RWMutex> lock(m_processQueueTableLock);
-    std::map<MessageQueue, ProcessQueue*>::iterator it = m_processQueueTable.begin();
-    for (; it != m_processQueueTable.end();)
-    {
-        MessageQueue mq = it->first;
-        std::map<std::string, SubscriptionData>::iterator itt = subTable.find(mq.getTopic());
-
-        if (itt == subTable.end())
-        {
-            ProcessQueue* pq = it->second;
-            if (pq != NULL)
-            {
-                pq->setDropped(true);
-                RMQ_WARN("doRebalance, {%s}, truncateMessageQueueNotMyTopic remove unnecessary mq, {%s}",
-                         m_consumerGroup.c_str(), mq.toString().c_str());
-            }
-            m_processQueueTable.erase(it++);
-        }
-        else
-        {
-            it++;
-        }
-    }
-}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/consumer/RebalanceImpl.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/consumer/RebalanceImpl.h b/rocketmq-client4cpp/src/consumer/RebalanceImpl.h
deleted file mode 100755
index 577a031..0000000
--- a/rocketmq-client4cpp/src/consumer/RebalanceImpl.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#ifndef __REBALANCEIMPL_H__
-#define __REBALANCEIMPL_H__
-
-#include <map>
-#include <string>
-#include <set>
-#include <list>
-
-#include "ConsumeType.h"
-#include "MessageQueue.h"
-#include "ProcessQueue.h"
-#include "PullRequest.h"
-#include "SubscriptionData.h"
-
-namespace rmq
-{
-    class AllocateMessageQueueStrategy;
-    class MQClientFactory;
-
-    class RebalanceImpl
-    {
-    public:
-        RebalanceImpl(const std::string& consumerGroup,
-                      MessageModel messageModel,
-                      AllocateMessageQueueStrategy* pAllocateMessageQueueStrategy,
-                      MQClientFactory* pMQClientFactory);
-        virtual ~RebalanceImpl();
-
-        virtual void messageQueueChanged(const std::string& topic,
-                                         std::set<MessageQueue>& mqAll,
-                                         std::set<MessageQueue>& mqDivided) = 0;
-        virtual bool removeUnnecessaryMessageQueue(MessageQueue& mq, ProcessQueue& pq) = 0;
-        virtual void dispatchPullRequest(std::list<PullRequest*>& pullRequestList) = 0;
-        virtual long long computePullFromWhere(MessageQueue& mq) = 0;
-		virtual ConsumeType consumeType() = 0;
-
-        bool lock(MessageQueue& mq);
-        void lockAll();
-
-        void unlock(MessageQueue& mq, bool oneway);
-        void unlockAll(bool oneway);
-
-        void doRebalance();
-
-        std::map<MessageQueue, ProcessQueue*>& getProcessQueueTable();
-		kpr::RWMutex& getProcessQueueTableLock();
-		std::map<std::string, SubscriptionData>& getSubscriptionInner();
-        std::map<std::string, std::set<MessageQueue> >& getTopicSubscribeInfoTable();
-
-        std::string& getConsumerGroup();
-        void setConsumerGroup(const std::string& consumerGroup);
-
-        MessageModel getMessageModel();
-        void setMessageModel(MessageModel messageModel);
-
-        AllocateMessageQueueStrategy* getAllocateMessageQueueStrategy();
-        void setAllocateMessageQueueStrategy(AllocateMessageQueueStrategy* pAllocateMessageQueueStrategy);
-
-        MQClientFactory* getmQClientFactory();
-        void setmQClientFactory(MQClientFactory* pMQClientFactory);
-
-		void removeProcessQueue(const MessageQueue& mq);
-
-    private:
-        std::map<std::string, std::set<MessageQueue> > buildProcessQueueTableByBrokerName();
-        void rebalanceByTopic(const std::string& topic);
-        bool updateProcessQueueTableInRebalance(const std::string& topic, std::set<MessageQueue>& mqSet);
-        void truncateMessageQueueNotMyTopic();
-
-    protected:
-        std::map<MessageQueue, ProcessQueue*> m_processQueueTable;
-        kpr::RWMutex m_processQueueTableLock;
-
-        std::map<std::string, std::set<MessageQueue> > m_topicSubscribeInfoTable;
-        kpr::Mutex m_topicSubscribeInfoTableLock;
-
-        std::map<std::string, SubscriptionData> m_subscriptionInner;
-        kpr::Mutex m_subscriptionInnerLock;
-
-        std::string m_consumerGroup;
-        MessageModel m_messageModel;
-        AllocateMessageQueueStrategy* m_pAllocateMessageQueueStrategy;
-        MQClientFactory* m_pMQClientFactory;
-    };
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/consumer/RebalancePullImpl.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/consumer/RebalancePullImpl.cpp b/rocketmq-client4cpp/src/consumer/RebalancePullImpl.cpp
deleted file mode 100755
index 1aa287b..0000000
--- a/rocketmq-client4cpp/src/consumer/RebalancePullImpl.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#include "RebalancePullImpl.h"
-#include "DefaultMQPullConsumerImpl.h"
-#include "AllocateMessageQueueStrategy.h"
-#include "MQClientFactory.h"
-#include "MessageQueueListener.h"
-#include "OffsetStore.h"
-#include "DefaultMQPullConsumer.h"
-
-namespace rmq
-{
-
-RebalancePullImpl::RebalancePullImpl(DefaultMQPullConsumerImpl* pDefaultMQPullConsumerImpl)
-    : RebalanceImpl("", BROADCASTING, NULL, NULL),
-      m_pDefaultMQPullConsumerImpl(pDefaultMQPullConsumerImpl)
-{
-}
-
-RebalancePullImpl::RebalancePullImpl(const std::string& consumerGroup,
-                                     MessageModel messageModel,
-                                     AllocateMessageQueueStrategy* pAllocateMessageQueueStrategy,
-                                     MQClientFactory* pMQClientFactory,
-                                     DefaultMQPullConsumerImpl* pDefaultMQPullConsumerImpl)
-    : RebalanceImpl(consumerGroup, messageModel, pAllocateMessageQueueStrategy, pMQClientFactory),
-      m_pDefaultMQPullConsumerImpl(pDefaultMQPullConsumerImpl)
-{
-}
-
-long long RebalancePullImpl::computePullFromWhere(MessageQueue& mq)
-{
-    return 0;
-}
-
-void RebalancePullImpl::dispatchPullRequest(std::list<PullRequest*>& pullRequestList)
-{
-}
-
-void RebalancePullImpl::messageQueueChanged(const std::string& topic,
-        std::set<MessageQueue>& mqAll,
-        std::set<MessageQueue>& mqDivided)
-{
-    MessageQueueListener* messageQueueListener =
-        m_pDefaultMQPullConsumerImpl->getDefaultMQPullConsumer()->getMessageQueueListener();
-    if (messageQueueListener != NULL)
-    {
-        try
-        {
-            messageQueueListener->messageQueueChanged(topic, mqAll, mqDivided);
-        }
-        catch (...)
-        {
-            RMQ_ERROR("messageQueueChanged exception, %s", topic.c_str());
-        }
-    }
-}
-
-bool RebalancePullImpl::removeUnnecessaryMessageQueue(MessageQueue& mq, ProcessQueue& pq)
-{
-    m_pDefaultMQPullConsumerImpl->getOffsetStore()->persist(mq);
-    m_pDefaultMQPullConsumerImpl->getOffsetStore()->removeOffset(mq);
-    return true;
-}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/consumer/RebalancePullImpl.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/consumer/RebalancePullImpl.h b/rocketmq-client4cpp/src/consumer/RebalancePullImpl.h
deleted file mode 100755
index 46dbcd1..0000000
--- a/rocketmq-client4cpp/src/consumer/RebalancePullImpl.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#ifndef __REBALANCEPULLIMPL_H__
-#define __REBALANCEPULLIMPL_H__
-
-#include "RebalanceImpl.h"
-
-namespace rmq
-{
-class DefaultMQPullConsumerImpl;
-
-class RebalancePullImpl : public RebalanceImpl
-{
-public:
-    RebalancePullImpl(DefaultMQPullConsumerImpl *pDefaultMQPullConsumerImpl);
-
-    RebalancePullImpl(const std::string &consumerGroup,
-                      MessageModel messageModel,
-                      AllocateMessageQueueStrategy *pAllocateMessageQueueStrategy,
-                      MQClientFactory *pMQClientFactory,
-                      DefaultMQPullConsumerImpl *pDefaultMQPullConsumerImpl);
-
-    long long computePullFromWhere(MessageQueue &mq);
-
-    void dispatchPullRequest(std::list<PullRequest *> &pullRequestList);
-
-    void messageQueueChanged(const std::string &topic,
-                             std::set<MessageQueue> &mqAll,
-                             std::set<MessageQueue> &mqDivided);
-
-    bool removeUnnecessaryMessageQueue(MessageQueue &mq, ProcessQueue &pq);
-
-    ConsumeType consumeType()
-    {
-        return CONSUME_ACTIVELY;
-    };
-
-private:
-    DefaultMQPullConsumerImpl *m_pDefaultMQPullConsumerImpl;
-};
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/consumer/RebalancePushImpl.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/consumer/RebalancePushImpl.cpp b/rocketmq-client4cpp/src/consumer/RebalancePushImpl.cpp
deleted file mode 100755
index fde770d..0000000
--- a/rocketmq-client4cpp/src/consumer/RebalancePushImpl.cpp
+++ /dev/null
@@ -1,217 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#include "RebalancePushImpl.h"
-
-#include <string.h>
-#include <limits.h>
-
-#include "DefaultMQPushConsumerImpl.h"
-#include "AllocateMessageQueueStrategy.h"
-#include "MQClientFactory.h"
-#include "MessageQueueListener.h"
-#include "OffsetStore.h"
-#include "DefaultMQPushConsumer.h"
-#include "MQAdminImpl.h"
-
-
-namespace rmq
-{
-
-RebalancePushImpl::RebalancePushImpl(DefaultMQPushConsumerImpl* pDefaultMQPushConsumerImpl)
-    : RebalanceImpl("", BROADCASTING, NULL, NULL),
-      m_pDefaultMQPushConsumerImpl(pDefaultMQPushConsumerImpl)
-{
-}
-
-RebalancePushImpl::RebalancePushImpl(const std::string& consumerGroup,
-                                     MessageModel messageModel,
-                                     AllocateMessageQueueStrategy* pAllocateMessageQueueStrategy,
-                                     MQClientFactory* pMQClientFactory,
-                                     DefaultMQPushConsumerImpl* pDefaultMQPushConsumerImpl)
-    : RebalanceImpl(consumerGroup, messageModel, pAllocateMessageQueueStrategy, pMQClientFactory),
-      m_pDefaultMQPushConsumerImpl(pDefaultMQPushConsumerImpl)
-{
-}
-
-void RebalancePushImpl::dispatchPullRequest(std::list<PullRequest*>& pullRequestList)
-{
-    std::list<PullRequest*>::iterator it = pullRequestList.begin();
-    for (; it != pullRequestList.end(); it++)
-    {
-        m_pDefaultMQPushConsumerImpl->executePullRequestImmediately(*it);
-        RMQ_INFO("doRebalance, {%s}, add a new pull request {%s}",
-        	m_consumerGroup.c_str(), (*it)->toString().c_str());
-    }
-}
-
-long long RebalancePushImpl::computePullFromWhere(MessageQueue& mq)
-{
-    long long result = -1;
-    ConsumeFromWhere consumeFromWhere =
-        m_pDefaultMQPushConsumerImpl->getDefaultMQPushConsumer()->getConsumeFromWhere();
-    OffsetStore* offsetStore = m_pDefaultMQPushConsumerImpl->getOffsetStore();
-
-    switch (consumeFromWhere)
-    {
-    	case CONSUME_FROM_FIRST_OFFSET:
-        {
-            long long lastOffset = offsetStore->readOffset(mq, READ_FROM_STORE);
-            if (lastOffset >= 0)
-            {
-                result = lastOffset;
-            }
-            else if (-1 == lastOffset)
-            {
-                result = 0L;
-            }
-            else
-            {
-                result = -1;
-            }
-            break;
-        }
-        case CONSUME_FROM_LAST_OFFSET:
-        {
-            long long lastOffset = offsetStore->readOffset(mq, READ_FROM_STORE);
-            if (lastOffset >= 0)
-            {
-                result = lastOffset;
-            }
-            else if (-1 == lastOffset)
-            {
-                if (strncmp(MixAll::RETRY_GROUP_TOPIC_PREFIX.c_str(), mq.getTopic().c_str(), MixAll::RETRY_GROUP_TOPIC_PREFIX.size()) == 0)
-                {
-                    result = 0L;
-                }
-                else
-                {
-                    //result = LLONG_MAX;
-                    try
-                    {
-                    	result = m_pMQClientFactory->getMQAdminImpl()->maxOffset(mq);
-                    }
-                    catch(...)
-                    {
-                    	result = -1;
-                    }
-                }
-            }
-            else
-            {
-                result = -1;
-            }
-            break;
-        }
-
-        case CONSUME_FROM_MAX_OFFSET:
-            result = LLONG_MAX;
-            break;
-        case CONSUME_FROM_MIN_OFFSET:
-            result = 0L;
-            break;
-        case CONSUME_FROM_TIMESTAMP:
-        	{
-	        	long long lastOffset = offsetStore->readOffset(mq, READ_FROM_STORE);
-	            if (lastOffset >= 0)
-	            {
-	                result = lastOffset;
-	            }
-	            else if (-1 == lastOffset)
-	            {
-	                if (strncmp(MixAll::RETRY_GROUP_TOPIC_PREFIX.c_str(), mq.getTopic().c_str(), MixAll::RETRY_GROUP_TOPIC_PREFIX.size()) == 0)
-	                {
-	                	//result = LLONG_MAX;
-	                    try
-	                    {
-	                    	result = m_pMQClientFactory->getMQAdminImpl()->maxOffset(mq);
-	                    }
-	                    catch(...)
-	                    {
-	                    	result = -1;
-	                    }
-	                }
-	                else
-	                {
-	                    try
-	                    {
-	                    	long timestamp = UtilAll::str2tm(
-                                    m_pDefaultMQPushConsumerImpl->getDefaultMQPushConsumer()->getConsumeTimestamp(),
-                                    rmq::yyyyMMddHHmmss);
-                        	result = m_pMQClientFactory->getMQAdminImpl()->searchOffset(mq, timestamp);
-	                    }
-	                    catch(...)
-	                    {
-	                    	result = -1;
-	                    }
-	                }
-	            }
-	            else
-	            {
-	                result = -1;
-	            }
-	            break;
-	        }
-        	break;
-        default:
-            break;
-    }
-
-    return result;
-}
-
-void RebalancePushImpl::messageQueueChanged(const std::string& topic,
-        std::set<MessageQueue>& mqAll,
-        std::set<MessageQueue>& mqDivided)
-{
-}
-
-
-bool RebalancePushImpl::removeUnnecessaryMessageQueue(MessageQueue& mq, ProcessQueue& pq)
-{
-    m_pDefaultMQPushConsumerImpl->getOffsetStore()->persist(mq);
-    m_pDefaultMQPushConsumerImpl->getOffsetStore()->removeOffset(mq);
-    if (m_pDefaultMQPushConsumerImpl->isConsumeOrderly()
-    	&& m_pDefaultMQPushConsumerImpl->messageModel() == CLUSTERING)
-    {
-    	if (pq.getLockConsume().TryLock(1000))
-    	{
-	    	try
-	    	{
-	        	this->unlock(mq, true);
-	        }
-	        catch (std::exception& e)
-	        {
-	            RMQ_ERROR("removeUnnecessaryMessageQueue Exception: %s", e.what());
-	        }
-	        pq.getLockConsume().Unlock();
-	   	}
-	   	else
-	   	{
-	   		RMQ_WARN("[WRONG]mq is consuming, so can not unlock it, MQ:%s, maybe hanged for a while, times:{%lld}",
-            	mq.toString().c_str(),
-            	pq.getTryUnlockTimes());
-
-			pq.incTryUnlockTimes();
-	   	}
-
-	   	return false;
-    }
-
-    return true;
-}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/consumer/RebalancePushImpl.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/consumer/RebalancePushImpl.h b/rocketmq-client4cpp/src/consumer/RebalancePushImpl.h
deleted file mode 100755
index 0aa2b0e..0000000
--- a/rocketmq-client4cpp/src/consumer/RebalancePushImpl.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __REBALANCEPUSHIMPL_H__
-#define __REBALANCEPUSHIMPL_H__
-
-#include "RebalanceImpl.h"
-
-namespace rmq
-{
-class DefaultMQPushConsumerImpl;
-
-class RebalancePushImpl : public RebalanceImpl
-{
-public:
-    RebalancePushImpl(DefaultMQPushConsumerImpl *pDefaultMQPushConsumerImpl);
-
-    RebalancePushImpl(const std::string &consumerGroup,
-                      MessageModel messageModel,
-                      AllocateMessageQueueStrategy *pAllocateMessageQueueStrategy,
-                      MQClientFactory *pMQClientFactory,
-                      DefaultMQPushConsumerImpl *pDefaultMQPushConsumerImpl);
-
-    void dispatchPullRequest(std::list<PullRequest *> &pullRequestList);
-    long long computePullFromWhere(MessageQueue &mq);
-    void messageQueueChanged(const std::string &topic,
-                             std::set<MessageQueue> &mqAll,
-                             std::set<MessageQueue> &mqDivided);
-    bool removeUnnecessaryMessageQueue(MessageQueue &mq, ProcessQueue &pq);
-
-
-    ConsumeType consumeType()
-    {
-        return CONSUME_PASSIVELY;
-    };
-
-private:
-    DefaultMQPushConsumerImpl *m_pDefaultMQPushConsumerImpl;
-};
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/consumer/RebalanceService.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/consumer/RebalanceService.cpp b/rocketmq-client4cpp/src/consumer/RebalanceService.cpp
deleted file mode 100644
index 013fefb..0000000
--- a/rocketmq-client4cpp/src/consumer/RebalanceService.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#include "RebalanceService.h"
-#include "MQClientFactory.h"
-
-namespace rmq
-{
-
-long RebalanceService::s_WaitInterval = 1000 * 10;
-
-RebalanceService::RebalanceService(MQClientFactory* pMQClientFactory)
-    : ServiceThread("RebalanceService"),
-      m_pMQClientFactory(pMQClientFactory)
-{
-}
-
-
-RebalanceService::~RebalanceService()
-{
-
-}
-
-void RebalanceService::Run()
-{
-	RMQ_INFO("%s service started", getServiceName().c_str());
-
-    while (!m_stoped)
-    {
-        waitForRunning(s_WaitInterval);
-        m_pMQClientFactory->doRebalance();
-    }
-
-    RMQ_INFO("%s service end", getServiceName().c_str());
-}
-
-std::string RebalanceService::getServiceName()
-{
-    return "RebalanceService";
-}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/consumer/RebalanceService.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/consumer/RebalanceService.h b/rocketmq-client4cpp/src/consumer/RebalanceService.h
deleted file mode 100755
index ef4d746..0000000
--- a/rocketmq-client4cpp/src/consumer/RebalanceService.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#ifndef __REBALANCESERVICE_H__
-#define __REBALANCESERVICE_H__
-
-#include "ServiceThread.h"
-
-namespace rmq
-{
-	class MQClientFactory;
-
-	/**
-	* Rebalance service
-	*
-	*/
-	class RebalanceService : public ServiceThread
-	{
-	public:
-	    RebalanceService(MQClientFactory* pMQClientFactory);
-	    ~RebalanceService();
-
-	    void Run();
-	    std::string getServiceName();
-
-	private:
-	    MQClientFactory* m_pMQClientFactory;
-	    static long s_WaitInterval;
-	};
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/consumer/RemoteBrokerOffsetStore.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/consumer/RemoteBrokerOffsetStore.cpp b/rocketmq-client4cpp/src/consumer/RemoteBrokerOffsetStore.cpp
deleted file mode 100755
index 1c4fd23..0000000
--- a/rocketmq-client4cpp/src/consumer/RemoteBrokerOffsetStore.cpp
+++ /dev/null
@@ -1,266 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#include "RemoteBrokerOffsetStore.h"
-#include "MQClientFactory.h"
-#include "ScopedLock.h"
-#include "MQClientException.h"
-#include "CommandCustomHeader.h"
-#include "MQClientAPIImpl.h"
-
-namespace rmq
-{
-
-RemoteBrokerOffsetStore::RemoteBrokerOffsetStore(MQClientFactory* pMQClientFactory, const std::string& groupName)
-{
-    m_pMQClientFactory = pMQClientFactory;
-    m_groupName = groupName;
-}
-
-void RemoteBrokerOffsetStore::load()
-{
-
-}
-
-void RemoteBrokerOffsetStore::updateOffset(const MessageQueue& mq, long long offset, bool increaseOnly)
-{
-    kpr::ScopedWLock<kpr::RWMutex> lock(m_tableMutex);
-    typeof(m_offsetTable.begin()) it = m_offsetTable.find(mq);
-    if (it == m_offsetTable.end())
-    {
-        m_offsetTable[mq] = offset;
-        it = m_offsetTable.find(mq);
-    }
-
-    kpr::AtomicLong& offsetOld = it->second;
-    if (increaseOnly)
-    {
-        MixAll::compareAndIncreaseOnly(offsetOld, offset);
-    }
-    else
-    {
-        offsetOld.set(offset);
-    }
-}
-
-long long RemoteBrokerOffsetStore::readOffset(const MessageQueue& mq, ReadOffsetType type)
-{
-    RMQ_DEBUG("readOffset, MQ:%s, type:%d", mq.toString().c_str(), type);
-    switch (type)
-    {
-        case MEMORY_FIRST_THEN_STORE:
-        case READ_FROM_MEMORY:
-        {
-            kpr::ScopedRLock<kpr::RWMutex> lock(m_tableMutex);
-            typeof(m_offsetTable.begin()) it = m_offsetTable.find(mq);
-            if (it != m_offsetTable.end())
-            {
-                return it->second.get();
-            }
-            else if (READ_FROM_MEMORY == type)
-            {
-                RMQ_DEBUG("No offset in memory, MQ:%s", mq.toString().c_str());
-                return -1;
-            }
-        }
-        case READ_FROM_STORE:
-        {
-            try
-            {
-                long long brokerOffset = this->fetchConsumeOffsetFromBroker(mq);
-                RMQ_DEBUG("fetchConsumeOffsetFromBroker, MQ:%s, brokerOffset:%lld",
-                          mq.toString().c_str(), brokerOffset);
-                if (brokerOffset >= 0)
-                {
-                    this->updateOffset(mq, brokerOffset, false);
-                }
-                return brokerOffset;
-            }
-            // No offset in broker
-            catch (const MQBrokerException& e)
-            {
-                RMQ_WARN("No offset in broker, MQ:%s, exception:%s", mq.toString().c_str(), e.what());
-                return -1;
-            }
-            catch (const std::exception& e)
-            {
-                RMQ_ERROR("fetchConsumeOffsetFromBroker exception, MQ:%s, msg:%s",
-                          mq.toString().c_str(), e.what());
-                return -2;
-            }
-            catch (...)
-            {
-                RMQ_ERROR("fetchConsumeOffsetFromBroker unknow exception, MQ:%s",
-                          mq.toString().c_str());
-                return -2;
-            }
-        }
-        default:
-            break;
-    }
-
-    return -1;
-}
-
-void RemoteBrokerOffsetStore::persistAll(std::set<MessageQueue>& mqs)
-{
-    if (mqs.empty())
-    {
-        return;
-    }
-
-    std::set<MessageQueue> unusedMQ;
-    long long times = m_storeTimesTotal.fetchAndAdd(1);
-
-    kpr::ScopedRLock<kpr::RWMutex> lock(m_tableMutex);
-    for (typeof(m_offsetTable.begin()) it = m_offsetTable.begin();
-         it != m_offsetTable.end(); it++)
-    {
-        MessageQueue mq = it->first;
-        kpr::AtomicLong& offset = it->second;
-        if (mqs.find(mq) != mqs.end())
-        {
-            try
-            {
-                this->updateConsumeOffsetToBroker(mq, offset.get());
-                if ((times % 12) == 0)
-                {
-                    RMQ_INFO("updateConsumeOffsetToBroker, Group: {%s} ClientId: {%s}  mq:{%s} offset {%llu}",
-                             m_groupName.c_str(),
-                             m_pMQClientFactory->getClientId().c_str(),
-                             mq.toString().c_str(),
-                             offset.get());
-                }
-            }
-            catch (...)
-            {
-                RMQ_ERROR("updateConsumeOffsetToBroker exception, mq=%s", mq.toString().c_str());
-            }
-        }
-        else
-        {
-            unusedMQ.insert(mq);
-        }
-    }
-
-    if (!unusedMQ.empty())
-    {
-        for (typeof(unusedMQ.begin()) it = unusedMQ.begin(); it != unusedMQ.end(); it++)
-        {
-            m_offsetTable.erase(*it);
-            RMQ_INFO("remove unused mq, %s, %s", it->toString().c_str(), m_groupName.c_str());
-        }
-    }
-}
-
-void RemoteBrokerOffsetStore::persist(const MessageQueue& mq)
-{
-    kpr::ScopedRLock<kpr::RWMutex> lock(m_tableMutex);
-    typeof(m_offsetTable.begin()) it = m_offsetTable.find(mq);
-    if (it != m_offsetTable.end())
-    {
-        try
-        {
-            this->updateConsumeOffsetToBroker(mq, it->second.get());
-            RMQ_DEBUG("updateConsumeOffsetToBroker ok, mq=%s, offset=%lld", mq.toString().c_str(), it->second.get());
-        }
-        catch (...)
-        {
-            RMQ_ERROR("updateConsumeOffsetToBroker exception, mq=%s", mq.toString().c_str());
-        }
-    }
-}
-
-void RemoteBrokerOffsetStore::removeOffset(const MessageQueue& mq)
-{
-    kpr::ScopedWLock<kpr::RWMutex> lock(m_tableMutex);
-    m_offsetTable.erase(mq);
-    RMQ_INFO("remove unnecessary messageQueue offset. mq=%s, offsetTableSize=%u",
-             mq.toString().c_str(), (unsigned)m_offsetTable.size());
-}
-
-
-std::map<MessageQueue, long long> RemoteBrokerOffsetStore::cloneOffsetTable(const std::string& topic)
-{
-    kpr::ScopedRLock<kpr::RWMutex> lock(m_tableMutex);
-    std::map<MessageQueue, long long> cloneOffsetTable;
-    RMQ_FOR_EACH(m_offsetTable, it)
-    {
-        MessageQueue mq = it->first;
-        kpr::AtomicLong& offset = it->second;
-        if (topic == mq.getTopic())
-        {
-            cloneOffsetTable[mq] = offset.get();
-        }
-    }
-
-    return cloneOffsetTable;
-}
-
-
-void RemoteBrokerOffsetStore::updateConsumeOffsetToBroker(const MessageQueue& mq, long long offset)
-{
-    FindBrokerResult findBrokerResult = m_pMQClientFactory->findBrokerAddressInAdmin(mq.getBrokerName());
-    if (findBrokerResult.brokerAddr.empty())
-    {
-        m_pMQClientFactory->updateTopicRouteInfoFromNameServer(mq.getTopic());
-        findBrokerResult = m_pMQClientFactory->findBrokerAddressInAdmin(mq.getBrokerName());
-    }
-
-    if (!findBrokerResult.brokerAddr.empty())
-    {
-        UpdateConsumerOffsetRequestHeader* requestHeader = new UpdateConsumerOffsetRequestHeader();
-        requestHeader->topic = mq.getTopic();
-        requestHeader->consumerGroup = this->m_groupName;
-        requestHeader->queueId = mq.getQueueId();
-        requestHeader->commitOffset = offset;
-
-        m_pMQClientFactory->getMQClientAPIImpl()->updateConsumerOffsetOneway(
-            findBrokerResult.brokerAddr, requestHeader, 1000 * 5);
-    }
-    else
-    {
-        THROW_MQEXCEPTION(MQClientException, "The broker[" + mq.getBrokerName() + "] not exist", -1);
-    }
-}
-
-long long RemoteBrokerOffsetStore::fetchConsumeOffsetFromBroker(const MessageQueue& mq)
-{
-    FindBrokerResult findBrokerResult = m_pMQClientFactory->findBrokerAddressInAdmin(mq.getBrokerName());
-    if (findBrokerResult.brokerAddr.empty())
-    {
-        // TODO Here may be heavily overhead for Name Server,need tuning
-        m_pMQClientFactory->updateTopicRouteInfoFromNameServer(mq.getTopic());
-        findBrokerResult = m_pMQClientFactory->findBrokerAddressInAdmin(mq.getBrokerName());
-    }
-
-    if (!findBrokerResult.brokerAddr.empty())
-    {
-        QueryConsumerOffsetRequestHeader* requestHeader = new QueryConsumerOffsetRequestHeader();
-        requestHeader->topic = mq.getTopic();
-        requestHeader->consumerGroup = this->m_groupName;
-        requestHeader->queueId = mq.getQueueId();
-
-        return m_pMQClientFactory->getMQClientAPIImpl()->queryConsumerOffset(
-                   findBrokerResult.brokerAddr, requestHeader, 1000 * 5);
-    }
-    else
-    {
-        THROW_MQEXCEPTION(MQClientException, "The broker[" + mq.getBrokerName() + "] not exist", -1);
-    }
-}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/consumer/RemoteBrokerOffsetStore.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/consumer/RemoteBrokerOffsetStore.h b/rocketmq-client4cpp/src/consumer/RemoteBrokerOffsetStore.h
deleted file mode 100755
index b613084..0000000
--- a/rocketmq-client4cpp/src/consumer/RemoteBrokerOffsetStore.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#ifndef __REMOTEBROKEROFFSETSTORE_H__
-#define __REMOTEBROKEROFFSETSTORE_H__
-
-#include "OffsetStore.h"
-#include <map>
-#include <string>
-#include <set>
-#include "MessageQueue.h"
-#include "AtomicValue.h"
-#include "Mutex.h"
-
-namespace rmq
-{
-    class MQClientFactory;
-
-    /**
-    * offset remote store
-    *
-    */
-    class RemoteBrokerOffsetStore : public OffsetStore
-    {
-    public:
-        RemoteBrokerOffsetStore(MQClientFactory* pMQClientFactory, const std::string& groupName) ;
-
-        void load();
-        void updateOffset(const MessageQueue& mq, long long offset, bool increaseOnly);
-        long long readOffset(const MessageQueue& mq, ReadOffsetType type);
-        void persistAll(std::set<MessageQueue>& mqs);
-        void persist(const MessageQueue& mq);
-        void removeOffset(const MessageQueue& mq) ;
-        std::map<MessageQueue, long long> cloneOffsetTable(const std::string& topic);
-
-    private:
-        void updateConsumeOffsetToBroker(const MessageQueue& mq, long long offset);
-        long long fetchConsumeOffsetFromBroker(const MessageQueue& mq);
-
-    private:
-        MQClientFactory* m_pMQClientFactory;
-        std::string m_groupName;
-        kpr::AtomicInteger m_storeTimesTotal;
-        std::map<MessageQueue, kpr::AtomicLong> m_offsetTable;
-        kpr::RWMutex m_tableMutex;
-    };
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/consumer/SubscriptionData.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/consumer/SubscriptionData.cpp b/rocketmq-client4cpp/src/consumer/SubscriptionData.cpp
deleted file mode 100755
index ed5cf12..0000000
--- a/rocketmq-client4cpp/src/consumer/SubscriptionData.cpp
+++ /dev/null
@@ -1,201 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#include "SubscriptionData.h"
-
-#include <sstream>
-#include "KPRUtil.h"
-#include "UtilAll.h"
-
-namespace rmq
-{
-
-std::string SubscriptionData::SUB_ALL = "*";
-
-SubscriptionData::SubscriptionData()
-{
-    m_subVersion = KPRUtil::GetCurrentTimeMillis();
-}
-
-SubscriptionData::SubscriptionData(const std::string& topic, const std::string& subString)
-    : m_topic(topic),
-      m_subString(subString)
-{
-    m_subVersion = KPRUtil::GetCurrentTimeMillis();
-}
-
-std::string SubscriptionData::getTopic()const
-{
-    return m_topic;
-}
-
-void SubscriptionData::setTopic(const std::string& topic)
-{
-    m_topic = topic;
-}
-
-std::string SubscriptionData::getSubString()
-{
-    return m_subString;
-}
-
-void SubscriptionData::setSubString(const std::string& subString)
-{
-    m_subString = subString;
-}
-
-std::set<std::string>& SubscriptionData::getTagsSet()
-{
-    return m_tagsSet;
-}
-
-void SubscriptionData::setTagsSet(const std::set<std::string>& tagsSet)
-{
-    m_tagsSet = tagsSet;
-}
-
-long long SubscriptionData::getSubVersion()
-{
-    return m_subVersion;
-}
-
-void SubscriptionData::setSubVersion(long long subVersion)
-{
-    m_subVersion = subVersion;
-}
-
-std::set<int>& SubscriptionData::getCodeSet()
-{
-    return m_codeSet;
-}
-
-void SubscriptionData::setCodeSet(const std::set<int>& codeSet)
-{
-    m_codeSet = codeSet;
-}
-
-int SubscriptionData::hashCode()
-{
-    /*
-    final int prime = 31;
-    int result = 1;
-    result = prime * result + (classFilterMode ? 1231 : 1237);
-    result = prime * result + ((codeSet == null) ? 0 : codeSet.hashCode());
-    result = prime * result + ((subString == null) ? 0 : subString.hashCode());
-    result = prime * result + ((tagsSet == null) ? 0 : tagsSet.hashCode());
-    result = prime * result + ((topic == null) ? 0 : topic.hashCode());
-    return result;
-    */
-    std::stringstream ss;
-    ss  << UtilAll::hashCode(m_codeSet)
-        << m_subString
-        << UtilAll::hashCode(m_tagsSet)
-        << m_topic;
-    return UtilAll::hashCode(ss.str());
-}
-
-
-
-
-bool SubscriptionData::operator==(const SubscriptionData& other)
-{
-    if (m_codeSet != other.m_codeSet)
-    {
-        return false;
-    }
-
-    if (m_subString != other.m_subString)
-    {
-        return false;
-    }
-
-    if (m_subVersion != other.m_subVersion)
-    {
-        return false;
-    }
-
-    if (m_tagsSet != other.m_tagsSet)
-    {
-        return false;
-    }
-
-    if (m_topic != other.m_topic)
-    {
-        return false;
-    }
-
-    return true;
-}
-
-bool SubscriptionData::operator<(const SubscriptionData& other)const
-{
-    if (m_topic < other.m_topic)
-    {
-        return true;
-    }
-    else if (m_topic == other.m_topic)
-    {
-        if (m_subString < other.m_subString)
-        {
-            return true;
-        }
-        else
-        {
-            return false;
-        }
-    }
-    else
-    {
-        return false;
-    }
-}
-
-void SubscriptionData::toJson(Json::Value& obj) const
-{
-    obj["classFilterMode"] = false;
-    obj["topic"] = m_topic;
-    obj["subString"] = m_subString;
-    obj["subVersion"] = (long long)m_subVersion;
-
-    Json::Value tagSet(Json::arrayValue);
-    RMQ_FOR_EACH(m_tagsSet, it)
-    {
-        tagSet.append(*it);
-    }
-    obj["tagsSet"] = tagSet;
-
-    Json::Value codeSet(Json::arrayValue);
-    RMQ_FOR_EACH(m_codeSet, it)
-    {
-        codeSet.append(*it);
-    }
-    obj["codeSet"] = codeSet;
-}
-
-std::string SubscriptionData::toString() const
-{
-    std::stringstream ss;
-    ss << "{classFilterMode=" << false
-       << ",topic=" << m_topic
-       << ",subString=" << m_subString
-       << ",subVersion=" << m_subVersion
-       << ",tagsSet=" << UtilAll::toString(m_tagsSet)
-       << ",codeSet=" << UtilAll::toString(m_codeSet)
-       << "}";
-    return ss.str();
-}
-
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/consumer/SubscriptionData.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/consumer/SubscriptionData.h b/rocketmq-client4cpp/src/consumer/SubscriptionData.h
deleted file mode 100755
index 4796fb7..0000000
--- a/rocketmq-client4cpp/src/consumer/SubscriptionData.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#ifndef __SUBSCRIPTIONDATA_H__
-#define __SUBSCRIPTIONDATA_H__
-
-#include <string>
-#include <set>
-
-#include "RocketMQClient.h"
-#include "RemotingSerializable.h"
-#include "RefHandle.h"
-#include "json/json.h"
-
-namespace rmq
-{
-    class SubscriptionData : public kpr::RefCount
-    {
-    public:
-        SubscriptionData();
-        SubscriptionData(const std::string& topic, const std::string& subString);
-
-        std::string getTopic()const;
-        void setTopic(const std::string& topic);
-
-        std::string getSubString();
-        void setSubString(const std::string& subString);
-
-        std::set<std::string>& getTagsSet();
-        void setTagsSet(const std::set<std::string>& tagsSet);
-
-        long long getSubVersion();
-        void setSubVersion(long long subVersion);
-
-        std::set<int>& getCodeSet();
-        void setCodeSet(const std::set<int>& codeSet);
-
-        int hashCode();
-        void toJson(Json::Value& obj) const;
-		std::string toString() const;
-
-        bool operator==(const SubscriptionData& other);
-        bool operator<(const SubscriptionData& other)const;
-
-    public:
-        static std::string SUB_ALL;
-
-    private:
-        std::string m_topic;
-        std::string m_subString;
-        std::set<std::string> m_tagsSet;
-        std::set<int> m_codeSet;
-        long long m_subVersion ;
-    };
-	typedef kpr::RefHandleT<SubscriptionData> SubscriptionDataPtr;
-
-	inline std::ostream& operator<<(std::ostream& os, const SubscriptionData& obj)
-	{
-	    os << obj.toString();
-	    return os;
-	}
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/jsoncpp/AUTHORS
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/jsoncpp/AUTHORS b/rocketmq-client4cpp/src/jsoncpp/AUTHORS
deleted file mode 100755
index e69de29..0000000

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/jsoncpp/LICENSE
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/jsoncpp/LICENSE b/rocketmq-client4cpp/src/jsoncpp/LICENSE
deleted file mode 100755
index 403d096..0000000
--- a/rocketmq-client4cpp/src/jsoncpp/LICENSE
+++ /dev/null
@@ -1 +0,0 @@
-The json-cpp library and this documentation are in Public Domain.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/jsoncpp/README.txt
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/jsoncpp/README.txt b/rocketmq-client4cpp/src/jsoncpp/README.txt
deleted file mode 100755
index 379d376..0000000
--- a/rocketmq-client4cpp/src/jsoncpp/README.txt
+++ /dev/null
@@ -1,117 +0,0 @@
-* Introduction:
-  =============
-
-JSON (JavaScript Object Notation) is a lightweight data-interchange format. 
-It can represent integer, real number, string, an ordered sequence of 
-value, and a collection of name/value pairs.
-
-JsonCpp is a simple API to manipulate JSON value, handle serialization 
-and unserialization to string.
-
-It can also preserve existing comment in unserialization/serialization steps,
-making it a convenient format to store user input files.
-
-Unserialization parsing is user friendly and provides precise error reports.
-
-
-* Building/Testing:
-  =================
-
-JsonCpp uses Scons (http://www.scons.org) as a build system. Scons requires
-python to be installed (http://www.python.org).
-
-You download scons-local distribution from the following url:
-http://sourceforge.net/project/showfiles.php?group_id=30337&package_id=67375
-
-Unzip it in the directory where you found this README file. scons.py Should be 
-at the same level as README.
-
-python scons.py platform=PLTFRM [TARGET]
-where PLTFRM may be one of:
-	suncc Sun C++ (Solaris)
-	vacpp Visual Age C++ (AIX)
-	mingw 
-	msvc6 Microsoft Visual Studio 6 service pack 5-6
-	msvc70 Microsoft Visual Studio 2002
-	msvc71 Microsoft Visual Studio 2003
-	msvc80 Microsoft Visual Studio 2005
-	linux-gcc Gnu C++ (linux, also reported to work for Mac OS X)
-	
-adding platform is fairly simple. You need to change the Sconstruct file 
-to do so.
-	
-and TARGET may be:
-	check: build library and run unit tests.
-
-    
-* Running the test manually:
-  ==========================
-
-cd test
-# This will run the Reader/Writer tests
-python runjsontests.py "path to jsontest.exe"
-
-# This will run the Reader/Writer tests, using JSONChecker test suite
-# (http://www.json.org/JSON_checker/).
-# Notes: not all tests pass: JsonCpp is too lenient (for example,
-# it allows an integer to start with '0'). The goal is to improve
-# strict mode parsing to get all tests to pass.
-python runjsontests.py --with-json-checker "path to jsontest.exe"
-
-# This will run the unit tests (mostly Value)
-python rununittests.py "path to test_lib_json.exe"
-
-You can run the tests using valgrind:
-python rununittests.py --valgrind "path to test_lib_json.exe"
-
-
-* Building the documentation:
-  ===========================
-
-Run the python script doxybuild.py from the top directory:
-
-python doxybuild.py --open --with-dot
-
-See doxybuild.py --help for options. 
-
-
-* Adding a reader/writer test:
-  ============================
-
-To add a test, you need to create two files in test/data:
-- a TESTNAME.json file, that contains the input document in JSON format.
-- a TESTNAME.expected file, that contains a flatened representation of 
-  the input document.
-  
-TESTNAME.expected file format:
-- each line represents a JSON element of the element tree represented 
-  by the input document.
-- each line has two parts: the path to access the element separated from
-  the element value by '='. Array and object values are always empty 
-  (e.g. represented by either [] or {}).
-- element path: '.' represented the root element, and is used to separate 
-  object members. [N] is used to specify the value of an array element
-  at index N.
-See test_complex_01.json and test_complex_01.expected to better understand
-element path.
-
-
-* Understanding reader/writer test output:
-  ========================================
-
-When a test is run, output files are generated aside the input test files. 
-Below is a short description of the content of each file:
-
-- test_complex_01.json: input JSON document
-- test_complex_01.expected: flattened JSON element tree used to check if 
-    parsing was corrected.
-
-- test_complex_01.actual: flattened JSON element tree produced by 
-    jsontest.exe from reading test_complex_01.json
-- test_complex_01.rewrite: JSON document written by jsontest.exe using the
-    Json::Value parsed from test_complex_01.json and serialized using
-    Json::StyledWritter.
-- test_complex_01.actual-rewrite: flattened JSON element tree produced by 
-    jsontest.exe from reading test_complex_01.rewrite.
-test_complex_01.process-output: jsontest.exe output, typically useful to
-    understand parsing error.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/jsoncpp/json/allocator.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/jsoncpp/json/allocator.h b/rocketmq-client4cpp/src/jsoncpp/json/allocator.h
deleted file mode 100755
index 1235a3e..0000000
--- a/rocketmq-client4cpp/src/jsoncpp/json/allocator.h
+++ /dev/null
@@ -1,96 +0,0 @@
-// Copyright 2007-2010 Baptiste Lepilleur
-// Distributed under MIT license, or public domain if desired and
-// recognized in your jurisdiction.
-// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
-
-#ifndef CPPTL_JSON_ALLOCATOR_H_INCLUDED
-#define CPPTL_JSON_ALLOCATOR_H_INCLUDED
-
-#include <cstring>
-#include <memory>
-
-namespace rmq {
-namespace Json {
-template<typename T>
-class SecureAllocator {
-	public:
-		// Type definitions
-		using value_type      = T;
-		using pointer         = T*;
-		using const_pointer   = const T*;
-		using reference       = T&;
-		using const_reference = const T&;
-		using size_type       = std::size_t;
-		using difference_type = std::ptrdiff_t;
-
-		/**
-		 * Allocate memory for N items using the standard allocator.
-		 */
-		pointer allocate(size_type n) {
-			// allocate using "global operator new"
-			return static_cast<pointer>(::operator new(n * sizeof(T)));
-		}
-
-		/**
-		 * Release memory which was allocated for N items at pointer P.
-		 *
-		 * The memory block is filled with zeroes before being released.
-		 * The pointer argument is tagged as "volatile" to prevent the
-		 * compiler optimizing out this critical step.
-		 */
-		void deallocate(volatile pointer p, size_type n) {
-			std::memset(p, 0, n * sizeof(T));
-			// free using "global operator delete"
-			::operator delete(p);
-		}
-
-		/**
-		 * Construct an item in-place at pointer P.
-		 */
-		template<typename... Args>
-		void construct(pointer p, Args&&... args) {
-			// construct using "placement new" and "perfect forwarding"
-			::new (static_cast<void*>(p)) T(std::forward<Args>(args)...);
-		}
-
-		size_type max_size() const {
-			return size_t(-1) / sizeof(T);
-		}
-
-		pointer address( reference x ) const {
-			return std::addressof(x);
-		}
-
-		const_pointer address( const_reference x ) const {
-			return std::addressof(x);
-		}
-
-		/**
-		 * Destroy an item in-place at pointer P.
-		 */
-		void destroy(pointer p) {
-			// destroy using "explicit destructor"
-			p->~T();
-		}
-
-		// Boilerplate
-		SecureAllocator() {}
-		template<typename U> SecureAllocator(const SecureAllocator<U>&) {}
-		template<typename U> struct rebind { using other = SecureAllocator<U>; };
-};
-
-
-template<typename T, typename U>
-bool operator==(const SecureAllocator<T>&, const SecureAllocator<U>&) {
-	return true;
-}
-
-template<typename T, typename U>
-bool operator!=(const SecureAllocator<T>&, const SecureAllocator<U>&) {
-	return false;
-}
-
-} //namespace Json
-} //namespace rmq
-
-#endif // CPPTL_JSON_ALLOCATOR_H_INCLUDED

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/jsoncpp/json/assertions.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/jsoncpp/json/assertions.h b/rocketmq-client4cpp/src/jsoncpp/json/assertions.h
deleted file mode 100755
index dc67b27..0000000
--- a/rocketmq-client4cpp/src/jsoncpp/json/assertions.h
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright 2007-2010 Baptiste Lepilleur
-// Distributed under MIT license, or public domain if desired and
-// recognized in your jurisdiction.
-// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
-
-#ifndef CPPTL_JSON_ASSERTIONS_H_INCLUDED
-#define CPPTL_JSON_ASSERTIONS_H_INCLUDED
-
-#include <stdlib.h>
-#include <sstream>
-
-#if !defined(JSON_IS_AMALGAMATION)
-#include "config.h"
-#endif // if !defined(JSON_IS_AMALGAMATION)
-
-/** It should not be possible for a maliciously designed file to
- *  cause an abort() or seg-fault, so these macros are used only
- *  for pre-condition violations and internal logic errors.
- */
-#if JSON_USE_EXCEPTION
-
-// @todo <= add detail about condition in exception
-# define JSON_ASSERT(condition)                                                \
-  {if (!(condition)) {rmq::Json::throwLogicError( "assert json failed" );}}
-
-# define JSON_FAIL_MESSAGE(message)                                            \
-  {                                                                            \
-    JSONCPP_OSTRINGSTREAM oss; oss << message;                                    \
-    rmq::Json::throwLogicError(oss.str());                                          \
-    abort();                                                                   \
-  }
-
-#else // JSON_USE_EXCEPTION
-
-# define JSON_ASSERT(condition) assert(condition)
-
-// The call to assert() will show the failure message in debug builds. In
-// release builds we abort, for a core-dump or debugger.
-# define JSON_FAIL_MESSAGE(message)                                            \
-  {                                                                            \
-    JSONCPP_OSTRINGSTREAM oss; oss << message;                                    \
-    assert(false && oss.str().c_str());                                        \
-    abort();                                                                   \
-  }
-
-
-#endif
-
-#define JSON_ASSERT_MESSAGE(condition, message)                                \
-  if (!(condition)) {                                                          \
-    JSON_FAIL_MESSAGE(message);                                                \
-  }
-
-#endif // CPPTL_JSON_ASSERTIONS_H_INCLUDED

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/jsoncpp/json/autolink.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/jsoncpp/json/autolink.h b/rocketmq-client4cpp/src/jsoncpp/json/autolink.h
deleted file mode 100644
index 6fcc8af..0000000
--- a/rocketmq-client4cpp/src/jsoncpp/json/autolink.h
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2007-2010 Baptiste Lepilleur
-// Distributed under MIT license, or public domain if desired and
-// recognized in your jurisdiction.
-// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
-
-#ifndef JSON_AUTOLINK_H_INCLUDED
-#define JSON_AUTOLINK_H_INCLUDED
-
-#include "config.h"
-
-#ifdef JSON_IN_CPPTL
-#include <cpptl/cpptl_autolink.h>
-#endif
-
-#if !defined(JSON_NO_AUTOLINK) && !defined(JSON_DLL_BUILD) &&                  \
-    !defined(JSON_IN_CPPTL)
-#define CPPTL_AUTOLINK_NAME "json"
-#undef CPPTL_AUTOLINK_DLL
-#ifdef JSON_DLL
-#define CPPTL_AUTOLINK_DLL
-#endif
-#include "autolink.h"
-#endif
-
-#endif // JSON_AUTOLINK_H_INCLUDED


[07/17] incubator-rocketmq-externals git commit: Polish cpp module

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/jsoncpp/json_value.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/jsoncpp/json_value.cpp b/rocketmq-client4cpp/src/jsoncpp/json_value.cpp
deleted file mode 100755
index 427e854..0000000
--- a/rocketmq-client4cpp/src/jsoncpp/json_value.cpp
+++ /dev/null
@@ -1,1612 +0,0 @@
-// Copyright 2011 Baptiste Lepilleur
-// Distributed under MIT license, or public domain if desired and
-// recognized in your jurisdiction.
-// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
-
-#if !defined(JSON_IS_AMALGAMATION)
-#include <json/assertions.h>
-#include <json/value.h>
-#include <json/writer.h>
-#endif // if !defined(JSON_IS_AMALGAMATION)
-#include <math.h>
-#include <sstream>
-#include <utility>
-#include <cstring>
-#include <cassert>
-#ifdef JSON_USE_CPPTL
-#include <cpptl/conststring.h>
-#endif
-#include <cstddef> // size_t
-#include <algorithm> // min()
-
-#define JSON_ASSERT_UNREACHABLE assert(false)
-
-namespace rmq {
-namespace Json {
-
-// This is a walkaround to avoid the static initialization of Value::null.
-// kNull must be word-aligned to avoid crashing on ARM.  We use an alignment of
-// 8 (instead of 4) as a bit of future-proofing.
-#if defined(__ARMEL__)
-#define ALIGNAS(byte_alignment) __attribute__((aligned(byte_alignment)))
-#else
-#define ALIGNAS(byte_alignment)
-#endif
-//static const unsigned char ALIGNAS(8) kNull[sizeof(Value)] = { 0 };
-//const unsigned char& kNullRef = kNull[0];
-//const Value& Value::null = reinterpret_cast<const Value&>(kNullRef);
-//const Value& Value::nullRef = null;
-
-// static
-Value const& Value::nullSingleton()
-{
- static Value const nullStatic;
- return nullStatic;
-}
-
-// for backwards compatibility, we'll leave these global references around, but DO NOT
-// use them in JSONCPP library code any more!
-Value const& Value::null = Value::nullSingleton();
-Value const& Value::nullRef = Value::nullSingleton();
-
-const Int Value::minInt = Int(~(UInt(-1) / 2));
-const Int Value::maxInt = Int(UInt(-1) / 2);
-const UInt Value::maxUInt = UInt(-1);
-#if defined(JSON_HAS_INT64)
-const Int64 Value::minInt64 = Int64(~(UInt64(-1) / 2));
-const Int64 Value::maxInt64 = Int64(UInt64(-1) / 2);
-const UInt64 Value::maxUInt64 = UInt64(-1);
-// The constant is hard-coded because some compiler have trouble
-// converting Value::maxUInt64 to a double correctly (AIX/xlC).
-// Assumes that UInt64 is a 64 bits integer.
-static const double maxUInt64AsDouble = 18446744073709551615.0;
-#endif // defined(JSON_HAS_INT64)
-const LargestInt Value::minLargestInt = LargestInt(~(LargestUInt(-1) / 2));
-const LargestInt Value::maxLargestInt = LargestInt(LargestUInt(-1) / 2);
-const LargestUInt Value::maxLargestUInt = LargestUInt(-1);
-
-#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
-template <typename T, typename U>
-static inline bool InRange(double d, T min, U max) {
-  // The casts can lose precision, but we are looking only for
-  // an approximate range. Might fail on edge cases though. ~cdunn
-  //return d >= static_cast<double>(min) && d <= static_cast<double>(max);
-  return d >= min && d <= max;
-}
-#else  // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
-static inline double integerToDouble(UInt64 value) {
-  return static_cast<double>(Int64(value / 2)) * 2.0 + static_cast<double>(Int64(value & 1));
-}
-
-template <typename T> static inline double integerToDouble(T value) {
-  return static_cast<double>(value);
-}
-
-template <typename T, typename U>
-static inline bool InRange(double d, T min, U max) {
-  return d >= integerToDouble(min) && d <= integerToDouble(max);
-}
-#endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
-
-/** Duplicates the specified string value.
- * @param value Pointer to the string to duplicate. Must be zero-terminated if
- *              length is "unknown".
- * @param length Length of the value. if equals to unknown, then it will be
- *               computed using strlen(value).
- * @return Pointer on the duplicate instance of string.
- */
-static inline char* duplicateStringValue(const char* value,
-                                         size_t length)
-{
-  // Avoid an integer overflow in the call to malloc below by limiting length
-  // to a sane value.
-  if (length >= static_cast<size_t>(Value::maxInt))
-    length = Value::maxInt - 1;
-
-  char* newString = static_cast<char*>(malloc(length + 1));
-  if (newString == NULL) {
-    throwRuntimeError(
-        "in Json::Value::duplicateStringValue(): "
-        "Failed to allocate string value buffer");
-  }
-  memcpy(newString, value, length);
-  newString[length] = 0;
-  return newString;
-}
-
-/* Record the length as a prefix.
- */
-static inline char* duplicateAndPrefixStringValue(
-    const char* value,
-    unsigned int length)
-{
-  // Avoid an integer overflow in the call to malloc below by limiting length
-  // to a sane value.
-  JSON_ASSERT_MESSAGE(length <= static_cast<unsigned>(Value::maxInt) - sizeof(unsigned) - 1U,
-                      "in Json::Value::duplicateAndPrefixStringValue(): "
-                      "length too big for prefixing");
-  unsigned actualLength = length + static_cast<unsigned>(sizeof(unsigned)) + 1U;
-  char* newString = static_cast<char*>(malloc(actualLength));
-  if (newString == 0) {
-    throwRuntimeError(
-        "in Json::Value::duplicateAndPrefixStringValue(): "
-        "Failed to allocate string value buffer");
-  }
-  *reinterpret_cast<unsigned*>(newString) = length;
-  memcpy(newString + sizeof(unsigned), value, length);
-  newString[actualLength - 1U] = 0; // to avoid buffer over-run accidents by users later
-  return newString;
-}
-inline static void decodePrefixedString(
-    bool isPrefixed, char const* prefixed,
-    unsigned* length, char const** value)
-{
-  if (!isPrefixed) {
-    *length = static_cast<unsigned>(strlen(prefixed));
-    *value = prefixed;
-  } else {
-    *length = *reinterpret_cast<unsigned const*>(prefixed);
-    *value = prefixed + sizeof(unsigned);
-  }
-}
-/** Free the string duplicated by duplicateStringValue()/duplicateAndPrefixStringValue().
- */
-#if JSONCPP_USING_SECURE_MEMORY
-static inline void releasePrefixedStringValue(char* value) {
-  unsigned length = 0;
-  char const* valueDecoded;
-  decodePrefixedString(true, value, &length, &valueDecoded);
-  size_t const size = sizeof(unsigned) + length + 1U;
-  memset(value, 0, size);
-  free(value);
-}
-static inline void releaseStringValue(char* value, unsigned length) {
-  // length==0 => we allocated the strings memory
-  size_t size = (length==0) ? strlen(value) : length;
-  memset(value, 0, size);
-  free(value);
-}
-#else // !JSONCPP_USING_SECURE_MEMORY
-static inline void releasePrefixedStringValue(char* value) {
-  free(value);
-}
-static inline void releaseStringValue(char* value, unsigned) {
-  free(value);
-}
-#endif // JSONCPP_USING_SECURE_MEMORY
-
-} // namespace Json
-} // namespace rmq
-
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// ValueInternals...
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-#if !defined(JSON_IS_AMALGAMATION)
-
-#include "json_valueiterator.inl"
-#endif // if !defined(JSON_IS_AMALGAMATION)
-
-namespace rmq {
-namespace Json {
-
-Exception::Exception(JSONCPP_STRING const& msg)
-  : msg_(msg)
-{}
-Exception::~Exception() throw()
-{}
-char const* Exception::what() const throw()
-{
-  return msg_.c_str();
-}
-RuntimeError::RuntimeError(JSONCPP_STRING const& msg)
-  : Exception(msg)
-{}
-LogicError::LogicError(JSONCPP_STRING const& msg)
-  : Exception(msg)
-{}
-JSONCPP_NORETURN void throwRuntimeError(JSONCPP_STRING const& msg)
-{
-  throw RuntimeError(msg);
-}
-JSONCPP_NORETURN void throwLogicError(JSONCPP_STRING const& msg)
-{
-  throw LogicError(msg);
-}
-
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// class Value::CommentInfo
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-
-Value::CommentInfo::CommentInfo() : comment_(0)
-{}
-
-Value::CommentInfo::~CommentInfo() {
-  if (comment_)
-    releaseStringValue(comment_, 0u);
-}
-
-void Value::CommentInfo::setComment(const char* text, size_t len) {
-  if (comment_) {
-    releaseStringValue(comment_, 0u);
-    comment_ = 0;
-  }
-  JSON_ASSERT(text != 0);
-  JSON_ASSERT_MESSAGE(
-      text[0] == '\0' || text[0] == '/',
-      "in Json::Value::setComment(): Comments must start with /");
-  // It seems that /**/ style comments are acceptable as well.
-  comment_ = duplicateStringValue(text, len);
-}
-
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// class Value::CZString
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-
-// Notes: policy_ indicates if the string was allocated when
-// a string is stored.
-
-Value::CZString::CZString(ArrayIndex aindex) : cstr_(0), index_(aindex) {}
-
-Value::CZString::CZString(char const* str, unsigned ulength, DuplicationPolicy allocate)
-    : cstr_(str) {
-  // allocate != duplicate
-  storage_.policy_ = allocate & 0x3;
-  storage_.length_ = ulength & 0x3FFFFFFF;
-}
-
-Value::CZString::CZString(const CZString& other) {
-  cstr_ = (other.storage_.policy_ != noDuplication && other.cstr_ != 0
-				 ? duplicateStringValue(other.cstr_, other.storage_.length_)
-				 : other.cstr_);
-  storage_.policy_ = static_cast<unsigned>(other.cstr_
-                 ? (static_cast<DuplicationPolicy>(other.storage_.policy_) == noDuplication
-                     ? noDuplication : duplicate)
-                 : static_cast<DuplicationPolicy>(other.storage_.policy_)) & 3U;
-  storage_.length_ = other.storage_.length_;
-}
-
-#if JSON_HAS_RVALUE_REFERENCES
-Value::CZString::CZString(CZString&& other)
-  : cstr_(other.cstr_), index_(other.index_) {
-  other.cstr_ = nullptr;
-}
-#endif
-
-Value::CZString::~CZString() {
-  if (cstr_ && storage_.policy_ == duplicate) {
-	  releaseStringValue(const_cast<char*>(cstr_), storage_.length_ + 1u); //+1 for null terminating character for sake of completeness but not actually necessary
-  }
-}
-
-void Value::CZString::swap(CZString& other) {
-  std::swap(cstr_, other.cstr_);
-  std::swap(index_, other.index_);
-}
-
-Value::CZString& Value::CZString::operator=(CZString other) {
-  swap(other);
-  return *this;
-}
-
-bool Value::CZString::operator<(const CZString& other) const {
-  if (!cstr_) return index_ < other.index_;
-  //return strcmp(cstr_, other.cstr_) < 0;
-  // Assume both are strings.
-  unsigned this_len = this->storage_.length_;
-  unsigned other_len = other.storage_.length_;
-  unsigned min_len = std::min(this_len, other_len);
-  JSON_ASSERT(this->cstr_ && other.cstr_);
-  int comp = memcmp(this->cstr_, other.cstr_, min_len);
-  if (comp < 0) return true;
-  if (comp > 0) return false;
-  return (this_len < other_len);
-}
-
-bool Value::CZString::operator==(const CZString& other) const {
-  if (!cstr_) return index_ == other.index_;
-  //return strcmp(cstr_, other.cstr_) == 0;
-  // Assume both are strings.
-  unsigned this_len = this->storage_.length_;
-  unsigned other_len = other.storage_.length_;
-  if (this_len != other_len) return false;
-  JSON_ASSERT(this->cstr_ && other.cstr_);
-  int comp = memcmp(this->cstr_, other.cstr_, this_len);
-  return comp == 0;
-}
-
-ArrayIndex Value::CZString::index() const { return index_; }
-
-//const char* Value::CZString::c_str() const { return cstr_; }
-const char* Value::CZString::data() const { return cstr_; }
-unsigned Value::CZString::length() const { return storage_.length_; }
-bool Value::CZString::isStaticString() const { return storage_.policy_ == noDuplication; }
-
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// class Value::Value
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-
-/*! \internal Default constructor initialization must be equivalent to:
- * memset( this, 0, sizeof(Value) )
- * This optimization is used in ValueInternalMap fast allocator.
- */
-Value::Value(ValueType vtype) {
-  static char const empty[] = "";
-  initBasic(vtype);
-  switch (vtype) {
-  case nullValue:
-    break;
-  case intValue:
-  case uintValue:
-    value_.int_ = 0;
-    break;
-  case realValue:
-    value_.real_ = 0.0;
-    break;
-  case stringValue:
-    // allocated_ == false, so this is safe.
-    value_.string_ = const_cast<char*>(static_cast<char const*>(empty));
-    break;
-  case arrayValue:
-  case objectValue:
-    value_.map_ = new ObjectValues();
-    break;
-  case booleanValue:
-    value_.bool_ = false;
-    break;
-  default:
-    JSON_ASSERT_UNREACHABLE;
-  }
-}
-
-Value::Value(Int value) {
-  initBasic(intValue);
-  value_.int_ = value;
-}
-
-Value::Value(UInt value) {
-  initBasic(uintValue);
-  value_.uint_ = value;
-}
-#if defined(JSON_HAS_INT64)
-Value::Value(Int64 value) {
-  initBasic(intValue);
-  value_.int_ = value;
-}
-Value::Value(UInt64 value) {
-  initBasic(uintValue);
-  value_.uint_ = value;
-}
-#endif // defined(JSON_HAS_INT64)
-
-Value::Value(double value) {
-  initBasic(realValue);
-  value_.real_ = value;
-}
-
-Value::Value(const char* value) {
-  initBasic(stringValue, true);
-  value_.string_ = duplicateAndPrefixStringValue(value, static_cast<unsigned>(strlen(value)));
-}
-
-Value::Value(const char* beginValue, const char* endValue) {
-  initBasic(stringValue, true);
-  value_.string_ =
-      duplicateAndPrefixStringValue(beginValue, static_cast<unsigned>(endValue - beginValue));
-}
-
-Value::Value(const JSONCPP_STRING& value) {
-  initBasic(stringValue, true);
-  value_.string_ =
-      duplicateAndPrefixStringValue(value.data(), static_cast<unsigned>(value.length()));
-}
-
-Value::Value(const StaticString& value) {
-  initBasic(stringValue);
-  value_.string_ = const_cast<char*>(value.c_str());
-}
-
-#ifdef JSON_USE_CPPTL
-Value::Value(const CppTL::ConstString& value) {
-  initBasic(stringValue, true);
-  value_.string_ = duplicateAndPrefixStringValue(value, static_cast<unsigned>(value.length()));
-}
-#endif
-
-Value::Value(bool value) {
-  initBasic(booleanValue);
-  value_.bool_ = value;
-}
-
-Value::Value(Value const& other)
-    : type_(other.type_), allocated_(false)
-      ,
-      comments_(0), start_(other.start_), limit_(other.limit_)
-{
-  switch (type_) {
-  case nullValue:
-  case intValue:
-  case uintValue:
-  case realValue:
-  case booleanValue:
-    value_ = other.value_;
-    break;
-  case stringValue:
-    if (other.value_.string_ && other.allocated_) {
-      unsigned len;
-      char const* str;
-      decodePrefixedString(other.allocated_, other.value_.string_,
-          &len, &str);
-      value_.string_ = duplicateAndPrefixStringValue(str, len);
-      allocated_ = true;
-    } else {
-      value_.string_ = other.value_.string_;
-      allocated_ = false;
-    }
-    break;
-  case arrayValue:
-  case objectValue:
-    value_.map_ = new ObjectValues(*other.value_.map_);
-    break;
-  default:
-    JSON_ASSERT_UNREACHABLE;
-  }
-  if (other.comments_) {
-    comments_ = new CommentInfo[numberOfCommentPlacement];
-    for (int comment = 0; comment < numberOfCommentPlacement; ++comment) {
-      const CommentInfo& otherComment = other.comments_[comment];
-      if (otherComment.comment_)
-        comments_[comment].setComment(
-            otherComment.comment_, strlen(otherComment.comment_));
-    }
-  }
-}
-
-#if JSON_HAS_RVALUE_REFERENCES
-// Move constructor
-Value::Value(Value&& other) {
-  initBasic(nullValue);
-  swap(other);
-}
-#endif
-
-Value::~Value() {
-  switch (type_) {
-  case nullValue:
-  case intValue:
-  case uintValue:
-  case realValue:
-  case booleanValue:
-    break;
-  case stringValue:
-    if (allocated_)
-      releasePrefixedStringValue(value_.string_);
-    break;
-  case arrayValue:
-  case objectValue:
-    delete value_.map_;
-    break;
-  default:
-    JSON_ASSERT_UNREACHABLE;
-  }
-
-  delete[] comments_;
-
-  value_.uint_ = 0;
-}
-
-Value& Value::operator=(Value other) {
-  swap(other);
-  return *this;
-}
-
-void Value::swapPayload(Value& other) {
-  ValueType temp = type_;
-  type_ = other.type_;
-  other.type_ = temp;
-  std::swap(value_, other.value_);
-  int temp2 = allocated_;
-  allocated_ = other.allocated_;
-  other.allocated_ = temp2 & 0x1;
-}
-
-void Value::swap(Value& other) {
-  swapPayload(other);
-  std::swap(comments_, other.comments_);
-  std::swap(start_, other.start_);
-  std::swap(limit_, other.limit_);
-}
-
-ValueType Value::type() const { return type_; }
-
-int Value::compare(const Value& other) const {
-  if (*this < other)
-    return -1;
-  if (*this > other)
-    return 1;
-  return 0;
-}
-
-bool Value::operator<(const Value& other) const {
-  int typeDelta = type_ - other.type_;
-  if (typeDelta)
-    return typeDelta < 0 ? true : false;
-  switch (type_) {
-  case nullValue:
-    return false;
-  case intValue:
-    return value_.int_ < other.value_.int_;
-  case uintValue:
-    return value_.uint_ < other.value_.uint_;
-  case realValue:
-    return value_.real_ < other.value_.real_;
-  case booleanValue:
-    return value_.bool_ < other.value_.bool_;
-  case stringValue:
-  {
-    if ((value_.string_ == 0) || (other.value_.string_ == 0)) {
-      if (other.value_.string_) return true;
-      else return false;
-    }
-    unsigned this_len;
-    unsigned other_len;
-    char const* this_str;
-    char const* other_str;
-    decodePrefixedString(this->allocated_, this->value_.string_, &this_len, &this_str);
-    decodePrefixedString(other.allocated_, other.value_.string_, &other_len, &other_str);
-    unsigned min_len = std::min(this_len, other_len);
-    JSON_ASSERT(this_str && other_str);
-    int comp = memcmp(this_str, other_str, min_len);
-    if (comp < 0) return true;
-    if (comp > 0) return false;
-    return (this_len < other_len);
-  }
-  case arrayValue:
-  case objectValue: {
-    int delta = int(value_.map_->size() - other.value_.map_->size());
-    if (delta)
-      return delta < 0;
-    return (*value_.map_) < (*other.value_.map_);
-  }
-  default:
-    JSON_ASSERT_UNREACHABLE;
-  }
-  return false; // unreachable
-}
-
-bool Value::operator<=(const Value& other) const { return !(other < *this); }
-
-bool Value::operator>=(const Value& other) const { return !(*this < other); }
-
-bool Value::operator>(const Value& other) const { return other < *this; }
-
-bool Value::operator==(const Value& other) const {
-  // if ( type_ != other.type_ )
-  // GCC 2.95.3 says:
-  // attempt to take address of bit-field structure member `Json::Value::type_'
-  // Beats me, but a temp solves the problem.
-  int temp = other.type_;
-  if (type_ != temp)
-    return false;
-  switch (type_) {
-  case nullValue:
-    return true;
-  case intValue:
-    return value_.int_ == other.value_.int_;
-  case uintValue:
-    return value_.uint_ == other.value_.uint_;
-  case realValue:
-    return value_.real_ == other.value_.real_;
-  case booleanValue:
-    return value_.bool_ == other.value_.bool_;
-  case stringValue:
-  {
-    if ((value_.string_ == 0) || (other.value_.string_ == 0)) {
-      return (value_.string_ == other.value_.string_);
-    }
-    unsigned this_len;
-    unsigned other_len;
-    char const* this_str;
-    char const* other_str;
-    decodePrefixedString(this->allocated_, this->value_.string_, &this_len, &this_str);
-    decodePrefixedString(other.allocated_, other.value_.string_, &other_len, &other_str);
-    if (this_len != other_len) return false;
-    JSON_ASSERT(this_str && other_str);
-    int comp = memcmp(this_str, other_str, this_len);
-    return comp == 0;
-  }
-  case arrayValue:
-  case objectValue:
-    return value_.map_->size() == other.value_.map_->size() &&
-           (*value_.map_) == (*other.value_.map_);
-  default:
-    JSON_ASSERT_UNREACHABLE;
-  }
-  return false; // unreachable
-}
-
-bool Value::operator!=(const Value& other) const { return !(*this == other); }
-
-const char* Value::asCString() const {
-  JSON_ASSERT_MESSAGE(type_ == stringValue,
-                      "in Json::Value::asCString(): requires stringValue");
-  if (value_.string_ == 0) return 0;
-  unsigned this_len;
-  char const* this_str;
-  decodePrefixedString(this->allocated_, this->value_.string_, &this_len, &this_str);
-  return this_str;
-}
-
-#if JSONCPP_USING_SECURE_MEMORY
-unsigned Value::getCStringLength() const {
-  JSON_ASSERT_MESSAGE(type_ == stringValue,
-	                  "in Json::Value::asCString(): requires stringValue");
-  if (value_.string_ == 0) return 0;
-  unsigned this_len;
-  char const* this_str;
-  decodePrefixedString(this->allocated_, this->value_.string_, &this_len, &this_str);
-  return this_len;
-}
-#endif
-
-bool Value::getString(char const** str, char const** cend) const {
-  if (type_ != stringValue) return false;
-  if (value_.string_ == 0) return false;
-  unsigned length;
-  decodePrefixedString(this->allocated_, this->value_.string_, &length, str);
-  *cend = *str + length;
-  return true;
-}
-
-JSONCPP_STRING Value::asString() const {
-  switch (type_) {
-  case nullValue:
-    return "";
-  case stringValue:
-  {
-    if (value_.string_ == 0) return "";
-    unsigned this_len;
-    char const* this_str;
-    decodePrefixedString(this->allocated_, this->value_.string_, &this_len, &this_str);
-    return JSONCPP_STRING(this_str, this_len);
-  }
-  case booleanValue:
-    return value_.bool_ ? "true" : "false";
-  case intValue:
-    return valueToString(value_.int_);
-  case uintValue:
-    return valueToString(value_.uint_);
-  case realValue:
-    return valueToString(value_.real_);
-  default:
-    JSON_FAIL_MESSAGE("Type is not convertible to string");
-  }
-}
-
-#ifdef JSON_USE_CPPTL
-CppTL::ConstString Value::asConstString() const {
-  unsigned len;
-  char const* str;
-  decodePrefixedString(allocated_, value_.string_,
-      &len, &str);
-  return CppTL::ConstString(str, len);
-}
-#endif
-
-Value::Int Value::asInt() const {
-  switch (type_) {
-  case intValue:
-    JSON_ASSERT_MESSAGE(isInt(), "LargestInt out of Int range");
-    return Int(value_.int_);
-  case uintValue:
-    JSON_ASSERT_MESSAGE(isInt(), "LargestUInt out of Int range");
-    return Int(value_.uint_);
-  case realValue:
-    JSON_ASSERT_MESSAGE(InRange(value_.real_, minInt, maxInt),
-                        "double out of Int range");
-    return Int(value_.real_);
-  case nullValue:
-    return 0;
-  case booleanValue:
-    return value_.bool_ ? 1 : 0;
-  default:
-    break;
-  }
-  JSON_FAIL_MESSAGE("Value is not convertible to Int.");
-}
-
-Value::UInt Value::asUInt() const {
-  switch (type_) {
-  case intValue:
-    JSON_ASSERT_MESSAGE(isUInt(), "LargestInt out of UInt range");
-    return UInt(value_.int_);
-  case uintValue:
-    JSON_ASSERT_MESSAGE(isUInt(), "LargestUInt out of UInt range");
-    return UInt(value_.uint_);
-  case realValue:
-    JSON_ASSERT_MESSAGE(InRange(value_.real_, 0, maxUInt),
-                        "double out of UInt range");
-    return UInt(value_.real_);
-  case nullValue:
-    return 0;
-  case booleanValue:
-    return value_.bool_ ? 1 : 0;
-  default:
-    break;
-  }
-  JSON_FAIL_MESSAGE("Value is not convertible to UInt.");
-}
-
-#if defined(JSON_HAS_INT64)
-
-Value::Int64 Value::asInt64() const {
-  switch (type_) {
-  case intValue:
-    return Int64(value_.int_);
-  case uintValue:
-    JSON_ASSERT_MESSAGE(isInt64(), "LargestUInt out of Int64 range");
-    return Int64(value_.uint_);
-  case realValue:
-    JSON_ASSERT_MESSAGE(InRange(value_.real_, minInt64, maxInt64),
-                        "double out of Int64 range");
-    return Int64(value_.real_);
-  case nullValue:
-    return 0;
-  case booleanValue:
-    return value_.bool_ ? 1 : 0;
-  default:
-    break;
-  }
-  JSON_FAIL_MESSAGE("Value is not convertible to Int64.");
-}
-
-Value::UInt64 Value::asUInt64() const {
-  switch (type_) {
-  case intValue:
-    JSON_ASSERT_MESSAGE(isUInt64(), "LargestInt out of UInt64 range");
-    return UInt64(value_.int_);
-  case uintValue:
-    return UInt64(value_.uint_);
-  case realValue:
-    JSON_ASSERT_MESSAGE(InRange(value_.real_, 0, maxUInt64),
-                        "double out of UInt64 range");
-    return UInt64(value_.real_);
-  case nullValue:
-    return 0;
-  case booleanValue:
-    return value_.bool_ ? 1 : 0;
-  default:
-    break;
-  }
-  JSON_FAIL_MESSAGE("Value is not convertible to UInt64.");
-}
-#endif // if defined(JSON_HAS_INT64)
-
-LargestInt Value::asLargestInt() const {
-#if defined(JSON_NO_INT64)
-  return asInt();
-#else
-  return asInt64();
-#endif
-}
-
-LargestUInt Value::asLargestUInt() const {
-#if defined(JSON_NO_INT64)
-  return asUInt();
-#else
-  return asUInt64();
-#endif
-}
-
-double Value::asDouble() const {
-  switch (type_) {
-  case intValue:
-    return static_cast<double>(value_.int_);
-  case uintValue:
-#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
-    return static_cast<double>(value_.uint_);
-#else  // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
-    return integerToDouble(value_.uint_);
-#endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
-  case realValue:
-    return value_.real_;
-  case nullValue:
-    return 0.0;
-  case booleanValue:
-    return value_.bool_ ? 1.0 : 0.0;
-  default:
-    break;
-  }
-  JSON_FAIL_MESSAGE("Value is not convertible to double.");
-}
-
-float Value::asFloat() const {
-  switch (type_) {
-  case intValue:
-    return static_cast<float>(value_.int_);
-  case uintValue:
-#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
-    return static_cast<float>(value_.uint_);
-#else  // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
-    // This can fail (silently?) if the value is bigger than MAX_FLOAT.
-    return static_cast<float>(integerToDouble(value_.uint_));
-#endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
-  case realValue:
-    return static_cast<float>(value_.real_);
-  case nullValue:
-    return 0.0;
-  case booleanValue:
-    return value_.bool_ ? 1.0f : 0.0f;
-  default:
-    break;
-  }
-  JSON_FAIL_MESSAGE("Value is not convertible to float.");
-}
-
-bool Value::asBool() const {
-  switch (type_) {
-  case booleanValue:
-    return value_.bool_;
-  case nullValue:
-    return false;
-  case intValue:
-    return value_.int_ ? true : false;
-  case uintValue:
-    return value_.uint_ ? true : false;
-  case realValue:
-    // This is kind of strange. Not recommended.
-    return (value_.real_ != 0.0) ? true : false;
-  default:
-    break;
-  }
-  JSON_FAIL_MESSAGE("Value is not convertible to bool.");
-}
-
-bool Value::isConvertibleTo(ValueType other) const {
-  switch (other) {
-  case nullValue:
-    return (isNumeric() && asDouble() == 0.0) ||
-           (type_ == booleanValue && value_.bool_ == false) ||
-           (type_ == stringValue && asString() == "") ||
-           (type_ == arrayValue && value_.map_->size() == 0) ||
-           (type_ == objectValue && value_.map_->size() == 0) ||
-           type_ == nullValue;
-  case intValue:
-    return isInt() ||
-           (type_ == realValue && InRange(value_.real_, minInt, maxInt)) ||
-           type_ == booleanValue || type_ == nullValue;
-  case uintValue:
-    return isUInt() ||
-           (type_ == realValue && InRange(value_.real_, 0, maxUInt)) ||
-           type_ == booleanValue || type_ == nullValue;
-  case realValue:
-    return isNumeric() || type_ == booleanValue || type_ == nullValue;
-  case booleanValue:
-    return isNumeric() || type_ == booleanValue || type_ == nullValue;
-  case stringValue:
-    return isNumeric() || type_ == booleanValue || type_ == stringValue ||
-           type_ == nullValue;
-  case arrayValue:
-    return type_ == arrayValue || type_ == nullValue;
-  case objectValue:
-    return type_ == objectValue || type_ == nullValue;
-  }
-  JSON_ASSERT_UNREACHABLE;
-  return false;
-}
-
-/// Number of values in array or object
-ArrayIndex Value::size() const {
-  switch (type_) {
-  case nullValue:
-  case intValue:
-  case uintValue:
-  case realValue:
-  case booleanValue:
-  case stringValue:
-    return 0;
-  case arrayValue: // size of the array is highest index + 1
-    if (!value_.map_->empty()) {
-      ObjectValues::const_iterator itLast = value_.map_->end();
-      --itLast;
-      return (*itLast).first.index() + 1;
-    }
-    return 0;
-  case objectValue:
-    return ArrayIndex(value_.map_->size());
-  }
-  JSON_ASSERT_UNREACHABLE;
-  return 0; // unreachable;
-}
-
-bool Value::empty() const {
-  if (isNull() || isArray() || isObject())
-    return size() == 0u;
-  else
-    return false;
-}
-
-bool Value::operator!() const { return isNull(); }
-
-void Value::clear() {
-  JSON_ASSERT_MESSAGE(type_ == nullValue || type_ == arrayValue ||
-                          type_ == objectValue,
-                      "in Json::Value::clear(): requires complex value");
-  start_ = 0;
-  limit_ = 0;
-  switch (type_) {
-  case arrayValue:
-  case objectValue:
-    value_.map_->clear();
-    break;
-  default:
-    break;
-  }
-}
-
-void Value::resize(ArrayIndex newSize) {
-  JSON_ASSERT_MESSAGE(type_ == nullValue || type_ == arrayValue,
-                      "in Json::Value::resize(): requires arrayValue");
-  if (type_ == nullValue)
-    *this = Value(arrayValue);
-  ArrayIndex oldSize = size();
-  if (newSize == 0)
-    clear();
-  else if (newSize > oldSize)
-    (*this)[newSize - 1];
-  else {
-    for (ArrayIndex index = newSize; index < oldSize; ++index) {
-      value_.map_->erase(index);
-    }
-    JSON_ASSERT(size() == newSize);
-  }
-}
-
-Value& Value::operator[](ArrayIndex index) {
-  JSON_ASSERT_MESSAGE(
-      type_ == nullValue || type_ == arrayValue,
-      "in Json::Value::operator[](ArrayIndex): requires arrayValue");
-  if (type_ == nullValue)
-    *this = Value(arrayValue);
-  CZString key(index);
-  ObjectValues::iterator it = value_.map_->lower_bound(key);
-  if (it != value_.map_->end() && (*it).first == key)
-    return (*it).second;
-
-  ObjectValues::value_type defaultValue(key, nullSingleton());
-  it = value_.map_->insert(it, defaultValue);
-  return (*it).second;
-}
-
-#if 0
-Value& Value::operator[](int index) {
-  JSON_ASSERT_MESSAGE(
-      index >= 0,
-      "in Json::Value::operator[](int index): index cannot be negative");
-  return (*this)[ArrayIndex(index)];
-}
-#endif
-const Value& Value::operator[](ArrayIndex index) const {
-  JSON_ASSERT_MESSAGE(
-      type_ == nullValue || type_ == arrayValue,
-      "in Json::Value::operator[](ArrayIndex)const: requires arrayValue");
-  if (type_ == nullValue)
-    return nullSingleton();
-  CZString key(index);
-  ObjectValues::const_iterator it = value_.map_->find(key);
-  if (it == value_.map_->end())
-    return nullSingleton();
-  return (*it).second;
-}
-
-#if 0
-const Value& Value::operator[](int index) const {
-  JSON_ASSERT_MESSAGE(
-      index >= 0,
-      "in Json::Value::operator[](int index) const: index cannot be negative");
-  return (*this)[ArrayIndex(index)];
-}
-#endif
-
-void Value::initBasic(ValueType vtype, bool allocated) {
-  type_ = vtype;
-  allocated_ = allocated;
-  comments_ = 0;
-  start_ = 0;
-  limit_ = 0;
-}
-
-// Access an object value by name, create a null member if it does not exist.
-// @pre Type of '*this' is object or null.
-// @param key is null-terminated.
-Value& Value::resolveReference(const char* key) {
-  JSON_ASSERT_MESSAGE(
-      type_ == nullValue || type_ == objectValue,
-      "in Json::Value::resolveReference(): requires objectValue");
-  if (type_ == nullValue)
-    *this = Value(objectValue);
-  CZString actualKey(
-      key, static_cast<unsigned>(strlen(key)), CZString::noDuplication); // NOTE!
-  ObjectValues::iterator it = value_.map_->lower_bound(actualKey);
-  if (it != value_.map_->end() && (*it).first == actualKey)
-    return (*it).second;
-
-  ObjectValues::value_type defaultValue(actualKey, nullSingleton());
-  it = value_.map_->insert(it, defaultValue);
-  Value& value = (*it).second;
-  return value;
-}
-
-// @param key is not null-terminated.
-Value& Value::resolveReference(char const* key, char const* cend)
-{
-  JSON_ASSERT_MESSAGE(
-      type_ == nullValue || type_ == objectValue,
-      "in Json::Value::resolveReference(key, end): requires objectValue");
-  if (type_ == nullValue)
-    *this = Value(objectValue);
-  CZString actualKey(
-      key, static_cast<unsigned>(cend-key), CZString::duplicateOnCopy);
-  ObjectValues::iterator it = value_.map_->lower_bound(actualKey);
-  if (it != value_.map_->end() && (*it).first == actualKey)
-    return (*it).second;
-
-  ObjectValues::value_type defaultValue(actualKey, nullSingleton());
-  it = value_.map_->insert(it, defaultValue);
-  Value& value = (*it).second;
-  return value;
-}
-
-Value Value::get(ArrayIndex index, const Value& defaultValue) const {
-  const Value* value = &((*this)[index]);
-  return value == &nullSingleton() ? defaultValue : *value;
-}
-
-bool Value::isValidIndex(ArrayIndex index) const { return index < size(); }
-
-Value const* Value::find(char const* key, char const* cend) const
-{
-  JSON_ASSERT_MESSAGE(
-      type_ == nullValue || type_ == objectValue,
-      "in Json::Value::find(key, end, found): requires objectValue or nullValue");
-  if (type_ == nullValue) return NULL;
-  CZString actualKey(key, static_cast<unsigned>(cend-key), CZString::noDuplication);
-  ObjectValues::const_iterator it = value_.map_->find(actualKey);
-  if (it == value_.map_->end()) return NULL;
-  return &(*it).second;
-}
-const Value& Value::operator[](const char* key) const
-{
-  Value const* found = find(key, key + strlen(key));
-  if (!found) return nullSingleton();
-  return *found;
-}
-Value const& Value::operator[](JSONCPP_STRING const& key) const
-{
-  Value const* found = find(key.data(), key.data() + key.length());
-  if (!found) return nullSingleton();
-  return *found;
-}
-
-Value& Value::operator[](const char* key) {
-  return resolveReference(key, key + strlen(key));
-}
-
-Value& Value::operator[](const JSONCPP_STRING& key) {
-  return resolveReference(key.data(), key.data() + key.length());
-}
-
-Value& Value::operator[](const StaticString& key) {
-  return resolveReference(key.c_str());
-}
-
-#ifdef JSON_USE_CPPTL
-Value& Value::operator[](const CppTL::ConstString& key) {
-  return resolveReference(key.c_str(), key.end_c_str());
-}
-Value const& Value::operator[](CppTL::ConstString const& key) const
-{
-  Value const* found = find(key.c_str(), key.end_c_str());
-  if (!found) return nullSingleton();
-  return *found;
-}
-#endif
-
-Value& Value::append(const Value& value) { return (*this)[size()] = value; }
-
-Value Value::get(char const* key, char const* cend, Value const& defaultValue) const
-{
-  Value const* found = find(key, cend);
-  return !found ? defaultValue : *found;
-}
-Value Value::get(char const* key, Value const& defaultValue) const
-{
-  return get(key, key + strlen(key), defaultValue);
-}
-Value Value::get(JSONCPP_STRING const& key, Value const& defaultValue) const
-{
-  return get(key.data(), key.data() + key.length(), defaultValue);
-}
-
-
-bool Value::removeMember(const char* key, const char* cend, Value* removed)
-{
-  if (type_ != objectValue) {
-    return false;
-  }
-  CZString actualKey(key, static_cast<unsigned>(cend-key), CZString::noDuplication);
-  ObjectValues::iterator it = value_.map_->find(actualKey);
-  if (it == value_.map_->end())
-    return false;
-  *removed = it->second;
-  value_.map_->erase(it);
-  return true;
-}
-bool Value::removeMember(const char* key, Value* removed)
-{
-  return removeMember(key, key + strlen(key), removed);
-}
-bool Value::removeMember(JSONCPP_STRING const& key, Value* removed)
-{
-  return removeMember(key.data(), key.data() + key.length(), removed);
-}
-Value Value::removeMember(const char* key)
-{
-  JSON_ASSERT_MESSAGE(type_ == nullValue || type_ == objectValue,
-                      "in Json::Value::removeMember(): requires objectValue");
-  if (type_ == nullValue)
-    return nullSingleton();
-
-  Value removed;  // null
-  removeMember(key, key + strlen(key), &removed);
-  return removed; // still null if removeMember() did nothing
-}
-Value Value::removeMember(const JSONCPP_STRING& key)
-{
-  return removeMember(key.c_str());
-}
-
-bool Value::removeIndex(ArrayIndex index, Value* removed) {
-  if (type_ != arrayValue) {
-    return false;
-  }
-  CZString key(index);
-  ObjectValues::iterator it = value_.map_->find(key);
-  if (it == value_.map_->end()) {
-    return false;
-  }
-  *removed = it->second;
-  ArrayIndex oldSize = size();
-  // shift left all items left, into the place of the "removed"
-  for (ArrayIndex i = index; i < (oldSize - 1); ++i){
-    CZString keey(i);
-    (*value_.map_)[keey] = (*this)[i + 1];
-  }
-  // erase the last one ("leftover")
-  CZString keyLast(oldSize - 1);
-  ObjectValues::iterator itLast = value_.map_->find(keyLast);
-  value_.map_->erase(itLast);
-  return true;
-}
-
-#ifdef JSON_USE_CPPTL
-Value Value::get(const CppTL::ConstString& key,
-                 const Value& defaultValue) const {
-  return get(key.c_str(), key.end_c_str(), defaultValue);
-}
-#endif
-
-bool Value::isMember(char const* key, char const* cend) const
-{
-  Value const* value = find(key, cend);
-  return NULL != value;
-}
-bool Value::isMember(char const* key) const
-{
-  return isMember(key, key + strlen(key));
-}
-bool Value::isMember(JSONCPP_STRING const& key) const
-{
-  return isMember(key.data(), key.data() + key.length());
-}
-
-#ifdef JSON_USE_CPPTL
-bool Value::isMember(const CppTL::ConstString& key) const {
-  return isMember(key.c_str(), key.end_c_str());
-}
-#endif
-
-Value::Members Value::getMemberNames() const {
-  JSON_ASSERT_MESSAGE(
-      type_ == nullValue || type_ == objectValue,
-      "in Json::Value::getMemberNames(), value must be objectValue");
-  if (type_ == nullValue)
-    return Value::Members();
-  Members members;
-  members.reserve(value_.map_->size());
-  ObjectValues::const_iterator it = value_.map_->begin();
-  ObjectValues::const_iterator itEnd = value_.map_->end();
-  for (; it != itEnd; ++it) {
-    members.push_back(JSONCPP_STRING((*it).first.data(),
-                                  (*it).first.length()));
-  }
-  return members;
-}
-//
-//# ifdef JSON_USE_CPPTL
-// EnumMemberNames
-// Value::enumMemberNames() const
-//{
-//   if ( type_ == objectValue )
-//   {
-//      return CppTL::Enum::any(  CppTL::Enum::transform(
-//         CppTL::Enum::keys( *(value_.map_), CppTL::Type<const CZString &>() ),
-//         MemberNamesTransform() ) );
-//   }
-//   return EnumMemberNames();
-//}
-//
-//
-// EnumValues
-// Value::enumValues() const
-//{
-//   if ( type_ == objectValue  ||  type_ == arrayValue )
-//      return CppTL::Enum::anyValues( *(value_.map_),
-//                                     CppTL::Type<const Value &>() );
-//   return EnumValues();
-//}
-//
-//# endif
-
-static bool IsIntegral(double d) {
-  double integral_part;
-  return modf(d, &integral_part) == 0.0;
-}
-
-bool Value::isNull() const { return type_ == nullValue; }
-
-bool Value::isBool() const { return type_ == booleanValue; }
-
-bool Value::isInt() const {
-  switch (type_) {
-  case intValue:
-    return value_.int_ >= minInt && value_.int_ <= maxInt;
-  case uintValue:
-    return value_.uint_ <= UInt(maxInt);
-  case realValue:
-    return value_.real_ >= minInt && value_.real_ <= maxInt &&
-           IsIntegral(value_.real_);
-  default:
-    break;
-  }
-  return false;
-}
-
-bool Value::isUInt() const {
-  switch (type_) {
-  case intValue:
-    return value_.int_ >= 0 && LargestUInt(value_.int_) <= LargestUInt(maxUInt);
-  case uintValue:
-    return value_.uint_ <= maxUInt;
-  case realValue:
-    return value_.real_ >= 0 && value_.real_ <= maxUInt &&
-           IsIntegral(value_.real_);
-  default:
-    break;
-  }
-  return false;
-}
-
-bool Value::isInt64() const {
-#if defined(JSON_HAS_INT64)
-  switch (type_) {
-  case intValue:
-    return true;
-  case uintValue:
-    return value_.uint_ <= UInt64(maxInt64);
-  case realValue:
-    // Note that maxInt64 (= 2^63 - 1) is not exactly representable as a
-    // double, so double(maxInt64) will be rounded up to 2^63. Therefore we
-    // require the value to be strictly less than the limit.
-    return value_.real_ >= double(minInt64) &&
-           value_.real_ < double(maxInt64) && IsIntegral(value_.real_);
-  default:
-    break;
-  }
-#endif // JSON_HAS_INT64
-  return false;
-}
-
-bool Value::isUInt64() const {
-#if defined(JSON_HAS_INT64)
-  switch (type_) {
-  case intValue:
-    return value_.int_ >= 0;
-  case uintValue:
-    return true;
-  case realValue:
-    // Note that maxUInt64 (= 2^64 - 1) is not exactly representable as a
-    // double, so double(maxUInt64) will be rounded up to 2^64. Therefore we
-    // require the value to be strictly less than the limit.
-    return value_.real_ >= 0 && value_.real_ < maxUInt64AsDouble &&
-           IsIntegral(value_.real_);
-  default:
-    break;
-  }
-#endif // JSON_HAS_INT64
-  return false;
-}
-
-bool Value::isIntegral() const {
-#if defined(JSON_HAS_INT64)
-  return isInt64() || isUInt64();
-#else
-  return isInt() || isUInt();
-#endif
-}
-
-bool Value::isDouble() const { return type_ == realValue || isIntegral(); }
-
-bool Value::isNumeric() const { return isIntegral() || isDouble(); }
-
-bool Value::isString() const { return type_ == stringValue; }
-
-bool Value::isArray() const { return type_ == arrayValue; }
-
-bool Value::isObject() const { return type_ == objectValue; }
-
-void Value::setComment(const char* comment, size_t len, CommentPlacement placement) {
-  if (!comments_)
-    comments_ = new CommentInfo[numberOfCommentPlacement];
-  if ((len > 0) && (comment[len-1] == '\n')) {
-    // Always discard trailing newline, to aid indentation.
-    len -= 1;
-  }
-  comments_[placement].setComment(comment, len);
-}
-
-void Value::setComment(const char* comment, CommentPlacement placement) {
-  setComment(comment, strlen(comment), placement);
-}
-
-void Value::setComment(const JSONCPP_STRING& comment, CommentPlacement placement) {
-  setComment(comment.c_str(), comment.length(), placement);
-}
-
-bool Value::hasComment(CommentPlacement placement) const {
-  return comments_ != 0 && comments_[placement].comment_ != 0;
-}
-
-JSONCPP_STRING Value::getComment(CommentPlacement placement) const {
-  if (hasComment(placement))
-    return comments_[placement].comment_;
-  return "";
-}
-
-void Value::setOffsetStart(ptrdiff_t start) { start_ = start; }
-
-void Value::setOffsetLimit(ptrdiff_t limit) { limit_ = limit; }
-
-ptrdiff_t Value::getOffsetStart() const { return start_; }
-
-ptrdiff_t Value::getOffsetLimit() const { return limit_; }
-
-JSONCPP_STRING Value::toStyledString() const {
-  StyledWriter writer;
-  return writer.write(*this);
-}
-
-Value::const_iterator Value::begin() const {
-  switch (type_) {
-  case arrayValue:
-  case objectValue:
-    if (value_.map_)
-      return const_iterator(value_.map_->begin());
-    break;
-  default:
-    break;
-  }
-  return const_iterator();
-}
-
-Value::const_iterator Value::end() const {
-  switch (type_) {
-  case arrayValue:
-  case objectValue:
-    if (value_.map_)
-      return const_iterator(value_.map_->end());
-    break;
-  default:
-    break;
-  }
-  return const_iterator();
-}
-
-Value::iterator Value::begin() {
-  switch (type_) {
-  case arrayValue:
-  case objectValue:
-    if (value_.map_)
-      return iterator(value_.map_->begin());
-    break;
-  default:
-    break;
-  }
-  return iterator();
-}
-
-Value::iterator Value::end() {
-  switch (type_) {
-  case arrayValue:
-  case objectValue:
-    if (value_.map_)
-      return iterator(value_.map_->end());
-    break;
-  default:
-    break;
-  }
-  return iterator();
-}
-
-// class PathArgument
-// //////////////////////////////////////////////////////////////////
-
-PathArgument::PathArgument() : key_(), index_(), kind_(kindNone) {}
-
-PathArgument::PathArgument(ArrayIndex index)
-    : key_(), index_(index), kind_(kindIndex) {}
-
-PathArgument::PathArgument(const char* key)
-    : key_(key), index_(), kind_(kindKey) {}
-
-PathArgument::PathArgument(const JSONCPP_STRING& key)
-    : key_(key.c_str()), index_(), kind_(kindKey) {}
-
-// class Path
-// //////////////////////////////////////////////////////////////////
-
-Path::Path(const JSONCPP_STRING& path,
-           const PathArgument& a1,
-           const PathArgument& a2,
-           const PathArgument& a3,
-           const PathArgument& a4,
-           const PathArgument& a5) {
-  InArgs in;
-  in.push_back(&a1);
-  in.push_back(&a2);
-  in.push_back(&a3);
-  in.push_back(&a4);
-  in.push_back(&a5);
-  makePath(path, in);
-}
-
-void Path::makePath(const JSONCPP_STRING& path, const InArgs& in) {
-  const char* current = path.c_str();
-  const char* end = current + path.length();
-  InArgs::const_iterator itInArg = in.begin();
-  while (current != end) {
-    if (*current == '[') {
-      ++current;
-      if (*current == '%')
-        addPathInArg(path, in, itInArg, PathArgument::kindIndex);
-      else {
-        ArrayIndex index = 0;
-        for (; current != end && *current >= '0' && *current <= '9'; ++current)
-          index = index * 10 + ArrayIndex(*current - '0');
-        args_.push_back(index);
-      }
-      if (current == end || *++current != ']')
-        invalidPath(path, int(current - path.c_str()));
-    } else if (*current == '%') {
-      addPathInArg(path, in, itInArg, PathArgument::kindKey);
-      ++current;
-    } else if (*current == '.' || *current == ']') {
-      ++current;
-    } else {
-      const char* beginName = current;
-      while (current != end && !strchr("[.", *current))
-        ++current;
-      args_.push_back(JSONCPP_STRING(beginName, current));
-    }
-  }
-}
-
-void Path::addPathInArg(const JSONCPP_STRING& /*path*/,
-                        const InArgs& in,
-                        InArgs::const_iterator& itInArg,
-                        PathArgument::Kind kind) {
-  if (itInArg == in.end()) {
-    // Error: missing argument %d
-  } else if ((*itInArg)->kind_ != kind) {
-    // Error: bad argument type
-  } else {
-    args_.push_back(**itInArg++);
-  }
-}
-
-void Path::invalidPath(const JSONCPP_STRING& /*path*/, int /*location*/) {
-  // Error: invalid path.
-}
-
-const Value& Path::resolve(const Value& root) const {
-  const Value* node = &root;
-  for (Args::const_iterator it = args_.begin(); it != args_.end(); ++it) {
-    const PathArgument& arg = *it;
-    if (arg.kind_ == PathArgument::kindIndex) {
-      if (!node->isArray() || !node->isValidIndex(arg.index_)) {
-        // Error: unable to resolve path (array value expected at position...
-        return Value::null;
-      }
-      node = &((*node)[arg.index_]);
-    } else if (arg.kind_ == PathArgument::kindKey) {
-      if (!node->isObject()) {
-        // Error: unable to resolve path (object value expected at position...)
-        return Value::null;
-      }
-      node = &((*node)[arg.key_]);
-      if (node == &Value::nullSingleton()) {
-        // Error: unable to resolve path (object has no member named '' at
-        // position...)
-        return Value::null;
-      }
-    }
-  }
-  return *node;
-}
-
-Value Path::resolve(const Value& root, const Value& defaultValue) const {
-  const Value* node = &root;
-  for (Args::const_iterator it = args_.begin(); it != args_.end(); ++it) {
-    const PathArgument& arg = *it;
-    if (arg.kind_ == PathArgument::kindIndex) {
-      if (!node->isArray() || !node->isValidIndex(arg.index_))
-        return defaultValue;
-      node = &((*node)[arg.index_]);
-    } else if (arg.kind_ == PathArgument::kindKey) {
-      if (!node->isObject())
-        return defaultValue;
-      node = &((*node)[arg.key_]);
-      if (node == &Value::nullSingleton())
-        return defaultValue;
-    }
-  }
-  return *node;
-}
-
-Value& Path::make(Value& root) const {
-  Value* node = &root;
-  for (Args::const_iterator it = args_.begin(); it != args_.end(); ++it) {
-    const PathArgument& arg = *it;
-    if (arg.kind_ == PathArgument::kindIndex) {
-      if (!node->isArray()) {
-        // Error: node is not an array at position ...
-      }
-      node = &((*node)[arg.index_]);
-    } else if (arg.kind_ == PathArgument::kindKey) {
-      if (!node->isObject()) {
-        // Error: node is not an object at position...
-      }
-      node = &((*node)[arg.key_]);
-    }
-  }
-  return *node;
-}
-
-} // namespace Json
-} // namespace rmq
-

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/jsoncpp/json_valueiterator.inl
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/jsoncpp/json_valueiterator.inl b/rocketmq-client4cpp/src/jsoncpp/json_valueiterator.inl
deleted file mode 100755
index 50b4aa2..0000000
--- a/rocketmq-client4cpp/src/jsoncpp/json_valueiterator.inl
+++ /dev/null
@@ -1,171 +0,0 @@
-// Copyright 2007-2010 Baptiste Lepilleur
-// Distributed under MIT license, or public domain if desired and
-// recognized in your jurisdiction.
-// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
-
-// included by json_value.cpp
-
-namespace rmq {
-namespace Json {
-
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// class ValueIteratorBase
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-
-ValueIteratorBase::ValueIteratorBase()
-    : current_(), isNull_(true) {
-}
-
-ValueIteratorBase::ValueIteratorBase(
-    const Value::ObjectValues::iterator& current)
-    : current_(current), isNull_(false) {}
-
-Value& ValueIteratorBase::deref() const {
-  return current_->second;
-}
-
-void ValueIteratorBase::increment() {
-  ++current_;
-}
-
-void ValueIteratorBase::decrement() {
-  --current_;
-}
-
-ValueIteratorBase::difference_type
-ValueIteratorBase::computeDistance(const SelfType& other) const {
-#ifdef JSON_USE_CPPTL_SMALLMAP
-  return other.current_ - current_;
-#else
-  // Iterator for null value are initialized using the default
-  // constructor, which initialize current_ to the default
-  // std::map::iterator. As begin() and end() are two instance
-  // of the default std::map::iterator, they can not be compared.
-  // To allow this, we handle this comparison specifically.
-  if (isNull_ && other.isNull_) {
-    return 0;
-  }
-
-  // Usage of std::distance is not portable (does not compile with Sun Studio 12
-  // RogueWave STL,
-  // which is the one used by default).
-  // Using a portable hand-made version for non random iterator instead:
-  //   return difference_type( std::distance( current_, other.current_ ) );
-  difference_type myDistance = 0;
-  for (Value::ObjectValues::iterator it = current_; it != other.current_;
-       ++it) {
-    ++myDistance;
-  }
-  return myDistance;
-#endif
-}
-
-bool ValueIteratorBase::isEqual(const SelfType& other) const {
-  if (isNull_) {
-    return other.isNull_;
-  }
-  return current_ == other.current_;
-}
-
-void ValueIteratorBase::copy(const SelfType& other) {
-  current_ = other.current_;
-  isNull_ = other.isNull_;
-}
-
-Value ValueIteratorBase::key() const {
-  const Value::CZString czstring = (*current_).first;
-  if (czstring.data()) {
-    if (czstring.isStaticString())
-      return Value(StaticString(czstring.data()));
-    return Value(czstring.data(), czstring.data() + czstring.length());
-  }
-  return Value(czstring.index());
-}
-
-UInt ValueIteratorBase::index() const {
-  const Value::CZString czstring = (*current_).first;
-  if (!czstring.data())
-    return czstring.index();
-  return Value::UInt(-1);
-}
-
-JSONCPP_STRING ValueIteratorBase::name() const {
-  char const* keey;
-  char const* end;
-  keey = memberName(&end);
-  if (!keey) return JSONCPP_STRING();
-  return JSONCPP_STRING(keey, end);
-}
-
-char const* ValueIteratorBase::memberName() const {
-  const char* cname = (*current_).first.data();
-  return cname ? cname : "";
-}
-
-char const* ValueIteratorBase::memberName(char const** end) const {
-  const char* cname = (*current_).first.data();
-  if (!cname) {
-    *end = NULL;
-    return NULL;
-  }
-  *end = cname + (*current_).first.length();
-  return cname;
-}
-
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// class ValueConstIterator
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-
-ValueConstIterator::ValueConstIterator() {}
-
-ValueConstIterator::ValueConstIterator(
-    const Value::ObjectValues::iterator& current)
-    : ValueIteratorBase(current) {}
-
-ValueConstIterator::ValueConstIterator(ValueIterator const& other)
-    : ValueIteratorBase(other) {}
-
-ValueConstIterator& ValueConstIterator::
-operator=(const ValueIteratorBase& other) {
-  copy(other);
-  return *this;
-}
-
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// class ValueIterator
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-
-ValueIterator::ValueIterator() {}
-
-ValueIterator::ValueIterator(const Value::ObjectValues::iterator& current)
-    : ValueIteratorBase(current) {}
-
-ValueIterator::ValueIterator(const ValueConstIterator& other)
-    : ValueIteratorBase(other) {
-  throwRuntimeError("ConstIterator to Iterator should never be allowed.");
-}
-
-ValueIterator::ValueIterator(const ValueIterator& other)
-    : ValueIteratorBase(other) {}
-
-ValueIterator& ValueIterator::operator=(const SelfType& other) {
-  copy(other);
-  return *this;
-}
-
-} // namespace Json
-} // namespace rmq
-
-


[04/17] incubator-rocketmq-externals git commit: Polish cpp module

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/message/MessageQueue.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/message/MessageQueue.cpp b/rocketmq-client4cpp/src/message/MessageQueue.cpp
deleted file mode 100755
index d632550..0000000
--- a/rocketmq-client4cpp/src/message/MessageQueue.cpp
+++ /dev/null
@@ -1,153 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#include "MessageQueue.h"
-
-#include <string>
-#include <sstream>
-#include <UtilAll.h>
-
-namespace rmq
-{
-
-MessageQueue::MessageQueue()
-	: m_queueId(0)
-{
-}
-
-MessageQueue::MessageQueue(const std::string& topic, const std::string& brokerName, int queueId)
-    : m_topic(topic), m_brokerName(brokerName), m_queueId(queueId)
-{
-
-}
-
-std::string MessageQueue::getTopic()const
-{
-    return m_topic;
-}
-
-void MessageQueue::setTopic(const std::string& topic)
-{
-    m_topic = topic;
-}
-
-std::string MessageQueue::getBrokerName()const
-{
-    return m_brokerName;
-}
-
-void MessageQueue::setBrokerName(const std::string& brokerName)
-{
-    m_brokerName = brokerName;
-}
-
-int MessageQueue::getQueueId()const
-{
-    return m_queueId;
-}
-
-void MessageQueue::setQueueId(int queueId)
-{
-    m_queueId = queueId;
-}
-
-int MessageQueue::hashCode()
-{
-    /*
-    final int prime = 31;
-    int result = 1;
-    result = prime * result + ((brokerName == null) ? 0 : brokerName.hashCode());
-    result = prime * result + queueId;
-    result = prime * result + ((topic == null) ? 0 : topic.hashCode());
-    return result;
-    */
-    std::stringstream ss;
-    ss << m_topic << m_brokerName << m_queueId;
-    return UtilAll::hashCode(ss.str());
-}
-
-std::string MessageQueue::toString() const
-{
-    std::stringstream ss;
-    ss << "{topic=" << m_topic
-       << ",brokerName=" << m_brokerName
-       << ",queueId=" << m_queueId << "}";
-    return ss.str();
-}
-
-
-std::string MessageQueue::toJsonString() const
-{
-    std::stringstream ss;
-    ss << "{\"topic\":\"" << m_topic
-       << "\",\"brokerName\":\"" << m_brokerName
-       << "\",\"queueId\":" << m_queueId << "}";
-    return ss.str();
-}
-
-
-bool MessageQueue::operator==(const MessageQueue& mq)const
-{
-    if (this == &mq)
-    {
-        return true;
-    }
-
-    if (m_brokerName != mq.m_brokerName)
-    {
-        return false;
-    }
-
-    if (m_queueId != mq.m_queueId)
-    {
-        return false;
-    }
-
-    if (m_topic != mq.m_topic)
-    {
-        return false;
-    }
-
-    return true;
-}
-
-int MessageQueue::compareTo(const MessageQueue& mq)const
-{
-    {
-        int result = strcmp(m_topic.c_str(), mq.m_topic.c_str());
-        if (result != 0)
-        {
-            return result;
-        }
-    }
-
-    {
-        int result = strcmp(m_brokerName.c_str(), mq.m_brokerName.c_str());
-        if (result != 0)
-        {
-            return result;
-        }
-    }
-
-    return m_queueId - mq.m_queueId;
-}
-
-bool MessageQueue::operator<(const MessageQueue& mq)const
-{
-    return compareTo(mq) < 0;
-}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/producer/DefaultMQProducer.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/producer/DefaultMQProducer.cpp b/rocketmq-client4cpp/src/producer/DefaultMQProducer.cpp
deleted file mode 100755
index dcad654..0000000
--- a/rocketmq-client4cpp/src/producer/DefaultMQProducer.cpp
+++ /dev/null
@@ -1,277 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License")
-{
-}
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#include "DefaultMQProducer.h"
-
-#include <assert.h>
-#include "MessageExt.h"
-#include "QueryResult.h"
-#include "DefaultMQProducerImpl.h"
-#include "MixAll.h"
-#include "MQClientException.h"
-
-namespace rmq
-{
-
-DefaultMQProducer::DefaultMQProducer()
-    : m_producerGroup(MixAll::DEFAULT_PRODUCER_GROUP),
-      m_createTopicKey(MixAll::DEFAULT_TOPIC),
-  	  m_defaultTopicQueueNums(4),
-      m_sendMsgTimeout(3000),
-      m_compressMsgBodyOverHowmuch(1024 * 4),
-	  m_retryTimesWhenSendFailed(2),
-      m_retryAnotherBrokerWhenNotStoreOK(false),
-      m_maxMessageSize(1024 * 128),
-      m_compressLevel(5)
-{
-    m_pDefaultMQProducerImpl = new DefaultMQProducerImpl(this);
-}
-
-DefaultMQProducer::DefaultMQProducer(const std::string& producerGroup)
-    : m_producerGroup(producerGroup),
-      m_createTopicKey(MixAll::DEFAULT_TOPIC),
-  	  m_defaultTopicQueueNums(4),
-      m_sendMsgTimeout(3000),
-      m_compressMsgBodyOverHowmuch(1024 * 4),
-      m_retryTimesWhenSendFailed(2),
-      m_retryAnotherBrokerWhenNotStoreOK(false),
-      m_maxMessageSize(1024 * 128),
-      m_compressLevel(5)
-{
-    m_pDefaultMQProducerImpl = new DefaultMQProducerImpl(this);
-}
-
-DefaultMQProducer::~DefaultMQProducer()
-{
-    // memleak: maybe core
-    delete m_pDefaultMQProducerImpl;
-}
-
-
-void DefaultMQProducer::start()
-{
-    m_pDefaultMQProducerImpl->start();
-}
-
-void DefaultMQProducer::shutdown()
-{
-    m_pDefaultMQProducerImpl->shutdown();
-}
-
-std::vector<MessageQueue>* DefaultMQProducer::fetchPublishMessageQueues(const std::string& topic)
-{
-    return m_pDefaultMQProducerImpl->fetchPublishMessageQueues(topic);
-}
-
-SendResult DefaultMQProducer::send(Message& msg)
-{
-    return m_pDefaultMQProducerImpl->send(msg);
-}
-
-void DefaultMQProducer::send(Message& msg, SendCallback* pSendCallback)
-{
-    m_pDefaultMQProducerImpl->send(msg, pSendCallback);
-}
-
-void DefaultMQProducer::sendOneway(Message& msg)
-{
-    m_pDefaultMQProducerImpl->sendOneway(msg);
-}
-
-SendResult DefaultMQProducer::send(Message& msg, MessageQueue& mq)
-{
-    return m_pDefaultMQProducerImpl->send(msg, mq);
-}
-
-void DefaultMQProducer::send(Message& msg, MessageQueue& mq, SendCallback* pSendCallback)
-{
-    m_pDefaultMQProducerImpl->send(msg, mq, pSendCallback);
-}
-
-void DefaultMQProducer::sendOneway(Message& msg, MessageQueue& mq)
-{
-    m_pDefaultMQProducerImpl->sendOneway(msg, mq);
-}
-
-SendResult DefaultMQProducer::send(Message& msg, MessageQueueSelector* pSelector, void* arg)
-{
-    return m_pDefaultMQProducerImpl->send(msg, pSelector, arg);
-}
-
-void DefaultMQProducer::send(Message& msg,
-                             MessageQueueSelector* pSelector,
-                             void* arg,
-                             SendCallback* pSendCallback)
-{
-    m_pDefaultMQProducerImpl->send(msg, pSelector, arg, pSendCallback);
-}
-
-void DefaultMQProducer::sendOneway(Message& msg, MessageQueueSelector* pSelector, void* arg)
-{
-    m_pDefaultMQProducerImpl->sendOneway(msg, pSelector, arg);
-}
-
-TransactionSendResult DefaultMQProducer::sendMessageInTransaction(Message& msg,
-        LocalTransactionExecuter* tranExecuter, void* arg)
-{
-    THROW_MQEXCEPTION(MQClientException,
-                      "sendMessageInTransaction not implement, please use TransactionMQProducer class", -1);
-    TransactionSendResult result;
-
-    return result;
-}
-
-void DefaultMQProducer::createTopic(const std::string& key, const std::string& newTopic, int queueNum)
-{
-    m_pDefaultMQProducerImpl->createTopic(key, newTopic, queueNum);
-}
-
-long long DefaultMQProducer::searchOffset(const MessageQueue& mq, long long timestamp)
-{
-    return m_pDefaultMQProducerImpl->searchOffset(mq, timestamp);
-}
-
-long long DefaultMQProducer::maxOffset(const MessageQueue& mq)
-{
-    return m_pDefaultMQProducerImpl->maxOffset(mq);
-}
-
-long long DefaultMQProducer::minOffset(const MessageQueue& mq)
-{
-    return m_pDefaultMQProducerImpl->minOffset(mq);
-}
-
-long long DefaultMQProducer::earliestMsgStoreTime(const MessageQueue& mq)
-{
-    return m_pDefaultMQProducerImpl->earliestMsgStoreTime(mq);
-}
-
-MessageExt* DefaultMQProducer::viewMessage(const std::string& msgId)
-{
-    return m_pDefaultMQProducerImpl->viewMessage(msgId);
-}
-
-QueryResult DefaultMQProducer::queryMessage(const std::string& topic,
-        const std::string& key,
-        int maxNum,
-        long long begin,
-        long long end)
-{
-
-    return m_pDefaultMQProducerImpl->queryMessage(topic, key, maxNum, begin, end);
-}
-
-std::string DefaultMQProducer::getProducerGroup()
-{
-    return m_producerGroup;
-}
-
-void DefaultMQProducer::setProducerGroup(const std::string& producerGroup)
-{
-    m_producerGroup = producerGroup;
-}
-
-std::string DefaultMQProducer::getCreateTopicKey()
-{
-    return m_createTopicKey;
-}
-
-void DefaultMQProducer::setCreateTopicKey(const std::string& createTopicKey)
-{
-    m_createTopicKey = createTopicKey;
-}
-
-int DefaultMQProducer::getSendMsgTimeout()
-{
-    return m_sendMsgTimeout;
-}
-
-void DefaultMQProducer::setSendMsgTimeout(int sendMsgTimeout)
-{
-    m_sendMsgTimeout = sendMsgTimeout;
-}
-
-int DefaultMQProducer::getCompressMsgBodyOverHowmuch()
-{
-    return m_compressMsgBodyOverHowmuch;
-}
-
-void DefaultMQProducer::setCompressMsgBodyOverHowmuch(int compressMsgBodyOverHowmuch)
-{
-    m_compressMsgBodyOverHowmuch = compressMsgBodyOverHowmuch;
-}
-
-DefaultMQProducerImpl* DefaultMQProducer::getDefaultMQProducerImpl()
-{
-    return m_pDefaultMQProducerImpl;
-}
-
-bool DefaultMQProducer::isRetryAnotherBrokerWhenNotStoreOK()
-{
-    return m_retryAnotherBrokerWhenNotStoreOK;
-}
-
-void DefaultMQProducer::setRetryAnotherBrokerWhenNotStoreOK(bool retryAnotherBrokerWhenNotStoreOK)
-{
-    m_retryAnotherBrokerWhenNotStoreOK = retryAnotherBrokerWhenNotStoreOK;
-}
-
-int DefaultMQProducer::getMaxMessageSize()
-{
-    return m_maxMessageSize;
-}
-
-void DefaultMQProducer::setMaxMessageSize(int maxMessageSize)
-{
-    m_maxMessageSize = maxMessageSize;
-}
-
-int DefaultMQProducer::getDefaultTopicQueueNums()
-{
-    return m_defaultTopicQueueNums;
-}
-
-void DefaultMQProducer::setDefaultTopicQueueNums(int defaultTopicQueueNums)
-{
-    m_defaultTopicQueueNums = defaultTopicQueueNums;
-}
-
-int DefaultMQProducer::getRetryTimesWhenSendFailed()
-{
-    return m_retryTimesWhenSendFailed;
-}
-
-void DefaultMQProducer::setRetryTimesWhenSendFailed(int retryTimesWhenSendFailed)
-{
-    m_retryTimesWhenSendFailed = retryTimesWhenSendFailed;
-}
-
-int DefaultMQProducer::getCompressLevel()
-{
-    return m_compressLevel;
-}
-
-void DefaultMQProducer::setCompressLevel(int compressLevel)
-{
-    assert(compressLevel >= 0 && compressLevel <= 9 || compressLevel == -1);
-
-    m_compressLevel = compressLevel;
-}
-
-
-}
-

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/producer/DefaultMQProducerImpl.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/producer/DefaultMQProducerImpl.cpp b/rocketmq-client4cpp/src/producer/DefaultMQProducerImpl.cpp
deleted file mode 100755
index 26b3f0b..0000000
--- a/rocketmq-client4cpp/src/producer/DefaultMQProducerImpl.cpp
+++ /dev/null
@@ -1,932 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License")
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#include "DefaultMQProducerImpl.h"
-#include "DefaultMQProducer.h"
-#include "MessageExt.h"
-#include "QueryResult.h"
-#include "TopicPublishInfo.h"
-#include "MQClientException.h"
-#include "LocalTransactionExecuter.h"
-#include "SendMessageHook.h"
-#include "MQClientManager.h"
-#include "MQClientFactory.h"
-#include "Validators.h"
-#include "MQAdminImpl.h"
-#include "MQClientAPIImpl.h"
-#include "MessageSysFlag.h"
-#include "CommandCustomHeader.h"
-#include "KPRUtil.h"
-#include "MessageDecoder.h"
-#include "MessageQueueSelector.h"
-#include "MQProtos.h"
-#include "RemotingCommand.h"
-#include "UtilAll.h"
-
-
-
-namespace rmq
-{
-
-DefaultMQProducerImpl::DefaultMQProducerImpl(DefaultMQProducer
-        *pDefaultMQProducer)
-    : m_pDefaultMQProducer(pDefaultMQProducer),
-      m_serviceState(CREATE_JUST),
-      m_pMQClientFactory(NULL)
-{
-}
-
-DefaultMQProducerImpl::~DefaultMQProducerImpl()
-{
-	//delete m_pMQClientFactory;
-}
-
-
-void DefaultMQProducerImpl::start()
-{
-    start(true);
-}
-
-void DefaultMQProducerImpl::start(bool startFactory)
-{
-    RMQ_DEBUG("DefaultMQProducerImpl::start()");
-
-    switch (m_serviceState)
-    {
-        case CREATE_JUST:
-        {
-        	RMQ_INFO("the producer [{%s}] start beginning.",
-                	m_pDefaultMQProducer->getProducerGroup().c_str());
-
-            m_serviceState = START_FAILED;
-            checkConfig();
-
-            if (m_pDefaultMQProducer->getProducerGroup() !=
-                MixAll::CLIENT_INNER_PRODUCER_GROUP)
-            {
-                m_pDefaultMQProducer->changeInstanceNameToPID();
-            }
-
-            m_pMQClientFactory =
-                MQClientManager::getInstance()->getAndCreateMQClientFactory(
-                    *m_pDefaultMQProducer);
-            bool registerOK = m_pMQClientFactory->registerProducer(
-                                  m_pDefaultMQProducer->getProducerGroup(), this);
-
-            if (!registerOK)
-            {
-                m_serviceState = CREATE_JUST;
-                THROW_MQEXCEPTION(MQClientException,
-                                  "The producer group[" + m_pDefaultMQProducer->getProducerGroup()
-                                  + "] has been created before, specify another name please.", -1);
-            }
-
-            m_topicPublishInfoTable[m_pDefaultMQProducer->getCreateTopicKey()] =
-                TopicPublishInfo();
-
-            if (startFactory)
-            {
-                m_pMQClientFactory->start();
-            }
-
-			RMQ_INFO("the producer [%s] start OK", m_pDefaultMQProducer->getProducerGroup().c_str());
-            m_serviceState = RUNNING;
-        }
-        break;
-
-        case RUNNING:
-            RMQ_ERROR("This client is already running.");
-
-        case START_FAILED:
-            RMQ_ERROR("This client failed to start previously.");
-
-        case SHUTDOWN_ALREADY:
-            RMQ_ERROR("This client has been shutted down.");
-            THROW_MQEXCEPTION(MQClientException,
-                              "The producer service state not OK, maybe started once, ", -1);
-
-        default:
-            break;
-    }
-
-    m_pMQClientFactory->sendHeartbeatToAllBrokerWithLock();
-}
-
-void DefaultMQProducerImpl::shutdown()
-{
-    shutdown(true);
-}
-
-void DefaultMQProducerImpl::shutdown(bool shutdownFactory)
-{
-    RMQ_DEBUG("DefaultMQProducerImpl::shutdown()");
-
-    switch (m_serviceState)
-    {
-        case CREATE_JUST:
-            break;
-
-        case RUNNING:
-            m_pMQClientFactory->unregisterProducer(
-                m_pDefaultMQProducer->getProducerGroup());
-
-            if (shutdownFactory)
-            {
-                m_pMQClientFactory->shutdown();
-            }
-
-			RMQ_INFO("the producer [%s] shutdown OK", m_pDefaultMQProducer->getProducerGroup().c_str());
-            m_serviceState = SHUTDOWN_ALREADY;
-            break;
-
-        case SHUTDOWN_ALREADY:
-            break;
-
-        default:
-            break;
-    }
-}
-
-
-void DefaultMQProducerImpl::initTransactionEnv()
-{
-    //TODO
-}
-
-void DefaultMQProducerImpl::destroyTransactionEnv()
-{
-    //TODO
-}
-
-bool DefaultMQProducerImpl::hasHook()
-{
-    return !m_hookList.empty();
-}
-
-void DefaultMQProducerImpl::registerHook(SendMessageHook* pHook)
-{
-    m_hookList.push_back(pHook);
-}
-
-void DefaultMQProducerImpl::executeHookBefore(const SendMessageContext& context)
-{
-    std::list<SendMessageHook*>::iterator it = m_hookList.begin();
-
-    for (; it != m_hookList.end(); it++)
-    {
-        try
-        {
-            (*it)->sendMessageBefore(context);
-        }
-        catch (...)
-        {
-        	RMQ_WARN("sendMessageBefore exception");
-        }
-    }
-}
-
-void DefaultMQProducerImpl::executeHookAfter(const SendMessageContext& context)
-{
-    std::list<SendMessageHook*>::iterator it = m_hookList.begin();
-
-    for (; it != m_hookList.end(); it++)
-    {
-        try
-        {
-            (*it)->sendMessageAfter(context);
-        }
-        catch (...)
-        {
-        	RMQ_WARN("sendMessageAfter exception");
-        }
-    }
-}
-
-
-std::set<std::string> DefaultMQProducerImpl::getPublishTopicList()
-{
-	kpr::ScopedRLock<kpr::RWMutex> lock(m_topicPublishInfoTableLock);
-    std::set<std::string> toplist;
-    std::map<std::string, TopicPublishInfo>::iterator it =
-        m_topicPublishInfoTable.begin();
-    for (; it != m_topicPublishInfoTable.end(); it++)
-    {
-        toplist.insert(it->first);
-    }
-
-    return toplist;
-}
-
-bool DefaultMQProducerImpl::isPublishTopicNeedUpdate(const std::string& topic)
-{
-	kpr::ScopedRLock<kpr::RWMutex> lock(m_topicPublishInfoTableLock);
-    std::map<std::string, TopicPublishInfo>::iterator it =
-        m_topicPublishInfoTable.find(topic);
-    if (it != m_topicPublishInfoTable.end())
-    {
-        return !it->second.ok();
-    }
-
-    return true;
-}
-
-void DefaultMQProducerImpl::checkTransactionState(const std::string& addr, //
-        const MessageExt& msg, //
-        const CheckTransactionStateRequestHeader& checkRequestHeader)
-{
-    //TODO
-}
-
-void DefaultMQProducerImpl::updateTopicPublishInfo(const std::string& topic,
-        TopicPublishInfo& info)
-{
-	{
-		kpr::ScopedWLock<kpr::RWMutex> lock(m_topicPublishInfoTableLock);
-	    std::map<std::string, TopicPublishInfo>::iterator it =
-	        m_topicPublishInfoTable.find(topic);
-	    if (it != m_topicPublishInfoTable.end())
-	    {
-	        info.getSendWhichQueue() = it->second.getSendWhichQueue();
-	        RMQ_INFO("updateTopicPublishInfo prev is not null, %s", it->second.toString().c_str());
-	    }
-	    m_topicPublishInfoTable[topic] = info;
-    }
-}
-
-void DefaultMQProducerImpl::createTopic(const std::string& key,
-                                        const std::string& newTopic, int queueNum)
-{
-    makeSureStateOK();
-    Validators::checkTopic(newTopic);
-
-    m_pMQClientFactory->getMQAdminImpl()->createTopic(key, newTopic, queueNum);
-}
-
-std::vector<MessageQueue>* DefaultMQProducerImpl::fetchPublishMessageQueues(
-    const std::string& topic)
-{
-    makeSureStateOK();
-    return m_pMQClientFactory->getMQAdminImpl()->fetchPublishMessageQueues(topic);
-}
-
-long long DefaultMQProducerImpl::searchOffset(const MessageQueue& mq,
-        long long timestamp)
-{
-    makeSureStateOK();
-    return m_pMQClientFactory->getMQAdminImpl()->searchOffset(mq, timestamp);
-}
-
-long long DefaultMQProducerImpl::maxOffset(const MessageQueue& mq)
-{
-    makeSureStateOK();
-    return m_pMQClientFactory->getMQAdminImpl()->maxOffset(mq);
-}
-
-long long DefaultMQProducerImpl::minOffset(const MessageQueue& mq)
-{
-    makeSureStateOK();
-    return m_pMQClientFactory->getMQAdminImpl()->minOffset(mq);
-}
-
-long long DefaultMQProducerImpl::earliestMsgStoreTime(const MessageQueue& mq)
-{
-    makeSureStateOK();
-    return m_pMQClientFactory->getMQAdminImpl()->earliestMsgStoreTime(mq);
-}
-
-MessageExt* DefaultMQProducerImpl::viewMessage(const std::string& msgId)
-{
-    makeSureStateOK();
-    return m_pMQClientFactory->getMQAdminImpl()->viewMessage(msgId);
-}
-
-QueryResult DefaultMQProducerImpl::queryMessage(const std::string& topic,
-        const std::string& key, int maxNum, long long begin, long long end)
-{
-    makeSureStateOK();
-    return m_pMQClientFactory->getMQAdminImpl()->queryMessage(topic, key, maxNum,
-            begin, end);
-}
-
-
-/**
- * DEFAULT ASYNC -------------------------------------------------------
- */
-void DefaultMQProducerImpl::send(Message& msg, SendCallback* pSendCallback)
-{
-    send(msg, pSendCallback, m_pDefaultMQProducer->getSendMsgTimeout());
-}
-void DefaultMQProducerImpl::send(Message& msg, SendCallback* pSendCallback, int timeout)
-{
-    try
-    {
-        sendDefaultImpl(msg, ASYNC, pSendCallback, timeout);
-    }
-    catch (MQBrokerException& e)
-    {
-        THROW_MQEXCEPTION(MQClientException, std::string("unknow exception: ") + e.what(), -1);
-    }
-}
-
-
-/**
- * DEFAULT ONEWAY -------------------------------------------------------
- */
-void DefaultMQProducerImpl::sendOneway(Message& msg)
-{
-    try
-    {
-        sendDefaultImpl(msg, ONEWAY, NULL, m_pDefaultMQProducer->getSendMsgTimeout());
-    }
-    catch (MQBrokerException& e)
-    {
-        THROW_MQEXCEPTION(MQClientException, std::string("unknow exception: ") + e.what(), -1);
-    }
-}
-
-
-/**
- * KERNEL SYNC -------------------------------------------------------
- */
-SendResult DefaultMQProducerImpl::send(Message& msg, MessageQueue& mq)
-{
-    return send(msg, mq, m_pDefaultMQProducer->getSendMsgTimeout());
-}
-SendResult DefaultMQProducerImpl::send(Message& msg, MessageQueue& mq, int timeout)
-{
-    makeSureStateOK();
-    Validators::checkMessage(msg, m_pDefaultMQProducer);
-
-    if (msg.getTopic() != mq.getTopic())
-    {
-        THROW_MQEXCEPTION(MQClientException, "message's topic not equal mq's topic", -1);
-    }
-
-    return sendKernelImpl(msg, mq, SYNC, NULL, timeout);
-}
-
-
-/**
- * KERNEL ASYNC -------------------------------------------------------
- */
-void DefaultMQProducerImpl::send(Message& msg, MessageQueue& mq,
-                                 SendCallback* pSendCallback)
-{
-    return send(msg, mq, pSendCallback, m_pDefaultMQProducer->getSendMsgTimeout());
-}
-void DefaultMQProducerImpl::send(Message& msg, MessageQueue& mq,
-	SendCallback* pSendCallback, int timeout)
-{
-    makeSureStateOK();
-    Validators::checkMessage(msg, m_pDefaultMQProducer);
-
-    if (msg.getTopic() != mq.getTopic())
-    {
-        THROW_MQEXCEPTION(MQClientException, "message's topic not equal mq's topic", -1);
-    }
-
-    try
-    {
-        sendKernelImpl(msg, mq, ASYNC, pSendCallback, timeout);
-    }
-    catch (MQBrokerException& e)
-    {
-        THROW_MQEXCEPTION(MQClientException, std::string("unknow exception: ") + e.what(), -1);
-    }
-}
-
-/**
- * KERNEL ONEWAY -------------------------------------------------------
- */
-void DefaultMQProducerImpl::sendOneway(Message& msg, MessageQueue& mq)
-{
-    makeSureStateOK();
-    Validators::checkMessage(msg, m_pDefaultMQProducer);
-
-    if (msg.getTopic() != mq.getTopic())
-    {
-        THROW_MQEXCEPTION(MQClientException, "message's topic not equal mq's topic", -1);
-    }
-
-    try
-    {
-        sendKernelImpl(msg, mq, ONEWAY, NULL, m_pDefaultMQProducer->getSendMsgTimeout());
-    }
-    catch (MQBrokerException& e)
-    {
-        THROW_MQEXCEPTION(MQClientException, std::string("unknow exception: ") + e.what(), -1);
-    }
-}
-
-
-/**
- * SELECT SYNC -------------------------------------------------------
- */
-SendResult DefaultMQProducerImpl::send(Message& msg,
-                                       MessageQueueSelector* pSelector, void* arg)
-{
-    return send(msg, pSelector, arg, m_pDefaultMQProducer->getSendMsgTimeout());
-}
-SendResult DefaultMQProducerImpl::send(Message& msg,
-                                       MessageQueueSelector* pSelector, void* arg, int timeout)
-{
-    return sendSelectImpl(msg, pSelector, arg, SYNC, NULL, timeout);
-}
-
-
-/**
- * SELECT ASYNC -------------------------------------------------------
- */
-void DefaultMQProducerImpl::send(Message& msg,
-                                 MessageQueueSelector* pSelector,
-                                 void* arg,
-                                 SendCallback* pSendCallback)
-{
-    return send(msg, pSelector, arg, pSendCallback, m_pDefaultMQProducer->getSendMsgTimeout());
-}
-void DefaultMQProducerImpl::send(Message& msg,
-                                 MessageQueueSelector* pSelector,
-                                 void* arg,
-                                 SendCallback* pSendCallback,
-                                 int timeout)
-{
-    try
-    {
-        sendSelectImpl(msg, pSelector, arg, ASYNC, pSendCallback, timeout);
-    }
-    catch (MQBrokerException& e)
-    {
-        THROW_MQEXCEPTION(MQClientException, std::string("unknow exception: ") + e.what(), -1);
-    }
-}
-
-
-/**
- * SELECT ONEWAY -------------------------------------------------------
- */
-void DefaultMQProducerImpl::sendOneway(Message& msg,
-	MessageQueueSelector* pSelector, void* arg)
-{
-    try
-    {
-        sendSelectImpl(msg, pSelector, arg, ONEWAY, NULL,
-        	m_pDefaultMQProducer->getSendMsgTimeout());
-    }
-    catch (MQBrokerException& e)
-    {
-        THROW_MQEXCEPTION(MQClientException, std::string("unknow exception: ") + e.what(), -1);
-    }
-}
-
-
-/*
- * Send with Transaction
- */
-TransactionSendResult DefaultMQProducerImpl::sendMessageInTransaction(
-    Message& msg,
-    LocalTransactionExecuter* tranExecuter, void* arg)
-{
-    //TODO
-    TransactionSendResult result;
-    return result;
-}
-
-void DefaultMQProducerImpl::endTransaction(//
-    SendResult sendResult, //
-    LocalTransactionState localTransactionState, //
-    MQClientException localException)
-{
-    //TODO
-}
-
-/**
- * DEFAULT SYNC -------------------------------------------------------
- */
-SendResult DefaultMQProducerImpl::send(Message& msg)
-{
-    return send(msg, m_pDefaultMQProducer->getSendMsgTimeout());
-}
-SendResult DefaultMQProducerImpl::send(Message& msg, int timeout)
-{
-    return sendDefaultImpl(msg, SYNC, NULL, timeout);
-}
-
-
-std::map<std::string, TopicPublishInfo> DefaultMQProducerImpl::getTopicPublishInfoTable()
-{
-    return m_topicPublishInfoTable;
-}
-
-MQClientFactory* DefaultMQProducerImpl::getMQClientFactory()
-{
-    return m_pMQClientFactory;
-}
-
-int DefaultMQProducerImpl::getZipCompressLevel()
-{
-    return m_zipCompressLevel;
-}
-
-void DefaultMQProducerImpl::setZipCompressLevel(int zipCompressLevel)
-{
-    m_zipCompressLevel = zipCompressLevel;
-}
-
-ServiceState DefaultMQProducerImpl::getServiceState() {
-    return m_serviceState;
-}
-
-
-void DefaultMQProducerImpl::setServiceState(ServiceState serviceState) {
-    m_serviceState = serviceState;
-}
-
-
-SendResult DefaultMQProducerImpl::sendDefaultImpl(Message& msg,
-        CommunicationMode communicationMode,
-        SendCallback* pSendCallback,
-        int timeout)
-{
-    makeSureStateOK();
-    Validators::checkMessage(msg, m_pDefaultMQProducer);
-
-	long long maxTimeout = m_pDefaultMQProducer->getSendMsgTimeout() + 1000;
-    long long beginTimestamp = KPRUtil::GetCurrentTimeMillis();
-    long long endTimestamp = beginTimestamp;
-    TopicPublishInfo& topicPublishInfo = tryToFindTopicPublishInfo(msg.getTopic());
-    SendResult sendResult;
-
-    if (topicPublishInfo.ok())
-    {
-        MessageQueue* mq = NULL;
-
-		int times = 0;
-		int timesTotal = 1 + m_pDefaultMQProducer->getRetryTimesWhenSendFailed();
-		std::vector<std::string> brokersSent;
-        for (; times < timesTotal && int(endTimestamp - beginTimestamp) < maxTimeout; times++)
-        {
-            std::string lastBrokerName = (NULL == mq) ? "" : mq->getBrokerName();
-            MessageQueue* tmpmq = topicPublishInfo.selectOneMessageQueue(lastBrokerName);
-
-            if (tmpmq != NULL)
-            {
-                mq = tmpmq;
-                brokersSent.push_back(mq->getBrokerName());
-
-                try
-                {
-                    sendResult = sendKernelImpl(msg, *mq, communicationMode, pSendCallback, timeout);
-                    endTimestamp = KPRUtil::GetCurrentTimeMillis();
-
-                    switch (communicationMode)
-                    {
-                        case ASYNC:
-                            return sendResult;
-
-                        case ONEWAY:
-                            return sendResult;
-
-                        case SYNC:
-                            if (sendResult.getSendStatus() != SEND_OK)
-                            {
-                                if (m_pDefaultMQProducer->isRetryAnotherBrokerWhenNotStoreOK())
-                                {
-                                    continue;
-                                }
-                            }
-
-                            return sendResult;
-
-                        default:
-                            break;
-                    }
-                }
-                catch (RemotingException& e)
-                {
-                    endTimestamp = KPRUtil::GetCurrentTimeMillis();
-                    continue;
-                }
-                catch (MQClientException& e)
-                {
-                    endTimestamp = KPRUtil::GetCurrentTimeMillis();
-                    continue;
-                }
-                catch (MQBrokerException& e)
-                {
-                    endTimestamp = KPRUtil::GetCurrentTimeMillis();
-
-                    switch (e.GetError())
-                    {
-                        case TOPIC_NOT_EXIST_VALUE:
-                        case SERVICE_NOT_AVAILABLE_VALUE:
-                        case SYSTEM_ERROR_VALUE:
-                        case NO_PERMISSION_VALUE:
-                        case NO_BUYER_ID_VALUE:
-                        case NOT_IN_CURRENT_UNIT_VALUE:
-                            continue;
-                        default:
-                        	if (sendResult.hasResult())
-                        	{
-                            	return sendResult;
-                            }
-                            throw;
-                    }
-                }
-                catch (InterruptedException& e)
-                {
-                	endTimestamp = KPRUtil::GetCurrentTimeMillis();
-                    throw;
-                }
-            }
-            else
-            {
-                break;
-            }
-        } // end of for
-
-		std::string info = RocketMQUtil::str2fmt("Send [%d] times, still failed, cost [%d]ms, Topic: %s, BrokersSent: %s",
-			times, int(endTimestamp - beginTimestamp), msg.getTopic().c_str(), UtilAll::toString(brokersSent).c_str());
-		RMQ_WARN("%s", info.c_str());
-        THROW_MQEXCEPTION(MQClientException, info, -1);
-        return sendResult;
-    }
-
-    std::vector<std::string> nsList =
-        getMQClientFactory()->getMQClientAPIImpl()->getNameServerAddressList();
-    if (nsList.empty())
-    {
-        THROW_MQEXCEPTION(MQClientException, "No name server address, please set it", -1);
-    }
-
-    THROW_MQEXCEPTION(MQClientException, std::string("No route info of this topic, ") + msg.getTopic(), -1);
-}
-
-SendResult DefaultMQProducerImpl::sendKernelImpl(Message& msg,
-        const MessageQueue& mq,
-        CommunicationMode communicationMode,
-        SendCallback* sendCallback,
-        int timeout)
-{
-    std::string brokerAddr = m_pMQClientFactory->findBrokerAddressInPublish(mq.getBrokerName());
-    if (brokerAddr.empty())
-    {
-        tryToFindTopicPublishInfo(mq.getTopic());
-        brokerAddr = m_pMQClientFactory->findBrokerAddressInPublish(mq.getBrokerName());
-    }
-
-    SendMessageContext context;
-    if (!brokerAddr.empty())
-    {
-        try
-        {
-            int sysFlag = 0;
-
-            if (tryToCompressMessage(msg))
-            {
-                sysFlag |= MessageSysFlag::CompressedFlag;
-            }
-
-            std::string tranMsg = msg.getProperty(Message::PROPERTY_TRANSACTION_PREPARED);
-            if (!tranMsg.empty() && tranMsg == "true")
-            {
-                sysFlag |= MessageSysFlag::TransactionPreparedType;
-            }
-
-            // ִ��hook
-            if (hasHook())
-            {
-                context.producerGroup = (m_pDefaultMQProducer->getProducerGroup());
-                context.communicationMode = (communicationMode);
-                context.brokerAddr = (brokerAddr);
-                context.msg = (msg);
-                context.mq = (mq);
-                executeHookBefore(context);
-            }
-
-            SendMessageRequestHeader* requestHeader = new SendMessageRequestHeader();
-            requestHeader->producerGroup = (m_pDefaultMQProducer->getProducerGroup());
-            requestHeader->topic = (msg.getTopic());
-            requestHeader->defaultTopic = (m_pDefaultMQProducer->getCreateTopicKey());
-            requestHeader->defaultTopicQueueNums = (m_pDefaultMQProducer->getDefaultTopicQueueNums());
-            requestHeader->queueId = (mq.getQueueId());
-            requestHeader->sysFlag = (sysFlag);
-            requestHeader->bornTimestamp = (KPRUtil::GetCurrentTimeMillis());
-            requestHeader->flag = (msg.getFlag());
-            requestHeader->properties = (MessageDecoder::messageProperties2String(msg.getProperties()));
-            requestHeader->reconsumeTimes = 0;
-
-			if (requestHeader->topic.find(MixAll::RETRY_GROUP_TOPIC_PREFIX) == 0)
-			{
-                std::string reconsumeTimes = msg.getProperty(Message::PROPERTY_RECONSUME_TIME);
-                if (!reconsumeTimes.empty())
-                {
-                    requestHeader->reconsumeTimes = int(UtilAll::str2ll(reconsumeTimes.c_str()));
-                    msg.clearProperty(Message::PROPERTY_RECONSUME_TIME);
-                }
-
-				/*
-				3.5.8 new features
-                std::string maxReconsumeTimes = msg.getProperty(Message::PROPERTY_MAX_RECONSUME_TIMES);
-                if (!maxReconsumeTimes.empty())
-                {
-                    requestHeader->maxReconsumeTimes = int(UtilAll::str2ll(maxReconsumeTimes.c_str()));
-                    msg.clearProperty(Message::PROPERTY_MAX_RECONSUME_TIMES);
-                }
-                */
-            }
-
-            SendResult sendResult = m_pMQClientFactory->getMQClientAPIImpl()->sendMessage(
-			    brokerAddr,
-			    mq.getBrokerName(),
-			    msg,
-			    requestHeader,
-			    timeout,
-			    communicationMode,
-			    sendCallback
-			);
-
-            if (hasHook())
-            {
-                context.sendResult = (sendResult);
-                executeHookAfter(context);
-            }
-
-            return sendResult;
-        }
-        catch (RemotingException& e)
-        {
-            if (hasHook())
-            {
-                context.pException = (&e);
-                executeHookAfter(context);
-            }
-			RMQ_WARN("sendKernelImpl exception: %s, msg: %s", e.what(), msg.toString().c_str());
-            throw;
-        }
-        catch (MQBrokerException& e)
-        {
-            if (hasHook())
-            {
-                context.pException = (&e);
-                executeHookAfter(context);
-            }
-			RMQ_WARN("sendKernelImpl exception: %s, msg: %s", e.what(), msg.toString().c_str());
-            throw;
-        }
-        catch (InterruptedException& e)
-        {
-            if (hasHook())
-            {
-                context.pException = (&e);
-                executeHookAfter(context);
-            }
-			RMQ_WARN("sendKernelImpl exception: %s, msg: %s", e.what(), msg.toString().c_str());
-            throw;
-        }
-    }
-
-    THROW_MQEXCEPTION(MQClientException, std::string("The broker[") + mq.getBrokerName() + "] not exist", -1);
-}
-
-SendResult DefaultMQProducerImpl::sendSelectImpl(Message& msg,
-        MessageQueueSelector* selector,
-        void* pArg,
-        CommunicationMode communicationMode,
-        SendCallback* sendCallback,
-        int timeout)
-{
-    makeSureStateOK();
-    Validators::checkMessage(msg, m_pDefaultMQProducer);
-
-    SendResult result;
-    TopicPublishInfo& topicPublishInfo = tryToFindTopicPublishInfo(msg.getTopic());
-    SendResult sendResult;
-
-    if (topicPublishInfo.ok())
-    {
-        MessageQueue* mq = NULL;
-
-		try
-		{
-			mq = selector->select(topicPublishInfo.getMessageQueueList(), msg, pArg);
-		}
-		catch (std::exception& e)
-		{
-            THROW_MQEXCEPTION(MQClientException,
-            	std::string("select message queue throwed exception, ") + e.what(), -1);
-        }
-        catch (...)
-		{
-            THROW_MQEXCEPTION(MQClientException, "select message queue throwed exception, ", -1);
-        }
-
-        if (mq != NULL)
-        {
-            return sendKernelImpl(msg, *mq, communicationMode, sendCallback, timeout);
-        }
-        else
-        {
-            THROW_MQEXCEPTION(MQClientException, "select message queue return null", -1);
-        }
-    }
-
-    THROW_MQEXCEPTION(MQClientException, std::string("No route info of this topic, ") + msg.getTopic(), -1);
-}
-
-void DefaultMQProducerImpl::makeSureStateOK()
-{
-    if (m_serviceState != RUNNING)
-    {
-        THROW_MQEXCEPTION(MQClientException, "The producer service state not OK, ", -1);
-    }
-}
-
-void DefaultMQProducerImpl::checkConfig()
-{
-	Validators::checkGroup(m_pDefaultMQProducer->getProducerGroup());
-
-    if (m_pDefaultMQProducer->getProducerGroup().empty())
-    {
-        THROW_MQEXCEPTION(MQClientException, "producerGroup is null", -1);
-    }
-
-    if (m_pDefaultMQProducer->getProducerGroup() == MixAll::DEFAULT_PRODUCER_GROUP)
-    {
-    	THROW_MQEXCEPTION(MQClientException,
-    		std::string("producerGroup can not equal [") + MixAll::DEFAULT_PRODUCER_GROUP + "], please specify another one",
-    		-1);
-    }
-}
-
-TopicPublishInfo& DefaultMQProducerImpl::tryToFindTopicPublishInfo(
-    const std::string& topic)
-{
-	std::map<std::string, TopicPublishInfo>::iterator it;
-	{
-		kpr::ScopedRLock<kpr::RWMutex> lock(m_topicPublishInfoTableLock);
-	    it = m_topicPublishInfoTable.find(topic);
-    }
-
-    if (it == m_topicPublishInfoTable.end() || !it->second.ok())
-    {
-    	{
-	    	kpr::ScopedWLock<kpr::RWMutex> lock(m_topicPublishInfoTableLock);
-	        m_topicPublishInfoTable[topic] = TopicPublishInfo();
-        }
-
-        m_pMQClientFactory->updateTopicRouteInfoFromNameServer(topic);
-
-        {
-	        kpr::ScopedRLock<kpr::RWMutex> lock(m_topicPublishInfoTableLock);
-	        it = m_topicPublishInfoTable.find(topic);
-        }
-    }
-
-    if (it != m_topicPublishInfoTable.end()
-    	&& (it->second.ok() || it->second.isHaveTopicRouterInfo()))
-    {
-    	return (it->second);
-    }
-    else
-    {
-    	m_pMQClientFactory->updateTopicRouteInfoFromNameServer(topic, true,
-                m_pDefaultMQProducer);
-        {
-	        kpr::ScopedRLock<kpr::RWMutex> lock(m_topicPublishInfoTableLock);
-    	    it = m_topicPublishInfoTable.find(topic);
-    	}
-    	return (it->second);
-    }
-}
-
-bool DefaultMQProducerImpl::tryToCompressMessage(Message& msg)
-{
-    if (msg.getBodyLen() >= m_pDefaultMQProducer->getCompressMsgBodyOverHowmuch())
-    {
-        if (msg.tryToCompress(m_pDefaultMQProducer->getCompressLevel()))
-        {
-            return true;
-        }
-    }
-
-    return false;
-}
-
-TransactionCheckListener* DefaultMQProducerImpl::checkListener()
-{
-    return NULL;
-}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/producer/DefaultMQProducerImpl.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/producer/DefaultMQProducerImpl.h b/rocketmq-client4cpp/src/producer/DefaultMQProducerImpl.h
deleted file mode 100755
index 3df914c..0000000
--- a/rocketmq-client4cpp/src/producer/DefaultMQProducerImpl.h
+++ /dev/null
@@ -1,205 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __DEFAULTMQPRODUCERIMPL_H__
-#define __DEFAULTMQPRODUCERIMPL_H__
-
-#include <list>
-#include <vector>
-#include "MQProducerInner.h"
-#include "QueryResult.h"
-#include "ServiceState.h"
-#include "CommunicationMode.h"
-#include "SendResult.h"
-#include "MQClientException.h"
-#include "Mutex.h"
-#include "ScopedLock.h"
-
-
-namespace rmq
-{
-    class DefaultMQProducer;
-    class SendMessageHook;
-    class SendMessageContext;
-    class MessageQueue;
-    class MessageExt;
-    class SendCallback;
-    class MessageQueueSelector;
-    class MQClientFactory;
-    class MQClientException;
-    class RemotingException;
-    class MQBrokerException;
-    class InterruptedException;
-    class LocalTransactionExecuter;
-
-
-    class DefaultMQProducerImpl : public MQProducerInner
-    {
-    public:
-        DefaultMQProducerImpl(DefaultMQProducer* pDefaultMQProducer);
-		~DefaultMQProducerImpl();
-        void initTransactionEnv();
-        void destroyTransactionEnv();
-
-        bool hasHook();
-        void registerHook(SendMessageHook* pHook);
-        void executeHookBefore(const SendMessageContext& context);
-        void executeHookAfter(const SendMessageContext& context);
-
-        void start();
-        void start(bool startFactory);
-        void shutdown();
-        void shutdown(bool shutdownFactory);
-
-        std::set<std::string> getPublishTopicList();
-        bool isPublishTopicNeedUpdate(const std::string& topic);
-
-        void checkTransactionState(const std::string& addr,
-                                   const MessageExt& msg,
-                                   const CheckTransactionStateRequestHeader& checkRequestHeader);
-
-        void updateTopicPublishInfo(const std::string& topic, TopicPublishInfo& info);
-        virtual TransactionCheckListener* checkListener();
-
-        void createTopic(const std::string& key, const std::string& newTopic, int queueNum);
-        std::vector<MessageQueue>* fetchPublishMessageQueues(const std::string& topic);
-
-        long long searchOffset(const MessageQueue& mq, long long timestamp);
-        long long maxOffset(const MessageQueue& mq);
-        long long minOffset(const MessageQueue& mq);
-
-        long long earliestMsgStoreTime(const MessageQueue& mq);
-
-        MessageExt* viewMessage(const std::string& msgId);
-        QueryResult queryMessage(const std::string& topic,
-                                 const std::string& key,
-                                 int maxNum,
-                                 long long begin,
-                                 long long end);
-
-        /**
-        * DEFAULT ASYNC -------------------------------------------------------
-        */
-        void send(Message& msg, SendCallback* sendCallback);
-		void send(Message& msg, SendCallback* sendCallback, int timeout);
-
-        /**
-        * DEFAULT ONEWAY -------------------------------------------------------
-        */
-        void sendOneway(Message& msg);
-
-        /**
-        * KERNEL SYNC -------------------------------------------------------
-        */
-        SendResult send(Message& msg, MessageQueue& mq);
-		SendResult send(Message& msg, MessageQueue& mq, int timeout);
-
-        /**
-        * KERNEL ASYNC -------------------------------------------------------
-        */
-        void send(Message& msg, MessageQueue& mq, SendCallback* sendCallback);
-		void send(Message& msg, MessageQueue& mq, SendCallback* sendCallback, int timeout);
-
-        /**
-        * KERNEL ONEWAY -------------------------------------------------------
-        */
-        void sendOneway(Message& msg, MessageQueue& mq);
-
-        /**
-        * SELECT SYNC -------------------------------------------------------
-        */
-        SendResult send(Message& msg, MessageQueueSelector* selector, void* arg);
-		SendResult send(Message& msg, MessageQueueSelector* selector, void* arg, int timeout);
-
-        /**
-        * SELECT ASYNC -------------------------------------------------------
-        */
-        void send(Message& msg, MessageQueueSelector* selector, void* arg, SendCallback* sendCallback);
-		void send(Message& msg, MessageQueueSelector* selector, void* arg, SendCallback* sendCallback, int timeout);
-
-        /**
-        * SELECT ONEWAY -------------------------------------------------------
-        */
-        void sendOneway(Message& msg, MessageQueueSelector* selector, void* arg);
-
-		/**
-		* SEND with Transaction
-		*/
-        TransactionSendResult sendMessageInTransaction(Message& msg, LocalTransactionExecuter* tranExecuter, void* arg);
-
-        /**
-        * DEFAULT SYNC -------------------------------------------------------
-        */
-        SendResult send(Message& msg);
-		SendResult send(Message& msg, int timeout);
-
-        std::map<std::string, TopicPublishInfo> getTopicPublishInfoTable();
-
-        MQClientFactory* getMQClientFactory();
-
-        int getZipCompressLevel();
-        void setZipCompressLevel(int zipCompressLevel);
-
-		ServiceState getServiceState();
-		void setServiceState(ServiceState serviceState);
-
-    private:
-        SendResult sendSelectImpl(Message& msg,
-                                  MessageQueueSelector* selector,
-                                  void* pArg,
-                                  CommunicationMode communicationMode,
-                                  SendCallback* sendCallback,
-                                  int timeout);
-
-        SendResult sendDefaultImpl(Message& msg,
-                                   CommunicationMode communicationMode,
-                                   SendCallback* pSendCallback,
-                                   int timeout);
-
-        SendResult sendKernelImpl(Message& msg,
-                                  const MessageQueue& mq,
-                                  CommunicationMode communicationMode,
-                                  SendCallback* pSendCallback,
-                                  int timeout);
-
-        void endTransaction(SendResult sendResult,
-                            LocalTransactionState localTransactionState,
-                            MQClientException localException);
-
-        void makeSureStateOK();
-        void checkConfig();
-
-        TopicPublishInfo& tryToFindTopicPublishInfo(const std::string& topic) ;
-        bool tryToCompressMessage(Message& msg);
-
-    protected:
-        //TODO transaction imp
-
-    private:
-        int m_zipCompressLevel;// message compress level, default is 5
-
-        DefaultMQProducer* m_pDefaultMQProducer;
-
-        std::map<std::string, TopicPublishInfo> m_topicPublishInfoTable;
-		kpr::RWMutex m_topicPublishInfoTableLock;
-
-        ServiceState m_serviceState;
-        MQClientFactory* m_pMQClientFactory;
-        std::list<SendMessageHook*> m_hookList;
-    };
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/producer/LocalTransactionExecuter.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/producer/LocalTransactionExecuter.h b/rocketmq-client4cpp/src/producer/LocalTransactionExecuter.h
deleted file mode 100755
index a124884..0000000
--- a/rocketmq-client4cpp/src/producer/LocalTransactionExecuter.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * Copyright (C) 2013 kangliqiang ,kangliq@163.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef __LOCALTRANSACTIONEXECUTER_H__
-#define __LOCALTRANSACTIONEXECUTER_H__
-
-#include "SendResult.h"
-
-namespace rmq
-{
-	class LocalTransactionExecuter
-	{
-	public:
-	    virtual~LocalTransactionExecuter() {}
-	    virtual LocalTransactionState executeLocalTransactionBranch(Message& msg, void* arg) = 0;
-	};
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/producer/MQProducerInner.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/producer/MQProducerInner.h b/rocketmq-client4cpp/src/producer/MQProducerInner.h
deleted file mode 100755
index 56194dc..0000000
--- a/rocketmq-client4cpp/src/producer/MQProducerInner.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __MQPRODUCERINNER_H__
-#define __MQPRODUCERINNER_H__
-
-#include <string>
-#include <set>
-
-namespace rmq
-{
-	class TransactionCheckListener;
-	class MessageExt;
-	class CheckTransactionStateRequestHeader;
-	class TopicPublishInfo;
-
-	class MQProducerInner
-	{
-	public:
-	    virtual ~MQProducerInner() {}
-	    virtual std::set<std::string> getPublishTopicList() = 0;
-	    virtual bool isPublishTopicNeedUpdate(const std::string& topic) = 0;
-	    virtual TransactionCheckListener* checkListener() = 0;
-	    virtual void checkTransactionState(const std::string& addr, //
-	                                       const MessageExt& msg, //
-	                                       const CheckTransactionStateRequestHeader& checkRequestHeader) = 0;
-	    virtual void updateTopicPublishInfo(const std::string& topic, TopicPublishInfo& info) = 0;
-	};
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/producer/MessageQueueSelector.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/producer/MessageQueueSelector.h b/rocketmq-client4cpp/src/producer/MessageQueueSelector.h
deleted file mode 100755
index 6d5ac48..0000000
--- a/rocketmq-client4cpp/src/producer/MessageQueueSelector.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __MESSAGEQUEUESELECTOR_H__
-#define __MESSAGEQUEUESELECTOR_H__
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <time.h>
-#include <math.h>
-#include <set>
-#include <string>
-#include <vector>
-
-#include "MessageQueue.h"
-#include "UtilAll.h"
-
-namespace rmq
-{
-    class Message;
-
-    class MessageQueueSelector
-    {
-    public:
-        virtual ~MessageQueueSelector() {}
-        virtual MessageQueue* select(std::vector<MessageQueue>& mqs, const Message& msg, void* arg) = 0;
-    };
-
-    class SelectMessageQueueByRandoom : public MessageQueueSelector
-    {
-    public:
-        MessageQueue* select(std::vector<MessageQueue>& mqs, const Message& msg, void* arg)
-        {
-            srand((unsigned)time(NULL));
-            int value = rand();
-            value = value % mqs.size();
-            return &(mqs.at(value));
-        }
-    };
-
-    class SelectMessageQueueByHash : public MessageQueueSelector
-    {
-    public:
-        MessageQueue* select(std::vector<MessageQueue>& mqs, const Message& msg, void* arg)
-        {
-			std::string* sArg = (std::string*)arg;
-            int value = UtilAll::hashCode(sArg->c_str(), sArg->size());
-            if (value < 0)
-            {
-                value = abs(value);
-            }
-
-            value = value % mqs.size();
-            return &(mqs.at(value));
-        }
-    };
-
-
-    class SelectMessageQueueByMachineRoom : public MessageQueueSelector
-    {
-    public:
-        MessageQueue* select(std::vector<MessageQueue>& mqs, const Message& msg, void* arg)
-        {
-            // TODO Auto-generated method stub
-            return NULL;
-        }
-
-        std::set<std::string> getConsumeridcs()
-        {
-            return m_consumeridcs;
-        }
-
-        void setConsumeridcs(const std::set<std::string>& consumeridcs)
-        {
-            m_consumeridcs = consumeridcs;
-        }
-
-    private:
-        std::set<std::string> m_consumeridcs;
-    };
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/producer/ProducerInvokeCallback.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/producer/ProducerInvokeCallback.cpp b/rocketmq-client4cpp/src/producer/ProducerInvokeCallback.cpp
deleted file mode 100755
index 573db95..0000000
--- a/rocketmq-client4cpp/src/producer/ProducerInvokeCallback.cpp
+++ /dev/null
@@ -1,101 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#include "ProducerInvokeCallback.h"
-#include "ResponseFuture.h"
-#include "SendResult.h"
-#include "MQClientAPIImpl.h"
-#include "SendCallback.h"
-#include "MQClientException.h"
-#include "RemotingCommand.h"
-
-namespace rmq
-{
-
-ProducerInvokeCallback::ProducerInvokeCallback(SendCallback* pSendCallBack,
-        MQClientAPIImpl* pMQClientAPIImpl,
-        const std::string& topic,
-        const std::string& brokerName)
-    : m_pSendCallBack(pSendCallBack),
-      m_pMQClientAPIImpl(pMQClientAPIImpl),
-      m_topic(topic),
-      m_brokerName(brokerName)
-{
-}
-
-ProducerInvokeCallback::~ProducerInvokeCallback()
-{
-	if (m_pSendCallBack)
-	{
-		delete m_pSendCallBack;
-		m_pSendCallBack = NULL;
-	}
-}
-
-void ProducerInvokeCallback::operationComplete(ResponseFuturePtr pResponseFuture)
-{
-    if (m_pSendCallBack == NULL)
-    {
-        delete this;
-        return;
-    }
-
-    RemotingCommand* response = pResponseFuture->getResponseCommand();
-    if (response != NULL)
-    {
-        try
-        {
-            SendResult* sendResult =
-                m_pMQClientAPIImpl->processSendResponse(m_brokerName, m_topic, response);
-
-			assert(sendResult != NULL);
-            m_pSendCallBack->onSuccess(*sendResult);
-
-            delete sendResult;
-        }
-        catch (MQException& e)
-        {
-            m_pSendCallBack->onException(e);
-        }
-
-        delete response;
-    }
-    else
-    {
-        if (!pResponseFuture->isSendRequestOK())
-        {
-            std::string msg = "send request failed";
-            MQClientException e(msg, -1, __FILE__, __LINE__);
-            m_pSendCallBack->onException(e);
-        }
-        else if (pResponseFuture->isTimeout())
-        {
-            std::string msg = RocketMQUtil::str2fmt("wait response timeout %lld ms",
-            	pResponseFuture->getTimeoutMillis());
-            MQClientException e(msg, -1, __FILE__, __LINE__);
-            m_pSendCallBack->onException(e);
-        }
-        else
-        {
-            std::string msg = "unknow reseaon";
-            MQClientException e(msg, -1, __FILE__, __LINE__);
-            m_pSendCallBack->onException(e);
-        }
-    }
-
-    delete this;
-}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/producer/ProducerInvokeCallback.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/producer/ProducerInvokeCallback.h b/rocketmq-client4cpp/src/producer/ProducerInvokeCallback.h
deleted file mode 100755
index d2c9825..0000000
--- a/rocketmq-client4cpp/src/producer/ProducerInvokeCallback.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __PRODUCERINVOKECALLBACK_H__
-#define __PRODUCERINVOKECALLBACK_H__
-
-#include <string>
-#include "InvokeCallback.h"
-
-namespace rmq
-{
-  class MQClientAPIImpl;
-  class SendCallback;
-
-  class ProducerInvokeCallback : public InvokeCallback
-  {
-  public:
-      ProducerInvokeCallback(SendCallback* pSendCallBack,
-                             MQClientAPIImpl* pMQClientAPIImpl,
-                             const std::string& topic,
-                             const std::string& brokerName);
-      virtual ~ProducerInvokeCallback();
-      virtual void operationComplete(ResponseFuturePtr pResponseFuture);
-
-  private:
-      SendCallback* m_pSendCallBack;
-      MQClientAPIImpl* m_pMQClientAPIImpl;
-      std::string m_topic;
-      std::string m_brokerName;
-  };
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/producer/TopicPublishInfo.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/producer/TopicPublishInfo.h b/rocketmq-client4cpp/src/producer/TopicPublishInfo.h
deleted file mode 100755
index 0d85b5f..0000000
--- a/rocketmq-client4cpp/src/producer/TopicPublishInfo.h
+++ /dev/null
@@ -1,141 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __TOPICPUBLISHINFO_H__
-#define __TOPICPUBLISHINFO_H__
-
-#include <list>
-#include <vector>
-#include <string>
-#include <sstream>
-#include <math.h>
-#include <stdlib.h>
-
-#include "RocketMQClient.h"
-#include "RefHandle.h"
-#include "MessageQueue.h"
-#include "AtomicValue.h"
-#include "UtilAll.h"
-
-
-namespace rmq
-{
-    class TopicPublishInfo : public kpr::RefCount
-    {
-    public:
-        TopicPublishInfo()
-        {
-            m_orderTopic = false;
-			m_haveTopicRouterInfo = false;
-        }
-
-        ~TopicPublishInfo()
-        {
-            m_messageQueueList.clear();
-        }
-
-        bool isOrderTopic()
-        {
-            return m_orderTopic;
-        }
-
-        bool ok()
-        {
-            return !m_messageQueueList.empty();
-        }
-
-        void setOrderTopic(bool orderTopic)
-        {
-            m_orderTopic = orderTopic;
-        }
-
-        std::vector<MessageQueue>& getMessageQueueList()
-        {
-            return m_messageQueueList;
-        }
-
-        void setMessageQueueList(const std::vector<MessageQueue>& messageQueueList)
-        {
-            m_messageQueueList = messageQueueList;
-        }
-
-        kpr::AtomicInteger& getSendWhichQueue()
-        {
-            return m_sendWhichQueue;
-        }
-
-        void setSendWhichQueue(kpr::AtomicInteger& sendWhichQueue)
-        {
-            m_sendWhichQueue = sendWhichQueue;
-        }
-
-		bool isHaveTopicRouterInfo()
-		{
-        	return m_haveTopicRouterInfo;
-	    }
-
-
-	    void setHaveTopicRouterInfo(bool haveTopicRouterInfo)
-		{
-	        m_haveTopicRouterInfo = haveTopicRouterInfo;
-	    }
-
-        MessageQueue* selectOneMessageQueue(const std::string lastBrokerName)
-        {
-            if (!lastBrokerName.empty())
-            {
-                int index = m_sendWhichQueue++;
-                for (size_t i = 0; i < m_messageQueueList.size(); i++)
-                {
-                    int pos = abs(index++) % m_messageQueueList.size();
-                    MessageQueue& mq = m_messageQueueList.at(pos);
-                    if (mq.getBrokerName() != lastBrokerName)
-                    {
-                        return &mq;
-                    }
-                }
-
-                return NULL;
-            }
-            else
-            {
-                int index = m_sendWhichQueue++;
-                int pos = abs(index) % m_messageQueueList.size();
-                return &(m_messageQueueList.at(pos));
-            }
-        }
-
-		std::string toString() const
-		{
-			std::stringstream ss;
-		    ss << "{orderTopic=" << m_orderTopic
-		       << ",messageQueueList=" << UtilAll::toString(m_messageQueueList)
-		       << ",sendWhichQueue=" << m_sendWhichQueue
-		       << ",haveTopicRouterInfo=" << m_haveTopicRouterInfo
-		       << "}";
-		    return ss.str();
-    	}
-
-    private:
-        bool m_orderTopic;
-        std::vector<MessageQueue> m_messageQueueList;
-        kpr::AtomicInteger m_sendWhichQueue;
-		bool m_haveTopicRouterInfo;
-    };
-	typedef kpr::RefHandleT<TopicPublishInfo> TopicPublishInfoPtr;
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/producer/TransactionCheckListener.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/producer/TransactionCheckListener.h b/rocketmq-client4cpp/src/producer/TransactionCheckListener.h
deleted file mode 100755
index 8955742..0000000
--- a/rocketmq-client4cpp/src/producer/TransactionCheckListener.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * Copyright (C) 2013 kangliqiang ,kangliq@163.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef __TRANSACTIONCHECKLISTENER_H__
-#define __TRANSACTIONCHECKLISTENER_H__
-
-#include "SendResult.h"
-
-namespace rmq
-{
-	class TransactionCheckListener
-	{
-	public:
-	    virtual ~TransactionCheckListener() {}
-	    virtual LocalTransactionState checkLocalTransactionState(MessageExt* pMsg) = 0;
-	};
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/producer/TransactionMQProducer.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/producer/TransactionMQProducer.h b/rocketmq-client4cpp/src/producer/TransactionMQProducer.h
deleted file mode 100755
index bee11a5..0000000
--- a/rocketmq-client4cpp/src/producer/TransactionMQProducer.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#ifndef __TRANSACTIONMQPRODUCER_H__
-#define __TRANSACTIONMQPRODUCER_H__
-
-#include "DefaultMQProducer.h"
-#include "DefaultMQProducerImpl.h"
-#include "MQClientException.h"
-
-namespace rmq
-{
-    class TransactionMQProducer : public DefaultMQProducer
-    {
-    public:
-        TransactionMQProducer()
-            : m_pTransactionCheckListener(NULL),
-              m_checkThreadPoolMinSize(1),
-              m_checkThreadPoolMaxSize(1),
-              m_checkRequestHoldMax(2000)
-        {
-
-        }
-
-        TransactionMQProducer(const std::string& producerGroup)
-            : DefaultMQProducer(producerGroup),
-              m_pTransactionCheckListener(NULL),
-              m_checkThreadPoolMinSize(1),
-              m_checkThreadPoolMaxSize(1),
-              m_checkRequestHoldMax(2000)
-        {
-
-        }
-
-        void start()
-        {
-            m_pDefaultMQProducerImpl->initTransactionEnv();
-            DefaultMQProducer::start();
-        }
-
-        void shutdown()
-        {
-            DefaultMQProducer::shutdown();
-            m_pDefaultMQProducerImpl->destroyTransactionEnv();
-        }
-
-        TransactionSendResult sendMessageInTransaction(const Message& msg,
-                LocalTransactionExecuter* tranExecuter, void* arg)
-        {
-            if (NULL == m_pTransactionCheckListener)
-            {
-                THROW_MQEXCEPTION("localTransactionBranchCheckListener is null", -1);
-            }
-
-            return m_pDefaultMQProducerImpl.sendMessageInTransaction(msg, tranExecuter, arg);
-        }
-
-        TransactionCheckListener* getTransactionCheckListener()
-        {
-            return m_pTransactionCheckListener;
-        }
-
-        void setTransactionCheckListener(TransactionCheckListener* pTransactionCheckListener)
-        {
-            m_pTransactionCheckListener = pTransactionCheckListener;
-        }
-
-        int getCheckThreadPoolMinSize()
-        {
-            return m_checkThreadPoolMinSize;
-        }
-
-        void setCheckThreadPoolMinSize(int checkThreadPoolMinSize)
-        {
-            m_checkThreadPoolMinSize = checkThreadPoolMinSize;
-        }
-
-        int getCheckThreadPoolMaxSize()
-        {
-            return m_checkThreadPoolMaxSize;
-        }
-
-        void setCheckThreadPoolMaxSize(int checkThreadPoolMaxSize)
-        {
-            m_checkThreadPoolMaxSize = checkThreadPoolMaxSize;
-        }
-
-        int getCheckRequestHoldMax()
-        {
-            return m_checkRequestHoldMax;
-        }
-
-        void setCheckRequestHoldMax(int checkRequestHoldMax)
-        {
-            m_checkRequestHoldMax = checkRequestHoldMax;
-        }
-
-    private:
-        TransactionCheckListener* m_pTransactionCheckListener;
-        int m_checkThreadPoolMinSize;
-        int m_checkThreadPoolMaxSize;
-        int m_checkRequestHoldMax;
-    };
-}
-
-#endif


[12/17] incubator-rocketmq-externals git commit: Polish cpp module

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/consumer/ConsumeMessageOrderlyService.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/consumer/ConsumeMessageOrderlyService.cpp b/rocketmq-client4cpp/src/consumer/ConsumeMessageOrderlyService.cpp
deleted file mode 100755
index c7d9695..0000000
--- a/rocketmq-client4cpp/src/consumer/ConsumeMessageOrderlyService.cpp
+++ /dev/null
@@ -1,574 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#include <list>
-#include <string>
-
-#include "ConsumeMessageOrderlyService.h"
-#include "DefaultMQPushConsumerImpl.h"
-#include "MQClientFactory.h"
-#include "DefaultMQProducer.h"
-#include "MessageListener.h"
-#include "MessageQueue.h"
-#include "RebalanceImpl.h"
-#include "DefaultMQPushConsumer.h"
-#include "OffsetStore.h"
-#include "ScopedLock.h"
-#include "KPRUtil.h"
-#include "MixAll.h"
-#include "UtilAll.h"
-
-namespace rmq
-{
-
-class LockMq : public kpr::TimerHandler
-{
-public:
-    LockMq(ConsumeMessageOrderlyService* pService)
-        : m_pService(pService)
-    {
-
-    }
-
-    void OnTimeOut(unsigned int timerID)
-    {
-        m_pService->lockMQPeriodically();
-
-        // can not delete
-        //delete this;
-    }
-
-private:
-    ConsumeMessageOrderlyService* m_pService;
-};
-
-class SubmitConsumeRequestLaterOrderly : public kpr::TimerHandler
-{
-public:
-    SubmitConsumeRequestLaterOrderly(ProcessQueue* pProcessQueue,
-                                     const MessageQueue& messageQueue,
-                                     ConsumeMessageOrderlyService* pService)
-        : m_pProcessQueue(pProcessQueue),
-          m_messageQueue(messageQueue),
-          m_pService(pService)
-    {
-
-    }
-
-    void OnTimeOut(unsigned int timerID)
-    {
-    	try
-    	{
-        	std::list<MessageExt*> msgs;
-       		m_pService->submitConsumeRequest(msgs, m_pProcessQueue, m_messageQueue, true);
-        }
-        catch(...)
-        {
-        	RMQ_ERROR("SubmitConsumeRequestLaterOrderly OnTimeOut exception");
-        }
-
-        delete this;
-    }
-
-private:
-    ProcessQueue* m_pProcessQueue;
-    MessageQueue m_messageQueue;
-    ConsumeMessageOrderlyService* m_pService;
-};
-
-
-class TryLockLaterAndReconsume : public kpr::TimerHandler
-{
-public:
-    TryLockLaterAndReconsume(ProcessQueue* pProcessQueue,
-                             MessageQueue& messageQueue,
-                             ConsumeMessageOrderlyService* pService)
-        : m_pProcessQueue(pProcessQueue),
-          m_messageQueue(messageQueue),
-          m_pService(pService)
-    {
-
-    }
-
-    void OnTimeOut(unsigned int timerID)
-    {
-    	try
-    	{
-	        bool lockOK = m_pService->lockOneMQ(m_messageQueue);
-	        if (lockOK)
-	        {
-	            m_pService->submitConsumeRequestLater(m_pProcessQueue, m_messageQueue, 10);
-	        }
-	        else
-	        {
-	            m_pService->submitConsumeRequestLater(m_pProcessQueue, m_messageQueue, 3000);
-	        }
-        }
-        catch(...)
-        {
-        	RMQ_ERROR("TryLockLaterAndReconsume OnTimeOut exception");
-        }
-
-        delete this;
-    }
-
-private:
-    ProcessQueue* m_pProcessQueue;
-    MessageQueue m_messageQueue;
-    ConsumeMessageOrderlyService* m_pService;
-};
-
-
-
-ConsumeMessageOrderlyService::ConsumeMessageOrderlyService(DefaultMQPushConsumerImpl* pDefaultMQPushConsumerImpl,
-        MessageListenerOrderly* pMessageListener)
-{
-	m_stoped = false;
-    m_pDefaultMQPushConsumerImpl = pDefaultMQPushConsumerImpl;
-    m_pMessageListener = pMessageListener;
-    m_pDefaultMQPushConsumer = m_pDefaultMQPushConsumerImpl->getDefaultMQPushConsumer();
-    m_consumerGroup = m_pDefaultMQPushConsumer->getConsumerGroup();
-    m_pConsumeExecutor = new kpr::ThreadPool("ConsumeMessageThreadPool", 1,
-    m_pDefaultMQPushConsumer->getConsumeThreadMin(), m_pDefaultMQPushConsumer->getConsumeThreadMax());
-    m_scheduledExecutorService = new kpr::TimerThread("ConsumeMessageConcurrentlyService", 10);
-}
-
-ConsumeMessageOrderlyService::~ConsumeMessageOrderlyService()
-{
-}
-
-
-void ConsumeMessageOrderlyService::start()
-{
-    m_scheduledExecutorService->Start();
-
-    LockMq* lm = new LockMq(this);
-    m_scheduledExecutorService->RegisterTimer(0, ProcessQueue::s_RebalanceLockInterval, lm, true);
-}
-
-void ConsumeMessageOrderlyService::shutdown()
-{
-    m_stoped = true;
-    m_pConsumeExecutor->Destroy();
-    m_scheduledExecutorService->Stop();
-    m_scheduledExecutorService->Join();
-    unlockAllMQ();
-}
-
-void ConsumeMessageOrderlyService::unlockAllMQ()
-{
-    m_pDefaultMQPushConsumerImpl->getRebalanceImpl()->unlockAll(false);
-}
-
-void ConsumeMessageOrderlyService::lockMQPeriodically()
-{
-    if (!m_stoped)
-    {
-        m_pDefaultMQPushConsumerImpl->getRebalanceImpl()->lockAll();
-    }
-}
-
-bool ConsumeMessageOrderlyService::lockOneMQ(MessageQueue& mq)
-{
-    if (!m_stoped)
-    {
-        return m_pDefaultMQPushConsumerImpl->getRebalanceImpl()->lock(mq);
-    }
-
-    return false;
-}
-
-void ConsumeMessageOrderlyService::tryLockLaterAndReconsume(MessageQueue& messageQueue,
-        ProcessQueue* pProcessQueue,
-        long long delayMills)
-{
-    TryLockLaterAndReconsume* consume = new TryLockLaterAndReconsume(pProcessQueue, messageQueue, this);
-    m_scheduledExecutorService->RegisterTimer(0, int(delayMills), consume, false);
-}
-
-ConsumerStat& ConsumeMessageOrderlyService::getConsumerStat()
-{
-    return m_pDefaultMQPushConsumerImpl->getConsumerStatManager()->getConsumertat();
-}
-
-void ConsumeMessageOrderlyService::submitConsumeRequestLater(ProcessQueue* pProcessQueue,
-        const MessageQueue& messageQueue,
-        long long suspendTimeMillis)
-{
-    long timeMillis = long(suspendTimeMillis);
-    if (timeMillis < 10)
-    {
-        timeMillis = 10;
-    }
-    else if (timeMillis > 30000)
-    {
-        timeMillis = 30000;
-    }
-
-    SubmitConsumeRequestLaterOrderly* sc = new SubmitConsumeRequestLaterOrderly(pProcessQueue, messageQueue, this);
-    m_scheduledExecutorService->RegisterTimer(0, timeMillis, sc, false);
-}
-
-void ConsumeMessageOrderlyService::submitConsumeRequest(std::list<MessageExt*>& msgs,
-        ProcessQueue* pProcessQueue,
-        const MessageQueue& messageQueue,
-        bool dispathToConsume)
-{
-    if (dispathToConsume)
-    {
-        kpr::ThreadPoolWorkPtr consumeRequest = new ConsumeOrderlyRequest(pProcessQueue, messageQueue, this);
-        m_pConsumeExecutor->AddWork(consumeRequest);
-    }
-}
-
-void ConsumeMessageOrderlyService::updateCorePoolSize(int corePoolSize)
-{
-}
-
-
-std::string& ConsumeMessageOrderlyService::getConsumerGroup()
-{
-    return m_consumerGroup;
-}
-
-MessageListenerOrderly* ConsumeMessageOrderlyService::getMessageListener()
-{
-    return m_pMessageListener;
-}
-
-DefaultMQPushConsumerImpl* ConsumeMessageOrderlyService::getDefaultMQPushConsumerImpl()
-{
-    return m_pDefaultMQPushConsumerImpl;
-}
-
-bool ConsumeMessageOrderlyService::processConsumeResult(std::list<MessageExt*>& msgs,
-        ConsumeOrderlyStatus status,
-        ConsumeOrderlyContext& context,
-        ConsumeOrderlyRequest& consumeRequest)
-{
-    bool continueConsume = true;
-    long long commitOffset = -1L;
-    int msgsSize = msgs.size();
-
-    if (context.autoCommit)
-    {
-        switch (status)
-        {
-            case COMMIT:
-            case ROLLBACK:
-                RMQ_WARN("the message queue consume result is illegal, we think you want to ack these message: %s",
-                	consumeRequest.getMessageQueue().toString().c_str());
-            case SUCCESS:
-                getConsumerStat().consumeMsgOKTotal.fetchAndAdd(msgsSize);
-                commitOffset = consumeRequest.getProcessQueue()->commit();
-                break;
-            case SUSPEND_CURRENT_QUEUE_A_MOMENT:
-                getConsumerStat().consumeMsgFailedTotal.fetchAndAdd(msgsSize);
-	            if (checkReconsumeTimes(msgs))
-	            {
-	                consumeRequest.getProcessQueue()->makeMessageToCosumeAgain(msgs);
-	                submitConsumeRequestLater(consumeRequest.getProcessQueue(),
-	                                          consumeRequest.getMessageQueue(),
-	                                          context.suspendCurrentQueueTimeMillis);
-	                continueConsume = false;
-				}
-				else
-				{
-					commitOffset = consumeRequest.getProcessQueue()->commit();
-				}
-
-                break;
-            default:
-                break;
-        }
-    }
-    else
-    {
-        switch (status)
-        {
-            case SUCCESS:
-                getConsumerStat().consumeMsgOKTotal.fetchAndAdd(msgsSize);
-                break;
-            case COMMIT:
-                commitOffset = consumeRequest.getProcessQueue()->commit();
-                break;
-            case ROLLBACK:
-                consumeRequest.getProcessQueue()->rollback();
-                submitConsumeRequestLater(consumeRequest.getProcessQueue(),
-                                          consumeRequest.getMessageQueue(),
-                                          context.suspendCurrentQueueTimeMillis);
-                continueConsume = false;
-                break;
-            case SUSPEND_CURRENT_QUEUE_A_MOMENT:
-                getConsumerStat().consumeMsgFailedTotal.fetchAndAdd(msgsSize);
-	            if (checkReconsumeTimes(msgs))
-	            {
-	                consumeRequest.getProcessQueue()->makeMessageToCosumeAgain(msgs);
-	                submitConsumeRequestLater(consumeRequest.getProcessQueue(),
-	                                          consumeRequest.getMessageQueue(),
-	                                          context.suspendCurrentQueueTimeMillis);
-	                continueConsume = false;
-                }
-                break;
-            default:
-                break;
-        }
-    }
-
-    if (commitOffset >= 0 && !consumeRequest.getProcessQueue()->isDropped())
-    {
-        m_pDefaultMQPushConsumerImpl->getOffsetStore()->updateOffset(consumeRequest.getMessageQueue(),
-                commitOffset, false);
-    }
-
-    return continueConsume;
-}
-
-bool ConsumeMessageOrderlyService::checkReconsumeTimes(std::list<MessageExt*>& msgs)
-{
-    bool suspend = false;
-
-    if (!msgs.empty())
-    {
-    	std::list<MessageExt*>::iterator it = msgs.begin();
-        for (; it != msgs.end(); it++)
-        {
-            MessageExt* msg = *it;
-            if (msg->getReconsumeTimes() >= m_pDefaultMQPushConsumer->getMaxReconsumeTimes())
-            {
-            	msg->putProperty(Message::PROPERTY_RECONSUME_TIME, UtilAll::toString(msg->getReconsumeTimes()));
-
-                if (!sendMessageBack(*msg))
-                {
-                    suspend = true;
-                    msg->setReconsumeTimes(msg->getReconsumeTimes() + 1);
-                }
-            }
-            else
-            {
-                suspend = true;
-                msg->setReconsumeTimes(msg->getReconsumeTimes() + 1);
-            }
-        }
-    }
-
-    return suspend;
-}
-
-bool ConsumeMessageOrderlyService::sendMessageBack(MessageExt& msg)
-{
-    try
-    {
-    	Message newMsg(MixAll::getRetryTopic(m_pDefaultMQPushConsumer->getConsumerGroup()),
-                       msg.getBody(), msg.getBodyLen());
-
-		std::string originMsgId = msg.getProperty(Message::PROPERTY_ORIGIN_MESSAGE_ID);
-		newMsg.putProperty(Message::PROPERTY_ORIGIN_MESSAGE_ID, UtilAll::isBlank(originMsgId) ? msg.getMsgId()
-                    : originMsgId);
-
-        newMsg.setFlag(msg.getFlag());
-        newMsg.setProperties(msg.getProperties());
-        newMsg.putProperty(Message::PROPERTY_RETRY_TOPIC, msg.getTopic());
-
-        int reTimes = msg.getReconsumeTimes() + 1;
-        newMsg.putProperty(Message::PROPERTY_RECONSUME_TIME, UtilAll::toString(reTimes));
-        newMsg.putProperty(Message::PROPERTY_MAX_RECONSUME_TIMES, UtilAll::toString(m_pDefaultMQPushConsumer->getMaxReconsumeTimes()));
-        newMsg.setDelayTimeLevel(3 + reTimes);
-
-        m_pDefaultMQPushConsumerImpl->getmQClientFactory()->getDefaultMQProducer()->send(newMsg);
-
-        return true;
-    }
-    catch (...)
-    {
-        RMQ_ERROR("sendMessageBack exception, group: %s, msg: %s",
-                  m_consumerGroup.c_str(), msg.toString().c_str());
-    }
-
-    return false;
-}
-
-
-MessageQueueLock& ConsumeMessageOrderlyService::getMessageQueueLock()
-{
-    return m_messageQueueLock;
-}
-
-DefaultMQPushConsumer* ConsumeMessageOrderlyService::getDefaultMQPushConsumer()
-{
-    return m_pDefaultMQPushConsumer;
-}
-
-ConsumeOrderlyRequest::ConsumeOrderlyRequest(ProcessQueue* pProcessQueue,
-        const MessageQueue& messageQueue,
-        ConsumeMessageOrderlyService* pService)
-{
-	m_pProcessQueue = pProcessQueue;
-	m_messageQueue = messageQueue;
-	m_pService = pService;
-}
-
-ConsumeOrderlyRequest::~ConsumeOrderlyRequest()
-{
-}
-
-void ConsumeOrderlyRequest::Do()
-{
-	if (m_pProcessQueue->isDropped())
-	{
-        RMQ_WARN("run, the message queue not be able to consume, because it's dropped, MQ: %s",
-            m_messageQueue.toString().c_str());
-        return;
-    }
-
-	try
-	{
-	    kpr::Mutex* objLock = m_pService->getMessageQueueLock().fetchLockObject(m_messageQueue);
-	    {
-	        kpr::ScopedLock<kpr::Mutex> lock(*objLock);
-
-	        MessageModel messageModel = m_pService->getDefaultMQPushConsumerImpl()->messageModel();
-	        if (BROADCASTING == messageModel
-	        	|| (m_pProcessQueue->isLocked() || !m_pProcessQueue->isLockExpired()))
-	        {
-	            long long beginTime = KPRUtil::GetCurrentTimeMillis();
-	            for (bool continueConsume = true; continueConsume;)
-	            {
-	                if (m_pProcessQueue->isDropped())
-	                {
-	                    RMQ_INFO("the message queue not be able to consume, because it's droped, MQ: %s",
-	                             m_messageQueue.toString().c_str());
-	                    break;
-	                }
-
-	                if (CLUSTERING == messageModel
-	                 	&& !m_pProcessQueue->isLocked())
-	                {
-	                    RMQ_WARN("the message queue not locked, so consume later, MQ: %s", m_messageQueue.toString().c_str());
-	                    m_pService->tryLockLaterAndReconsume(m_messageQueue, m_pProcessQueue, 10);
-	                    break;
-	                }
-
-	                if (CLUSTERING == messageModel
-	                 	&& m_pProcessQueue->isLockExpired())
-	                {
-	                    RMQ_WARN("the message queue lock expired, so consume later, MQ: %s", m_messageQueue.toString().c_str());
-	                    m_pService->tryLockLaterAndReconsume(m_messageQueue, m_pProcessQueue, 10);
-	                    break;
-	                }
-
-	                long interval = long(KPRUtil::GetCurrentTimeMillis() - beginTime);
-	                if (interval > ConsumeMessageOrderlyService::s_MaxTimeConsumeContinuously)
-	                {
-	                    m_pService->submitConsumeRequestLater(m_pProcessQueue, m_messageQueue, 10);
-	                    break;
-	                }
-
-	                int consumeBatchSize =
-	                    m_pService->getDefaultMQPushConsumer()->getConsumeMessageBatchMaxSize();
-
-	                std::list<MessageExt*> msgs = m_pProcessQueue->takeMessages(consumeBatchSize);
-	                if (!msgs.empty())
-	                {
-	                    ConsumeOrderlyContext context(m_messageQueue);
-
-	                    ConsumeOrderlyStatus status = SUSPEND_CURRENT_QUEUE_A_MOMENT;
-
-	                    ConsumeMessageContext consumeMessageContext;
-	                    if (m_pService->getDefaultMQPushConsumerImpl()->hasHook())
-	                    {
-	                        consumeMessageContext.consumerGroup = m_pService->getConsumerGroup();
-	                        consumeMessageContext.mq = m_messageQueue;
-	                        consumeMessageContext.msgList = msgs;
-	                        consumeMessageContext.success = false;
-	                        m_pService->getDefaultMQPushConsumerImpl()->executeHookBefore(consumeMessageContext);
-	                    }
-
-	                    long long beginTimestamp = KPRUtil::GetCurrentTimeMillis();
-	                    try
-	                    {
-	                    	kpr::ScopedLock<kpr::Mutex> lock(m_pProcessQueue->getLockConsume());
-	                    	if (m_pProcessQueue->isDropped())
-							{
-						        RMQ_WARN("consumeMessage, the message queue not be able to consume, because it's dropped, MQ: %s",
-						            m_messageQueue.toString().c_str());
-						        break;
-						    }
-
-	                        status = m_pService->getMessageListener()->consumeMessage(msgs, context);
-	                    }
-	                    catch (...)
-	                    {
-	                        RMQ_WARN("consumeMessage exception, Group: {%s}, Msgs: {%u}, MQ: %s",//
-	                                 m_pService->getConsumerGroup().c_str(),
-	                                 (unsigned)msgs.size(),
-	                                 m_messageQueue.toString().c_str());
-	                    }
-
-	                    long long consumeRT = KPRUtil::GetCurrentTimeMillis() - beginTimestamp;
-
-	                    if (SUSPEND_CURRENT_QUEUE_A_MOMENT == status
-	                    	|| ROLLBACK == status)
-	                    {
-	                    	RMQ_WARN("consumeMessage Orderly return not OK, Group: {%s} Msgs: {%u} MQ: %s",//
-	                                    m_pService->getConsumerGroup().c_str(),
-	                                    (unsigned)msgs.size(),
-	                                     m_messageQueue.toString().c_str());
-	                    	//status = ConsumeOrderlyStatus.SUSPEND_CURRENT_QUEUE_A_MOMENT;
-	                    }
-
-	                    if (m_pService->getDefaultMQPushConsumerImpl()->hasHook())
-	                    {
-	                        consumeMessageContext.success = (SUCCESS == status
-	                                                         || COMMIT == status);
-	                        m_pService->getDefaultMQPushConsumerImpl()->executeHookAfter(consumeMessageContext);
-	                    }
-
-	                    m_pService->getConsumerStat().consumeMsgRTTotal.fetchAndAdd(consumeRT);
-	                    MixAll::compareAndIncreaseOnly(m_pService->getConsumerStat()
-	                                                   .consumeMsgRTMax, consumeRT);
-
-	                    continueConsume = m_pService->processConsumeResult(msgs, status, context, *this);
-	                }
-	                else
-	                {
-	                    continueConsume = false;
-	                }
-	            }
-	        }
-	        else
-	        {
-	        	if (m_pProcessQueue->isDropped())
-				{
-			        RMQ_WARN("consumeMessage, the message queue not be able to consume, because it's dropped, MQ: %s",
-			            m_messageQueue.toString().c_str());
-			        return;
-			    }
-
-	            m_pService->tryLockLaterAndReconsume(m_messageQueue, m_pProcessQueue, 100);
-	        }
-	    }
-	}
-	catch(...)
-	{
-		RMQ_WARN("ConsumeOrderlyRequest exception");
-	}
-
-    return;
-}
-
-}
-

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/consumer/ConsumeMessageOrderlyService.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/consumer/ConsumeMessageOrderlyService.h b/rocketmq-client4cpp/src/consumer/ConsumeMessageOrderlyService.h
deleted file mode 100755
index 0f8628b..0000000
--- a/rocketmq-client4cpp/src/consumer/ConsumeMessageOrderlyService.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __CONSUMEMESSAGEORDERLYSERVICE_H__
-#define __CONSUMEMESSAGEORDERLYSERVICE_H__
-
-#include "ConsumeMessageService.h"
-
-#include <list>
-#include <string>
-#include "RocketMQClient.h"
-#include "ConsumerStatManage.h"
-#include "MessageQueueLock.h"
-#include "MessageListener.h"
-#include "ThreadPool.h"
-#include "TimerThread.h"
-
-namespace rmq
-{
-class DefaultMQPushConsumerImpl;
-class MessageListenerOrderly;
-class DefaultMQPushConsumer;
-class ConsumeMessageOrderlyService;
-
-class ConsumeOrderlyRequest: public kpr::ThreadPoolWork
-{
-public:
-    ConsumeOrderlyRequest(ProcessQueue *pProcessQueue,
-                          const MessageQueue &messageQueue,
-                          ConsumeMessageOrderlyService *pService);
-    ~ConsumeOrderlyRequest();
-
-    virtual void Do();
-
-    ProcessQueue *getProcessQueue()
-    {
-        return m_pProcessQueue;
-    }
-
-    MessageQueue &getMessageQueue()
-    {
-        return m_messageQueue;
-    }
-
-private:
-    ProcessQueue *m_pProcessQueue;
-    MessageQueue m_messageQueue;
-    ConsumeMessageOrderlyService *m_pService;
-};
-
-
-class ConsumeMessageOrderlyService : public ConsumeMessageService
-{
-public:
-	static const long s_MaxTimeConsumeContinuously = 60000;
-
-public:
-    ConsumeMessageOrderlyService(DefaultMQPushConsumerImpl
-                                 *pDefaultMQPushConsumerImpl,
-                                 MessageListenerOrderly *pMessageListener);
-    ~ConsumeMessageOrderlyService();
-
-    void start();
-    void shutdown();
-
-    void unlockAllMQ();
-    void lockMQPeriodically();
-    bool lockOneMQ(MessageQueue &mq);
-    void tryLockLaterAndReconsume(MessageQueue &messageQueue,
-                                  ProcessQueue *pProcessQueue,
-                                  long long delayMills);
-    bool processConsumeResult(std::list<MessageExt *> &msgs,
-                              ConsumeOrderlyStatus status,
-                              ConsumeOrderlyContext &context,
-                              ConsumeOrderlyRequest &consumeRequest);
-    bool checkReconsumeTimes(std::list<MessageExt *> &msgs);
-    bool sendMessageBack(MessageExt &msg);
-    ConsumerStat& getConsumerStat();
-
-    void submitConsumeRequestLater(ProcessQueue *pProcessQueue,
-                                   const MessageQueue &messageQueue,
-                                   long long suspendTimeMillis);
-
-    void submitConsumeRequest(std::list<MessageExt *> &msgs,
-                              ProcessQueue *pProcessQueue,
-                              const MessageQueue &messageQueue,
-                              bool dispathToConsume);
-
-    void updateCorePoolSize(int corePoolSize);
-    MessageQueueLock &getMessageQueueLock();
-    std::string &getConsumerGroup();
-    MessageListenerOrderly *getMessageListener();
-    DefaultMQPushConsumerImpl *getDefaultMQPushConsumerImpl();
-    DefaultMQPushConsumer *getDefaultMQPushConsumer();
-
-private:
-    volatile bool m_stoped;
-    DefaultMQPushConsumerImpl *m_pDefaultMQPushConsumerImpl;
-    DefaultMQPushConsumer *m_pDefaultMQPushConsumer;
-    MessageListenerOrderly *m_pMessageListener;
-    std::string m_consumerGroup;
-    MessageQueueLock m_messageQueueLock;
-
-    kpr::ThreadPoolPtr m_pConsumeExecutor;
-    kpr::TimerThreadPtr m_scheduledExecutorService;
-};
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/consumer/ConsumeMessageService.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/consumer/ConsumeMessageService.h b/rocketmq-client4cpp/src/consumer/ConsumeMessageService.h
deleted file mode 100755
index 57a9bee..0000000
--- a/rocketmq-client4cpp/src/consumer/ConsumeMessageService.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#ifndef __CONSUMEMESSAGESERVICE_H__
-#define __CONSUMEMESSAGESERVICE_H__
-
-#include <list>
-
-namespace rmq
-{
-	class MessageExt;
-	class ProcessQueue;
-	class MessageQueue;
-
-	class ConsumeMessageService
-	{
-	public:
-	    virtual ~ConsumeMessageService() {}
-	    virtual void start() = 0;
-	    virtual void shutdown() = 0;
-	    virtual void updateCorePoolSize(int corePoolSize) = 0;
-	    virtual void submitConsumeRequest(std::list<MessageExt*>& msgs,
-	                                      ProcessQueue* pProcessQueue,
-	                                      const MessageQueue& messageQueue,
-	                                      bool dispathToConsume) = 0;
-	};
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/consumer/ConsumeType.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/consumer/ConsumeType.cpp b/rocketmq-client4cpp/src/consumer/ConsumeType.cpp
deleted file mode 100755
index 6ef5837..0000000
--- a/rocketmq-client4cpp/src/consumer/ConsumeType.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#include "ConsumeType.h"
-
-namespace rmq
-{
-
-const char* getConsumeTypeString(ConsumeType type)
-{
-    switch (type)
-    {
-        case CONSUME_ACTIVELY:
-            return "CONSUME_ACTIVELY";
-        case CONSUME_PASSIVELY:
-            return "CONSUME_PASSIVELY";
-    }
-
-    return "UnknowConsumeType";
-}
-
-const char* getConsumeFromWhereString(ConsumeFromWhere type)
-{
-    switch (type)
-    {
-        case CONSUME_FROM_LAST_OFFSET:
-            return "CONSUME_FROM_LAST_OFFSET";
-        case CONSUME_FROM_LAST_OFFSET_AND_FROM_MIN_WHEN_BOOT_FIRST:
-            return "CONSUME_FROM_LAST_OFFSET_AND_FROM_MIN_WHEN_BOOT_FIRST";
-        case CONSUME_FROM_MAX_OFFSET:
-            return "CONSUME_FROM_MAX_OFFSET";
-        case CONSUME_FROM_MIN_OFFSET:
-            return "CONSUME_FROM_MIN_OFFSET";
-        case CONSUME_FROM_FIRST_OFFSET:
-            return "CONSUME_FROM_FIRST_OFFSET";
-        case CONSUME_FROM_TIMESTAMP:
-            return "CONSUME_FROM_TIMESTAMP";
-    }
-
-    return "UnknowConsumeFromWhere";
-}
-
-const char* getMessageModelString(MessageModel type)
-{
-    switch (type)
-    {
-        case CLUSTERING:
-            return "CLUSTERING";
-        case BROADCASTING:
-            return "BROADCASTING";
-    }
-
-    return "UnknowMessageModel";
-}
-
-}
-

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/consumer/ConsumerInvokeCallback.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/consumer/ConsumerInvokeCallback.cpp b/rocketmq-client4cpp/src/consumer/ConsumerInvokeCallback.cpp
deleted file mode 100755
index c9dc304..0000000
--- a/rocketmq-client4cpp/src/consumer/ConsumerInvokeCallback.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#include "ConsumerInvokeCallback.h"
-#include "ResponseFuture.h"
-#include "PullResult.h"
-#include "MQClientAPIImpl.h"
-#include "PullCallback.h"
-#include "MQClientException.h"
-#include "RemotingCommand.h"
-
-namespace rmq
-{
-
-ConsumerInvokeCallback::ConsumerInvokeCallback(PullCallback* pPullCallback, MQClientAPIImpl* pMQClientAPIImpl)
-    : m_pPullCallback(pPullCallback),
-      m_pMQClientAPIImpl(pMQClientAPIImpl)
-{
-}
-
-ConsumerInvokeCallback::~ConsumerInvokeCallback()
-{
-    if (m_pPullCallback != NULL)
-    {
-        delete m_pPullCallback;
-        m_pPullCallback = NULL;
-    }
-}
-
-void ConsumerInvokeCallback::operationComplete(ResponseFuturePtr pResponseFuture)
-{
-    if (m_pPullCallback == NULL)
-    {
-        delete this;
-        return;
-    }
-
-    RemotingCommand* response = pResponseFuture->getResponseCommand();
-    if (response != NULL)
-    {
-        try
-        {
-            PullResult* pullResult = m_pMQClientAPIImpl->processPullResponse(response);
-            response->setBody(NULL, 0, false);
-
-            m_pPullCallback->onSuccess(*pullResult);
-
-            pullResult->msgFoundList.clear();
-            delete pullResult;
-        }
-        catch (MQException& e)
-        {
-            m_pPullCallback->onException(e);
-        }
-
-        delete response;
-    }
-    else
-    {
-        if (!pResponseFuture->isSendRequestOK())
-        {
-            std::string msg = "send request failed";
-            MQClientException e(msg, -1, __FILE__, __LINE__);
-            m_pPullCallback->onException(e);
-        }
-        else if (pResponseFuture->isTimeout())
-        {
-            std::string msg = "wait response timeout";
-            MQClientException e(msg, -1, __FILE__, __LINE__);
-            m_pPullCallback->onException(e);
-        }
-        else
-        {
-            std::string msg = "unknow reseaon";
-            MQClientException e(msg, -1, __FILE__, __LINE__);
-            m_pPullCallback->onException(e);
-        }
-    }
-
-    delete this;
-}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/consumer/ConsumerInvokeCallback.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/consumer/ConsumerInvokeCallback.h b/rocketmq-client4cpp/src/consumer/ConsumerInvokeCallback.h
deleted file mode 100755
index 675f2fd..0000000
--- a/rocketmq-client4cpp/src/consumer/ConsumerInvokeCallback.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __CONSUMER_INVOKECALLBACK_H__
-#define __CONSUMER_INVOKECALLBACK_H__
-
-#include "InvokeCallback.h"
-
-namespace rmq
-{
-	class PullCallback;
-	class MQClientAPIImpl;
-
-	class ConsumerInvokeCallback : public InvokeCallback
-	{
-	public:
-	    ConsumerInvokeCallback(PullCallback* pPullCallback, MQClientAPIImpl* pMQClientAPIImpl);
-	    virtual ~ConsumerInvokeCallback();
-	    virtual void operationComplete(ResponseFuturePtr pResponseFuture);
-
-	private:
-	    PullCallback* m_pPullCallback;
-	    MQClientAPIImpl* m_pMQClientAPIImpl;
-	};
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/consumer/ConsumerStatManage.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/consumer/ConsumerStatManage.h b/rocketmq-client4cpp/src/consumer/ConsumerStatManage.h
deleted file mode 100755
index 92cf74c..0000000
--- a/rocketmq-client4cpp/src/consumer/ConsumerStatManage.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#ifndef __CONSUMERSTAT_H__
-#define __CONSUMERSTAT_H__
-
-#include <list>
-#include <string>
-
-#include "AtomicValue.h"
-#include "KPRUtil.h"
-#include "Mutex.h"
-#include "ScopedLock.h"
-
-namespace rmq
-{
-    struct ConsumerStat
-    {
-        long long createTimestamp;
-        kpr::AtomicLong consumeMsgRTMax;
-        kpr::AtomicLong consumeMsgRTTotal;
-        kpr::AtomicLong consumeMsgOKTotal;
-        kpr::AtomicLong consumeMsgFailedTotal;
-        kpr::AtomicLong pullRTTotal;
-        kpr::AtomicLong pullTimesTotal;
-
-		ConsumerStat()
-		{
-			createTimestamp = KPRUtil::GetCurrentTimeMillis();
-			consumeMsgRTMax = 0;
-			consumeMsgRTTotal = 0;
-			consumeMsgOKTotal = 0;
-			consumeMsgFailedTotal = 0;
-			pullRTTotal = 0;
-			pullTimesTotal = 0;
-		}
-    };
-
-
-    class ConsumerStatManager
-    {
-    public:
-        ConsumerStat& getConsumertat()
-        {
-            return m_consumertat;
-        }
-
-        std::list<ConsumerStat>& getSnapshotList()
-        {
-            return m_snapshotList;
-        }
-
-        /**
-        * every 1s
-        */
-        void recordSnapshotPeriodically()
-        {
-            kpr::ScopedWLock<kpr::RWMutex> lock(m_snapshotListLock);
-            m_snapshotList.push_back(m_consumertat);
-            if (m_snapshotList.size() > 60)
-            {
-                m_snapshotList.pop_front();
-            }
-        }
-
-        /**
-        * every 1m
-        */
-        void logStatsPeriodically(std::string& group, std::string& clientId)
-        {
-            kpr::ScopedRLock<kpr::RWMutex> lock(m_snapshotListLock);
-            if (m_snapshotList.size() >= 60)
-            {
-                ConsumerStat& first = m_snapshotList.front();
-                ConsumerStat& last = m_snapshotList.back();
-
-                {
-                    double avgRT = (last.consumeMsgRTTotal.get() - first.consumeMsgRTTotal.get())
-                                   /
-                                   (double)((last.consumeMsgOKTotal.get() + last.consumeMsgFailedTotal.get())
-                                            - (first.consumeMsgOKTotal.get() + first.consumeMsgFailedTotal.get()));
-
-                    double tps = ((last.consumeMsgOKTotal.get() + last.consumeMsgFailedTotal.get())
-                                  - (first.consumeMsgOKTotal.get() + first.consumeMsgFailedTotal.get()))
-                                 / (double)(last.createTimestamp - first.createTimestamp);
-
-                    tps *= 1000;
-
-                    RMQ_INFO(
-                        "Consumer, {%s} {%s}, ConsumeAvgRT: {%f} ConsumeMaxRT: {%lld} TotalOKMsg: {%lld} TotalFailedMsg: {%lld} consumeTPS: {%f}",
-                        group.c_str(),
-                        clientId.c_str(),
-                        avgRT,
-                        last.consumeMsgRTMax.get(),
-                        last.consumeMsgOKTotal.get(),
-                        last.consumeMsgFailedTotal.get(),
-                        tps);
-                }
-
-                {
-                    double avgRT = (last.pullRTTotal.get() - first.pullRTTotal.get())
-                                   / (double)(last.pullTimesTotal.get() - first.pullTimesTotal.get());
-
-                    RMQ_INFO("Consumer, {%s} {%s}, PullAvgRT: {%f}  PullTimesTotal: {%lld}",
-                             group.c_str(),
-                             clientId.c_str(),
-                             avgRT,
-                             last.pullTimesTotal.get());
-                }
-            }
-        }
-
-    private:
-        ConsumerStat m_consumertat;
-        std::list<ConsumerStat> m_snapshotList;
-        kpr::RWMutex m_snapshotListLock;
-    };
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/consumer/DefaultMQPullConsumer.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/consumer/DefaultMQPullConsumer.cpp b/rocketmq-client4cpp/src/consumer/DefaultMQPullConsumer.cpp
deleted file mode 100755
index 67a8c8c..0000000
--- a/rocketmq-client4cpp/src/consumer/DefaultMQPullConsumer.cpp
+++ /dev/null
@@ -1,309 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#include "DefaultMQPullConsumer.h"
-
-#include <list>
-#include <string>
-
-#include "MessageQueue.h"
-#include "MessageExt.h"
-#include "ClientConfig.h"
-#include "DefaultMQPullConsumerImpl.h"
-#include "MixAll.h"
-#include "AllocateMessageQueueStrategyInner.h"
-
-namespace rmq
-{
-
-DefaultMQPullConsumer::DefaultMQPullConsumer()
-    : m_consumerGroup(MixAll::DEFAULT_CONSUMER_GROUP),
-      m_brokerSuspendMaxTimeMillis(1000 * 20),
-      m_consumerTimeoutMillisWhenSuspend(1000 * 30),
-      m_consumerPullTimeoutMillis(1000 * 10),
-      m_messageModel(CLUSTERING),
-      m_pMessageQueueListener(NULL),
-      m_pOffsetStore(NULL),
-      m_pAllocateMessageQueueStrategy(new AllocateMessageQueueAveragely()),
-      m_unitMode(false),
-      m_maxReconsumeTimes(16)
-{
-    m_pDefaultMQPullConsumerImpl = new DefaultMQPullConsumerImpl(this);
-}
-
-DefaultMQPullConsumer::DefaultMQPullConsumer(const std::string& consumerGroup)
-    : m_consumerGroup(consumerGroup),
-      m_brokerSuspendMaxTimeMillis(1000 * 20),
-      m_consumerTimeoutMillisWhenSuspend(1000 * 30),
-      m_consumerPullTimeoutMillis(1000 * 10),
-      m_messageModel(CLUSTERING),
-      m_pMessageQueueListener(NULL),
-      m_pOffsetStore(NULL),
-      m_pAllocateMessageQueueStrategy(new AllocateMessageQueueAveragely()),
-      m_unitMode(false),
-      m_maxReconsumeTimes(16)
-{
-    m_pDefaultMQPullConsumerImpl = new DefaultMQPullConsumerImpl(this);
-}
-
-DefaultMQPullConsumer::~DefaultMQPullConsumer()
-{
-	//memleak or coredump
-	if (m_pAllocateMessageQueueStrategy)
-		delete m_pAllocateMessageQueueStrategy;
-	if (m_pDefaultMQPullConsumerImpl)
-		delete m_pDefaultMQPullConsumerImpl;
-}
-
-//MQAdmin
-void DefaultMQPullConsumer::createTopic(const std::string& key, const std::string& newTopic, int queueNum)
-{
-    m_pDefaultMQPullConsumerImpl->createTopic(key, newTopic, queueNum);
-}
-
-long long DefaultMQPullConsumer::searchOffset(const MessageQueue& mq, long long timestamp)
-{
-    return m_pDefaultMQPullConsumerImpl->searchOffset(mq, timestamp);
-}
-
-long long DefaultMQPullConsumer::maxOffset(const MessageQueue& mq)
-{
-    return m_pDefaultMQPullConsumerImpl->maxOffset(mq);
-}
-
-long long DefaultMQPullConsumer::minOffset(const MessageQueue& mq)
-{
-    return m_pDefaultMQPullConsumerImpl->minOffset(mq);
-}
-
-long long DefaultMQPullConsumer::earliestMsgStoreTime(const MessageQueue& mq)
-{
-    return m_pDefaultMQPullConsumerImpl->earliestMsgStoreTime(mq);
-}
-
-MessageExt* DefaultMQPullConsumer::viewMessage(const std::string& msgId)
-{
-    return m_pDefaultMQPullConsumerImpl->viewMessage(msgId);
-}
-
-QueryResult DefaultMQPullConsumer::queryMessage(const std::string& topic,
-        const std::string&  key,
-        int maxNum,
-        long long begin,
-        long long end)
-{
-    return m_pDefaultMQPullConsumerImpl->queryMessage(topic, key, maxNum, begin, end);
-}
-// MQadmin end
-
-AllocateMessageQueueStrategy* DefaultMQPullConsumer::getAllocateMessageQueueStrategy()
-{
-    return m_pAllocateMessageQueueStrategy;
-}
-
-void DefaultMQPullConsumer::setAllocateMessageQueueStrategy(AllocateMessageQueueStrategy* pAllocateMessageQueueStrategy)
-{
-    m_pAllocateMessageQueueStrategy = pAllocateMessageQueueStrategy;
-}
-
-int DefaultMQPullConsumer::getBrokerSuspendMaxTimeMillis()
-{
-    return m_brokerSuspendMaxTimeMillis;
-}
-
-void DefaultMQPullConsumer::setBrokerSuspendMaxTimeMillis(int brokerSuspendMaxTimeMillis)
-{
-    m_brokerSuspendMaxTimeMillis = brokerSuspendMaxTimeMillis;
-}
-
-std::string DefaultMQPullConsumer::getConsumerGroup()
-{
-    return m_consumerGroup;
-}
-
-void DefaultMQPullConsumer::setConsumerGroup(const std::string& consumerGroup)
-{
-    m_consumerGroup = consumerGroup;
-}
-
-int DefaultMQPullConsumer::getConsumerPullTimeoutMillis()
-{
-    return m_consumerPullTimeoutMillis;
-}
-
-void DefaultMQPullConsumer::setConsumerPullTimeoutMillis(int consumerPullTimeoutMillis)
-{
-    m_consumerPullTimeoutMillis = consumerPullTimeoutMillis;
-}
-
-int DefaultMQPullConsumer::getConsumerTimeoutMillisWhenSuspend()
-{
-    return m_consumerTimeoutMillisWhenSuspend;
-}
-
-void DefaultMQPullConsumer::setConsumerTimeoutMillisWhenSuspend(int consumerTimeoutMillisWhenSuspend)
-{
-    m_consumerTimeoutMillisWhenSuspend = consumerTimeoutMillisWhenSuspend;
-}
-
-MessageModel DefaultMQPullConsumer::getMessageModel()
-{
-    return m_messageModel;
-}
-
-void DefaultMQPullConsumer::setMessageModel(MessageModel messageModel)
-{
-    m_messageModel = messageModel;
-}
-
-MessageQueueListener* DefaultMQPullConsumer::getMessageQueueListener()
-{
-    return m_pMessageQueueListener;
-}
-
-void DefaultMQPullConsumer::setMessageQueueListener(MessageQueueListener* pMessageQueueListener)
-{
-    m_pMessageQueueListener = pMessageQueueListener;
-}
-
-std::set<std::string> DefaultMQPullConsumer::getRegisterTopics()
-{
-    return m_registerTopics;
-}
-
-void DefaultMQPullConsumer::setRegisterTopics(std::set<std::string> registerTopics)
-{
-    m_registerTopics = registerTopics;
-}
-
-//MQConsumer
-void DefaultMQPullConsumer::sendMessageBack(MessageExt& msg, int delayLevel)
-{
-    m_pDefaultMQPullConsumerImpl->sendMessageBack(msg, delayLevel, "");
-}
-
-void DefaultMQPullConsumer::sendMessageBack(MessageExt& msg, int delayLevel, const std::string& brokerName)
-{
-    m_pDefaultMQPullConsumerImpl->sendMessageBack(msg, delayLevel, brokerName);
-}
-
-
-
-std::set<MessageQueue>* DefaultMQPullConsumer::fetchSubscribeMessageQueues(const std::string& topic)
-{
-    return m_pDefaultMQPullConsumerImpl->fetchSubscribeMessageQueues(topic);
-}
-
-void DefaultMQPullConsumer::start()
-{
-    m_pDefaultMQPullConsumerImpl->start();
-}
-
-void DefaultMQPullConsumer::shutdown()
-{
-    m_pDefaultMQPullConsumerImpl->shutdown();
-}
-//MQConsumer end
-
-//MQPullConsumer
-void DefaultMQPullConsumer::registerMessageQueueListener(const std::string& topic, MessageQueueListener* pListener)
-{
-    m_registerTopics.insert(topic);
-
-    if (pListener)
-    {
-        m_pMessageQueueListener = pListener;
-    }
-}
-
-PullResult* DefaultMQPullConsumer::pull(MessageQueue& mq, const std::string& subExpression, long long offset, int maxNums)
-{
-    return m_pDefaultMQPullConsumerImpl->pull(mq, subExpression, offset, maxNums);
-}
-
-void DefaultMQPullConsumer::pull(MessageQueue& mq, const std::string& subExpression, long long offset, int maxNums, PullCallback* pPullCallback)
-{
-    m_pDefaultMQPullConsumerImpl->pull(mq, subExpression, offset, maxNums, pPullCallback);
-}
-
-PullResult* DefaultMQPullConsumer::pullBlockIfNotFound(MessageQueue& mq, const std::string& subExpression, long long offset, int maxNums)
-{
-    return m_pDefaultMQPullConsumerImpl->pullBlockIfNotFound(mq, subExpression, offset, maxNums);
-}
-
-void DefaultMQPullConsumer::pullBlockIfNotFound(MessageQueue& mq,
-        const std::string& subExpression,
-        long long offset,
-        int maxNums,
-        PullCallback* pPullCallback)
-{
-    m_pDefaultMQPullConsumerImpl->pullBlockIfNotFound(mq, subExpression, offset, maxNums, pPullCallback);
-}
-
-void DefaultMQPullConsumer::updateConsumeOffset(MessageQueue& mq, long long offset)
-{
-    m_pDefaultMQPullConsumerImpl->updateConsumeOffset(mq, offset);
-}
-
-long long DefaultMQPullConsumer::fetchConsumeOffset(MessageQueue& mq, bool fromStore)
-{
-    return m_pDefaultMQPullConsumerImpl->fetchConsumeOffset(mq, fromStore);
-}
-
-std::set<MessageQueue>* DefaultMQPullConsumer::fetchMessageQueuesInBalance(const std::string& topic)
-{
-    return m_pDefaultMQPullConsumerImpl->fetchMessageQueuesInBalance(topic);
-}
-//MQPullConsumer end
-
-OffsetStore* DefaultMQPullConsumer::getOffsetStore()
-{
-    return m_pOffsetStore;
-}
-
-void DefaultMQPullConsumer::setOffsetStore(OffsetStore* offsetStore)
-{
-    m_pOffsetStore = offsetStore;
-}
-
-DefaultMQPullConsumerImpl* DefaultMQPullConsumer::getDefaultMQPullConsumerImpl()
-{
-    return m_pDefaultMQPullConsumerImpl;
-}
-
-bool DefaultMQPullConsumer::isUnitMode()
-{
-    return m_unitMode;
-}
-
-void DefaultMQPullConsumer::setUnitMode(bool isUnitMode)
-{
-    m_unitMode = isUnitMode;
-}
-
-int DefaultMQPullConsumer::getMaxReconsumeTimes()
-{
-    return m_maxReconsumeTimes;
-}
-
-void DefaultMQPullConsumer::setMaxReconsumeTimes(int maxReconsumeTimes)
-{
-    m_maxReconsumeTimes = maxReconsumeTimes;
-}
-
-
-}
-

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/consumer/DefaultMQPullConsumerImpl.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/consumer/DefaultMQPullConsumerImpl.cpp b/rocketmq-client4cpp/src/consumer/DefaultMQPullConsumerImpl.cpp
deleted file mode 100755
index d6465e9..0000000
--- a/rocketmq-client4cpp/src/consumer/DefaultMQPullConsumerImpl.cpp
+++ /dev/null
@@ -1,630 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#include "DefaultMQPullConsumerImpl.h"
-
-#include <iostream>
-#include <string>
-#include <set>
-#include "DefaultMQPullConsumer.h"
-#include "DefaultMQProducer.h"
-#include "MQClientFactory.h"
-#include "MQAdminImpl.h"
-#include "RebalancePullImpl.h"
-#include "MQClientAPIImpl.h"
-#include "OffsetStore.h"
-#include "MixAll.h"
-#include "MQClientManager.h"
-#include "LocalFileOffsetStore.h"
-#include "RemoteBrokerOffsetStore.h"
-#include "PullSysFlag.h"
-#include "FilterAPI.h"
-#include "PullAPIWrapper.h"
-#include "MQClientException.h"
-#include "Validators.h"
-#include "ScopedLock.h"
-
-namespace rmq
-{
-
-DefaultMQPullConsumerImpl::DefaultMQPullConsumerImpl(DefaultMQPullConsumer* pDefaultMQPullConsumer)
-    : m_pDefaultMQPullConsumer(pDefaultMQPullConsumer),
-      m_serviceState(CREATE_JUST)
-{
-	m_pMQClientFactory = NULL;
-	m_pPullAPIWrapper = NULL;
-    m_pOffsetStore = NULL;
-    m_pRebalanceImpl = new RebalancePullImpl(this);
-}
-
-DefaultMQPullConsumerImpl::~DefaultMQPullConsumerImpl()
-{
-	if (m_pRebalanceImpl)
-		delete m_pRebalanceImpl;
-	if (m_pPullAPIWrapper)
-		delete m_pPullAPIWrapper;
-	if (m_pOffsetStore)
-		delete m_pOffsetStore;
-	//delete m_pMQClientFactory;
-}
-
-void  DefaultMQPullConsumerImpl::start()
-{
-    RMQ_INFO("DefaultMQPullConsumerImpl::start()");
-    switch (m_serviceState)
-    {
-        case CREATE_JUST:
-	        {
-	        	RMQ_INFO("the consumer [{%s}] start beginning. messageModel={%s}",
-                	m_pDefaultMQPullConsumer->getConsumerGroup().c_str(),
-                	getMessageModelString(m_pDefaultMQPullConsumer->getMessageModel()));
-
-	            m_serviceState = START_FAILED;
-	            checkConfig();
-	            copySubscription();
-
-	            if (m_pDefaultMQPullConsumer->getMessageModel() == CLUSTERING)
-	            {
-	                m_pDefaultMQPullConsumer->changeInstanceNameToPID();
-	            }
-
-	            m_pMQClientFactory = MQClientManager::getInstance()->getAndCreateMQClientFactory(*m_pDefaultMQPullConsumer);
-
-	            m_pRebalanceImpl->setConsumerGroup(m_pDefaultMQPullConsumer->getConsumerGroup());
-	            m_pRebalanceImpl->setMessageModel(m_pDefaultMQPullConsumer->getMessageModel());
-	            m_pRebalanceImpl->setAllocateMessageQueueStrategy(m_pDefaultMQPullConsumer->getAllocateMessageQueueStrategy());
-	            m_pRebalanceImpl->setmQClientFactory(m_pMQClientFactory);
-
-	            m_pPullAPIWrapper = new PullAPIWrapper(m_pMQClientFactory, m_pDefaultMQPullConsumer->getConsumerGroup());
-
-	            if (m_pDefaultMQPullConsumer->getOffsetStore() != NULL)
-	            {
-	                m_pOffsetStore = m_pDefaultMQPullConsumer->getOffsetStore();
-	            }
-	            else
-	            {
-	                switch (m_pDefaultMQPullConsumer->getMessageModel())
-	                {
-	                    case BROADCASTING:
-	                        m_pOffsetStore = new LocalFileOffsetStore(m_pMQClientFactory, m_pDefaultMQPullConsumer->getConsumerGroup());
-	                        break;
-	                    case CLUSTERING:
-	                        m_pOffsetStore = new RemoteBrokerOffsetStore(m_pMQClientFactory, m_pDefaultMQPullConsumer->getConsumerGroup());
-	                        break;
-	                    default:
-	                        break;
-	                }
-	            }
-
-	            m_pOffsetStore->load();
-
-	            bool registerOK =
-	                m_pMQClientFactory->registerConsumer(m_pDefaultMQPullConsumer->getConsumerGroup(), this);
-	            if (!registerOK)
-	            {
-	                m_serviceState = CREATE_JUST;
-	                std::string str = "The consumer group[" + m_pDefaultMQPullConsumer->getConsumerGroup();
-	                str += "] has been created before, specify another name please.";
-	                THROW_MQEXCEPTION(MQClientException, str, -1);
-	            }
-
-	            m_pMQClientFactory->start();
-
-	            m_serviceState = RUNNING;
-	        }
-        	break;
-        case RUNNING:
-        case START_FAILED:
-        case SHUTDOWN_ALREADY:
-            THROW_MQEXCEPTION(MQClientException, "The PullConsumer service state not OK, maybe started once, ", -1);
-        default:
-            break;
-    }
-}
-
-
-void  DefaultMQPullConsumerImpl::shutdown()
-{
-    RMQ_DEBUG("DefaultMQPullConsumerImpl::shutdown()");
-    switch (m_serviceState)
-    {
-        case CREATE_JUST:
-            break;
-        case RUNNING:
-            persistConsumerOffset();
-            m_pMQClientFactory->unregisterConsumer(m_pDefaultMQPullConsumer->getConsumerGroup());
-            m_pMQClientFactory->shutdown();
-
-            m_serviceState = SHUTDOWN_ALREADY;
-            break;
-        case SHUTDOWN_ALREADY:
-            break;
-        default:
-            break;
-    }
-}
-
-
-void DefaultMQPullConsumerImpl::createTopic(const std::string& key, const std::string& newTopic, int queueNum)
-{
-    makeSureStateOK();
-    m_pMQClientFactory->getMQAdminImpl()->createTopic(key, newTopic, queueNum);
-}
-
-long long DefaultMQPullConsumerImpl::fetchConsumeOffset(MessageQueue& mq, bool fromStore)
-{
-    makeSureStateOK();
-    return m_pOffsetStore->readOffset(mq, fromStore ? READ_FROM_STORE : MEMORY_FIRST_THEN_STORE);
-}
-
-std::set<MessageQueue>* DefaultMQPullConsumerImpl::fetchMessageQueuesInBalance(const std::string& topic)
-{
-    makeSureStateOK();
-    std::set<MessageQueue>* mqResult = new std::set<MessageQueue>;
-
-	kpr::ScopedRLock<kpr::RWMutex> lock(m_pRebalanceImpl->getProcessQueueTableLock());
-    std::map<MessageQueue, ProcessQueue*>& mqTable = m_pRebalanceImpl->getProcessQueueTable();
-    RMQ_FOR_EACH(mqTable, it)
-    {
-        if (it->first.getTopic() == topic)
-        {
-            mqResult->insert(it->first);
-        }
-    }
-
-    return mqResult;
-}
-
-std::vector<MessageQueue>* DefaultMQPullConsumerImpl::fetchPublishMessageQueues(const std::string&  topic)
-{
-    makeSureStateOK();
-    return m_pMQClientFactory->getMQAdminImpl()->fetchPublishMessageQueues(topic);
-}
-
-std::set<MessageQueue>*  DefaultMQPullConsumerImpl::fetchSubscribeMessageQueues(const std::string& topic)
-{
-    makeSureStateOK();
-    return m_pMQClientFactory->getMQAdminImpl()->fetchSubscribeMessageQueues(topic);
-}
-
-long long  DefaultMQPullConsumerImpl::earliestMsgStoreTime(const MessageQueue& mq)
-{
-    makeSureStateOK();
-    return m_pMQClientFactory->getMQAdminImpl()->earliestMsgStoreTime(mq);
-}
-
-std::string  DefaultMQPullConsumerImpl::groupName()
-{
-    return m_pDefaultMQPullConsumer->getConsumerGroup();
-}
-
-MessageModel  DefaultMQPullConsumerImpl::messageModel()
-{
-    return m_pDefaultMQPullConsumer->getMessageModel();
-}
-
-ConsumeType  DefaultMQPullConsumerImpl::consumeType()
-{
-    return CONSUME_ACTIVELY;
-}
-
-ConsumeFromWhere  DefaultMQPullConsumerImpl::consumeFromWhere()
-{
-    return CONSUME_FROM_LAST_OFFSET;
-}
-
-std::set<SubscriptionData>  DefaultMQPullConsumerImpl::subscriptions()
-{
-    //TODO
-    std::set<SubscriptionData> result;
-    return result;
-}
-
-void DefaultMQPullConsumerImpl::doRebalance()
-{
-    if (m_pRebalanceImpl != NULL)
-    {
-        m_pRebalanceImpl->doRebalance();
-    }
-}
-
-void  DefaultMQPullConsumerImpl::persistConsumerOffset()
-{
-    try
-    {
-        makeSureStateOK();
-
-        std::set<MessageQueue> mqs;
-		{
-	        kpr::ScopedRLock<kpr::RWMutex> lock(m_pRebalanceImpl->getProcessQueueTableLock());
-	        std::map<MessageQueue, ProcessQueue*> processQueueTable = m_pRebalanceImpl->getProcessQueueTable();
-	        RMQ_FOR_EACH(processQueueTable, it)
-	        {
-	            mqs.insert(it->first);
-	        }
-        }
-
-        m_pOffsetStore->persistAll(mqs);
-    }
-    catch (...)
-    {
-        RMQ_ERROR("group {%s} persistConsumerOffset exception",
-                  m_pDefaultMQPullConsumer->getConsumerGroup().c_str());
-    }
-}
-
-void  DefaultMQPullConsumerImpl::updateTopicSubscribeInfo(const std::string& topic, const std::set<MessageQueue>& info)
-{
-    std::map<std::string, SubscriptionData>& subTable = m_pRebalanceImpl->getSubscriptionInner();
-
-    if (subTable.find(topic) != subTable.end())
-    {
-        m_pRebalanceImpl->getTopicSubscribeInfoTable().insert(std::pair<std::string, std::set<MessageQueue> >(topic, info));
-    }
-}
-
-bool  DefaultMQPullConsumerImpl::isSubscribeTopicNeedUpdate(const std::string& topic)
-{
-    std::map<std::string, SubscriptionData>& subTable = m_pRebalanceImpl->getSubscriptionInner();
-    if (subTable.find(topic) != subTable.end())
-    {
-        std::map<std::string, std::set<MessageQueue> >& mqs =
-            m_pRebalanceImpl->getTopicSubscribeInfoTable();
-        return mqs.find(topic) == mqs.end();
-    }
-
-    return false;
-}
-
-long long  DefaultMQPullConsumerImpl::maxOffset(const MessageQueue& mq)
-{
-    makeSureStateOK();
-    return m_pMQClientFactory->getMQAdminImpl()->maxOffset(mq);
-}
-
-long long  DefaultMQPullConsumerImpl::minOffset(const MessageQueue& mq)
-{
-    makeSureStateOK();
-    return m_pMQClientFactory->getMQAdminImpl()->minOffset(mq);
-}
-
-PullResult* DefaultMQPullConsumerImpl::pull(MessageQueue& mq,
-        const std::string& subExpression,
-        long long offset,
-        int maxNums)
-{
-    return pullSyncImpl(mq, subExpression, offset, maxNums, false);
-}
-
-void  DefaultMQPullConsumerImpl::pull(MessageQueue& mq,
-                                      const std::string& subExpression,
-                                      long long offset,
-                                      int maxNums,
-                                      PullCallback* pPullCallback)
-{
-    pullAsyncImpl(mq, subExpression, offset, maxNums, pPullCallback, false);
-}
-
-PullResult* DefaultMQPullConsumerImpl::pullBlockIfNotFound(MessageQueue& mq,
-        const std::string& subExpression,
-        long long offset,
-        int maxNums)
-{
-    return pullSyncImpl(mq, subExpression, offset, maxNums, true);
-}
-
-void  DefaultMQPullConsumerImpl::pullBlockIfNotFound(MessageQueue& mq,
-        const std::string& subExpression,
-        long long offset,
-        int maxNums,
-        PullCallback* pPullCallback)
-{
-    pullAsyncImpl(mq, subExpression, offset, maxNums, pPullCallback, true);
-}
-
-QueryResult  DefaultMQPullConsumerImpl::queryMessage(const std::string& topic,
-        const std::string&  key,
-        int maxNum,
-        long long begin,
-        long long end)
-{
-    makeSureStateOK();
-
-    QueryResult result(0, std::list<MessageExt*>());
-    return m_pMQClientFactory->getMQAdminImpl()->queryMessage(topic, key, maxNum, begin, end);
-}
-
-long long DefaultMQPullConsumerImpl::searchOffset(const MessageQueue& mq, long long timestamp)
-{
-    makeSureStateOK();
-    return m_pMQClientFactory->getMQAdminImpl()->searchOffset(mq, timestamp);
-}
-
-void  DefaultMQPullConsumerImpl::sendMessageBack(MessageExt& msg, int delayLevel, const std::string& brokerName)
-{
-	return sendMessageBack(msg, delayLevel, brokerName, m_pDefaultMQPullConsumer->getConsumerGroup());
-}
-
-
-void DefaultMQPullConsumerImpl::sendMessageBack(MessageExt& msg, int delayLevel, const std::string& brokerName,
-	const std::string& consumerGroup)
-{
-    try
-    {
-    	std::string brokerAddr = brokerName.empty() ?
-    		socketAddress2IPPort(msg.getStoreHost()) : m_pMQClientFactory->findBrokerAddressInPublish(brokerName);
-
-        m_pMQClientFactory->getMQClientAPIImpl()->consumerSendMessageBack(brokerAddr, msg,
-                consumerGroup.empty() ? m_pDefaultMQPullConsumer->getConsumerGroup() : consumerGroup,
-                delayLevel,
-                3000);
-    }
-    catch (...)
-    {
-        RMQ_ERROR("sendMessageBack Exception, group: %s", m_pDefaultMQPullConsumer->getConsumerGroup().c_str());
-        Message newMsg(MixAll::getRetryTopic(m_pDefaultMQPullConsumer->getConsumerGroup()),
-                       msg.getBody(), msg.getBodyLen());
-
-		std::string originMsgId = msg.getProperty(Message::PROPERTY_ORIGIN_MESSAGE_ID);
-		newMsg.putProperty(Message::PROPERTY_ORIGIN_MESSAGE_ID, UtilAll::isBlank(originMsgId) ? msg.getMsgId()
-                    : originMsgId);
-
-        newMsg.setFlag(msg.getFlag());
-        newMsg.setProperties(msg.getProperties());
-        newMsg.putProperty(Message::PROPERTY_RETRY_TOPIC, msg.getTopic());
-
-        int reTimes = msg.getReconsumeTimes() + 1;
-        newMsg.putProperty(Message::PROPERTY_RECONSUME_TIME, UtilAll::toString(reTimes));
-        newMsg.putProperty(Message::PROPERTY_MAX_RECONSUME_TIMES, UtilAll::toString(m_pDefaultMQPullConsumer->getMaxReconsumeTimes()));
-        newMsg.setDelayTimeLevel(3 + reTimes);
-
-        m_pMQClientFactory->getDefaultMQProducer()->send(newMsg);
-    }
-}
-
-void  DefaultMQPullConsumerImpl::updateConsumeOffset(MessageQueue& mq, long long offset)
-{
-    makeSureStateOK();
-    m_pOffsetStore->updateOffset(mq, offset, false);
-}
-
-MessageExt*  DefaultMQPullConsumerImpl::viewMessage(const std::string& msgId)
-{
-    makeSureStateOK();
-
-    return m_pMQClientFactory->getMQAdminImpl()->viewMessage(msgId);
-}
-
-DefaultMQPullConsumer*  DefaultMQPullConsumerImpl::getDefaultMQPullConsumer()
-{
-    return m_pDefaultMQPullConsumer;
-}
-
-OffsetStore*  DefaultMQPullConsumerImpl::getOffsetStore()
-{
-    return m_pOffsetStore;
-}
-
-void  DefaultMQPullConsumerImpl::setOffsetStore(OffsetStore* pOffsetStore)
-{
-    m_pOffsetStore = pOffsetStore;
-}
-
-void  DefaultMQPullConsumerImpl::makeSureStateOK()
-{
-    if (m_serviceState != RUNNING)
-    {
-        THROW_MQEXCEPTION(MQClientException, "The consumer service state not OK, ", -1);
-    }
-}
-
-PullResult* DefaultMQPullConsumerImpl::pullSyncImpl(MessageQueue& mq,
-        const std::string& subExpression,
-        long long offset,
-        int maxNums,
-        bool block)
-{
-    makeSureStateOK();
-
-    if (offset < 0)
-    {
-        THROW_MQEXCEPTION(MQClientException, "offset < 0", -1);
-    }
-
-    if (maxNums <= 0)
-    {
-        THROW_MQEXCEPTION(MQClientException, "maxNums <= 0", -1);
-    }
-
-    subscriptionAutomatically(mq.getTopic());
-
-    int sysFlag = PullSysFlag::buildSysFlag(false, block, true);
-
-    SubscriptionDataPtr subscriptionData = NULL;
-    try
-    {
-        subscriptionData = FilterAPI::buildSubscriptionData(mq.getTopic(), subExpression);
-    }
-    catch (...)
-    {
-        THROW_MQEXCEPTION(MQClientException, "parse subscription error", -1);
-    }
-
-    int timeoutMillis =
-        block ? m_pDefaultMQPullConsumer->getConsumerTimeoutMillisWhenSuspend()
-        : m_pDefaultMQPullConsumer->getConsumerPullTimeoutMillis();
-
-    PullResult* pullResult = m_pPullAPIWrapper->pullKernelImpl(//
-                                 mq, // 1
-                                 subscriptionData->getSubString(), // 2
-                                 0L, // 3
-                                 offset, // 4
-                                 maxNums, // 5
-                                 sysFlag, // 6
-                                 0, // 7
-                                 m_pDefaultMQPullConsumer->getBrokerSuspendMaxTimeMillis(), // 8
-                                 timeoutMillis, // 9
-                                 SYNC, // 10
-                                 NULL// 11
-                             );
-
-    return m_pPullAPIWrapper->processPullResult(mq, *pullResult, *subscriptionData);
-}
-
-void  DefaultMQPullConsumerImpl::subscriptionAutomatically(const std::string& topic)
-{
-    std::map<std::string, SubscriptionData>& sd = m_pRebalanceImpl->getSubscriptionInner();
-    std::map<std::string, SubscriptionData>::iterator it = sd.find(topic);
-
-    if (it == sd.end())
-    {
-        try
-        {
-            SubscriptionDataPtr subscriptionData =
-                FilterAPI::buildSubscriptionData(topic, SubscriptionData::SUB_ALL);
-            sd[topic] = *subscriptionData;
-        }
-        catch (...)
-        {
-        	RMQ_WARN("FilterAPI::buildSubscriptionData exception");
-        }
-    }
-}
-
-void DefaultMQPullConsumerImpl::pullAsyncImpl(//
-    MessageQueue& mq, const std::string& subExpression, long long offset, int maxNums,
-    PullCallback* pPullCallback,//
-    bool block)
-{
-    makeSureStateOK();
-
-    if (offset < 0)
-    {
-        THROW_MQEXCEPTION(MQClientException, "offset < 0", -1);
-    }
-
-    if (maxNums <= 0)
-    {
-        THROW_MQEXCEPTION(MQClientException, "maxNums <= 0", -1);
-    }
-
-    if (pPullCallback == NULL)
-    {
-        THROW_MQEXCEPTION(MQClientException, "pullCallback is null", -1);
-    }
-
-    subscriptionAutomatically(mq.getTopic());
-    try
-    {
-        int sysFlag = PullSysFlag::buildSysFlag(false, block, true);
-
-        SubscriptionDataPtr subscriptionData = NULL;
-        try
-        {
-            subscriptionData = FilterAPI::buildSubscriptionData(mq.getTopic(), subExpression);
-        }
-        catch (...)
-        {
-            THROW_MQEXCEPTION(MQClientException, "parse subscription error", -1);
-        }
-
-        int timeoutMillis =
-            block ? m_pDefaultMQPullConsumer->getConsumerTimeoutMillisWhenSuspend()
-            : m_pDefaultMQPullConsumer->getConsumerPullTimeoutMillis();
-        DefaultMQPullConsumerImplCallback* callback =
-            new DefaultMQPullConsumerImplCallback(*subscriptionData,
-                    mq, this, pPullCallback);
-
-        m_pPullAPIWrapper->pullKernelImpl(
-			mq, // 1
-			subscriptionData->getSubString(), // 2
-			0L, // 3
-			offset, // 4
-			maxNums, // 5
-			sysFlag, // 6
-			0, // 7
-			m_pDefaultMQPullConsumer->getBrokerSuspendMaxTimeMillis(), // 8
-			timeoutMillis, // 9
-			ASYNC, // 10
-			callback// 11
-		);
-    }
-    catch (const MQBrokerException& e)
-    {
-        THROW_MQEXCEPTION(MQClientException, "pullAsync unknow exception", -1);
-    }
-}
-
-
-void  DefaultMQPullConsumerImpl::copySubscription()
-{
-    try
-    {
-        std::set<std::string> registerTopics = m_pDefaultMQPullConsumer->getRegisterTopics();
-        std::set<std::string>::iterator it = registerTopics.begin();
-
-        for (; it != registerTopics.end(); it++)
-        {
-            SubscriptionDataPtr subscriptionData =
-                FilterAPI::buildSubscriptionData(*it, SubscriptionData::SUB_ALL);
-            m_pRebalanceImpl->getSubscriptionInner()[*it] = *subscriptionData;
-        }
-    }
-    catch (...)
-    {
-        THROW_MQEXCEPTION(MQClientException, "subscription exception", -1);
-    }
-}
-
-
-void  DefaultMQPullConsumerImpl::checkConfig()
-{
-    // check consumerGroup
-    Validators::checkGroup(m_pDefaultMQPullConsumer->getConsumerGroup());
-
-    // consumerGroup
-    if (m_pDefaultMQPullConsumer->getConsumerGroup() == MixAll::DEFAULT_CONSUMER_GROUP)
-    {
-        THROW_MQEXCEPTION(MQClientException, "consumerGroup can not equal "
-                          + MixAll::DEFAULT_CONSUMER_GROUP //
-                          + ", please specify another one.", -1);
-    }
-
-    if (m_pDefaultMQPullConsumer->getMessageModel() != BROADCASTING
-        && m_pDefaultMQPullConsumer->getMessageModel() != CLUSTERING)
-    {
-        THROW_MQEXCEPTION(MQClientException, "messageModel is valid ", -1);
-    }
-
-    // allocateMessageQueueStrategy
-    if (m_pDefaultMQPullConsumer->getAllocateMessageQueueStrategy() == NULL)
-    {
-        THROW_MQEXCEPTION(MQClientException, "allocateMessageQueueStrategy is null", -1);
-    }
-}
-
-ServiceState DefaultMQPullConsumerImpl::getServiceState()
-{
-    return m_serviceState;
-}
-
-void DefaultMQPullConsumerImpl::setServiceState(ServiceState serviceState)
-{
-    m_serviceState = serviceState;
-}
-
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/consumer/DefaultMQPullConsumerImpl.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/consumer/DefaultMQPullConsumerImpl.h b/rocketmq-client4cpp/src/consumer/DefaultMQPullConsumerImpl.h
deleted file mode 100755
index 171565c..0000000
--- a/rocketmq-client4cpp/src/consumer/DefaultMQPullConsumerImpl.h
+++ /dev/null
@@ -1,174 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#ifndef __DEFAULTMQPULLCONSUMERIMPL_H__
-#define __DEFAULTMQPULLCONSUMERIMPL_H__
-
-#include <string>
-#include <set>
-#include <map>
-#include <vector>
-#include "MQConsumerInner.h"
-#include "MessageExt.h"
-#include "QueryResult.h"
-#include "ServiceState.h"
-#include "PullRequest.h"
-#include "MessageQueue.h"
-#include "PullResult.h"
-#include "PullCallback.h"
-#include "PullAPIWrapper.h"
-
-namespace rmq
-{
-class DefaultMQPullConsumer;
-class PullCallback;
-class OffsetStore;
-class RebalanceImpl;
-class MQClientFactory;
-class PullAPIWrapper;
-
-/**
-* PullConsumer imp
-*/
-class DefaultMQPullConsumerImpl : public  MQConsumerInner
-{
-public:
-    DefaultMQPullConsumerImpl(DefaultMQPullConsumer *pDefaultMQPullConsumer);
-    ~DefaultMQPullConsumerImpl();
-    void createTopic(const std::string &key, const std::string &newTopic,
-                     int queueNum);
-    long long fetchConsumeOffset(MessageQueue &mq, bool fromStore);
-    std::set<MessageQueue> *fetchMessageQueuesInBalance(const std::string &topic);
-    std::vector<MessageQueue> *fetchPublishMessageQueues(const std::string  &topic);
-    std::set<MessageQueue> *fetchSubscribeMessageQueues(const std::string &topic);
-    long long earliestMsgStoreTime(const MessageQueue &mq);
-    std::string groupName();
-    MessageModel messageModel();
-    ConsumeType consumeType();
-    ConsumeFromWhere consumeFromWhere();
-    std::set<SubscriptionData> subscriptions();
-    void doRebalance();
-    void persistConsumerOffset();
-    void updateTopicSubscribeInfo(const std::string &topic,
-                                  const std::set<MessageQueue> &info);
-    bool isSubscribeTopicNeedUpdate(const std::string &topic);
-    long long maxOffset(const MessageQueue &mq);
-    long long minOffset(const MessageQueue &mq);
-
-    PullResult *pull(MessageQueue &mq,
-                     const std::string &subExpression,
-                     long long offset,
-                     int maxNums);
-
-    void pull(MessageQueue &mq,
-              const std::string &subExpression,
-              long long offset,
-              int maxNums,
-              PullCallback *pPullCallback);
-
-    PullResult *pullBlockIfNotFound(MessageQueue &mq,
-                                    const std::string &subExpression,
-                                    long long offset, int maxNums);
-
-    void pullBlockIfNotFound(MessageQueue &mq,
-                             const std::string &subExpression,
-                             long long offset, int maxNums,
-                             PullCallback *pPullCallback);
-
-    QueryResult queryMessage(const std::string &topic,
-                             const std::string  &key,
-                             int maxNum,
-                             long long begin,
-                             long long end);
-
-    long long searchOffset(const MessageQueue &mq, long long timestamp);
-    void sendMessageBack(MessageExt &msg, int delayLevel,
-                         const std::string &brokerName);
-    void sendMessageBack(MessageExt &msg, int delayLevel,
-                         const std::string &brokerName, const std::string &consumerGroup);
-    void shutdown();
-    void updateConsumeOffset(MessageQueue &mq, long long offset);
-    MessageExt *viewMessage(const std::string &msgId);
-    DefaultMQPullConsumer *getDefaultMQPullConsumer();
-    OffsetStore *getOffsetStore();
-    void setOffsetStore(OffsetStore *pOffsetStore);
-    void start();
-
-    ServiceState getServiceState();
-    void setServiceState(ServiceState serviceState);
-
-private:
-    void makeSureStateOK();
-    void subscriptionAutomatically(const std::string &topic);
-    void copySubscription();
-    void checkConfig();
-
-    PullResult *pullSyncImpl(MessageQueue &mq,
-                             const std::string &subExpression,
-                             long long offset,
-                             int maxNums,
-                             bool block) ;
-    void pullAsyncImpl(MessageQueue &mq,
-                       const std::string &subExpression,
-                       long long offset,
-                       int maxNums,
-                       PullCallback *pPullCallback,
-                       bool block);
-
-private:
-    DefaultMQPullConsumer *m_pDefaultMQPullConsumer;
-    ServiceState m_serviceState;
-    MQClientFactory *m_pMQClientFactory;
-    PullAPIWrapper *m_pPullAPIWrapper;
-    OffsetStore *m_pOffsetStore;
-    RebalanceImpl *m_pRebalanceImpl;
-    friend class DefaultMQPullConsumerImplCallback;
-};
-
-class DefaultMQPullConsumerImplCallback : public PullCallback
-{
-public:
-    DefaultMQPullConsumerImplCallback(SubscriptionData &subscriptionData,
-                                      MessageQueue &mq,
-                                      DefaultMQPullConsumerImpl *pDefaultMQPullConsumerImpl,
-                                      PullCallback *pCallback)
-        : m_subscriptionData(subscriptionData),
-          m_mq(mq),
-          m_pDefaultMQPullConsumerImpl(pDefaultMQPullConsumerImpl),
-          m_pCallback(pCallback)
-    {
-    }
-
-    void onSuccess(PullResult &pullResult)
-    {
-        m_pCallback->onSuccess(
-            *m_pDefaultMQPullConsumerImpl->m_pPullAPIWrapper->
-            processPullResult(m_mq, pullResult, m_subscriptionData));
-    }
-
-    void onException(MQException &e)
-    {
-        m_pCallback->onException(e);
-    }
-
-private:
-    SubscriptionData m_subscriptionData;
-    MessageQueue m_mq;
-    DefaultMQPullConsumerImpl *m_pDefaultMQPullConsumerImpl;
-    PullCallback *m_pCallback;
-};
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/consumer/DefaultMQPushConsumer.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/consumer/DefaultMQPushConsumer.cpp b/rocketmq-client4cpp/src/consumer/DefaultMQPushConsumer.cpp
deleted file mode 100755
index 45ee907..0000000
--- a/rocketmq-client4cpp/src/consumer/DefaultMQPushConsumer.cpp
+++ /dev/null
@@ -1,399 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#include "DefaultMQPushConsumer.h"
-#include <list>
-#include <string>
-
-#include "DefaultMQPushConsumerImpl.h"
-#include "MessageQueue.h"
-#include "MessageExt.h"
-#include "ClientConfig.h"
-#include "ConsumerStatManage.h"
-#include "MixAll.h"
-#include "AllocateMessageQueueStrategyInner.h"
-
-namespace rmq
-{
-
-class AllocateMessageQueueStrategy;
-
-DefaultMQPushConsumer::DefaultMQPushConsumer()
-{
-    m_consumerGroup = MixAll::DEFAULT_CONSUMER_GROUP;
-    m_messageModel = CLUSTERING;
-    m_consumeFromWhere = CONSUME_FROM_LAST_OFFSET;
-    m_pAllocateMessageQueueStrategy = new AllocateMessageQueueAveragely();
-    m_pMessageListener = NULL;
-    m_consumeThreadMin = 5;
-    m_consumeThreadMax = 25;
-    m_consumeConcurrentlyMaxSpan = 2000;
-    m_pullThresholdForQueue = 1000;
-    m_pullInterval = 0;
-    m_consumeMessageBatchMaxSize = 1;
-    m_pullBatchSize = 32;
-    m_postSubscriptionWhenPull = false;
-    m_unitMode = false;
-    m_maxReconsumeTimes = 16;
-    m_suspendCurrentQueueTimeMillis = 1000;
-    m_consumeTimeout = 15;
-    m_pOffsetStore = NULL;
-    m_pDefaultMQPushConsumerImpl = new DefaultMQPushConsumerImpl(this);
-}
-
-DefaultMQPushConsumer::DefaultMQPushConsumer(const std::string& consumerGroup)
-{
-    m_consumerGroup = consumerGroup;
-    m_messageModel = CLUSTERING;
-    m_consumeFromWhere = CONSUME_FROM_LAST_OFFSET;
-    m_pAllocateMessageQueueStrategy = new AllocateMessageQueueAveragely();
-    m_pMessageListener = NULL;
-    m_consumeThreadMin = 5;
-    m_consumeThreadMax = 25;
-    m_consumeConcurrentlyMaxSpan = 2000;
-    m_pullThresholdForQueue = 1000;
-    m_pullInterval = 0;
-    m_consumeMessageBatchMaxSize = 1;
-    m_pullBatchSize = 32;
-    m_postSubscriptionWhenPull = false;
-    m_unitMode = false;
-    m_maxReconsumeTimes = 16;
-    m_suspendCurrentQueueTimeMillis = 1000;
-    m_consumeTimeout = 15;
-    m_pOffsetStore = NULL;
-    m_pDefaultMQPushConsumerImpl = new DefaultMQPushConsumerImpl(this);
-}
-
-DefaultMQPushConsumer::~DefaultMQPushConsumer()
-{
-    delete m_pAllocateMessageQueueStrategy;
-    delete m_pDefaultMQPushConsumerImpl;
-}
-
-//MQAdmin
-void DefaultMQPushConsumer::createTopic(const std::string& key, const std::string& newTopic, int queueNum)
-{
-    m_pDefaultMQPushConsumerImpl->createTopic(key, newTopic, queueNum);
-}
-
-long long DefaultMQPushConsumer::searchOffset(const MessageQueue& mq, long long timestamp)
-{
-    return m_pDefaultMQPushConsumerImpl->searchOffset(mq, timestamp);
-}
-
-long long DefaultMQPushConsumer::maxOffset(const MessageQueue& mq)
-{
-    return m_pDefaultMQPushConsumerImpl->maxOffset(mq);
-}
-
-long long DefaultMQPushConsumer::minOffset(const MessageQueue& mq)
-{
-    return m_pDefaultMQPushConsumerImpl->minOffset(mq);
-}
-
-long long DefaultMQPushConsumer::earliestMsgStoreTime(const MessageQueue& mq)
-{
-    return m_pDefaultMQPushConsumerImpl->earliestMsgStoreTime(mq);
-}
-
-MessageExt* DefaultMQPushConsumer::viewMessage(const std::string& msgId)
-{
-    return m_pDefaultMQPushConsumerImpl->viewMessage(msgId);
-}
-
-QueryResult DefaultMQPushConsumer::queryMessage(const std::string& topic,
-        const std::string&  key,
-        int maxNum,
-        long long begin,
-        long long end)
-{
-    return m_pDefaultMQPushConsumerImpl->queryMessage(topic, key, maxNum, begin, end);
-}
-// MQadmin end
-
-AllocateMessageQueueStrategy* DefaultMQPushConsumer::getAllocateMessageQueueStrategy()
-{
-    return m_pAllocateMessageQueueStrategy;
-}
-
-void DefaultMQPushConsumer::setAllocateMessageQueueStrategy(AllocateMessageQueueStrategy* pAllocateMessageQueueStrategy)
-{
-    m_pAllocateMessageQueueStrategy = pAllocateMessageQueueStrategy;
-}
-
-int DefaultMQPushConsumer::getConsumeConcurrentlyMaxSpan()
-{
-    return m_consumeConcurrentlyMaxSpan;
-}
-
-void DefaultMQPushConsumer::setConsumeConcurrentlyMaxSpan(int consumeConcurrentlyMaxSpan)
-{
-    m_consumeConcurrentlyMaxSpan = consumeConcurrentlyMaxSpan;
-}
-
-ConsumeFromWhere DefaultMQPushConsumer::getConsumeFromWhere()
-{
-    return m_consumeFromWhere;
-}
-
-void DefaultMQPushConsumer::setConsumeFromWhere(ConsumeFromWhere consumeFromWhere)
-{
-    m_consumeFromWhere = consumeFromWhere;
-}
-
-int DefaultMQPushConsumer::getConsumeMessageBatchMaxSize()
-{
-    return m_consumeMessageBatchMaxSize;
-}
-
-void DefaultMQPushConsumer::setConsumeMessageBatchMaxSize(int consumeMessageBatchMaxSize)
-{
-    m_consumeMessageBatchMaxSize = consumeMessageBatchMaxSize;
-}
-
-std::string DefaultMQPushConsumer::getConsumerGroup()
-{
-    return m_consumerGroup;
-}
-
-void DefaultMQPushConsumer::setConsumerGroup(const std::string& consumerGroup)
-{
-    m_consumerGroup = consumerGroup;
-}
-
-int DefaultMQPushConsumer::getConsumeThreadMax()
-{
-    return m_consumeThreadMax;
-}
-
-void DefaultMQPushConsumer::setConsumeThreadMax(int consumeThreadMax)
-{
-    m_consumeThreadMax = consumeThreadMax;
-}
-
-int DefaultMQPushConsumer::getConsumeThreadMin()
-{
-    return m_consumeThreadMin;
-}
-
-void DefaultMQPushConsumer::setConsumeThreadMin(int consumeThreadMin)
-{
-    m_consumeThreadMin = consumeThreadMin;
-}
-
-DefaultMQPushConsumerImpl* DefaultMQPushConsumer::getDefaultMQPushConsumerImpl()
-{
-    return m_pDefaultMQPushConsumerImpl;
-}
-
-MessageListener* DefaultMQPushConsumer::getMessageListener()
-{
-    return m_pMessageListener;
-}
-
-void DefaultMQPushConsumer::setMessageListener(MessageListener* pMessageListener)
-{
-    m_pMessageListener = pMessageListener;
-}
-
-MessageModel DefaultMQPushConsumer::getMessageModel()
-{
-    return m_messageModel;
-}
-
-void DefaultMQPushConsumer::setMessageModel(MessageModel messageModel)
-{
-    m_messageModel = messageModel;
-}
-
-int DefaultMQPushConsumer::getPullBatchSize()
-{
-    return m_pullBatchSize;
-}
-
-void DefaultMQPushConsumer::setPullBatchSize(int pullBatchSize)
-{
-    m_pullBatchSize = pullBatchSize;
-}
-
-long DefaultMQPushConsumer::getPullInterval()
-{
-    return m_pullInterval;
-}
-
-void DefaultMQPushConsumer::setPullInterval(long pullInterval)
-{
-    m_pullInterval = pullInterval;
-}
-
-int DefaultMQPushConsumer::getPullThresholdForQueue()
-{
-    return m_pullThresholdForQueue;
-}
-
-void DefaultMQPushConsumer::setPullThresholdForQueue(int pullThresholdForQueue)
-{
-    m_pullThresholdForQueue = pullThresholdForQueue;
-}
-
-std::map<std::string, std::string>& DefaultMQPushConsumer::getSubscription()
-{
-    return m_subscription;
-}
-
-void DefaultMQPushConsumer::setSubscription(const std::map<std::string, std::string>& subscription)
-{
-    m_subscription = subscription;
-}
-
-//MQConsumer
-void DefaultMQPushConsumer::sendMessageBack(MessageExt& msg, int delayLevel)
-{
-    m_pDefaultMQPushConsumerImpl->sendMessageBack(msg, delayLevel, "");
-}
-
-void DefaultMQPushConsumer::sendMessageBack(MessageExt& msg, int delayLevel, const std::string brokerName)
-{
-    m_pDefaultMQPushConsumerImpl->sendMessageBack(msg, delayLevel, brokerName);
-}
-
-
-std::set<MessageQueue>* DefaultMQPushConsumer::fetchSubscribeMessageQueues(const std::string& topic)
-{
-    return m_pDefaultMQPushConsumerImpl->fetchSubscribeMessageQueues(topic);
-}
-
-void DefaultMQPushConsumer::start()
-{
-    m_pDefaultMQPushConsumerImpl->start();
-}
-
-void DefaultMQPushConsumer::shutdown()
-{
-    m_pDefaultMQPushConsumerImpl->shutdown();
-}
-//MQConsumer end
-
-//MQPushConsumer
-void DefaultMQPushConsumer::registerMessageListener(MessageListener* pMessageListener)
-{
-    m_pMessageListener = pMessageListener;
-    m_pDefaultMQPushConsumerImpl->registerMessageListener(pMessageListener);
-}
-
-void DefaultMQPushConsumer::subscribe(const std::string& topic, const std::string& subExpression)
-{
-    m_pDefaultMQPushConsumerImpl->subscribe(topic, subExpression);
-}
-
-void DefaultMQPushConsumer::unsubscribe(const std::string& topic)
-{
-    m_pDefaultMQPushConsumerImpl->unsubscribe(topic);
-}
-
-void DefaultMQPushConsumer::updateCorePoolSize(int corePoolSize)
-{
-    m_pDefaultMQPushConsumerImpl->updateCorePoolSize(corePoolSize);
-}
-
-void DefaultMQPushConsumer::suspend()
-{
-    m_pDefaultMQPushConsumerImpl->suspend();
-}
-
-void DefaultMQPushConsumer::resume()
-{
-    m_pDefaultMQPushConsumerImpl->resume();
-}
-//MQPushConsumer end
-
-OffsetStore* DefaultMQPushConsumer::getOffsetStore()
-{
-    return m_pOffsetStore;
-}
-
-void DefaultMQPushConsumer::setOffsetStore(OffsetStore* pOffsetStore)
-{
-    m_pOffsetStore = pOffsetStore;
-}
-
-std::string DefaultMQPushConsumer::getConsumeTimestamp() {
-    return m_consumeTimestamp;
-}
-
-void DefaultMQPushConsumer::setConsumeTimestamp(std::string consumeTimestamp) {
-    m_consumeTimestamp = consumeTimestamp;
-}
-
-bool DefaultMQPushConsumer::isPostSubscriptionWhenPull()
-{
-    return m_postSubscriptionWhenPull;
-}
-
-
-void DefaultMQPushConsumer::setPostSubscriptionWhenPull(bool postSubscriptionWhenPull)
-{
-    m_postSubscriptionWhenPull = postSubscriptionWhenPull;
-}
-
-
-bool DefaultMQPushConsumer::isUnitMode()
-{
-    return m_unitMode;
-}
-
-
-void DefaultMQPushConsumer::setUnitMode(bool isUnitMode)
-{
-    m_unitMode = isUnitMode;
-}
-
-int DefaultMQPushConsumer::getMaxReconsumeTimes()
-{
-    return m_maxReconsumeTimes;
-}
-
-
-void DefaultMQPushConsumer::setMaxReconsumeTimes(int maxReconsumeTimes)
-{
-    m_maxReconsumeTimes = maxReconsumeTimes;
-}
-
-
-int DefaultMQPushConsumer::getSuspendCurrentQueueTimeMillis()
-{
-    return m_suspendCurrentQueueTimeMillis;
-}
-
-
-void DefaultMQPushConsumer::setSuspendCurrentQueueTimeMillis(int suspendCurrentQueueTimeMillis)
-{
-    m_suspendCurrentQueueTimeMillis = suspendCurrentQueueTimeMillis;
-}
-
-
-int DefaultMQPushConsumer::getConsumeTimeout()
-{
-    return m_consumeTimeout;
-}
-
-void DefaultMQPushConsumer::setConsumeTimeout(int consumeTimeout)
-{
-    m_consumeTimeout = consumeTimeout;
-}
-
-
-}


[17/17] incubator-rocketmq-externals git commit: Polish cpp module

Posted by vo...@apache.org.
Polish cpp module


Project: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/commit/b9bb6cfa
Tree: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/tree/b9bb6cfa
Diff: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/diff/b9bb6cfa

Branch: refs/heads/master
Commit: b9bb6cfa7a37b3a544ee8ddaa715d8b2d4cba70a
Parents: 70ce5c7
Author: vongosling <vo...@apache.org>
Authored: Mon Sep 4 14:44:26 2017 +0800
Committer: vongosling <vo...@apache.org>
Committed: Mon Sep 4 14:44:26 2017 +0800

----------------------------------------------------------------------
 rocketmq-beam/LICENSE                           |  201 --
 rocketmq-beam/NOTICE                            |    5 -
 rocketmq-client4cpp/.gitignore                  |   30 -
 rocketmq-client4cpp/LICENSE                     |  201 --
 rocketmq-client4cpp/Makefile                    |    5 -
 rocketmq-client4cpp/NOTICE                      |    5 -
 rocketmq-client4cpp/README.md                   |   21 -
 rocketmq-client4cpp/build.sh                    |   38 -
 rocketmq-client4cpp/clean.sh                    |    7 -
 rocketmq-client4cpp/docs/roadmap.md             |    0
 rocketmq-client4cpp/example/Makefile            |    5 -
 .../example/demo/AsyncProducer.cpp              |  249 ---
 rocketmq-client4cpp/example/demo/Common.cpp     |   20 -
 rocketmq-client4cpp/example/demo/Common.h       |  162 --
 rocketmq-client4cpp/example/demo/Makefile       |   40 -
 rocketmq-client4cpp/example/demo/Producer.cpp   |  199 --
 .../example/demo/PullConsumer.cpp               |  194 --
 .../example/demo/PushConsumer.cpp               |  256 ---
 .../include/AllocateMessageQueueStrategy.h      |   54 -
 rocketmq-client4cpp/include/ClientConfig.h      |   75 -
 .../include/ConsumeMessageHook.h                |   45 -
 rocketmq-client4cpp/include/ConsumeType.h       |   56 -
 rocketmq-client4cpp/include/DefaultMQProducer.h |  129 --
 .../include/DefaultMQPullConsumer.h             |  154 --
 .../include/DefaultMQPushConsumer.h             |  181 --
 rocketmq-client4cpp/include/MQAdmin.h           |   66 -
 rocketmq-client4cpp/include/MQClientException.h |  105 -
 rocketmq-client4cpp/include/MQConsumer.h        |   48 -
 rocketmq-client4cpp/include/MQProducer.h        |   71 -
 rocketmq-client4cpp/include/MQPullConsumer.h    |   54 -
 rocketmq-client4cpp/include/MQPushConsumer.h    |   49 -
 rocketmq-client4cpp/include/Message.h           |  136 --
 rocketmq-client4cpp/include/MessageExt.h        |  108 -
 rocketmq-client4cpp/include/MessageListener.h   |   94 -
 rocketmq-client4cpp/include/MessageQueue.h      |   70 -
 .../include/MessageQueueListener.h              |   38 -
 rocketmq-client4cpp/include/OffsetStore.h       |   58 -
 rocketmq-client4cpp/include/PullCallback.h      |   39 -
 rocketmq-client4cpp/include/PullResult.h        |   91 -
 rocketmq-client4cpp/include/QueryResult.h       |   56 -
 rocketmq-client4cpp/include/RocketMQClient.h    |  100 -
 rocketmq-client4cpp/include/SendCallback.h      |   39 -
 rocketmq-client4cpp/include/SendMessageHook.h   |   50 -
 rocketmq-client4cpp/include/SendResult.h        |   89 -
 rocketmq-client4cpp/include/TopicFilterType.h   |   32 -
 rocketmq-client4cpp/rocketmq.mk                 |    6 -
 rocketmq-client4cpp/src/ClientConfig.cpp        |  168 --
 .../src/ClientRemotingProcessor.cpp             |  154 --
 .../src/ClientRemotingProcessor.h               |   45 -
 rocketmq-client4cpp/src/CommunicationMode.h     |   34 -
 rocketmq-client4cpp/src/FindBrokerResult.h      |   28 -
 rocketmq-client4cpp/src/MQAdminImpl.cpp         |  295 ---
 rocketmq-client4cpp/src/MQAdminImpl.h           |   63 -
 rocketmq-client4cpp/src/MQClientAPIImpl.cpp     | 1323 ------------
 rocketmq-client4cpp/src/MQClientAPIImpl.h       |  280 ---
 rocketmq-client4cpp/src/MQClientFactory.cpp     | 1258 -----------
 rocketmq-client4cpp/src/MQClientFactory.h       |  214 --
 rocketmq-client4cpp/src/MQClientManager.cpp     |   75 -
 rocketmq-client4cpp/src/MQClientManager.h       |   49 -
 rocketmq-client4cpp/src/Makefile                |   26 -
 rocketmq-client4cpp/src/Makefile.std            |  127 --
 rocketmq-client4cpp/src/RocketMQClient.cpp      |  186 --
 rocketmq-client4cpp/src/common/ConsumeStats.h   |   95 -
 rocketmq-client4cpp/src/common/FilterAPI.h      |   72 -
 rocketmq-client4cpp/src/common/MQVersion.cpp    |   88 -
 rocketmq-client4cpp/src/common/MQVersion.h      |  184 --
 .../src/common/MessageSysFlag.cpp               |   47 -
 rocketmq-client4cpp/src/common/MessageSysFlag.h |   46 -
 rocketmq-client4cpp/src/common/MixAll.cpp       |   88 -
 rocketmq-client4cpp/src/common/MixAll.h         |   62 -
 rocketmq-client4cpp/src/common/NamesrvConfig.h  |   72 -
 rocketmq-client4cpp/src/common/NamesrvUtil.h    |   29 -
 rocketmq-client4cpp/src/common/PermName.cpp     |   63 -
 rocketmq-client4cpp/src/common/PermName.h       |   39 -
 rocketmq-client4cpp/src/common/PullSysFlag.cpp  |   68 -
 rocketmq-client4cpp/src/common/PullSysFlag.h    |   38 -
 rocketmq-client4cpp/src/common/SendResult.cpp   |  132 --
 rocketmq-client4cpp/src/common/ServiceState.h   |   31 -
 .../src/common/ServiceThread.cpp                |   73 -
 rocketmq-client4cpp/src/common/ServiceThread.h  |   50 -
 .../src/common/SubscriptionGroupConfig.h        |   50 -
 rocketmq-client4cpp/src/common/TopAddressing.h  |   54 -
 rocketmq-client4cpp/src/common/TopicConfig.cpp  |  167 --
 rocketmq-client4cpp/src/common/TopicConfig.h    |   71 -
 .../src/common/TopicStatsTable.h                |   51 -
 rocketmq-client4cpp/src/common/UtilAll.h        |  608 ------
 rocketmq-client4cpp/src/common/Validators.cpp   |  132 --
 rocketmq-client4cpp/src/common/Validators.h     |   49 -
 .../src/common/VirtualEnvUtil.cpp               |   66 -
 rocketmq-client4cpp/src/common/VirtualEnvUtil.h |   41 -
 .../AllocateMessageQueueStrategyInner.h         |  205 --
 .../ConsumeMessageConcurrentlyService.cpp       |  476 ----
 .../ConsumeMessageConcurrentlyService.h         |  120 -
 .../consumer/ConsumeMessageOrderlyService.cpp   |  574 -----
 .../src/consumer/ConsumeMessageOrderlyService.h |  122 --
 .../src/consumer/ConsumeMessageService.h        |   41 -
 .../src/consumer/ConsumeType.cpp                |   70 -
 .../src/consumer/ConsumerInvokeCallback.cpp     |   96 -
 .../src/consumer/ConsumerInvokeCallback.h       |   40 -
 .../src/consumer/ConsumerStatManage.h           |  132 --
 .../src/consumer/DefaultMQPullConsumer.cpp      |  309 ---
 .../src/consumer/DefaultMQPullConsumerImpl.cpp  |  630 ------
 .../src/consumer/DefaultMQPullConsumerImpl.h    |  174 --
 .../src/consumer/DefaultMQPushConsumer.cpp      |  399 ----
 .../src/consumer/DefaultMQPushConsumerImpl.cpp  | 1018 ---------
 .../src/consumer/DefaultMQPushConsumerImpl.h    |  169 --
 .../src/consumer/LocalFileOffsetStore.cpp       |  257 ---
 .../src/consumer/LocalFileOffsetStore.h         |   61 -
 .../src/consumer/MQConsumerInner.h              |   46 -
 .../src/consumer/MessageQueueLock.h             |   68 -
 .../src/consumer/ProcessQueue.cpp               |  445 ----
 rocketmq-client4cpp/src/consumer/ProcessQueue.h |  102 -
 .../src/consumer/PullAPIWrapper.cpp             |  222 --
 .../src/consumer/PullAPIWrapper.h               |   67 -
 .../src/consumer/PullMessageService.cpp         |  171 --
 .../src/consumer/PullMessageService.h           |   56 -
 .../src/consumer/PullRequest.cpp                |  108 -
 rocketmq-client4cpp/src/consumer/PullRequest.h  |   59 -
 .../src/consumer/PullResultExt.h                |   53 -
 .../src/consumer/RebalanceImpl.cpp              |  613 ------
 .../src/consumer/RebalanceImpl.h                |  102 -
 .../src/consumer/RebalancePullImpl.cpp          |   79 -
 .../src/consumer/RebalancePullImpl.h            |   56 -
 .../src/consumer/RebalancePushImpl.cpp          |  217 --
 .../src/consumer/RebalancePushImpl.h            |   55 -
 .../src/consumer/RebalanceService.cpp           |   55 -
 .../src/consumer/RebalanceService.h             |   44 -
 .../src/consumer/RemoteBrokerOffsetStore.cpp    |  266 ---
 .../src/consumer/RemoteBrokerOffsetStore.h      |   61 -
 .../src/consumer/SubscriptionData.cpp           |  201 --
 .../src/consumer/SubscriptionData.h             |   76 -
 rocketmq-client4cpp/src/jsoncpp/AUTHORS         |    0
 rocketmq-client4cpp/src/jsoncpp/LICENSE         |    1 -
 rocketmq-client4cpp/src/jsoncpp/README.txt      |  117 -
 .../src/jsoncpp/json/allocator.h                |   96 -
 .../src/jsoncpp/json/assertions.h               |   54 -
 rocketmq-client4cpp/src/jsoncpp/json/autolink.h |   25 -
 rocketmq-client4cpp/src/jsoncpp/json/config.h   |  182 --
 rocketmq-client4cpp/src/jsoncpp/json/features.h |   59 -
 rocketmq-client4cpp/src/jsoncpp/json/forwards.h |   39 -
 rocketmq-client4cpp/src/jsoncpp/json/json.h     |   15 -
 rocketmq-client4cpp/src/jsoncpp/json/reader.h   |  406 ----
 rocketmq-client4cpp/src/jsoncpp/json/value.h    |  868 --------
 rocketmq-client4cpp/src/jsoncpp/json/version.h  |   20 -
 rocketmq-client4cpp/src/jsoncpp/json/writer.h   |  333 ---
 rocketmq-client4cpp/src/jsoncpp/json_reader.cpp | 2042 ------------------
 rocketmq-client4cpp/src/jsoncpp/json_tool.h     |  113 -
 rocketmq-client4cpp/src/jsoncpp/json_value.cpp  | 1612 --------------
 .../src/jsoncpp/json_valueiterator.inl          |  171 --
 rocketmq-client4cpp/src/jsoncpp/json_writer.cpp | 1220 -----------
 rocketmq-client4cpp/src/jsoncpp/version         |    1 -
 rocketmq-client4cpp/src/kpr/AtomicValue.cpp     |  146 --
 rocketmq-client4cpp/src/kpr/AtomicValue.h       |  200 --
 rocketmq-client4cpp/src/kpr/Condition.cpp       |  158 --
 rocketmq-client4cpp/src/kpr/Condition.h         |   54 -
 rocketmq-client4cpp/src/kpr/Epoller.cpp         |   96 -
 rocketmq-client4cpp/src/kpr/Epoller.h           |   62 -
 rocketmq-client4cpp/src/kpr/Exception.h         |  100 -
 rocketmq-client4cpp/src/kpr/FileUtil.cpp        |  523 -----
 rocketmq-client4cpp/src/kpr/FileUtil.h          |   90 -
 rocketmq-client4cpp/src/kpr/KPRTypes.h          |   65 -
 rocketmq-client4cpp/src/kpr/KPRUtil.cpp         |   76 -
 rocketmq-client4cpp/src/kpr/KPRUtil.h           |   38 -
 rocketmq-client4cpp/src/kpr/Monitor.cpp         |  125 --
 rocketmq-client4cpp/src/kpr/Monitor.h           |   48 -
 rocketmq-client4cpp/src/kpr/Mutex.cpp           |  296 ---
 rocketmq-client4cpp/src/kpr/Mutex.h             |  107 -
 rocketmq-client4cpp/src/kpr/RefHandle.h         |  328 ---
 rocketmq-client4cpp/src/kpr/ScopedLock.h        |   91 -
 rocketmq-client4cpp/src/kpr/Semaphore.cpp       |   73 -
 rocketmq-client4cpp/src/kpr/Semaphore.h         |   42 -
 rocketmq-client4cpp/src/kpr/Thread.cpp          |  191 --
 rocketmq-client4cpp/src/kpr/Thread.h            |   68 -
 rocketmq-client4cpp/src/kpr/ThreadLocal.cpp     |   56 -
 rocketmq-client4cpp/src/kpr/ThreadLocal.h       |   37 -
 rocketmq-client4cpp/src/kpr/ThreadPool.cpp      |  418 ----
 rocketmq-client4cpp/src/kpr/ThreadPool.h        |  124 --
 rocketmq-client4cpp/src/kpr/ThreadPoolWork.h    |   34 -
 .../src/kpr/TimerTaskManager.cpp                |   91 -
 rocketmq-client4cpp/src/kpr/TimerTaskManager.h  |   95 -
 rocketmq-client4cpp/src/kpr/TimerThread.cpp     |  186 --
 rocketmq-client4cpp/src/kpr/TimerThread.h       |   79 -
 rocketmq-client4cpp/src/message/Message.cpp     |  379 ----
 .../src/message/MessageDecoder.cpp              |  366 ----
 .../src/message/MessageDecoder.h                |   64 -
 rocketmq-client4cpp/src/message/MessageExt.cpp  |  244 ---
 rocketmq-client4cpp/src/message/MessageId.h     |   59 -
 .../src/message/MessageQueue.cpp                |  153 --
 .../src/producer/DefaultMQProducer.cpp          |  277 ---
 .../src/producer/DefaultMQProducerImpl.cpp      |  932 --------
 .../src/producer/DefaultMQProducerImpl.h        |  205 --
 .../src/producer/LocalTransactionExecuter.h     |   31 -
 .../src/producer/MQProducerInner.h              |   44 -
 .../src/producer/MessageQueueSelector.h         |   96 -
 .../src/producer/ProducerInvokeCallback.cpp     |  101 -
 .../src/producer/ProducerInvokeCallback.h       |   46 -
 .../src/producer/TopicPublishInfo.h             |  141 --
 .../src/producer/TransactionCheckListener.h     |   31 -
 .../src/producer/TransactionMQProducer.h        |  118 -
 .../src/protocol/CommandCustomHeader.cpp        |  672 ------
 .../src/protocol/CommandCustomHeader.h          |  604 ------
 .../src/protocol/ConsumerRunningInfo.cpp        |  168 --
 .../src/protocol/ConsumerRunningInfo.h          |   97 -
 .../GetConsumerListByGroupResponseBody.h        |   97 -
 .../src/protocol/HeartbeatData.cpp              |   52 -
 .../src/protocol/HeartbeatData.h                |  157 --
 rocketmq-client4cpp/src/protocol/KVTable.h      |   58 -
 .../src/protocol/LockBatchBody.cpp              |  112 -
 .../src/protocol/LockBatchBody.h                |   73 -
 rocketmq-client4cpp/src/protocol/MQProtos.cpp   |  248 ---
 rocketmq-client4cpp/src/protocol/MQProtos.h     |  150 --
 .../src/protocol/OffsetSerializeWrapper.h       |  135 --
 .../src/protocol/RemotingCommand.cpp            |  421 ----
 .../src/protocol/RemotingCommand.h              |  153 --
 .../src/protocol/RemotingSerializable.h         |   33 -
 rocketmq-client4cpp/src/protocol/TopicList.h    |   60 -
 .../src/protocol/TopicRouteData.h               |  279 ---
 .../src/transport/InvokeCallback.h              |   32 -
 .../src/transport/RemoteClientConfig.h          |   67 -
 .../src/transport/ResponseFuture.cpp            |  183 --
 .../src/transport/ResponseFuture.h              |   77 -
 .../src/transport/SocketUtil.cpp                |  250 ---
 rocketmq-client4cpp/src/transport/SocketUtil.h  |   75 -
 .../src/transport/TcpRemotingClient.cpp         |  841 --------
 .../src/transport/TcpRemotingClient.h           |  152 --
 .../src/transport/TcpRequestProcessor.h         |   32 -
 .../src/transport/TcpTransport.cpp              |  387 ----
 .../src/transport/TcpTransport.h                |   78 -
 rocketmq-cpp/README.md                          |   76 +-
 rocketmq-donet/.gitignore                       |    9 -
 rocketmq-donet/LICENSE                          |  201 --
 rocketmq-donet/NOTICE                           |    5 -
 rocketmq-mongodb/LICENSE                        |  201 --
 rocketmq-mongodb/NOTICE                         |    5 -
 234 files changed, 36 insertions(+), 39699 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-beam/LICENSE
----------------------------------------------------------------------
diff --git a/rocketmq-beam/LICENSE b/rocketmq-beam/LICENSE
deleted file mode 100644
index b67d909..0000000
--- a/rocketmq-beam/LICENSE
+++ /dev/null
@@ -1,201 +0,0 @@
-Apache License
-                           Version 2.0, January 2004
-                        http://www.apache.org/licenses/
-
-   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-   1. Definitions.
-
-      "License" shall mean the terms and conditions for use, reproduction,
-      and distribution as defined by Sections 1 through 9 of this document.
-
-      "Licensor" shall mean the copyright owner or entity authorized by
-      the copyright owner that is granting the License.
-
-      "Legal Entity" shall mean the union of the acting entity and all
-      other entities that control, are controlled by, or are under common
-      control with that entity. For the purposes of this definition,
-      "control" means (i) the power, direct or indirect, to cause the
-      direction or management of such entity, whether by contract or
-      otherwise, or (ii) ownership of fifty percent (50%) or more of the
-      outstanding shares, or (iii) beneficial ownership of such entity.
-
-      "You" (or "Your") shall mean an individual or Legal Entity
-      exercising permissions granted by this License.
-
-      "Source" form shall mean the preferred form for making modifications,
-      including but not limited to software source code, documentation
-      source, and configuration files.
-
-      "Object" form shall mean any form resulting from mechanical
-      transformation or translation of a Source form, including but
-      not limited to compiled object code, generated documentation,
-      and conversions to other media types.
-
-      "Work" shall mean the work of authorship, whether in Source or
-      Object form, made available under the License, as indicated by a
-      copyright notice that is included in or attached to the work
-      (an example is provided in the Appendix below).
-
-      "Derivative Works" shall mean any work, whether in Source or Object
-      form, that is based on (or derived from) the Work and for which the
-      editorial revisions, annotations, elaborations, or other modifications
-      represent, as a whole, an original work of authorship. For the purposes
-      of this License, Derivative Works shall not include works that remain
-      separable from, or merely link (or bind by name) to the interfaces of,
-      the Work and Derivative Works thereof.
-
-      "Contribution" shall mean any work of authorship, including
-      the original version of the Work and any modifications or additions
-      to that Work or Derivative Works thereof, that is intentionally
-      submitted to Licensor for inclusion in the Work by the copyright owner
-      or by an individual or Legal Entity authorized to submit on behalf of
-      the copyright owner. For the purposes of this definition, "submitted"
-      means any form of electronic, verbal, or written communication sent
-      to the Licensor or its representatives, including but not limited to
-      communication on electronic mailing lists, source code control systems,
-      and issue tracking systems that are managed by, or on behalf of, the
-      Licensor for the purpose of discussing and improving the Work, but
-      excluding communication that is conspicuously marked or otherwise
-      designated in writing by the copyright owner as "Not a Contribution."
-
-      "Contributor" shall mean Licensor and any individual or Legal Entity
-      on behalf of whom a Contribution has been received by Licensor and
-      subsequently incorporated within the Work.
-
-   2. Grant of Copyright License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      copyright license to reproduce, prepare Derivative Works of,
-      publicly display, publicly perform, sublicense, and distribute the
-      Work and such Derivative Works in Source or Object form.
-
-   3. Grant of Patent License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      (except as stated in this section) patent license to make, have made,
-      use, offer to sell, sell, import, and otherwise transfer the Work,
-      where such license applies only to those patent claims licensable
-      by such Contributor that are necessarily infringed by their
-      Contribution(s) alone or by combination of their Contribution(s)
-      with the Work to which such Contribution(s) was submitted. If You
-      institute patent litigation against any entity (including a
-      cross-claim or counterclaim in a lawsuit) alleging that the Work
-      or a Contribution incorporated within the Work constitutes direct
-      or contributory patent infringement, then any patent licenses
-      granted to You under this License for that Work shall terminate
-      as of the date such litigation is filed.
-
-   4. Redistribution. You may reproduce and distribute copies of the
-      Work or Derivative Works thereof in any medium, with or without
-      modifications, and in Source or Object form, provided that You
-      meet the following conditions:
-
-      (a) You must give any other recipients of the Work or
-          Derivative Works a copy of this License; and
-
-      (b) You must cause any modified files to carry prominent notices
-          stating that You changed the files; and
-
-      (c) You must retain, in the Source form of any Derivative Works
-          that You distribute, all copyright, patent, trademark, and
-          attribution notices from the Source form of the Work,
-          excluding those notices that do not pertain to any part of
-          the Derivative Works; and
-
-      (d) If the Work includes a "NOTICE" text file as part of its
-          distribution, then any Derivative Works that You distribute must
-          include a readable copy of the attribution notices contained
-          within such NOTICE file, excluding those notices that do not
-          pertain to any part of the Derivative Works, in at least one
-          of the following places: within a NOTICE text file distributed
-          as part of the Derivative Works; within the Source form or
-          documentation, if provided along with the Derivative Works; or,
-          within a display generated by the Derivative Works, if and
-          wherever such third-party notices normally appear. The contents
-          of the NOTICE file are for informational purposes only and
-          do not modify the License. You may add Your own attribution
-          notices within Derivative Works that You distribute, alongside
-          or as an addendum to the NOTICE text from the Work, provided
-          that such additional attribution notices cannot be construed
-          as modifying the License.
-
-      You may add Your own copyright statement to Your modifications and
-      may provide additional or different license terms and conditions
-      for use, reproduction, or distribution of Your modifications, or
-      for any such Derivative Works as a whole, provided Your use,
-      reproduction, and distribution of the Work otherwise complies with
-      the conditions stated in this License.
-
-   5. Submission of Contributions. Unless You explicitly state otherwise,
-      any Contribution intentionally submitted for inclusion in the Work
-      by You to the Licensor shall be under the terms and conditions of
-      this License, without any additional terms or conditions.
-      Notwithstanding the above, nothing herein shall supersede or modify
-      the terms of any separate license agreement you may have executed
-      with Licensor regarding such Contributions.
-
-   6. Trademarks. This License does not grant permission to use the trade
-      names, trademarks, service marks, or product names of the Licensor,
-      except as required for reasonable and customary use in describing the
-      origin of the Work and reproducing the content of the NOTICE file.
-
-   7. Disclaimer of Warranty. Unless required by applicable law or
-      agreed to in writing, Licensor provides the Work (and each
-      Contributor provides its Contributions) on an "AS IS" BASIS,
-      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-      implied, including, without limitation, any warranties or conditions
-      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
-      PARTICULAR PURPOSE. You are solely responsible for determining the
-      appropriateness of using or redistributing the Work and assume any
-      risks associated with Your exercise of permissions under this License.
-
-   8. Limitation of Liability. In no event and under no legal theory,
-      whether in tort (including negligence), contract, or otherwise,
-      unless required by applicable law (such as deliberate and grossly
-      negligent acts) or agreed to in writing, shall any Contributor be
-      liable to You for damages, including any direct, indirect, special,
-      incidental, or consequential damages of any character arising as a
-      result of this License or out of the use or inability to use the
-      Work (including but not limited to damages for loss of goodwill,
-      work stoppage, computer failure or malfunction, or any and all
-      other commercial damages or losses), even if such Contributor
-      has been advised of the possibility of such damages.
-
-   9. Accepting Warranty or Additional Liability. While redistributing
-      the Work or Derivative Works thereof, You may choose to offer,
-      and charge a fee for, acceptance of support, warranty, indemnity,
-      or other liability obligations and/or rights consistent with this
-      License. However, in accepting such obligations, You may act only
-      on Your own behalf and on Your sole responsibility, not on behalf
-      of any other Contributor, and only if You agree to indemnify,
-      defend, and hold each Contributor harmless for any liability
-      incurred by, or claims asserted against, such Contributor by reason
-      of your accepting any such warranty or additional liability.
-
-   END OF TERMS AND CONDITIONS
-
-   APPENDIX: How to apply the Apache License to your work.
-
-      To apply the Apache License to your work, attach the following
-      boilerplate notice, with the fields enclosed by brackets "{}"
-      replaced with your own identifying information. (Don't include
-      the brackets!)  The text should be enclosed in the appropriate
-      comment syntax for the file format. We also recommend that a
-      file or class name and description of purpose be included on the
-      same "printed page" as the copyright notice for easier
-      identification within third-party archives.
-
-   Copyright {}
-
-   Licensed under the Apache License, Version 2.0 (the "License");
-   you may not use this file except in compliance with the License.
-   You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-beam/NOTICE
----------------------------------------------------------------------
diff --git a/rocketmq-beam/NOTICE b/rocketmq-beam/NOTICE
deleted file mode 100644
index 5384857..0000000
--- a/rocketmq-beam/NOTICE
+++ /dev/null
@@ -1,5 +0,0 @@
-Apache RocketMQ (incubating)
-Copyright 2016-2017 The Apache Software Foundation
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/.gitignore
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/.gitignore b/rocketmq-client4cpp/.gitignore
deleted file mode 100644
index c17af80..0000000
--- a/rocketmq-client4cpp/.gitignore
+++ /dev/null
@@ -1,30 +0,0 @@
-# Compiled Object files
-*.slo
-*.lo
-*.o
-*.d
-*.obj
-
-# Precompiled Headers
-*.gch
-*.pch
-
-# Compiled Dynamic libraries
-*.so
-*.dylib
-*.dll
-
-# Fortran module files
-*.mod
-*.smod
-
-# Compiled Static libraries
-*.lai
-*.la
-*.a
-*.lib
-
-# Executables
-*.exe
-*.out
-*.app

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/LICENSE
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/LICENSE b/rocketmq-client4cpp/LICENSE
deleted file mode 100644
index 5c304d1..0000000
--- a/rocketmq-client4cpp/LICENSE
+++ /dev/null
@@ -1,201 +0,0 @@
-Apache License
-                           Version 2.0, January 2004
-                        http://www.apache.org/licenses/
-
-   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-   1. Definitions.
-
-      "License" shall mean the terms and conditions for use, reproduction,
-      and distribution as defined by Sections 1 through 9 of this document.
-
-      "Licensor" shall mean the copyright owner or entity authorized by
-      the copyright owner that is granting the License.
-
-      "Legal Entity" shall mean the union of the acting entity and all
-      other entities that control, are controlled by, or are under common
-      control with that entity. For the purposes of this definition,
-      "control" means (i) the power, direct or indirect, to cause the
-      direction or management of such entity, whether by contract or
-      otherwise, or (ii) ownership of fifty percent (50%) or more of the
-      outstanding shares, or (iii) beneficial ownership of such entity.
-
-      "You" (or "Your") shall mean an individual or Legal Entity
-      exercising permissions granted by this License.
-
-      "Source" form shall mean the preferred form for making modifications,
-      including but not limited to software source code, documentation
-      source, and configuration files.
-
-      "Object" form shall mean any form resulting from mechanical
-      transformation or translation of a Source form, including but
-      not limited to compiled object code, generated documentation,
-      and conversions to other media types.
-
-      "Work" shall mean the work of authorship, whether in Source or
-      Object form, made available under the License, as indicated by a
-      copyright notice that is included in or attached to the work
-      (an example is provided in the Appendix below).
-
-      "Derivative Works" shall mean any work, whether in Source or Object
-      form, that is based on (or derived from) the Work and for which the
-      editorial revisions, annotations, elaborations, or other modifications
-      represent, as a whole, an original work of authorship. For the purposes
-      of this License, Derivative Works shall not include works that remain
-      separable from, or merely link (or bind by name) to the interfaces of,
-      the Work and Derivative Works thereof.
-
-      "Contribution" shall mean any work of authorship, including
-      the original version of the Work and any modifications or additions
-      to that Work or Derivative Works thereof, that is intentionally
-      submitted to Licensor for inclusion in the Work by the copyright owner
-      or by an individual or Legal Entity authorized to submit on behalf of
-      the copyright owner. For the purposes of this definition, "submitted"
-      means any form of electronic, verbal, or written communication sent
-      to the Licensor or its representatives, including but not limited to
-      communication on electronic mailing lists, source code control systems,
-      and issue tracking systems that are managed by, or on behalf of, the
-      Licensor for the purpose of discussing and improving the Work, but
-      excluding communication that is conspicuously marked or otherwise
-      designated in writing by the copyright owner as "Not a Contribution."
-
-      "Contributor" shall mean Licensor and any individual or Legal Entity
-      on behalf of whom a Contribution has been received by Licensor and
-      subsequently incorporated within the Work.
-
-   2. Grant of Copyright License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      copyright license to reproduce, prepare Derivative Works of,
-      publicly display, publicly perform, sublicense, and distribute the
-      Work and such Derivative Works in Source or Object form.
-
-   3. Grant of Patent License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      (except as stated in this section) patent license to make, have made,
-      use, offer to sell, sell, import, and otherwise transfer the Work,
-      where such license applies only to those patent claims licensable
-      by such Contributor that are necessarily infringed by their
-      Contribution(s) alone or by combination of their Contribution(s)
-      with the Work to which such Contribution(s) was submitted. If You
-      institute patent litigation against any entity (including a
-      cross-claim or counterclaim in a lawsuit) alleging that the Work
-      or a Contribution incorporated within the Work constitutes direct
-      or contributory patent infringement, then any patent licenses
-      granted to You under this License for that Work shall terminate
-      as of the date such litigation is filed.
-
-   4. Redistribution. You may reproduce and distribute copies of the
-      Work or Derivative Works thereof in any medium, with or without
-      modifications, and in Source or Object form, provided that You
-      meet the following conditions:
-
-      (a) You must give any other recipients of the Work or
-          Derivative Works a copy of this License; and
-
-      (b) You must cause any modified files to carry prominent notices
-          stating that You changed the files; and
-
-      (c) You must retain, in the Source form of any Derivative Works
-          that You distribute, all copyright, patent, trademark, and
-          attribution notices from the Source form of the Work,
-          excluding those notices that do not pertain to any part of
-          the Derivative Works; and
-
-      (d) If the Work includes a "NOTICE" text file as part of its
-          distribution, then any Derivative Works that You distribute must
-          include a readable copy of the attribution notices contained
-          within such NOTICE file, excluding those notices that do not
-          pertain to any part of the Derivative Works, in at least one
-          of the following places: within a NOTICE text file distributed
-          as part of the Derivative Works; within the Source form or
-          documentation, if provided along with the Derivative Works; or,
-          within a display generated by the Derivative Works, if and
-          wherever such third-party notices normally appear. The contents
-          of the NOTICE file are for informational purposes only and
-          do not modify the License. You may add Your own attribution
-          notices within Derivative Works that You distribute, alongside
-          or as an addendum to the NOTICE text from the Work, provided
-          that such additional attribution notices cannot be construed
-          as modifying the License.
-
-      You may add Your own copyright statement to Your modifications and
-      may provide additional or different license terms and conditions
-      for use, reproduction, or distribution of Your modifications, or
-      for any such Derivative Works as a whole, provided Your use,
-      reproduction, and distribution of the Work otherwise complies with
-      the conditions stated in this License.
-
-   5. Submission of Contributions. Unless You explicitly state otherwise,
-      any Contribution intentionally submitted for inclusion in the Work
-      by You to the Licensor shall be under the terms and conditions of
-      this License, without any additional terms or conditions.
-      Notwithstanding the above, nothing herein shall supersede or modify
-      the terms of any separate license agreement you may have executed
-      with Licensor regarding such Contributions.
-
-   6. Trademarks. This License does not grant permission to use the trade
-      names, trademarks, service marks, or product names of the Licensor,
-      except as required for reasonable and customary use in describing the
-      origin of the Work and reproducing the content of the NOTICE file.
-
-   7. Disclaimer of Warranty. Unless required by applicable law or
-      agreed to in writing, Licensor provides the Work (and each
-      Contributor provides its Contributions) on an "AS IS" BASIS,
-      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-      implied, including, without limitation, any warranties or conditions
-      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
-      PARTICULAR PURPOSE. You are solely responsible for determining the
-      appropriateness of using or redistributing the Work and assume any
-      risks associated with Your exercise of permissions under this License.
-
-   8. Limitation of Liability. In no event and under no legal theory,
-      whether in tort (including negligence), contract, or otherwise,
-      unless required by applicable law (such as deliberate and grossly
-      negligent acts) or agreed to in writing, shall any Contributor be
-      liable to You for damages, including any direct, indirect, special,
-      incidental, or consequential damages of any character arising as a
-      result of this License or out of the use or inability to use the
-      Work (including but not limited to damages for loss of goodwill,
-      work stoppage, computer failure or malfunction, or any and all
-      other commercial damages or losses), even if such Contributor
-      has been advised of the possibility of such damages.
-
-   9. Accepting Warranty or Additional Liability. While redistributing
-      the Work or Derivative Works thereof, You may choose to offer,
-      and charge a fee for, acceptance of support, warranty, indemnity,
-      or other liability obligations and/or rights consistent with this
-      License. However, in accepting such obligations, You may act only
-      on Your own behalf and on Your sole responsibility, not on behalf
-      of any other Contributor, and only if You agree to indemnify,
-      defend, and hold each Contributor harmless for any liability
-      incurred by, or claims asserted against, such Contributor by reason
-      of your accepting any such warranty or additional liability.
-
-   END OF TERMS AND CONDITIONS
-
-   APPENDIX: How to apply the Apache License to your work.
-
-      To apply the Apache License to your work, attach the following
-      boilerplate notice, with the fields enclosed by brackets "{}"
-      replaced with your own identifying information. (Don't include
-      the brackets!)  The text should be enclosed in the appropriate
-      comment syntax for the file format. We also recommend that a
-      file or class name and description of purpose be included on the
-      same "printed page" as the copyright notice for easier
-      identification within third-party archives.
-
-   Copyright {yyyy} {name of copyright owner}
-
-   Licensed under the Apache License, Version 2.0 (the "License");
-   you may not use this file except in compliance with the License.
-   You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/Makefile
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/Makefile b/rocketmq-client4cpp/Makefile
deleted file mode 100644
index 7b31385..0000000
--- a/rocketmq-client4cpp/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-all:
-	make -C src all
-
-clean:
-	make -C src clean

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/NOTICE
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/NOTICE b/rocketmq-client4cpp/NOTICE
deleted file mode 100644
index 5384857..0000000
--- a/rocketmq-client4cpp/NOTICE
+++ /dev/null
@@ -1,5 +0,0 @@
-Apache RocketMQ (incubating)
-Copyright 2016-2017 The Apache Software Foundation
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/README.md
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/README.md b/rocketmq-client4cpp/README.md
deleted file mode 100755
index b4fa664..0000000
--- a/rocketmq-client4cpp/README.md
+++ /dev/null
@@ -1,21 +0,0 @@
-Fork from [RocketMQ-Client4CPP](https://github.com/NDPMediaCorp/RocketMQ-Client4CPP)
-
-[RocketMQ](https://github.com/alibaba/RocketMQ) C++ Client
-===================
-
-### Contributors
-* @[kangliqiang](https://github.com/kangliqiang)
-* @[lizhanhui](https://github.com/lizhanhui)
-* @[suwenkuang](https://github.com/hooligan520)
-
-### Current status
-* On the basis of the original repair a lot of coredump, and memory leak (valgrind) problem, add namespace, fill some of the features
-* only support linux system
-* Currently supports sending messages, support pull mode consumption messages, support push mode consumption messages
-
-### Roadmap
-* Support for transaction messages
-* Continue to support more commands (such as support broker query client running information)
-
-
-

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/build.sh
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/build.sh b/rocketmq-client4cpp/build.sh
deleted file mode 100755
index 1519780..0000000
--- a/rocketmq-client4cpp/build.sh
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/bin/sh
-VERSION=1.0.3
-BUILD_PATH=`pwd`
-INSTALL_PATH=$BUILD_PATH/release
-RELEASE_PATH=/data/libs/rocketmq
-
-echo -e  "\e[33;1m# copy include files...\e[0m"
-mkdir -p $INSTALL_PATH
-rm -rf $INSTALL_PATH/*
-cp -rf $BUILD_PATH/rocketmq.mk $INSTALL_PATH/
-cp -rf $BUILD_PATH/include $INSTALL_PATH/
-cp -rf $BUILD_PATH/example $INSTALL_PATH/
-
-echo -e  "\e[33;1m# build target with BIT=32...\e[0m"
-cd $BUILD_PATH/
-BIT=32 make clean >/dev/null
-BIT=32 make all >/dev/null
-mkdir -p $INSTALL_PATH/lib32
-cp -rf $BUILD_PATH/src/librocketmq.a $INSTALL_PATH/lib32/librocketmq.a
-
-echo -e  "\e[33;1m# build target with BIT=64...\e[0m"
-cd $BUILD_PATH/
-BIT=64 make clean >/dev/null
-BIT=64 make all  >/dev/null
-mkdir -p $INSTALL_PATH/lib64
-cp -rf $BUILD_PATH/src/librocketmq.a $INSTALL_PATH/lib64/librocketmq.a
-
-echo -e  "\e[33;1m# release libs...\e[0m"
-cd $BUILD_PATH/
-tar czf rocketmq-client4cpp-${VERSION}.tgz release/
-
-#rm -rf $RELEASE_PATH
-#cp -rf $INSTALL_PATH $RELEASE_PATH
-
-echo -e "\e[33;1m# build example...\e[0m"
-cd $INSTALL_PATH/example
-make all >/dev/null
-

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/clean.sh
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/clean.sh b/rocketmq-client4cpp/clean.sh
deleted file mode 100755
index 3cf8145..0000000
--- a/rocketmq-client4cpp/clean.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-
-BUILD_PATH=`pwd`
-BIT=32 make -C ./src/ cleanall
-BIT=64 make -C ./src/ cleanall
-rm -rf release
-

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/docs/roadmap.md
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/docs/roadmap.md b/rocketmq-client4cpp/docs/roadmap.md
deleted file mode 100644
index e69de29..0000000

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/example/Makefile
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/example/Makefile b/rocketmq-client4cpp/example/Makefile
deleted file mode 100755
index 25a9450..0000000
--- a/rocketmq-client4cpp/example/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-all:
-	make -C demo all
-
-clean:
-	make -C demo clean

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/example/demo/AsyncProducer.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/example/demo/AsyncProducer.cpp b/rocketmq-client4cpp/example/demo/AsyncProducer.cpp
deleted file mode 100644
index 045a32a..0000000
--- a/rocketmq-client4cpp/example/demo/AsyncProducer.cpp
+++ /dev/null
@@ -1,249 +0,0 @@
-/**
-* Copyright (C) 2013 suwenkuang ,hooligan_520@qq.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#include "Common.h"
-#include "SendCallback.h"
-#include "DefaultMQProducer.h"
-using namespace rmq;
-
-long long g_lastUpdateTime = 0;
-volatile long long g_cnt_total = 0;
-volatile long long g_cnt_last = 0;
-volatile long long g_cnt_succ = 0;
-volatile long long g_cnt_fail = 0;
-
-
-void Usage(const char* program)
-{
-    printf("Usage:%s ip:port [-g group] [-t topic] [-n count] [-s size] [-w logpath]\n", program);
-    printf("\t -g group\n");
-    printf("\t -t topic\n");
-    printf("\t -n message count\n");
-    printf("\t -s message size \n");
-    printf("\t -w log path\n");
-}
-
-
-class SampleSendCallback : public SendCallback {
-public:
-    SampleSendCallback()
-    {
-    }
-
-    virtual ~SampleSendCallback()
-    {
-    }
-
-    int count()
-    {
-
-        long long now = MyUtil::getNowMs();
-        long long old = g_lastUpdateTime;
-        long long total = g_cnt_succ + g_cnt_fail;
-        if ((now - old) >= 1000)
-        {
-            if (__sync_bool_compare_and_swap(&g_lastUpdateTime, old, now))
-            {
-                long long time = now - old;
-                int tps = (int)((total - g_cnt_last) * 1.0 / time * 1000.0);
-                g_cnt_last = total;
-
-                MYDEBUG("[producer]succ: %lld, fail: %lld, TPS: %d\n",
-                    g_cnt_succ, g_cnt_fail, tps);
-            }
-        }
-    }
-
-    void onSuccess(SendResult& sendResult)
-    {
-        int cnt = __sync_fetch_and_add(&g_cnt_total, 1);
-        __sync_fetch_and_add(&g_cnt_succ, 1);
-        MYLOG("[%d]|succ|%s\n",  cnt, sendResult.toString().c_str());
-    }
-
-    void onException(MQException& e)
-    {
-        int cnt = __sync_fetch_and_add(&g_cnt_total, 1);
-        __sync_fetch_and_add(&g_cnt_fail, 1);
-
-        MYLOG("[%d]|fail|%s\n",  cnt, e.what());
-    }
-};
-
-int main(int argc, char *argv[]) {
-    if (argc < 2)
-    {
-        Usage(argv[0]);
-        return 0;
-    }
-
-    std::string namesrv = argv[1];
-    std::string group = "pg_test_group";
-    std::string topic = "topic_test";
-    int size = 32;
-    int count = 1000;
-
-    for (int i=2; i< argc; i++)
-    {
-        if (strcmp(argv[i],"-g")==0)
-        {
-            if (i+1 < argc)
-            {
-                group = argv[i+1];
-                i++;
-            }
-            else
-            {
-                Usage(argv[0]);
-                return 0;
-            }
-        }
-        else if (strcmp(argv[i],"-t")==0)
-        {
-            if (i+1 < argc)
-            {
-                topic = argv[i+1];
-                i++;
-            }
-            else
-            {
-                Usage(argv[0]);
-                return 0;
-            }
-        }
-        else if (strcmp(argv[i],"-n")==0)
-        {
-            if (i+1 < argc)
-            {
-                count = atoi(argv[i+1]);
-                i++;
-            }
-            else
-            {
-                Usage(argv[0]);
-                return 0;
-            }
-        }
-        else if (strcmp(argv[i],"-s")==0)
-        {
-            if (i+1 < argc)
-            {
-                size = atoi(argv[i+1]);
-                i++;
-            }
-            else
-            {
-                Usage(argv[0]);
-                return 0;
-            }
-        }
-        else if (strcmp(argv[i],"-w")==0)
-        {
-            if (i+1 < argc)
-            {
-                MyUtil::initLog(argv[i+1]);
-                i++;
-            }
-            else
-            {
-                Usage(argv[0]);
-                return 0;
-            }
-        }
-        else
-        {
-            Usage(argv[0]);
-            return 0;
-        }
-    }
-
-    // init client api log, here is not necessary, need to debug the api need to be initialized, you can consider comment it
-    // Here only the default print warning, error log, the log will be rolling by day, if you need to modify the log level, please set the environment variable, export ROCKETMQ_LOGLEVEL = loglevel
-    // The log level is as follows:
-    // 0 - close the log
-    // 1 - write error log
-    // 2 - write error, warning log
-    // 3 - write error, warning, info log
-    // 4 - write errors, warnings, info, debug logs
-    RocketMQUtil::initLog("/tmp/rocketmq_producer.log");
-
-    RMQ_DEBUG("producer.new: %s", "pg_CppClient");
-    DefaultMQProducer producer("pg_CppClient");
-
-    RMQ_DEBUG("producer.setNamesrvAddr: %s", namesrv.c_str());
-    producer.setNamesrvAddr(namesrv);
-
-    RMQ_DEBUG("producer.start");
-    producer.start();
-
-    std::string tags[] = { "TagA", "TagB", "TagC", "TagD", "TagE" };
-    int nNow = time(NULL);
-    char key[64];
-    char value[1024];
-
-    std::string str;
-    for (int i = 0; i < size; i += 8)
-    {
-        str.append("hello baby");
-    }
-
-    TimeCount tcTotal;
-    tcTotal.begin();
-
-    for (int i = 0; i < count; i++)
-    {
-        try
-        {
-            snprintf(key, sizeof(key), "KEY_%d_%d", nNow, i);
-            snprintf(value, sizeof(value), "%011d_%s", i, str.c_str());
-            Message msg(topic,// topic
-                tags[i % 5],// tag
-                key,// key
-                value,// body
-                strlen(value)+1
-            );
-
-            // Send messages asynchronously
-            SampleSendCallback* pSendCallback = new SampleSendCallback();
-            producer.send(msg, pSendCallback);
-        }
-        catch (MQClientException& e)
-        {
-            std::cout << e << std::endl;
-            __sync_fetch_and_add(&g_cnt_fail, 1);
-            MyUtil::msleep(3000);
-        }
-    }
-
-    while (1)
-    {
-        if ((g_cnt_succ + g_cnt_fail)  >= count)
-        {
-            break;
-        }
-    }
-
-    tcTotal.end();
-
-    printf("statsics: succ=%d, fail=%d, total_cost=%ds, tps=%d, avg=%dms\n",
-        g_cnt_succ, g_cnt_fail, tcTotal.countSec(),
-        (int)((double)count/((double)tcTotal.countUsec()/1000/1000)), tcTotal.countMsec()/count);
-
-    producer.shutdown();
-
-    return 0;
-}
-

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/example/demo/Common.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/example/demo/Common.cpp b/rocketmq-client4cpp/example/demo/Common.cpp
deleted file mode 100755
index b4db55c..0000000
--- a/rocketmq-client4cpp/example/demo/Common.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-/**
-* Copyright (C) 2013 suwenkuang ,hooligan_520@qq.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#include "Common.h"
-
-
-std::string MyUtil::_logPath = "";

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/example/demo/Common.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/example/demo/Common.h b/rocketmq-client4cpp/example/demo/Common.h
deleted file mode 100644
index 4863588..0000000
--- a/rocketmq-client4cpp/example/demo/Common.h
+++ /dev/null
@@ -1,162 +0,0 @@
-/**
-* Copyright (C) 2013 suwenkuang ,hooligan_520@qq.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <string.h>
-#include <assert.h>
-#include <time.h>
-#include <stdarg.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <signal.h>
-#include <pthread.h>
-
-#include <sys/time.h>
-#include <sys/timeb.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/file.h>
-#include <sys/syscall.h>
-#include <linux/unistd.h>
-
-#include <cstdio>
-#include <iostream>
-#include <string>
-#include <sstream>
-#include <vector>
-#include <map>
-#include <set>
-
-
-#define MYDEBUG(fmt, args...)   printf(fmt, ##args)
-#define MYLOG(fmt, args...)     MyUtil::writelog("[%s]"fmt, RocketMQUtil::now2str().c_str(), ##args)
-
-class MyUtil
-{
-public:
-    static void msleep(long millis)
-    {
-        struct timespec tv;
-        tv.tv_sec = millis / 1000;
-        tv.tv_nsec = (millis % 1000) * 1000000;
-        nanosleep(&tv, 0);
-    }
-
-    static long long str2ll( const char *str )
-    {
-        return atoll(str);
-    }
-
-    static unsigned long long getNowMs()
-    {
-        struct timeval tv;
-        gettimeofday(&tv, 0);
-        return tv.tv_sec * 1000ULL+tv.tv_usec/1000;
-    }
-
-    static int initLog(const std::string& logPath)
-    {
-        _logPath = logPath;
-    }
-
-    static void writelog(const char* fmt, ...)
-    {
-        if (_logPath.empty())
-        {
-            return;
-        }
-
-        static int logFd = -1;
-        if (logFd < 0)
-        {
-            logFd = open(_logPath.c_str(), O_CREAT | O_RDWR | O_APPEND, 0666);
-        }
-
-        if (logFd > 0)
-        {
-            char buf[1024*128];
-            buf[0] = buf[sizeof(buf) - 1] = '\0';
-
-            va_list ap;
-            va_start(ap, fmt);
-            int size = vsnprintf(buf, sizeof(buf), fmt, ap);
-            va_end(ap);
-
-            write(logFd, buf, size);
-        }
-
-        return;
-    }
-public:
-    static std::string _logPath;
-};
-
-/*
- * int test()
- * {
- *      TimeCount tc;
- *      tc.begin();
- *      func1();
- *      tc.end();
- *      cout << "cost:" << tc.countSec() << endl;
- * }
- */
-class TimeCount
-{
-public:
-    TimeCount()
-    {
-        m_tBegin.tv_sec  = 0;
-        m_tBegin.tv_usec = 0;
-
-        m_tEnd.tv_sec  = 0;
-        m_tEnd.tv_usec = 0;
-    }
-
-    ~TimeCount(){}
-public:
-    void begin()
-    {
-        gettimeofday(&m_tBegin,0);
-    }
-
-    void end()
-    {
-        gettimeofday(&m_tEnd, 0);
-    }
-
-    int countMsec()
-    {
-        return (int)((m_tEnd.tv_sec - m_tBegin.tv_sec)*1000 + (m_tEnd.tv_usec -m_tBegin.tv_usec)/1000.0);
-    }
-
-    int countUsec()
-    {
-        return (m_tEnd.tv_sec - m_tBegin.tv_sec)*1000000+(m_tEnd.tv_usec -m_tBegin.tv_usec);
-    }
-
-    int countSec()
-    {
-        return (m_tEnd.tv_sec - m_tBegin.tv_sec);
-    }
-
-public:
-    timeval m_tBegin;
-    timeval m_tEnd;
-};
-

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/example/demo/Makefile
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/example/demo/Makefile b/rocketmq-client4cpp/example/demo/Makefile
deleted file mode 100755
index be2d60f..0000000
--- a/rocketmq-client4cpp/example/demo/Makefile
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/bin/sh
-TOPDIR=../..
-
-CFLAGS=-g -ggdb -Wno-deprecated -fno-strict-aliasing -fno-omit-frame-pointer
-INCLUDE=-I${TOPDIR}/include
-LIB=-L${TOPDIR}/lib64 -lrocketmq -lz -lrt -lpthread
-TARGET=Producer AsyncProducer PullConsumer PushConsumer
-DEPEND_OBJ=Common.o
-
-
-LOCAL_SRC += $(sort $(wildcard *.cpp *.cc *.c))
-LOCAL_OBJ += $(patsubst %.cpp,%.o, $(patsubst %.cc,%.o, $(patsubst %.c,%.o, $(LOCAL_SRC))))
-
-all:${LOCAL_OBJ} ${TARGET}
-	@echo "build succ!"
-
-clean:
-	rm -vf ${TARGET} *.o
-	@echo "clean succ!"
-
-Producer:Producer.o ${DEPEND_OBJ}
-	$(CXX) $(CFLAGS) -o $@ $^ $(INCLUDE) $(LIB)
-
-AsyncProducer:AsyncProducer.o ${DEPEND_OBJ}
-	$(CXX) $(CFLAGS) -o $@ $^ $(INCLUDE) $(LIB)
-
-PullConsumer:PullConsumer.o ${DEPEND_OBJ}
-	$(CXX) $(CFLAGS) -o $@ $^ $(INCLUDE) $(LIB)
-
-PushConsumer:PushConsumer.o ${DEPEND_OBJ}
-	$(CXX) $(CFLAGS) -o $@ $^ $(INCLUDE) $(LIB)
-
-%.o: %.cpp
-	$(CXX) $(CFLAGS) $(INCLUDE) -o $@ -c $<
-
-%.o: %.cc
-	$(CXX) $(CFLAGS) $(INCLUDE) -o $@ -c $<
-
-%.o: %.c
-	$(CC) $(CFLAGS) $(INCLUDE) -o $@ -c $<

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/example/demo/Producer.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/example/demo/Producer.cpp b/rocketmq-client4cpp/example/demo/Producer.cpp
deleted file mode 100644
index 9905e0b..0000000
--- a/rocketmq-client4cpp/example/demo/Producer.cpp
+++ /dev/null
@@ -1,199 +0,0 @@
-/**
-* Copyright (C) 2013 suwenkuang ,hooligan_520@qq.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#include "Common.h"
-#include "DefaultMQProducer.h"
-using namespace rmq;
-
-void Usage(const char* program)
-{
-	printf("Usage:%s ip:port [-g group] [-t topic] [-n count] [-s size] [-w logpath]\n", program);
-	printf("\t -g group\n");
-	printf("\t -t topic\n");
-	printf("\t -n message count\n");
-	printf("\t -s message size \n");
-	printf("\t -w log path\n");
-}
-
-int main(int argc, char* argv[])
-{
-	if (argc < 2)
-	{
-		Usage(argv[0]);
-		return 0;
-	}
-
-	std::string namesrv = argv[1];
-	std::string group = "pg_test_group";
-	std::string topic = "topic_test";
-	int size = 32;
-	int count = 1000;
-
-	for (int i=2; i< argc; i++)
-	{
-		if (strcmp(argv[i],"-g")==0)
-		{
-			if (i+1 < argc)
-			{
-				group = argv[i+1];
-				i++;
-			}
-			else
-			{
-				Usage(argv[0]);
-				return 0;
-			}
-		}
-		else if (strcmp(argv[i],"-t")==0)
-		{
-			if (i+1 < argc)
-			{
-				topic = argv[i+1];
-				i++;
-			}
-			else
-			{
-				Usage(argv[0]);
-				return 0;
-			}
-		}
-		else if (strcmp(argv[i],"-n")==0)
-		{
-			if (i+1 < argc)
-			{
-				count = atoi(argv[i+1]);
-				i++;
-			}
-			else
-			{
-				Usage(argv[0]);
-				return 0;
-			}
-		}
-		else if (strcmp(argv[i],"-s")==0)
-		{
-			if (i+1 < argc)
-			{
-				size = atoi(argv[i+1]);
-				i++;
-			}
-			else
-			{
-				Usage(argv[0]);
-				return 0;
-			}
-		}
-		else if (strcmp(argv[i],"-w")==0)
-        {
-            if (i+1 < argc)
-            {
-                MyUtil::initLog(argv[i+1]);
-                i++;
-            }
-            else
-            {
-                Usage(argv[0]);
-                return 0;
-            }
-        }
-		else
-		{
-			Usage(argv[0]);
-			return 0;
-		}
-	}
-
-	// init client api log, here is not necessary, need to debug the api need to be initialized, you can consider comment it
-    // Here only the default print warning, error log, the log will be rolling by day, if you need to modify the log level, please set the environment variable, export ROCKETMQ_LOGLEVEL = loglevel
-    // The log level is as follows:
-    // 0 - close the log
-    // 1 - write error log
-    // 2 - write error, warning log
-    // 3 - write error, warning, info log
-    // 4 - write errors, warnings, info, debug logs
-	RocketMQUtil::initLog("/tmp/rocketmq_producer.log");
-
-	RMQ_DEBUG("producer.new: %s", group.c_str());
-	DefaultMQProducer producer(group);
-
-	RMQ_DEBUG("producer.setNamesrvAddr: %s", namesrv.c_str());
-	producer.setNamesrvAddr(namesrv);
-
-	RMQ_DEBUG("producer.start");
-	producer.start();
-
-	std::string tags[] = { "TagA", "TagB", "TagC", "TagD", "TagE" };
-
-	int _cost = 0, _tps = 0, _avg = 0, _min = 0, _max = 0;
-	int _failCnt = 0;
-	TimeCount tc;
-	TimeCount tcTotal;
-	tcTotal.begin();
-
-	int nNow = time(NULL);
-	char key[64];
-	char value[1024];
-
-	std::string str;
-	for (int i = 0; i < size; i += 8)
-	{
-        str.append("hello baby");
-    }
-
-	for (int i = 0; i < count; i++)
-	{
-		try
-		{
-
-			tc.begin();
-
-			snprintf(key, sizeof(key), "KEY_%d_%d", nNow, i);
-			snprintf(value, sizeof(value), "%011d_%s", i, str.c_str());
-			Message msg(topic,// topic
-				tags[i % 5],// tag
-				key,// key
-				value,// body
-				strlen(value)+1
-			);
-
-			// Send messages synchronously
-			SendResult sendResult = producer.send(msg);
-
-			tc.end();
-
-			int cost = tc.countMsec();
-			_min = (_min == 0) ? cost : (std::min(cost, _min));
-			_max = (_max == 0) ? cost : (std::max(cost, _max));
-
-			MYLOG("[%d]|succ|cost:%dms, result:%s\n", i, cost, sendResult.toString().c_str());
-		}
-		catch (MQClientException& e)
-		{
-			_failCnt++;
-			MYLOG("[%d]|fail|%s\n", i, e.what());
-		}
-	}
-	tcTotal.end();
-
-	MYDEBUG("statsics: num=%d, fail=%d, total_cost=%ds, tps=%d, avg=%dms, min=%dms, max=%dms\n",
-		count, _failCnt, tcTotal.countSec(), (int)((double)count/(tcTotal.countMsec()/1000)),
-		tcTotal.countMsec()/count, _min, _max);
-
-	// 停止生产者
-	producer.shutdown();
-
-	return 0;
-}
-

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/example/demo/PullConsumer.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/example/demo/PullConsumer.cpp b/rocketmq-client4cpp/example/demo/PullConsumer.cpp
deleted file mode 100755
index 3fae6dc..0000000
--- a/rocketmq-client4cpp/example/demo/PullConsumer.cpp
+++ /dev/null
@@ -1,194 +0,0 @@
-/**
-* Copyright (C) 2013 suwenkuang ,hooligan_520@qq.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#include "Common.h"
-#include "DefaultMQPullConsumer.h"
-using namespace rmq;
-
-volatile long long g_totalCnt = 0;
-
-void PrintResult(PullResult& result)
-{
-	std::list<MessageExt*>::iterator it = result.msgFoundList.begin();
-	for (;it!=result.msgFoundList.end();it++)
-	{
-		MessageExt* me = *it;
-		std::string str;
-		str.assign(me->getBody(),me->getBodyLen());
-
-		int cnt = __sync_fetch_and_add(&g_totalCnt, 1);
-		MYLOG("[%d]|%s|%s\n",  cnt, me->toString().c_str(), str.c_str());
-	}
-}
-
-
-void Usage(const char* program)
-{
-	printf("Usage:%s ip:port [-g group] [-t topic] [-w logpath]\n", program);
-	printf("\t -g consumer group\n");
-	printf("\t -t topic\n");
-	printf("\t -w log path\n");
-}
-
-
-int main(int argc, char* argv[])
-{
-	if (argc<2)
-	{
-		Usage(argv[0]);
-		return 0;
-	}
-
-	std::string namesrv = argv[1];
-	std::string group = "cg_test_pull_group";
-	std::string topic = "topic_test";
-
-	for (int i=2; i< argc; i++)
-	{
-		if (strcmp(argv[i],"-g")==0)
-		{
-			if (i+1 < argc)
-			{
-				group = argv[i+1];
-				i++;
-			}
-			else
-			{
-				Usage(argv[0]);
-				return 0;
-			}
-		}
-		else if (strcmp(argv[i],"-t")==0)
-		{
-			if (i+1 < argc)
-			{
-				topic = argv[i+1];
-				i++;
-			}
-			else
-			{
-				Usage(argv[0]);
-				return 0;
-			}
-		}
-		else if (strcmp(argv[i],"-w")==0)
-		{
-			if (i+1 < argc)
-			{
-				MyUtil::initLog(argv[i+1]);
-				i++;
-			}
-			else
-			{
-				Usage(argv[0]);
-				return 0;
-			}
-		}
-		else
-		{
-			Usage(argv[0]);
-			return 0;
-		}
-	}
-
-	// init client api log, here is not necessary, need to debug the api need to be initialized, you can consider comment it
-    // Here only the default print warning, error log, the log will be rolling by day, if you need to modify the log level, please set the environment variable, export ROCKETMQ_LOGLEVEL = loglevel
-    // The log level is as follows:
-    // 0 - close the log
-    // 1 - write error log
-    // 2 - write error, warning log
-    // 3 - write error, warning, info log
-    // 4 - write errors, warnings, info, debug logs
-	RocketMQUtil::initLog("/tmp/rocketmq_pullconsumer.log");
-
-	RMQ_DEBUG("consumer.new: %s", group.c_str());
-	DefaultMQPullConsumer consumer(group);
-
-	RMQ_DEBUG("consumer.setNamesrvAddr: %s", namesrv.c_str());
-	consumer.setNamesrvAddr(namesrv);
-
-	RMQ_DEBUG("consumer.setMessageModel: %s", getMessageModelString(CLUSTERING));
-	consumer.setMessageModel(CLUSTERING);
-
-	consumer.setConsumerPullTimeoutMillis(4000);
-	consumer.setBrokerSuspendMaxTimeMillis(3000);
-	consumer.setConsumerTimeoutMillisWhenSuspend(5000);
-
-	RMQ_DEBUG("consumer.start");
-	consumer.start();
-
-	RMQ_DEBUG("consumer.fetchSubscribeMessageQueues");
-	std::set<MessageQueue>* mqs = consumer.fetchSubscribeMessageQueues(topic);
-
-	std::set<MessageQueue>::iterator it = mqs->begin();
-	for (; it!=mqs->end(); it++)
-	{
-		MessageQueue mq = *it;
-		bool noNewMsg = false;
-		while (!noNewMsg)
-		{
-			try
-			{
-				RMQ_DEBUG("consumer.fetchConsumeOffset");
-                long long offset = consumer.fetchConsumeOffset(mq, false);
-                if (offset < 0)
-                {
-                    offset = consumer.maxOffset(mq);
-                    if (offset < 0)
-                    {
-						offset = LLONG_MAX;
-                    }
-                }
-
-				RMQ_DEBUG("consumer.pullBlockIfNotFound");
-				//PullResult* pullResult = consumer.pullBlockIfNotFound(mq, "*", offset, 32);
-				PullResult* pullResult = consumer.pull(mq, "*", offset, 32);
-				PrintResult(*pullResult);
-
-				RMQ_DEBUG("consumer.updateConsumeOffset");
-                consumer.updateConsumeOffset(mq, pullResult->nextBeginOffset);
-
-				switch (pullResult->pullStatus)
-				{
-					case FOUND:
-						// TODO
-						break;
-					case NO_MATCHED_MSG:
-						break;
-					case NO_NEW_MSG:
-						noNewMsg = true;
-						break;
-					case OFFSET_ILLEGAL:
-						break;
-					default:
-						break;
-				}
-
-				delete pullResult;
-			}
-			catch (MQException& e)
-			{
-				std::cout<<e<<std::endl;
-			}
-		}
-	}
-	delete mqs;
-
-	RMQ_DEBUG("consumer.shutdown");
-	consumer.shutdown();
-
-	return 0;
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/example/demo/PushConsumer.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/example/demo/PushConsumer.cpp b/rocketmq-client4cpp/example/demo/PushConsumer.cpp
deleted file mode 100755
index 1a8bfed..0000000
--- a/rocketmq-client4cpp/example/demo/PushConsumer.cpp
+++ /dev/null
@@ -1,256 +0,0 @@
-/**
-* Copyright (C) 2013 suwenkuang ,hooligan_520@qq.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#include "Common.h"
-#include "DefaultMQPushConsumer.h"
-using namespace rmq;
-
-volatile long long g_lastCnt = 0;
-volatile long long g_totalCnt = 0;
-long long g_lastUpdateTime = 0;
-
-static std::string bin2str(const std::string& strBin)
-{
-	if(strBin.size() == 0)
-	{
-		return "";
-	}
-
-	std::string sOut;
-    const char *p = (const char *)strBin.data();
-    size_t len = strBin.size();
-
-    char sBuf[255];
-    for (size_t i = 0; i < len; ++i, ++p)
-	{
-        snprintf(sBuf, sizeof(sBuf), "%02x", (unsigned char) *p);
-		sOut += sBuf;
-    }
-
-    return sOut;
-}
-
-
-class MsgListener : public MessageListenerConcurrently
-{
-public:
-	MsgListener()
-	{
-		consumeTimes = 0;
-	}
-
-	~MsgListener()
-	{
-
-	}
-
-	/**
-	 * consume messages
-	 * !!!Notice:multi-thread call, need to pay attention to dealing with multi-threaded re-entry problem
-	 * @param  msgs    message list
-	 * @param  context context for consumer
-	 * @return         [CONSUME_SUCCESS- success,RECONSUME_LATER-consume fail and retry later]
-	 */
-	ConsumeConcurrentlyStatus consumeMessage(std::list<MessageExt*>& msgs,
-											ConsumeConcurrentlyContext& context)
-	{
-		int cnt = __sync_fetch_and_add(&g_totalCnt, 1);
-		long long now = MyUtil::getNowMs();
-		long long old = g_lastUpdateTime;
-		if ((now - old) >= 1000)
-		{
-			if (__sync_bool_compare_and_swap(&g_lastUpdateTime, old, now))
-			{
-				long long time = now - old;
-				int tps = (int)((g_totalCnt - g_lastCnt) * 1.0 / time * 1000.0);
-				g_lastCnt = g_totalCnt;
-
-				MYDEBUG("[consume]msgcount: %lld, TPS: %d\n", g_totalCnt, tps);
-			}
-		}
-
-
-		MessageExt* msg = msgs.front();
-		long long offset = msg->getQueueOffset();
-		std::string maxOffset = msg->getProperty(Message::PROPERTY_MAX_OFFSET);
-
-		long long diff = MyUtil::str2ll(maxOffset.c_str()) - offset;
-		if (diff > 100000)
-		{
-			if (diff % 10000 == 0)
-			{
-				MYDEBUG("overload, offset:%lld, diff:%lld\n", offset, diff);
-			}
-			// return CONSUME_SUCCESS;
-		}
-
-		std::list<MessageExt*>::iterator it = msgs.begin();
-		for (;it != msgs.end();it++)
-		{
-			MessageExt* me = *it;
-			std::string str;
-			str.assign(me->getBody(),me->getBodyLen());
-
-			MYLOG("[%d]|%s|%s\n",  cnt, me->toString().c_str(), str.c_str());
-		}
-
-		consumeTimes++;
-
-		/*
-		if ((consumeTimes % 2) == 0)
-		{
-			return RECONSUME_LATER;
-		}
-		else if ((consumeTimes % 3) == 0)
-		{
-			context.delayLevelWhenNextConsume = 5;
-			return RECONSUME_LATER;
-		}
-		*/
-
-		// context.ackIndex = msgs.size() - 1;
-		return CONSUME_SUCCESS;
-	}
-
-	int consumeTimes;
-};
-
-
-void Usage(const char* program)
-{
-	printf("Usage:%s ip:port [-g group] [-t topic] [-w logpath]\n", program);
-	printf("\t -g consumer group\n");
-	printf("\t -t topic\n");
-	printf("\t -w log path\n");
-}
-
-
-int main(int argc, char* argv[])
-{
-	if (argc < 2)
-	{
-		Usage(argv[0]);
-		return 0;
-	}
-
-	std::string namesrv = argv[1];
-	std::string group = "cg_test_push_group";
-	std::string topic = "topic_test";
-	for (int i=2; i< argc; i++)
-	{
-		if (strcmp(argv[i],"-g")==0)
-		{
-			if (i+1 < argc)
-			{
-				group = argv[i+1];
-				i++;
-			}
-			else
-			{
-				Usage(argv[0]);
-				return 0;
-			}
-		}
-		else if (strcmp(argv[i],"-t")==0)
-		{
-			if (i+1 < argc)
-			{
-				topic = argv[i+1];
-				i++;
-			}
-			else
-			{
-				Usage(argv[0]);
-				return 0;
-			}
-		}
-		else if (strcmp(argv[i],"-w")==0)
-		{
-			if (i+1 < argc)
-			{
-				MyUtil::initLog(argv[i+1]);
-				i++;
-			}
-			else
-			{
-				Usage(argv[0]);
-				return 0;
-			}
-		}
-		else
-		{
-			Usage(argv[0]);
-			return 0;
-		}
-	}
-
-    // init client api log, here is not necessary, need to debug the api need to be initialized, you can consider comment it
-    // Here only the default print warning, error log, the log will be rolling by day, if you need to modify the log level, please set the environment variable, export ROCKETMQ_LOGLEVEL = loglevel
-    // The log level is as follows:
-    // 0 - close the log
-    // 1 - write error log
-    // 2 - write error, warning log
-    // 3 - write error, warning, info log
-    // 4 - write errors, warnings, info, debug logs
-	RocketMQUtil::initLog("/tmp/rocketmq_pushconsumer.log");
-
-	RMQ_DEBUG("consumer.new: %s", group.c_str());
-	DefaultMQPushConsumer consumer(group);
-
-	RMQ_DEBUG("consumer.setNamesrvAddr: %s", namesrv.c_str());
-	consumer.setNamesrvAddr(namesrv);
-
-	RMQ_DEBUG("consumer.setMessageModel: %s", getMessageModelString(CLUSTERING));
-	consumer.setMessageModel(CLUSTERING);
-
-	RMQ_DEBUG("consumer.subscribe");
-	consumer.subscribe(topic, "*");
-
-	consumer.setConsumeFromWhere(CONSUME_FROM_LAST_OFFSET);
-
-	// Set the number of each consumption message, the default is 1
-	// consumer.setConsumeMessageBatchMaxSize(1);
-
-	// The number of consumer thread pool, the default minimum 5, the maximum 25, the proposed set to the same, more stable
-	// consumer.setConsumeThreadMin(25);
-	// consumer.setConsumeThreadMax(25);
-
-	// Single message consume timeout, default is 15 minutes
-	// When the consumption times out, message will be send back to the retry queue and re-delivered
-	// consumer.setConsumeTimeout(15);
-
-	RMQ_DEBUG("consumer.registerMessageListener");
-	MsgListener* listener = new MsgListener();
-	consumer.registerMessageListener(listener);
-
-	RMQ_DEBUG("consumer.start");
-	consumer.start();
-
-	while(1)
-	{
-		if (getchar()=='e'&&getchar()=='x'&&getchar()=='i'&&getchar()=='t')
-		{
-			break;
-		}
-		::sleep(1);
-	}
-
-	RMQ_DEBUG("consumer.shutdown");
-	consumer.shutdown();
-	delete listener;
-
-	return 0;
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/include/AllocateMessageQueueStrategy.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/include/AllocateMessageQueueStrategy.h b/rocketmq-client4cpp/include/AllocateMessageQueueStrategy.h
deleted file mode 100755
index fc10072..0000000
--- a/rocketmq-client4cpp/include/AllocateMessageQueueStrategy.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#ifndef __RMQ_ALLOCATEMESSAGEQUEUESTRATEGY_H__
-#define __RMQ_ALLOCATEMESSAGEQUEUESTRATEGY_H__
-
-#include <vector>
-#include <string>
-#include <list>
-
-#include "RocketMQClient.h"
-#include "MessageQueue.h"
-
-namespace rmq
-{
-	/**
-	* Consumer Queue Automatic Assignment Policy
-	*
-	*/
-	class AllocateMessageQueueStrategy
-	{
-	public:
-		virtual ~AllocateMessageQueueStrategy() {}
-
-		/**
-		* Assign queues to the current ConsumerId
-		*
-		* @param [currentCID] Current ConsumerId
-		* @param [mqAll] All queues of the current Topic, no duplicate data, and orderly
-		* @param [cidAll] All subscription groups for the current subscription group, without duplication of data, and orderly
-		* @return allocation results, no duplicate data
-		*/
-		virtual std::vector<MessageQueue>* allocate(
-				const std::string& consumerGroup,
-				const std::string& currentCID,
-				std::vector<MessageQueue>& mqAll,
-				std::list<std::string>& cidAll)=0;
-		virtual std::string getName()=0;
-	};
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/include/ClientConfig.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/include/ClientConfig.h b/rocketmq-client4cpp/include/ClientConfig.h
deleted file mode 100755
index ca36830..0000000
--- a/rocketmq-client4cpp/include/ClientConfig.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * Copyright (C) 2010-2013 kangliqiang <ka...@163.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef __RMQ_CLIENTCONFIG_H__
-#define __RMQ_CLIENTCONFIG_H__
-
-#include <string>
-#include "RocketMQClient.h"
-
-namespace rmq
-{
-	/**
-	 * Producer and Consumer common configuration
-	 *
-	 */
-	class ClientConfig
-	{
-	public:
-		ClientConfig();
-		virtual ~ClientConfig();
-
-		std::string buildMQClientId();
-		void changeInstanceNameToPID();
-
-		void resetClientConfig(const ClientConfig& cc);
-		ClientConfig cloneClientConfig();
-
-		std::string getNamesrvAddr();
-		void setNamesrvAddr(const std::string& namesrvAddr);
-
-		std::string getClientIP();
-		void setClientIP(const std::string& clientIP);
-
-		std::string getInstanceName();
-		void setInstanceName(const std::string& instanceName);
-
-		int getClientCallbackExecutorThreads();
-		void setClientCallbackExecutorThreads(int clientCallbackExecutorThreads);
-
-		int getPollNameServerInterval();
-
-		void setPollNameServerInterval(int pollNameServerInterval);
-
-		int getHeartbeatBrokerInterval();
-		void setHeartbeatBrokerInterval(int heartbeatBrokerInterval);
-
-		int getPersistConsumerOffsetInterval();
-		void setPersistConsumerOffsetInterval(int persistConsumerOffsetInterval);
-
-		std::string toString() const;
-
-	private:
-		int m_clientCallbackExecutorThreads;
-		int m_pollNameServerInterval;
-		int m_heartbeatBrokerInterval;
-		int m_persistConsumerOffsetInterval;
-		std::string m_clientIP;
-		std::string m_instanceName;
-		std::string m_namesrvAddr;
-	};
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/include/ConsumeMessageHook.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/include/ConsumeMessageHook.h b/rocketmq-client4cpp/include/ConsumeMessageHook.h
deleted file mode 100644
index c13e6c7..0000000
--- a/rocketmq-client4cpp/include/ConsumeMessageHook.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#ifndef __RMQ_CONSUMEMESSAGEHOOK_H__
-#define __RMQ_CONSUMEMESSAGEHOOK_H__
-
-#include <list>
-
-#include "RocketMQClient.h"
-#include "MessageQueue.h"
-
-namespace rmq
-{
-	typedef struct
-	{
-		std::string consumerGroup;
-		std::list<MessageExt*> msgList;
-		MessageQueue mq;
-		bool success;
-		void* arg;
-	} ConsumeMessageContext;
-
-	class ConsumeMessageHook
-	{
-	public:
-		virtual ~ConsumeMessageHook() {}
-		virtual std::string hookName()=0;
-		virtual void consumeMessageBefore(const ConsumeMessageContext& context)=0;
-		virtual void consumeMessageAfter(const ConsumeMessageContext& context)=0;
-	};
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/include/ConsumeType.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/include/ConsumeType.h b/rocketmq-client4cpp/include/ConsumeType.h
deleted file mode 100755
index a4748ab..0000000
--- a/rocketmq-client4cpp/include/ConsumeType.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#ifndef __RMQ_CONSUMETYPE_H__
-#define __RMQ_CONSUMETYPE_H__
-
-#include "RocketMQClient.h"
-
-namespace rmq
-{
-	enum ConsumeType
-	{
-		/**
-		* Active comsume
-		*/
-		CONSUME_ACTIVELY,
-		/**
-		* Passive comsume
-		*/
-		CONSUME_PASSIVELY,
-	};
-
-	enum ConsumeFromWhere
-	{
-		CONSUME_FROM_LAST_OFFSET,
-		CONSUME_FROM_LAST_OFFSET_AND_FROM_MIN_WHEN_BOOT_FIRST,
-		CONSUME_FROM_MIN_OFFSET,
-		CONSUME_FROM_MAX_OFFSET,
-	    CONSUME_FROM_FIRST_OFFSET,
-	    CONSUME_FROM_TIMESTAMP,
-	};
-
-	enum MessageModel
-	{
-		BROADCASTING,
-		CLUSTERING,
-	};
-
-	const char* getConsumeTypeString(ConsumeType type);
-	const char* getConsumeFromWhereString(ConsumeFromWhere type);
-	const char* getMessageModelString(MessageModel type);
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/include/DefaultMQProducer.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/include/DefaultMQProducer.h b/rocketmq-client4cpp/include/DefaultMQProducer.h
deleted file mode 100755
index 9bf2f74..0000000
--- a/rocketmq-client4cpp/include/DefaultMQProducer.h
+++ /dev/null
@@ -1,129 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __RMQ_DEFAULTMQPRODUCER_H__
-#define __RMQ_DEFAULTMQPRODUCER_H__
-
-#include <string>
-#include <list>
-#include <vector>
-
-#include "RocketMQClient.h"
-#include "MQClientException.h"
-#include "Message.h"
-#include "SendResult.h"
-#include "ClientConfig.h"
-#include "MQProducer.h"
-
-namespace rmq
-{
-	class MessageQueue;
-	class MessageQueueSelector;
-	class MQClientException;
-	class Message;
-	class DefaultMQProducerImpl;
-
-	/**
-	* Message producer
-	*
-	*/
-	class DefaultMQProducer : public ClientConfig ,public MQProducer
-	{
-	public:
-		DefaultMQProducer();
-		DefaultMQProducer(const std::string& producerGroup);
-		~DefaultMQProducer();
-
-		//begin MQProducer
-		void start();
-		void shutdown();
-
-		std::vector<MessageQueue>* fetchPublishMessageQueues(const std::string& topic);
-
-		SendResult send(Message& msg);
-		SendResult send(Message& msg, MessageQueue& mq);
-		SendResult send(Message& msg, MessageQueueSelector* selector, void* arg);
-		void send(Message& msg, SendCallback* pSendCallback);
-		void send(Message& msg, MessageQueue& mq, SendCallback* pSendCallback);
-		void send(Message& msg, MessageQueueSelector* selector, void* arg, SendCallback* pSendCallback);
-		void sendOneway(Message& msg);
-		void sendOneway(Message& msg, MessageQueue& mq);
-		void sendOneway(Message& msg, MessageQueueSelector* selector, void* arg);
-
-		TransactionSendResult sendMessageInTransaction(Message& msg,
-														LocalTransactionExecuter* pTranExecuter,
-														void* arg);
-		//end MQProducer
-
-		void createTopic(const std::string& key, const std::string& newTopic, int queueNum) ;
-		long long searchOffset(const MessageQueue& mq, long long timestamp);
-		long long maxOffset(const MessageQueue& mq);
-		long long minOffset(const MessageQueue& mq);
-		long long earliestMsgStoreTime(const MessageQueue& mq);
-		MessageExt* viewMessage(const std::string& msgId) ;
-		QueryResult queryMessage(const std::string& topic,
-								 const std::string& key,
-								 int maxNum,
-								 long long begin,
-								 long long end);
-
-		std::string getProducerGroup();
-		void setProducerGroup(const std::string& producerGroup);
-
-		std::string getCreateTopicKey();
-		void setCreateTopicKey(const std::string& createTopicKey);
-
-		int getSendMsgTimeout();
-		void setSendMsgTimeout(int sendMsgTimeout) ;
-
-		int getCompressMsgBodyOverHowmuch();
-		void setCompressMsgBodyOverHowmuch(int compressMsgBodyOverHowmuch);
-
-		int getCompressLevel();
-		void setCompressLevel(int compressLevel);
-
-		DefaultMQProducerImpl* getDefaultMQProducerImpl();
-
-		bool isRetryAnotherBrokerWhenNotStoreOK();
-		void setRetryAnotherBrokerWhenNotStoreOK(bool retryAnotherBrokerWhenNotStoreOK);
-
-		int getMaxMessageSize();
-		void setMaxMessageSize(int maxMessageSize);
-
-		int getDefaultTopicQueueNums();
-		void setDefaultTopicQueueNums(int defaultTopicQueueNums);
-
-		int getRetryTimesWhenSendFailed();
-	    void setRetryTimesWhenSendFailed(int retryTimesWhenSendFailed);
-
-	protected:
-		DefaultMQProducerImpl* m_pDefaultMQProducerImpl;
-
-	private:
-		std::string m_producerGroup;
-		std::string m_createTopicKey;
-
-		int m_defaultTopicQueueNums;
-		int m_sendMsgTimeout;
-		int m_compressMsgBodyOverHowmuch;
-		int m_retryTimesWhenSendFailed;
-		bool m_retryAnotherBrokerWhenNotStoreOK;
-		int m_maxMessageSize;
-		int m_compressLevel;
-	};
-}
-
-#endif


[13/17] incubator-rocketmq-externals git commit: Polish cpp module

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/common/PermName.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/common/PermName.cpp b/rocketmq-client4cpp/src/common/PermName.cpp
deleted file mode 100644
index 084de79..0000000
--- a/rocketmq-client4cpp/src/common/PermName.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#include "PermName.h"
-
-namespace rmq
-{
-
-int PermName::PERM_PRIORITY = 0x1 << 3;
-int PermName::PERM_READ = 0x1 << 2;
-int PermName::PERM_WRITE = 0x1 << 1;
-int PermName::PERM_INHERIT = 0x1 << 0;
-
-bool PermName::isReadable(int perm)
-{
-    return (perm & PERM_READ) == PERM_READ;
-}
-
-bool PermName::isWriteable(int perm)
-{
-    return (perm & PERM_WRITE) == PERM_WRITE;
-}
-
-bool PermName::isInherited(int perm)
-{
-    return (perm & PERM_INHERIT) == PERM_INHERIT;
-}
-
-std::string PermName::perm2String(int perm)
-{
-    std::string pm("---");
-    if (isReadable(perm))
-    {
-        pm.replace(0, 1, "R");
-    }
-
-    if (isWriteable(perm))
-    {
-        pm.replace(1, 2, "W");
-    }
-
-    if (isInherited(perm))
-    {
-        pm.replace(2, 3, "X");
-    }
-
-    return pm;
-}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/common/PermName.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/common/PermName.h b/rocketmq-client4cpp/src/common/PermName.h
deleted file mode 100644
index 364ddeb..0000000
--- a/rocketmq-client4cpp/src/common/PermName.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __PERMNAME_H__
-#define __PERMNAME_H__
-
-#include <string>
-
-namespace rmq
-{
-	class PermName
-	{
-	public:
-	    static int PERM_PRIORITY;
-	    static int PERM_READ;
-	    static int PERM_WRITE;
-	    static int PERM_INHERIT;
-
-	    static bool isReadable(int perm);
-	    static bool isWriteable(int perm);
-	    static bool isInherited(int perm);
-	    static std::string perm2String(int perm);
-	};
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/common/PullSysFlag.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/common/PullSysFlag.cpp b/rocketmq-client4cpp/src/common/PullSysFlag.cpp
deleted file mode 100644
index f6fc1c2..0000000
--- a/rocketmq-client4cpp/src/common/PullSysFlag.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#include "PullSysFlag.h"
-
-namespace rmq
-{
-
-int PullSysFlag::FLAG_COMMIT_OFFSET = 0x1 << 0;
-int PullSysFlag::FLAG_SUSPEND = 0x1 << 1;
-int PullSysFlag::FLAG_SUBSCRIPTION = 0x1 << 2;
-
-int PullSysFlag::buildSysFlag(bool commitOffset, bool suspend, bool subscription)
-{
-    int flag = 0;
-
-    if (commitOffset)
-    {
-        flag |= FLAG_COMMIT_OFFSET;
-    }
-
-    if (suspend)
-    {
-        flag |= FLAG_SUSPEND;
-    }
-
-    if (subscription)
-    {
-        flag |= FLAG_SUBSCRIPTION;
-    }
-
-    return flag;
-}
-
-int PullSysFlag::clearCommitOffsetFlag(int sysFlag)
-{
-    return sysFlag & (~FLAG_COMMIT_OFFSET);
-}
-
-bool PullSysFlag::hasCommitOffsetFlag(int sysFlag)
-{
-    return (sysFlag & FLAG_COMMIT_OFFSET) == FLAG_COMMIT_OFFSET;
-}
-
-bool PullSysFlag::hasSuspendFlag(int sysFlag)
-{
-    return (sysFlag & FLAG_SUSPEND) == FLAG_SUSPEND;
-}
-
-bool PullSysFlag::hasSubscriptionFlag(int sysFlag)
-{
-    return (sysFlag & FLAG_SUBSCRIPTION) == FLAG_SUBSCRIPTION;
-}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/common/PullSysFlag.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/common/PullSysFlag.h b/rocketmq-client4cpp/src/common/PullSysFlag.h
deleted file mode 100755
index c19eac3..0000000
--- a/rocketmq-client4cpp/src/common/PullSysFlag.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __PULLSYSFLAG_H__
-#define __PULLSYSFLAG_H__
-
-namespace rmq
-{
-	class PullSysFlag
-	{
-	public:
-	    static int buildSysFlag(bool commitOffset, bool suspend, bool subscription);
-	    static int clearCommitOffsetFlag(int sysFlag);
-	    static bool hasCommitOffsetFlag(int sysFlag);
-	    static bool hasSuspendFlag(int sysFlag);
-	    static bool hasSubscriptionFlag(int sysFlag);
-
-	private:
-	    static int FLAG_COMMIT_OFFSET;
-	    static int FLAG_SUSPEND;
-	    static int FLAG_SUBSCRIPTION;
-	};
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/common/SendResult.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/common/SendResult.cpp b/rocketmq-client4cpp/src/common/SendResult.cpp
deleted file mode 100755
index 5263d29..0000000
--- a/rocketmq-client4cpp/src/common/SendResult.cpp
+++ /dev/null
@@ -1,132 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#include "SendResult.h"
-#include "UtilAll.h"
-#include "VirtualEnvUtil.h"
-
-namespace rmq
-{
-
-SendResult::SendResult()
-    : m_sendStatus(SEND_OK),m_queueOffset(0)
-{
-}
-
-SendResult::SendResult(const SendStatus& sendStatus,
-                       const std::string&  msgId,
-                       MessageQueue& messageQueue,
-                       long long queueOffset,
-                       std::string&  projectGroupPrefix)
-    : m_sendStatus(sendStatus),
-      m_msgId(msgId),
-      m_messageQueue(messageQueue),
-      m_queueOffset(queueOffset)
-{
-    if (!UtilAll::isBlank(projectGroupPrefix))
-    {
-        m_messageQueue.setTopic(VirtualEnvUtil::clearProjectGroup(m_messageQueue.getTopic(),
-                                projectGroupPrefix));
-    }
-}
-
-const std::string&  SendResult::getMsgId()
-{
-    return m_msgId;
-}
-
-void SendResult::setMsgId(const std::string&  msgId)
-{
-    m_msgId = msgId;
-}
-
-SendStatus SendResult::getSendStatus()
-{
-    return m_sendStatus;
-}
-
-void SendResult::setSendStatus(const SendStatus& sendStatus)
-{
-    m_sendStatus = sendStatus;
-}
-
-MessageQueue& SendResult::getMessageQueue()
-{
-    return m_messageQueue;
-}
-
-void SendResult::setMessageQueue(MessageQueue& messageQueue)
-{
-    m_messageQueue = messageQueue;
-}
-
-long long SendResult::getQueueOffset()
-{
-    return m_queueOffset;
-}
-
-void SendResult::setQueueOffset(long long queueOffset)
-{
-    m_queueOffset = queueOffset;
-}
-
-
-bool SendResult::hasResult()
-{
-	return !m_msgId.empty();
-}
-
-
-
-std::string SendResult::toString() const
-{
-    std::stringstream ss;
-    ss << "{sendStatus=" << m_sendStatus
-       << ",msgId=" << m_msgId
-       << ",messageQueue=" << m_messageQueue.toString()
-       << ",queueOffset=" << m_queueOffset
-       << "}";
-    return ss.str();
-}
-
-
-std::string SendResult::toJsonString() const
-{
-    std::stringstream ss;
-    ss << "{\"sendStatus\":\"" << m_sendStatus
-       << "\",\"msgId\":\"" << m_msgId
-       << "\",\"messageQueue\":" << m_messageQueue.toJsonString()
-       << ",\"queueOffset\":\"" << m_queueOffset
-       << "}";
-    return ss.str();
-}
-
-
-
-TransactionSendResult::TransactionSendResult()
-{
-}
-
-LocalTransactionState TransactionSendResult::getLocalTransactionState()
-{
-    return m_localTransactionState;
-}
-
-void TransactionSendResult::setLocalTransactionState(LocalTransactionState localTransactionState)
-{
-    m_localTransactionState = localTransactionState;
-}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/common/ServiceState.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/common/ServiceState.h b/rocketmq-client4cpp/src/common/ServiceState.h
deleted file mode 100755
index 7b41add..0000000
--- a/rocketmq-client4cpp/src/common/ServiceState.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * Copyright (C) 2013 kangliqiang ,kangliq@163.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __SERVICESTATE_H__
-#define __SERVICESTATE_H__
-
-namespace rmq
-{
-    enum ServiceState
-    {
-        CREATE_JUST,
-        RUNNING,
-        SHUTDOWN_ALREADY,
-        START_FAILED
-    };
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/common/ServiceThread.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/common/ServiceThread.cpp b/rocketmq-client4cpp/src/common/ServiceThread.cpp
deleted file mode 100644
index 1abff9f..0000000
--- a/rocketmq-client4cpp/src/common/ServiceThread.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#include "ServiceThread.h"
-#include "Monitor.h"
-#include "ScopedLock.h"
-
-namespace rmq
-{
-
-ServiceThread::ServiceThread(const char* name)
-    : kpr::Thread(name),
-      m_notified(false),
-      m_stoped(false)
-{
-
-}
-
-ServiceThread::~ServiceThread()
-{
-
-}
-
-void ServiceThread::stop()
-{
-    m_stoped = true;
-    wakeup();
-}
-
-void ServiceThread::wakeup()
-{
-    kpr::ScopedLock<kpr::Monitor> lock(*this);
-
-    if (!m_notified)
-    {
-        m_notified = true;
-        Notify();
-    }
-}
-
-void ServiceThread::waitForRunning(long interval)
-{
-    kpr::ScopedLock<kpr::Monitor> lock(*this);
-    if (m_notified)
-    {
-        m_notified = false;
-        return;
-    }
-
-    try
-    {
-        Wait(interval);
-    }
-    catch (...)
-    {
-        m_notified = false;
-    }
-}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/common/ServiceThread.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/common/ServiceThread.h b/rocketmq-client4cpp/src/common/ServiceThread.h
deleted file mode 100755
index d7ec3ef..0000000
--- a/rocketmq-client4cpp/src/common/ServiceThread.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __SERVICETHREAD_H__
-#define __SERVICETHREAD_H__
-
-#include <string>
-#include "Thread.h"
-#include "Monitor.h"
-
-namespace rmq
-{
-	const long JoinTime = 90 * 1000;
-
-	/**
-	* service thread base class
-	*
-	*/
-	class ServiceThread : public kpr::Thread, public kpr::Monitor
-	{
-	public:
-	    ServiceThread(const char* name = NULL);
-	    virtual ~ServiceThread();
-
-	    virtual std::string  getServiceName() = 0;
-
-	    void stop();
-	    void wakeup();
-	    void waitForRunning(long interval);
-
-	protected:
-	    volatile bool m_notified;
-	    volatile bool m_stoped;
-	};
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/common/SubscriptionGroupConfig.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/common/SubscriptionGroupConfig.h b/rocketmq-client4cpp/src/common/SubscriptionGroupConfig.h
deleted file mode 100755
index 12bd48a..0000000
--- a/rocketmq-client4cpp/src/common/SubscriptionGroupConfig.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang, kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#ifndef __SUBSCRIPTIONGROUPCONFIG_H__
-#define __SUBSCRIPTIONGROUPCONFIG_H__
-
-#include <string>
-#include "MixAll.h"
-
-namespace rmq
-{
-    class SubscriptionGroupConfig
-    {
-    public:
-        SubscriptionGroupConfig(const std::string& groupName)
-        {
-            this->groupName = groupName;
-            consumeEnable = true;
-            consumeFromMinEnable = true;
-            consumeBroadcastEnable = true;
-            retryQueueNums = 1;
-            retryMaxTimes = 5;
-            brokerId = MixAll::MASTER_ID;
-            whichBrokerWhenConsumeSlowly = 1;
-        }
-
-        std::string groupName;
-        bool consumeEnable;
-        bool consumeFromMinEnable;
-        bool consumeBroadcastEnable;
-        int retryQueueNums;
-        int retryMaxTimes;
-        long brokerId;
-        long whichBrokerWhenConsumeSlowly;
-    };
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/common/TopAddressing.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/common/TopAddressing.h b/rocketmq-client4cpp/src/common/TopAddressing.h
deleted file mode 100755
index 07b0c0c..0000000
--- a/rocketmq-client4cpp/src/common/TopAddressing.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang, kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#ifndef __TOPADDRESSING_H__
-#define  __TOPADDRESSING_H__
-
-#include <string>
-#include <sstream>
-#include "SocketUtil.h"
-
-namespace rmq
-{
-    class TopAddressing
-    {
-    public:
-        TopAddressing()
-			: m_nsAddr("")
-        {
-        }
-
-		const std::string& getNsAddr()
-        {
-            return m_nsAddr;
-        }
-
-		void setNsAddr(std::string& nsAddr)
-        {
-           	m_nsAddr = nsAddr;
-        }
-
-        std::string fetchNSAddr()
-        {
-
-            return "";
-        }
-
-    private:
-		std::string m_nsAddr;
-    };
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/common/TopicConfig.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/common/TopicConfig.cpp b/rocketmq-client4cpp/src/common/TopicConfig.cpp
deleted file mode 100644
index 036b41c..0000000
--- a/rocketmq-client4cpp/src/common/TopicConfig.cpp
+++ /dev/null
@@ -1,167 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#include <stdlib.h>
-#include <sstream>
-
-#include "TopicConfig.h"
-#include "PermName.h"
-
-namespace rmq
-{
-
-int TopicConfig::DefaultReadQueueNums = 16;
-int TopicConfig::DefaultWriteQueueNums = 16;
-std::string TopicConfig::SEPARATOR = " ";
-
-TopicConfig::TopicConfig()
-    : m_topicName(""),
-      m_readQueueNums(DefaultReadQueueNums),
-      m_writeQueueNums(DefaultWriteQueueNums),
-      m_perm(PermName::PERM_READ | PermName::PERM_WRITE),
-      m_topicFilterType(SINGLE_TAG),
-      m_topicSysFlag(0),
-      m_order(false)
-{
-
-}
-
-TopicConfig::TopicConfig(const std::string& topicName)
-    : m_topicName(topicName),
-      m_readQueueNums(DefaultReadQueueNums),
-      m_writeQueueNums(DefaultWriteQueueNums),
-      m_perm(PermName::PERM_READ | PermName::PERM_WRITE),
-      m_topicFilterType(SINGLE_TAG),
-      m_topicSysFlag(0),
-      m_order(false)
-{
-
-}
-
-TopicConfig::TopicConfig(const std::string& topicName, int readQueueNums, int writeQueueNums, int perm)
-    : m_topicName(topicName),
-      m_readQueueNums(readQueueNums),
-      m_writeQueueNums(writeQueueNums),
-      m_perm(perm),
-      m_topicFilterType(SINGLE_TAG),
-      m_topicSysFlag(0),
-      m_order(false)
-{
-}
-
-TopicConfig::~TopicConfig()
-{
-}
-
-std::string  TopicConfig::encode()
-{
-    std::stringstream ss;
-    ss << m_topicName << SEPARATOR
-       << m_readQueueNums << SEPARATOR
-       << m_writeQueueNums << SEPARATOR
-       << m_perm << SEPARATOR
-       << m_topicFilterType;
-
-    return ss.str();
-}
-
-bool  TopicConfig::decode(const std::string& in)
-{
-    std::stringstream ss(in);
-
-    ss >> m_topicName;
-    ss >> m_readQueueNums;
-    ss >> m_writeQueueNums;
-    ss >> m_perm;
-
-    int type;
-    ss >> type;
-    m_topicFilterType = (TopicFilterType)type;
-
-    return true;
-}
-
-const std::string&  TopicConfig::getTopicName()
-{
-    return m_topicName;
-}
-
-void  TopicConfig::setTopicName(const std::string& topicName)
-{
-    m_topicName = topicName;
-}
-
-int  TopicConfig::getReadQueueNums()
-{
-    return m_readQueueNums;
-}
-
-void  TopicConfig::setReadQueueNums(int readQueueNums)
-{
-    m_readQueueNums = readQueueNums;
-}
-
-int  TopicConfig::getWriteQueueNums()
-{
-    return m_writeQueueNums;
-}
-
-void  TopicConfig::setWriteQueueNums(int writeQueueNums)
-{
-    m_writeQueueNums = writeQueueNums;
-}
-
-int  TopicConfig::getPerm()
-{
-    return m_perm;
-}
-
-void  TopicConfig::setPerm(int perm)
-{
-    m_perm = perm;
-}
-
-TopicFilterType  TopicConfig::getTopicFilterType()
-{
-    return m_topicFilterType;
-}
-
-void  TopicConfig::setTopicFilterType(TopicFilterType topicFilterType)
-{
-    m_topicFilterType = topicFilterType;
-}
-
-int  TopicConfig::getTopicSysFlag()
-{
-    return m_topicSysFlag;
-}
-
-void  TopicConfig::setTopicSysFlag(int perm)
-{
-    m_topicSysFlag = perm;
-}
-
-bool  TopicConfig::isOrder()
-{
-    return m_order;
-}
-
-void  TopicConfig::setOrder(bool order)
-{
-    m_order = order;
-}
-
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/common/TopicConfig.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/common/TopicConfig.h b/rocketmq-client4cpp/src/common/TopicConfig.h
deleted file mode 100644
index b9f2bcb..0000000
--- a/rocketmq-client4cpp/src/common/TopicConfig.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __TOPICCONFIG_H__
-#define __TOPICCONFIG_H__
-
-#include <string>
-#include "TopicFilterType.h"
-
-namespace rmq
-    {
-    /**
-    * Topic
-    *
-    */
-    class TopicConfig
-    {
-    public:
-        TopicConfig();
-        TopicConfig(const std::string& topicName);
-        TopicConfig(const std::string& topicName, int readQueueNums, int writeQueueNums, int perm);
-        ~TopicConfig();
-
-        std::string encode();
-        bool decode(const std::string& in);
-        const std::string& getTopicName();
-        void setTopicName(const std::string& topicName);
-        int getReadQueueNums();
-        void setReadQueueNums(int readQueueNums);
-        int getWriteQueueNums();
-        void setWriteQueueNums(int writeQueueNums);
-        int getPerm();
-        void setPerm(int perm);
-        TopicFilterType getTopicFilterType();
-        void setTopicFilterType(TopicFilterType topicFilterType);
-		int getTopicSysFlag();
-        void setTopicSysFlag(int topicSysFlag);
-		bool isOrder();
-        void setOrder(bool order);
-
-    public:
-        static int DefaultReadQueueNums;
-        static int DefaultWriteQueueNums;
-
-    private:
-        static std::string SEPARATOR;
-
-        std::string m_topicName;
-        int m_readQueueNums;
-        int m_writeQueueNums;
-        int m_perm;
-        TopicFilterType m_topicFilterType;
-		int m_topicSysFlag;
-		bool m_order;
-    };
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/common/TopicStatsTable.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/common/TopicStatsTable.h b/rocketmq-client4cpp/src/common/TopicStatsTable.h
deleted file mode 100755
index 4319e54..0000000
--- a/rocketmq-client4cpp/src/common/TopicStatsTable.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __TOPICSTATSTABLE_H__
-#define __TOPICSTATSTABLE_H__
-
-#include <map>
-
-namespace rmq
-{
-    class MessageQueue;
-
-    typedef struct
-    {
-        long long minOffset;
-        long long maxOffset;
-        long long lastUpdateTimestamp;
-    } TopicOffset;
-
-    class TopicStatsTable
-    {
-    public:
-        std::map<MessageQueue*, TopicOffset> getOffsetTable()
-        {
-            return m_offsetTable;
-        }
-
-        void setOffsetTable(const std::map<MessageQueue*, TopicOffset>& offsetTable)
-        {
-            m_offsetTable = offsetTable;
-        }
-
-    private:
-        std::map<MessageQueue*, TopicOffset> m_offsetTable;
-    };
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/common/UtilAll.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/common/UtilAll.h b/rocketmq-client4cpp/src/common/UtilAll.h
deleted file mode 100755
index b239edb..0000000
--- a/rocketmq-client4cpp/src/common/UtilAll.h
+++ /dev/null
@@ -1,608 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#ifndef __UTILALL_H__
-#define __UTILALL_H__
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
-#include <time.h>
-
-#include <string>
-#include <sstream>
-#include <vector>
-#include <list>
-#include <set>
-#include <map>
-
-#include "RocketMQClient.h"
-#include "zlib.h"
-#include "json/value.h"
-#include "json/writer.h"
-
-namespace rmq
-{
-    const std::string WHITESPACE = " \t\r\n";
-    const int CHUNK = 8192;
-	const std::string yyyy_MM_dd_HH_mm_ss = "yyyy-MM-dd HH:mm:ss";
-    const std::string yyyy_MM_dd_HH_mm_ss_SSS = "yyyy-MM-dd#HH:mm:ss:SSS";
-    const std::string yyyyMMddHHmmss = "yyyyMMddHHmmss";
-
-    class UtilAll
-    {
-    public:
-        static pid_t getPid()
-        {
-            static __thread pid_t pid = 0;
-            if (!pid || pid != getpid())
-            {
-                pid = getpid();
-            }
-            return pid;
-        }
-
-        static pid_t getTid()
-        {
-            static __thread pid_t pid = 0;
-            static __thread pid_t tid = 0;
-            if (!pid || !tid || pid != getpid())
-            {
-                pid = getpid();
-                tid = syscall(__NR_gettid);
-            }
-            return tid;
-        }
-
-        static int Split(std::vector<std::string>& out, const std::string& in, const std::string& delimiter)
-        {
-            std::string::size_type left = 0;
-            for (size_t i = 1; i < in.size(); i++)
-            {
-                std::string::size_type right = in.find(delimiter, left);
-
-                if (right == std::string::npos)
-                {
-                    break;
-                }
-
-                out.push_back(in.substr(left, right - left));
-
-                left = right + delimiter.length();
-            }
-
-            out.push_back(in.substr(left));
-
-            return out.size();
-        }
-
-        static int Split(std::vector<std::string>& out, const std::string& in, const char delimiter)
-        {
-            std::string::size_type left = 0;
-            for (size_t i = 1; i < in.size(); i++)
-            {
-                std::string::size_type right = in.find(delimiter, left);
-
-                if (right == std::string::npos)
-                {
-                    break;
-                }
-
-                out.push_back(in.substr(left, right - left));
-
-                left = right + 1;
-            }
-
-            out.push_back(in.substr(left));
-
-            return out.size();
-        }
-
-        static std::string Trim(const std::string& str)
-        {
-            if (str.empty())
-            {
-                return str;
-            }
-
-            std::string::size_type left = str.find_first_not_of(WHITESPACE);
-
-            if (left == std::string::npos)
-            {
-                return "";
-            }
-
-            std::string::size_type right = str.find_last_not_of(WHITESPACE);
-
-            if (right == std::string::npos)
-            {
-                return str.substr(left);
-            }
-
-            return str.substr(left, right + 1 - left);
-        }
-
-        static bool isBlank(const std::string& str)
-        {
-            if (str.empty())
-            {
-                return true;
-            }
-
-            std::string::size_type left = str.find_first_not_of(WHITESPACE);
-
-            if (left == std::string::npos)
-            {
-                return true;
-            }
-
-            return false;
-        }
-
-        static int availableProcessors()
-        {
-            return 4;
-        }
-
-
-        static int hashCode(const char* pData, int len)
-        {
-            int h = 0;
-            if (pData != NULL && len > 0)
-            {
-                unsigned char c;
-                for (int i = 0; i < len; i++)
-                {
-                    c = (unsigned char)pData[i];
-                    h = 31 * h + c;
-                }
-            }
-
-            return h;
-        }
-
-        static int hashCode(const std::string& s)
-        {
-            return hashCode(s.c_str(), s.length());
-        }
-
-        static int hashCode(const char* pData)
-        {
-            return hashCode(std::string(pData));
-        }
-
-        static int hashCode(char x)
-        {
-            return x;
-        }
-
-        static int hashCode(unsigned char x)
-        {
-            return x;
-        }
-
-        static int hashCode(short x)
-        {
-            return x;
-        }
-
-        static int hashCode(unsigned short x)
-        {
-            return x;
-        }
-
-        static int hashCode(int x)
-        {
-            return x;
-        }
-
-        static int hashCode(unsigned int x)
-        {
-            return x;
-        }
-
-        static int hashCode(long x)
-        {
-            return x;
-        }
-
-        static int hashCode(unsigned long x)
-        {
-            return x;
-        }
-
-        template <typename T>
-        static int hashCode(const std::vector<T>& v)
-        {
-            int h = 0;
-            typeof(v.begin()) it = v.begin();
-            while (it != v.end())
-            {
-                h += hashCode(*it);
-                ++it;
-            }
-            return h;
-        }
-
-        template <typename T>
-        static int hashCode(const std::set<T>& v)
-        {
-            int h = 0;
-            typeof(v.begin()) it = v.begin();
-            while (it != v.end())
-            {
-                h += hashCode(*it);
-                ++it;
-            }
-            return h;
-        }
-
-		static std::string toString(Json::Value& json)
-		{
-			Json::FastWriter fastWriter;
-			return fastWriter.write(json);
-		}
-
-        template<typename T>
-        static std::string toString(const T& v)
-        {
-            std::ostringstream ss;
-            ss << v;
-            return ss.str();
-        }
-
-        template<typename T>
-        static std::string toString(const std::vector<T>& v)
-        {
-            std::string s;
-            s.append("[");
-            typeof(v.begin()) it = v.begin();
-            while (it != v.end())
-            {
-                s.append(toString(*it));
-                s.append(",");
-                ++it;
-            }
-			if (s.size() > 1)
-			{
-				s.erase(s.size() - 1, 1);
-			}
-            s.append("]");
-            return s;
-        }
-
-
-        template <typename T>
-        static std::string toString(const std::list<T>& v)
-        {
-            std::string s;
-            s.append("[");
-            typeof(v.begin()) it = v.begin();
-            while (it != v.end())
-            {
-                s.append(toString(*it));
-                s.append(",");
-                ++it;
-            }
-			if (s.size() > 1)
-			{
-				s.erase(s.size() - 1, 1);
-			}
-            s.append("]");
-
-            return s;
-        }
-
-        template <typename T>
-        static std::string toString(const std::set<T>& v)
-        {
-            std::string s;
-            s.append("[");
-            typeof(v.begin()) it = v.begin();
-            while (it != v.end())
-            {
-                s.append(toString(*it));
-                s.append(",");
-                ++it;
-            }
-			if (s.size() > 1)
-			{
-				s.erase(s.size() - 1, 1);
-			}
-            s.append("]");
-            return s;
-        }
-
-        template<typename K, typename V, typename D, typename A>
-        static std::string toString(const std::map<K, V, D, A>& v)
-        {
-            std::string s;
-            s.append("{");
-            typeof(v.begin()) it = v.begin();
-            while (it != v.end())
-            {
-                s.append(toString(it->first));
-                s.append("=");
-                s.append(toString(it->second));
-                s.append(",");
-                ++it;
-            }
-			if (s.size() > 1)
-			{
-				s.erase(s.size() - 1, 1);
-			}
-            s.append("}");
-            return s;
-        }
-
-        template<typename out_type, typename in_type>
-        static out_type convert(const in_type& t)
-        {
-            out_type result;
-            std::stringstream stream;
-            stream << t;
-            stream >> result;
-            return result;
-        }
-
-        static bool compress(const char* pIn, int inLen, unsigned char** pOut, int* pOutLen, int level)
-        {
-            int ret, flush;
-            int have;
-            z_stream strm;
-            unsigned char out[CHUNK];
-
-            /* allocate deflate state */
-            strm.zalloc = Z_NULL;
-            strm.zfree = Z_NULL;
-            strm.opaque = Z_NULL;
-            ret = deflateInit(&strm, level);
-            if (ret != Z_OK)
-            {
-                return false;
-            }
-
-            int outBufferLen = inLen;
-            unsigned char* outData = (unsigned char*)malloc(outBufferLen);
-            int left = inLen;
-            int used = 0;
-            int outDataLen = 0;
-
-            /* compress until end of buffer */
-            do
-            {
-                strm.avail_in = left > CHUNK ? CHUNK : left;
-                flush = left <= CHUNK ? Z_FINISH : Z_NO_FLUSH;
-                strm.next_in = (unsigned char*)pIn + used;
-                used += strm.avail_in;
-                left -= strm.avail_in;
-
-                /* run deflate() on input until output buffer not full, finish
-                compression if all of source has been read in */
-                do
-                {
-                    strm.avail_out = CHUNK;
-                    strm.next_out = out;
-                    ret = deflate(&strm, flush);    /* no bad return value */
-                    assert(ret != Z_STREAM_ERROR);  /* state not clobbered */
-                    have = CHUNK - strm.avail_out;
-
-                    if (outDataLen + have > outBufferLen)
-                    {
-                        outBufferLen = outDataLen + have;
-                        outBufferLen <<= 1;
-                        unsigned char* tmp = (unsigned char*)realloc(outData, outBufferLen);
-                        if (!tmp)
-                        {
-                            free(outData);
-                            return false;
-                        }
-
-                        outData = tmp;
-                    }
-
-                    memcpy(outData + outDataLen, out, have);
-                    outDataLen += have;
-
-                }
-                while (strm.avail_out == 0);
-                assert(strm.avail_in == 0);     /* all input will be used */
-
-                /* done when last data in file processed */
-            }
-            while (flush != Z_FINISH);
-            assert(ret == Z_STREAM_END);        /* stream will be complete */
-
-            *pOutLen = outDataLen;
-            *pOut = outData;
-
-            /* clean up and return */
-            (void)deflateEnd(&strm);
-            return true;
-        }
-
-        static bool decompress(const char* pIn, int inLen, unsigned char** pOut, int* pOutLen)
-        {
-            int ret;
-            int have;
-            z_stream strm;
-
-            unsigned char out[CHUNK];
-
-            /* allocate inflate state */
-            strm.zalloc = Z_NULL;
-            strm.zfree = Z_NULL;
-            strm.opaque = Z_NULL;
-            strm.avail_in = 0;
-            strm.next_in = Z_NULL;
-            ret = inflateInit(&strm);
-            if (ret != Z_OK)
-            {
-                return false;
-            }
-
-            int outBufferLen = inLen << 2;
-            unsigned char* outData = (unsigned char*)malloc(outBufferLen);
-
-            int left = inLen;
-            int used = 0;
-            int outDataLen = 0;
-
-            /* decompress until deflate stream ends or end of buffer */
-            do
-            {
-                strm.avail_in = left > CHUNK ? CHUNK : left;
-                if (strm.avail_in <= 0)
-                {
-                    break;
-                }
-
-                strm.next_in = (unsigned char*)pIn + used;
-                used += strm.avail_in;
-                left -= strm.avail_in;
-
-                /* run inflate() on input until output buffer not full */
-                do
-                {
-                    strm.avail_out = CHUNK;
-                    strm.next_out = out;
-                    ret = inflate(&strm, Z_NO_FLUSH);
-                    assert(ret != Z_STREAM_ERROR);  /* state not clobbered */
-                    switch (ret)
-                    {
-                        case Z_NEED_DICT:
-                            ret = Z_DATA_ERROR;     /* and fall through */
-                        case Z_DATA_ERROR:
-                        case Z_MEM_ERROR:
-                            (void)inflateEnd(&strm);
-                            free(outData);
-                            return false;
-                    }
-                    have = CHUNK - strm.avail_out;
-
-                    if (outDataLen + have > outBufferLen)
-                    {
-                        outBufferLen = outDataLen + have;
-                        outBufferLen <<= 1;
-                        unsigned char* tmp = (unsigned char*)realloc(outData, outBufferLen);
-                        if (!tmp)
-                        {
-                            free(outData);
-                            return false;
-                        }
-
-                        outData = tmp;
-                    }
-
-                    memcpy(outData + outDataLen, out, have);
-                    outDataLen += have;
-
-                }
-                while (strm.avail_out == 0);
-
-                /* done when inflate() says it's done */
-            }
-            while (ret != Z_STREAM_END);
-
-            /* clean up and return */
-            (void)inflateEnd(&strm);
-
-            if (ret == Z_STREAM_END)
-            {
-                *pOutLen = outDataLen;
-                *pOut = outData;
-
-                return true;
-            }
-            else
-            {
-                free(outData);
-
-                return false;
-            }
-        }
-
-        static unsigned long long hexstr2ull(const char* str)
-        {
-            char* end;
-            return strtoull(str, &end, 16);
-        }
-
-		static long long str2ll(const char *str)
-		{
-			return atoll(str);
-		}
-
-
-		static std::string tm2str(const time_t& t, const std::string& sFormat)
-		{
-			struct tm stTm;
-			localtime_r(&t, &stTm);
-
-			char sTimeString[255] = "\0";
-			strftime(sTimeString, sizeof(sTimeString), sFormat.c_str(), &stTm);
-
-			return std::string(sTimeString);
-		}
-
-		static std::string now2str(const std::string& sFormat)
-		{
-			time_t t = time(NULL);
-			return tm2str(t, sFormat.c_str());
-		}
-
-		static std::string now2str()
-		{
-			return now2str("%Y-%m-%d %H:%M:%S");
-		}
-
-		static int64_t now2ms()
-		{
-			struct timeval tv;
-			gettimeofday(&tv, NULL);
-			return tv.tv_sec * (int64_t)1000 + tv.tv_usec / 1000;
-		}
-
-		static int64_t now2us()
-		{
-			struct timeval tv;
-			gettimeofday(&tv, NULL);
-			return tv.tv_sec * (int64_t)1000*1000 + tv.tv_usec;
-		}
-
-		static int str2tm(const std::string &sString, const std::string &sFormat, struct tm &stTm)
-		{
-			char *p = strptime(sString.c_str(), sFormat.c_str(), &stTm);
-    		return (p != NULL) ? 0 : -1;
-		}
-
-		static time_t str2tm(const std::string &sString, const std::string &sFormat)
-		{
-			struct tm stTm;
-			if (str2tm(sString, sFormat, stTm) == 0)
-			{
-				time_t t = mktime(&stTm);
-				return t;
-			}
-			else
-			{
-				return -1;
-			}
-		}
-    };
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/common/Validators.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/common/Validators.cpp b/rocketmq-client4cpp/src/common/Validators.cpp
deleted file mode 100755
index 29f36a0..0000000
--- a/rocketmq-client4cpp/src/common/Validators.cpp
+++ /dev/null
@@ -1,132 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang, kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#include "Validators.h"
-
-#include <stdlib.h>
-#include <stdio.h>
-#include "MQClientException.h"
-#include "UtilAll.h"
-#include "MixAll.h"
-#include "Message.h"
-#include "MQProtos.h"
-#include "DefaultMQProducer.h"
-
-namespace rmq
-{
-
-const std::string Validators::validPatternStr = "^[a-zA-Z0-9_-]+$";
-const size_t Validators::CHARACTER_MAX_LENGTH = 255;
-
-bool Validators::regularExpressionMatcher(const std::string& origin, const std::string& patternStr)
-{
-    if (UtilAll::isBlank(origin))
-    {
-        return false;
-    }
-
-    if (UtilAll::isBlank(patternStr))
-    {
-        return true;
-    }
-
-    //Pattern pattern = Pattern.compile(patternStr);
-    //Matcher matcher = pattern.matcher(origin);
-
-    //return matcher.matches();
-    return true;
-}
-
-std::string Validators::getGroupWithRegularExpression(const std::string& origin, const std::string& patternStr)
-{
-    /*Pattern pattern = Pattern.compile(patternStr);
-    Matcher matcher = pattern.matcher(origin);
-    while (matcher.find()) {
-    return matcher.group(0);
-    }*/
-    return "";
-}
-
-void Validators::checkTopic(const std::string& topic)
-{
-    if (UtilAll::isBlank(topic))
-    {
-        THROW_MQEXCEPTION(MQClientException, "the specified topic is blank", -1);
-    }
-
-    if (topic.length() > CHARACTER_MAX_LENGTH)
-    {
-        THROW_MQEXCEPTION(MQClientException, "the specified topic is longer than topic max length 255.", -1);
-    }
-
-    // Topic�����Ƿ��뱣���ֶγ�ͻ
-    if (topic == MixAll::DEFAULT_TOPIC)
-    {
-        THROW_MQEXCEPTION(MQClientException, "the topic[" + topic + "] is conflict with default topic.", -1);
-    }
-
-    if (!regularExpressionMatcher(topic, validPatternStr))
-    {
-        std::string str;
-        str = "the specified topic[" + topic + "] contains illegal characters, allowing only" + validPatternStr;
-
-        THROW_MQEXCEPTION(MQClientException, str.c_str(), -1);
-    }
-}
-
-void Validators::checkGroup(const std::string& group)
-{
-    if (UtilAll::isBlank(group))
-    {
-        THROW_MQEXCEPTION(MQClientException, "the specified group is blank", -1);
-    }
-
-    if (!regularExpressionMatcher(group, validPatternStr))
-    {
-        std::string str;
-        str = "the specified group[" + group + "] contains illegal characters, allowing only" + validPatternStr;
-
-        THROW_MQEXCEPTION(MQClientException, str.c_str(), -1);
-    }
-    if (group.length() > CHARACTER_MAX_LENGTH)
-    {
-        THROW_MQEXCEPTION(MQClientException, "the specified group is longer than group max length 255.", -1);
-    }
-}
-
-void Validators::checkMessage(const Message& msg, DefaultMQProducer* pDefaultMQProducer)
-{
-    checkTopic(msg.getTopic());
-
-    //// body
-    if (msg.getBody() == NULL)
-    {
-        THROW_MQEXCEPTION(MQClientException, "the message body is null", MESSAGE_ILLEGAL_VALUE);
-    }
-
-    if (msg.getBodyLen() == 0)
-    {
-        THROW_MQEXCEPTION(MQClientException, "the message body length is zero", MESSAGE_ILLEGAL_VALUE);
-    }
-
-    if (msg.getBodyLen() > pDefaultMQProducer->getMaxMessageSize())
-    {
-        char info[256];
-        snprintf(info, sizeof(info), "the message body size over max value, MAX: %d", pDefaultMQProducer->getMaxMessageSize());
-        THROW_MQEXCEPTION(MQClientException, info, MESSAGE_ILLEGAL_VALUE);
-    }
-}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/common/Validators.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/common/Validators.h b/rocketmq-client4cpp/src/common/Validators.h
deleted file mode 100755
index 36ab299..0000000
--- a/rocketmq-client4cpp/src/common/Validators.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang, kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#ifndef __VALIDATORST_H__
-#define  __VALIDATORST_H__
-
-#include <string>
-
-namespace rmq
-{
-    class MQClientException;
-    class DefaultMQProducer;
-    class Message;
-
-    /**
-    * Validator class
-    *
-    * @author manhong.yqd<jo...@gmail.com>
-    * @since 2013-8-28
-    */
-    class Validators
-    {
-    public:
-        static bool regularExpressionMatcher(const std::string& origin, const std::string& patternStr);
-        static std::string getGroupWithRegularExpression(const std::string& origin, const std::string& patternStr);
-
-        static void checkTopic(const std::string& topic);
-        static void checkGroup(const std::string& group);
-        static void checkMessage(const Message& msg, DefaultMQProducer* pDefaultMQProducer);
-
-    public:
-        static const std::string validPatternStr;
-        static const size_t CHARACTER_MAX_LENGTH;
-    };
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/common/VirtualEnvUtil.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/common/VirtualEnvUtil.cpp b/rocketmq-client4cpp/src/common/VirtualEnvUtil.cpp
deleted file mode 100755
index c68bfc8..0000000
--- a/rocketmq-client4cpp/src/common/VirtualEnvUtil.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang, kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#include "VirtualEnvUtil.h"
-
-#include <stdlib.h>
-#include <stdio.h>
-#include "UtilAll.h"
-
-namespace rmq
-{
-
-const char* VirtualEnvUtil::VIRTUAL_APPGROUP_PREFIX = "%%PROJECT_%s%%";
-
-std::string VirtualEnvUtil::buildWithProjectGroup(const std::string& origin, const std::string& projectGroup)
-{
-    if (!UtilAll::isBlank(projectGroup))
-    {
-        char prefix[1024];
-        snprintf(prefix, sizeof(prefix), VIRTUAL_APPGROUP_PREFIX, projectGroup.c_str());
-
-        if (origin.find_last_of(prefix) == std::string::npos)
-        {
-            return origin + prefix;
-        }
-        else
-        {
-            return origin;
-        }
-    }
-    else
-    {
-        return origin;
-    }
-}
-
-
-std::string VirtualEnvUtil::clearProjectGroup(const std::string& origin, const std::string& projectGroup)
-{
-    char prefix[1024];
-    snprintf(prefix, sizeof(prefix), VIRTUAL_APPGROUP_PREFIX, projectGroup.c_str());
-    std::string::size_type pos = origin.find_last_of(prefix);
-
-    if (!UtilAll::isBlank(prefix) && pos != std::string::npos)
-    {
-        return origin.substr(0, pos);
-    }
-    else
-    {
-        return origin;
-    }
-}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/common/VirtualEnvUtil.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/common/VirtualEnvUtil.h b/rocketmq-client4cpp/src/common/VirtualEnvUtil.h
deleted file mode 100755
index 10ca0cd..0000000
--- a/rocketmq-client4cpp/src/common/VirtualEnvUtil.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang, kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __VIRTUALENVUTIL_H__
-#define __VIRTUALENVUTIL_H__
-
-#include <string>
-
-namespace rmq
-{
-    /**
-    * VirtualEnv API
-    *
-    * @author manhong.yqd<jo...@gmail.com>
-    * @since 2013-8-26
-    */
-    class VirtualEnvUtil
-    {
-    public:
-        static std::string buildWithProjectGroup(const std::string& origin, const std::string& projectGroup);
-        static std::string clearProjectGroup(const std::string& origin, const std::string& projectGroup);
-
-    public:
-        static const char* VIRTUAL_APPGROUP_PREFIX;
-    };
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/consumer/AllocateMessageQueueStrategyInner.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/consumer/AllocateMessageQueueStrategyInner.h b/rocketmq-client4cpp/src/consumer/AllocateMessageQueueStrategyInner.h
deleted file mode 100755
index 49e1e7c..0000000
--- a/rocketmq-client4cpp/src/consumer/AllocateMessageQueueStrategyInner.h
+++ /dev/null
@@ -1,205 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#ifndef __ALLOCATEMESSAGEQUEUESTRATEGYINNER_H__
-#define __ALLOCATEMESSAGEQUEUESTRATEGYINNER_H__
-
-#include <algorithm>
-
-#include "AllocateMessageQueueStrategy.h"
-#include "MQClientException.h"
-#include "UtilAll.h"
-
-
-namespace rmq
-{
-
-    class AllocateMessageQueueAveragely : public AllocateMessageQueueStrategy
-    {
-    public:
-        virtual ~AllocateMessageQueueAveragely() {}
-        virtual std::vector<MessageQueue>* allocate(
-				const std::string& consumerGroup,
-				const std::string& currentCID,
-                std::vector<MessageQueue>& mqAll,
-                std::list<std::string>& cidAll)
-        {
-            if (currentCID.empty())
-            {
-                THROW_MQEXCEPTION(MQClientException, "currentCID is empty", -1);
-            }
-
-            if (mqAll.empty())
-            {
-                THROW_MQEXCEPTION(MQClientException, "mqAll is empty", -1);
-            }
-
-            if (cidAll.empty())
-            {
-                THROW_MQEXCEPTION(MQClientException, "cidAll is empty", -1);
-            }
-
-            int index = -1;
-            int cidAllSize = cidAll.size();
-
-            std::list<std::string>::iterator it = cidAll.begin();
-            for (int i = 0; it != cidAll.end(); it++, i++)
-            {
-                if (*it == currentCID)
-                {
-                    index = i;
-                    break;
-                }
-            }
-
-            if (index == -1)
-            {
-				RMQ_ERROR("[BUG] ConsumerGroup: {%s} The consumerId: {%s} not in cidAll: {%s}", //
-                    consumerGroup.c_str(),
-                    currentCID.c_str(),
-                    UtilAll::toString(cidAll).c_str());
-                return NULL;
-            }
-
-            int mqAllSize = mqAll.size();
-            int mod = mqAllSize % cidAllSize;
-            int averageSize =
-                mqAllSize <= cidAllSize ? 1 : (mod > 0 && index < mod ? mqAllSize / cidAllSize
-                                               + 1 : mqAllSize / cidAllSize);
-            int startIndex = (mod > 0 && index < mod) ? index * averageSize : index * averageSize + mod;
-
-            std::vector<MessageQueue>* result = new std::vector<MessageQueue>();
-            int range = std::min<int>(averageSize, mqAllSize - startIndex);
-
-            for (int i = 0; i < range; i++)
-            {
-                result->push_back(mqAll.at((startIndex + i) % mqAllSize));
-            }
-
-            return result;
-        }
-
-        virtual std::string getName()
-        {
-            return "AVG";
-        }
-    };
-
-
-    class AllocateMessageQueueAveragelyByCircle : public AllocateMessageQueueStrategy
-    {
-    public:
-        virtual ~AllocateMessageQueueAveragelyByCircle() {}
-        virtual std::vector<MessageQueue>* allocate(
-				const std::string& consumerGroup,
-				const std::string& currentCID,
-                std::vector<MessageQueue>& mqAll,
-                std::list<std::string>& cidAll)
-        {
-            if (currentCID.empty())
-            {
-                THROW_MQEXCEPTION(MQClientException, "currentCID is empty", -1);
-            }
-
-            if (mqAll.empty())
-            {
-                THROW_MQEXCEPTION(MQClientException, "mqAll is empty", -1);
-            }
-
-            if (cidAll.empty())
-            {
-                THROW_MQEXCEPTION(MQClientException, "cidAll is empty", -1);
-            }
-
-            int index = -1;
-            std::list<std::string>::iterator it = cidAll.begin();
-            for (int i = 0; it != cidAll.end(); it++, i++)
-            {
-                if (*it == currentCID)
-                {
-                    index = i;
-                    break;
-                }
-            }
-
-            if (index == -1)
-            {
-				RMQ_ERROR("[BUG] ConsumerGroup: {%s} The consumerId: {%s} not in cidAll: {%s}", //
-                    consumerGroup.c_str(),
-                    currentCID.c_str(),
-                    UtilAll::toString(cidAll).c_str());
-                return NULL;
-            }
-
-			std::vector<MessageQueue>* result = new std::vector<MessageQueue>();
-	        for (int i = index; i < (int)mqAll.size(); i++)
-			{
-	            if (i % (int)cidAll.size() == index)
-				{
-					result->push_back(mqAll.at(i));
-	            }
-	        }
-
-	        return result;
-        }
-
-        virtual std::string getName()
-        {
-            return "AVG_BY_CIRCLE";
-        }
-    };
-
-
-    class AllocateMessageQueueByConfig : public AllocateMessageQueueStrategy
-    {
-    public:
-        virtual ~AllocateMessageQueueByConfig() {}
-        virtual std::vector<MessageQueue>* allocate(
-				const std::string& consumerGroup,
-				const std::string& currentCID,
-                std::vector<MessageQueue>& mqAll,
-                std::list<std::string>& cidAll)
-        {
-            return NULL;
-        }
-
-        virtual std::string getName()
-        {
-            return "CONFIG";
-        }
-    };
-
-
-    class AllocateMessageQueueByMachineRoom : public AllocateMessageQueueStrategy
-    {
-    public:
-        virtual ~AllocateMessageQueueByMachineRoom() {}
-        virtual std::vector<MessageQueue>* allocate(
-				const std::string& consumerGroup,
-				const std::string& currentCID,
-                std::vector<MessageQueue>& mqAll,
-                std::list<std::string>& cidAll)
-        {
-            return NULL;
-        }
-
-        virtual std::string getName()
-        {
-            return "MACHINE_ROOM";
-        }
-    };
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/consumer/ConsumeMessageConcurrentlyService.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/consumer/ConsumeMessageConcurrentlyService.cpp b/rocketmq-client4cpp/src/consumer/ConsumeMessageConcurrentlyService.cpp
deleted file mode 100755
index 7550acb..0000000
--- a/rocketmq-client4cpp/src/consumer/ConsumeMessageConcurrentlyService.cpp
+++ /dev/null
@@ -1,476 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#include "ConsumeMessageConcurrentlyService.h"
-
-#include "DefaultMQPushConsumerImpl.h"
-#include "MessageListener.h"
-#include "MessageQueue.h"
-#include "RebalanceImpl.h"
-#include "DefaultMQPushConsumer.h"
-#include "MixAll.h"
-#include "KPRUtil.h"
-#include "UtilAll.h"
-#include "OffsetStore.h"
-
-namespace rmq
-{
-
-
-class SubmitConsumeRequestLater : public kpr::TimerHandler
-{
-public:
-    SubmitConsumeRequestLater(std::list<MessageExt*>& msgs,
-                              ProcessQueue* pProcessQueue,
-                              MessageQueue messageQueue,
-                              ConsumeMessageConcurrentlyService* pService)
-        : m_msgs(msgs),
-          m_pProcessQueue(pProcessQueue),
-          m_messageQueue(messageQueue),
-          m_pService(pService)
-    {
-
-    }
-
-    void OnTimeOut(unsigned int timerID)
-    {
-    	try
-    	{
-        	m_pService->submitConsumeRequest(m_msgs, m_pProcessQueue, m_messageQueue, true);
-        }
-        catch(...)
-        {
-        	RMQ_ERROR("SubmitConsumeRequestLater OnTimeOut exception");
-        }
-
-        delete this;
-    }
-
-private:
-    std::list<MessageExt*> m_msgs;
-    ProcessQueue* m_pProcessQueue;
-    MessageQueue m_messageQueue;
-    ConsumeMessageConcurrentlyService* m_pService;
-};
-
-
-class CleanExpireMsgTask : public kpr::TimerHandler
-{
-public:
-    CleanExpireMsgTask(ConsumeMessageConcurrentlyService* pService)
-        : m_pService(pService)
-    {
-
-    }
-
-    void OnTimeOut(unsigned int timerID)
-    {
-    	try
-    	{
-        	m_pService->cleanExpireMsg();
-        }
-        catch(...)
-        {
-        	RMQ_ERROR("CleanExpireMsgTask OnTimeOut exception");
-        }
-    }
-
-private:
-    ConsumeMessageConcurrentlyService* m_pService;
-};
-
-
-
-ConsumeMessageConcurrentlyService::ConsumeMessageConcurrentlyService(
-    DefaultMQPushConsumerImpl* pDefaultMQPushConsumerImpl,
-    MessageListenerConcurrently* pMessageListener)
-{
-    m_pDefaultMQPushConsumerImpl = pDefaultMQPushConsumerImpl;
-    m_pMessageListener = pMessageListener;
-    m_pDefaultMQPushConsumer = m_pDefaultMQPushConsumerImpl->getDefaultMQPushConsumer();
-    m_consumerGroup = m_pDefaultMQPushConsumer->getConsumerGroup();
-    m_pConsumeExecutor = new kpr::ThreadPool("ConsumeMessageThreadPool", 5,
-    m_pDefaultMQPushConsumer->getConsumeThreadMin(), m_pDefaultMQPushConsumer->getConsumeThreadMax());
-    m_pScheduledExecutorService = new kpr::TimerThread("ConsumeMessageConcurrentlyService", 1000);
-    m_pCleanExpireMsgExecutors = new kpr::TimerThread("CleanExpireMsgService", 1000);
-	m_pCleanExpireMsgTask = new CleanExpireMsgTask(this);
-}
-
-ConsumeMessageConcurrentlyService::~ConsumeMessageConcurrentlyService()
-{
-	delete m_pCleanExpireMsgTask;
-}
-
-
-void ConsumeMessageConcurrentlyService::start()
-{
-	m_pCleanExpireMsgExecutors->RegisterTimer(60 * 1000, 60 * 1000, m_pCleanExpireMsgTask, true);
-    m_pScheduledExecutorService->Start();
-    m_pCleanExpireMsgExecutors->Start();
-}
-
-void ConsumeMessageConcurrentlyService::shutdown()
-{
-    m_pConsumeExecutor->Destroy();
-    m_pScheduledExecutorService->Stop();
-    m_pScheduledExecutorService->Join();
-
-    m_pCleanExpireMsgExecutors->Stop();
-    m_pCleanExpireMsgExecutors->Join();
-}
-
-
-void ConsumeMessageConcurrentlyService::cleanExpireMsg()
-{
-	kpr::ScopedRLock<kpr::RWMutex> lock(m_pDefaultMQPushConsumerImpl->getRebalanceImpl()->getProcessQueueTableLock());
-	std::map<MessageQueue, ProcessQueue*>& processQueueTable
-		= m_pDefaultMQPushConsumerImpl->getRebalanceImpl()->getProcessQueueTable();
-	RMQ_FOR_EACH(processQueueTable, it)
-	{
-		ProcessQueue* pq = it->second;
-		if (!pq->isDropped())
-		{
-        	pq->cleanExpiredMsg(m_pDefaultMQPushConsumer);
-        }
-	}
-}
-
-
-ConsumerStat& ConsumeMessageConcurrentlyService::getConsumerStat()
-{
-    return m_pDefaultMQPushConsumerImpl->getConsumerStatManager()->getConsumertat();
-}
-
-bool ConsumeMessageConcurrentlyService::sendMessageBack(MessageExt& msg,
-        ConsumeConcurrentlyContext& context)
-{
-    try
-    {
-        m_pDefaultMQPushConsumerImpl->sendMessageBack(msg,
-        	context.delayLevelWhenNextConsume, context.messageQueue.getBrokerName());
-        return true;
-    }
-    catch (...)
-    {
-		RMQ_ERROR("sendMessageBack exception, group: %s, msg: %s",
-			m_consumerGroup.c_str(), msg.toString().c_str());
-    }
-
-    return false;
-}
-
-void ConsumeMessageConcurrentlyService::submitConsumeRequestLater(std::list<MessageExt*>& msgs,
-        ProcessQueue* pProcessQueue,
-        const MessageQueue& messageQueue)
-{
-    SubmitConsumeRequestLater* sc = new SubmitConsumeRequestLater(msgs, pProcessQueue, messageQueue, this);
-    m_pScheduledExecutorService->RegisterTimer(0, 5000, sc, false);
-}
-
-void ConsumeMessageConcurrentlyService::submitConsumeRequest(std::list<MessageExt*>& msgs,
-        ProcessQueue* pProcessQueue,
-        const MessageQueue& messageQueue,
-        bool dispathToConsume)
-{
-	size_t consumeBatchSize = m_pDefaultMQPushConsumer->getConsumeMessageBatchMaxSize();
-
-	RMQ_DEBUG("submitConsumeRequest begin, msgs.size=%d, messageQueue=%s, consumeBatchSize=%d, dispathToConsume=%d",
-		(int)msgs.size(), messageQueue.toString().c_str(), (int)consumeBatchSize, dispathToConsume
-    );
-
-    if (msgs.size() <= consumeBatchSize)
-    {
-        kpr::ThreadPoolWorkPtr consumeRequest = new ConsumeConcurrentlyRequest(msgs, pProcessQueue, messageQueue, this);
-        m_pConsumeExecutor->AddWork(consumeRequest);
-    }
-    else
-    {
-        std::list<MessageExt*>::iterator it = msgs.begin();
-        for (; it != msgs.end();)
-        {
-            std::list<MessageExt*> msgThis;
-            for (size_t i = 0; i < consumeBatchSize; i++, it++)
-            {
-                if (it != msgs.end())
-                {
-                    msgThis.push_back(*it);
-                }
-                else
-                {
-                    break;
-                }
-            }
-
-            kpr::ThreadPoolWorkPtr consumeRequest = new ConsumeConcurrentlyRequest(msgThis, pProcessQueue, messageQueue, this);
-            m_pConsumeExecutor->AddWork(consumeRequest);
-        }
-    }
-
-    RMQ_DEBUG("submitConsumeRequest end");
-}
-
-void ConsumeMessageConcurrentlyService::updateCorePoolSize(int corePoolSize)
-{
-	//todo
-}
-
-void ConsumeMessageConcurrentlyService::processConsumeResult(ConsumeConcurrentlyStatus status,
-        ConsumeConcurrentlyContext& context,
-        ConsumeConcurrentlyRequest& consumeRequest)
-{
-    int ackIndex = context.ackIndex;
-
-    if (consumeRequest.getMsgs().empty())
-    {
-        return;
-    }
-
-    int msgsSize = consumeRequest.getMsgs().size();
-
-    switch (status)
-    {
-        case CONSUME_SUCCESS:
-        {
-            if (ackIndex >= msgsSize)
-            {
-                ackIndex = msgsSize - 1;
-            }
-
-            int ok = ackIndex + 1;
-            int failed = msgsSize - ok;
-            getConsumerStat().consumeMsgOKTotal.fetchAndAdd(ok);
-            getConsumerStat().consumeMsgFailedTotal.fetchAndAdd(failed);
-        }
-
-        break;
-        case RECONSUME_LATER:
-            ackIndex = -1;
-            getConsumerStat().consumeMsgFailedTotal.fetchAndAdd(msgsSize);
-            break;
-        default:
-            break;
-    }
-
-    std::list<MessageExt*>& msgs = consumeRequest.getMsgs();
-    std::list<MessageExt*>::iterator it = msgs.begin();
-
-    for (int i = 0; i < ackIndex + 1 && it != msgs.end(); i++)
-    {
-        it++;
-    }
-
-    switch (m_pDefaultMQPushConsumer->getMessageModel())
-    {
-        case BROADCASTING:
-            for (; it != msgs.end(); it++)
-            {
-                MessageExt* msg = *it;
-                RMQ_WARN("BROADCASTING, the message consume failed, drop it, %s", msg->toString().c_str());
-            }
-            break;
-        case CLUSTERING:
-        {
-            std::list<MessageExt*> msgBackFailed;
-            for (; it != msgs.end(); it++)
-            {
-                MessageExt* msg = *it;
-                bool result = sendMessageBack(*msg, context);
-                if (!result)
-                {
-                    msg->setReconsumeTimes(msg->getReconsumeTimes() + 1);
-                    msgBackFailed.push_back(msg);
-                }
-            }
-
-            if (!msgBackFailed.empty())
-            {
-                it = msgs.begin();
-
-                for (; it != msgs.end();)
-                {
-                    bool find = false;
-                    std::list<MessageExt*>::iterator itFailed = msgBackFailed.begin();
-                    for (; itFailed != msgBackFailed.end(); itFailed++)
-                    {
-                        if (*it == *itFailed)
-                        {
-                            it = msgs.erase(it);
-                            find = true;
-                            break;
-                        }
-                    }
-
-                    if (!find)
-                    {
-                        it++;
-                    }
-                }
-
-                submitConsumeRequestLater(msgBackFailed, consumeRequest.getProcessQueue(),
-                                          consumeRequest.getMessageQueue());
-            }
-        }
-        break;
-        default:
-            break;
-    }
-
-    long long offset = consumeRequest.getProcessQueue()->removeMessage(consumeRequest.getMsgs());
-    if (offset >= 0 && !(consumeRequest.getProcessQueue()->isDropped()))
-    {
-        m_pDefaultMQPushConsumerImpl->getOffsetStore()->updateOffset(consumeRequest.getMessageQueue(),
-                offset, true);
-    }
-}
-
-std::string& ConsumeMessageConcurrentlyService::getConsumerGroup()
-{
-    return m_consumerGroup;
-}
-
-MessageListenerConcurrently* ConsumeMessageConcurrentlyService::getMessageListener()
-{
-    return m_pMessageListener;
-}
-
-DefaultMQPushConsumerImpl* ConsumeMessageConcurrentlyService::getDefaultMQPushConsumerImpl()
-{
-    return m_pDefaultMQPushConsumerImpl;
-}
-
-ConsumeConcurrentlyRequest::ConsumeConcurrentlyRequest(std::list<MessageExt*>& msgs,
-        ProcessQueue* pProcessQueue,
-        const MessageQueue& messageQueue,
-        ConsumeMessageConcurrentlyService* pService)
-{
-	m_msgs = msgs;
-	m_pProcessQueue = pProcessQueue;
-	m_pService = pService;
-    m_messageQueue = messageQueue;
-}
-
-ConsumeConcurrentlyRequest::~ConsumeConcurrentlyRequest()
-{
-	m_msgs.clear();
-}
-
-void ConsumeConcurrentlyRequest::Do()
-{
-	RMQ_DEBUG("consumeMessage begin, m_msgs.size=%d", (int)m_msgs.size());
-
-    if (m_pProcessQueue->isDropped())
-    {
-        RMQ_WARN("the message queue not be able to consume, because it's droped, {%s}",
-        	m_messageQueue.toString().c_str());
-        return;
-    }
-
-	try
-	{
-	    MessageListenerConcurrently* listener = m_pService->getMessageListener();
-	    ConsumeConcurrentlyContext context(m_messageQueue);
-	    ConsumeConcurrentlyStatus status = RECONSUME_LATER;
-
-	    ConsumeMessageContext consumeMessageContext;
-	    if (m_pService->getDefaultMQPushConsumerImpl()->hasHook())
-	    {
-	        consumeMessageContext.consumerGroup = m_pService->getConsumerGroup();
-	        consumeMessageContext.mq = m_messageQueue;
-	        consumeMessageContext.msgList = m_msgs;
-	        consumeMessageContext.success = false;
-	        m_pService->getDefaultMQPushConsumerImpl()->executeHookBefore(consumeMessageContext);
-	    }
-
-	    long long beginTimestamp = KPRUtil::GetCurrentTimeMillis();
-	    try
-	    {
-	        resetRetryTopic(m_msgs);
-	        if (!m_msgs.empty())
-	        {
-	        	std::list<MessageExt*>::iterator it = m_msgs.begin();
-			    for (; it != m_msgs.end(); it++)
-			    {
-			        MessageExt* msg = (*it);
-			        msg->putProperty(Message::PROPERTY_CONSUME_START_TIMESTAMP,
-			        	UtilAll::toString(KPRUtil::GetCurrentTimeMillis()));
-			    }
-            }
-	        status = listener->consumeMessage(m_msgs, context);
-	    }
-	    catch (...)
-	    {
-	        RMQ_WARN("consumeMessage exception, Group: {%s} Msgs: {%d} MQ: {%s}",
-	        	m_pService->getConsumerGroup().c_str(),
-	        	(int)m_msgs.size(),
-	        	m_messageQueue.toString().c_str()
-	        );
-	    }
-
-	    long long consumeRT = KPRUtil::GetCurrentTimeMillis() - beginTimestamp;
-
-	    if (m_pService->getDefaultMQPushConsumerImpl()->hasHook())
-	    {
-	        consumeMessageContext.success = (status == CONSUME_SUCCESS);
-	        m_pService->getDefaultMQPushConsumerImpl()->executeHookAfter(consumeMessageContext);
-	    }
-
-	    m_pService->getConsumerStat().consumeMsgRTTotal.fetchAndAdd(consumeRT);
-	    bool updated = MixAll::compareAndIncreaseOnly(m_pService->getConsumerStat().consumeMsgRTMax, consumeRT);
-	    if (updated)
-	    {
-	        RMQ_WARN("consumeMessage RT new max: %lld, Group: %s, Msgs: %d, MQ: %s",
-	        	consumeRT,
-	        	m_pService->getConsumerGroup().c_str(),
-	        	(int)m_msgs.size(),
-	        	m_messageQueue.toString().c_str()
-	        );
-	    }
-
-		if (!m_pProcessQueue->isDropped())
-		{
-	    	m_pService->processConsumeResult(status, context, *this);
-	    }
-	    else
-	    {
-	    	RMQ_WARN("processQueue is dropped without process consume result, messageQueue={%s}, msgs.size={%d}",
-	        	m_messageQueue.toString().c_str(), (int)m_msgs.size());
-	    }
-	}
-	catch(...)
-	{
-		RMQ_WARN("ConsumeConcurrentlyRequest exception");
-	}
-	RMQ_DEBUG("consumeMessage end, m_msgs.size=%d", (int)m_msgs.size());
-
-    return;
-}
-
-void ConsumeConcurrentlyRequest::resetRetryTopic(std::list<MessageExt*>& msgs)
-{
-    std::string groupTopic = MixAll::getRetryTopic(m_pService->getConsumerGroup());
-    std::list<MessageExt*>::iterator it = msgs.begin();
-
-    for (; it != msgs.end(); it++)
-    {
-        MessageExt* msg = (*it);
-        std::string retryTopic = msg->getProperty(Message::PROPERTY_RETRY_TOPIC);
-        if (!retryTopic.empty() && groupTopic == msg->getTopic())
-        {
-            msg->setTopic(retryTopic);
-        }
-    }
-}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/consumer/ConsumeMessageConcurrentlyService.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/consumer/ConsumeMessageConcurrentlyService.h b/rocketmq-client4cpp/src/consumer/ConsumeMessageConcurrentlyService.h
deleted file mode 100755
index acb7538..0000000
--- a/rocketmq-client4cpp/src/consumer/ConsumeMessageConcurrentlyService.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __CONSUMEMESSAGECONCURRENTLYSERVICE_H__
-#define __CONSUMEMESSAGECONCURRENTLYSERVICE_H__
-
-#include "ConsumeMessageService.h"
-
-#include <list>
-#include <string>
-#include "MessageQueueLock.h"
-#include "ConsumerStatManage.h"
-#include "MessageExt.h"
-#include "MessageListener.h"
-#include "ProcessQueue.h"
-#include "ThreadPool.h"
-#include "TimerThread.h"
-
-namespace rmq
-{
-  class DefaultMQPushConsumerImpl;
-  class DefaultMQPushConsumer;
-  class MessageListenerConcurrently;
-  class ConsumeMessageConcurrentlyService;
-
-  class ConsumeConcurrentlyRequest: public kpr::ThreadPoolWork
-  {
-  public:
-      ConsumeConcurrentlyRequest(std::list<MessageExt*>& msgs,
-                                 ProcessQueue* pProcessQueue,
-                                 const MessageQueue& messageQueue,
-                                 ConsumeMessageConcurrentlyService* pService);
-      ~ConsumeConcurrentlyRequest();
-      virtual void Do();
-
-      std::list<MessageExt*>& getMsgs()
-      {
-          return m_msgs;
-      }
-
-      ProcessQueue* getProcessQueue()
-      {
-          return m_pProcessQueue;
-      }
-
-      MessageQueue getMessageQueue()
-      {
-          return m_messageQueue;
-      }
-
-  private:
-      void resetRetryTopic(std::list<MessageExt*>& msgs);
-
-  private:
-      std::list<MessageExt*> m_msgs;
-      ProcessQueue* m_pProcessQueue;
-      MessageQueue m_messageQueue;
-      ConsumeMessageConcurrentlyService* m_pService;
-  };
-
-
-  class ConsumeMessageConcurrentlyService : public ConsumeMessageService
-  {
-  public:
-      ConsumeMessageConcurrentlyService(DefaultMQPushConsumerImpl* pDefaultMQPushConsumerImpl,
-                                        MessageListenerConcurrently* pMessageListener);
-	  ~ConsumeMessageConcurrentlyService();
-
-      void start();
-      void shutdown();
-
-	  void cleanExpireMsg();
-      ConsumerStat& getConsumerStat();
-
-      bool sendMessageBack(MessageExt& msg, ConsumeConcurrentlyContext& context);
-      void processConsumeResult(ConsumeConcurrentlyStatus status,
-                                ConsumeConcurrentlyContext& context,
-                                ConsumeConcurrentlyRequest& consumeRequest);
-
-      void submitConsumeRequestLater(std::list<MessageExt*>& pMsgs,
-                                     ProcessQueue* pProcessQueue,
-                                     const MessageQueue& messageQueue);
-
-      void submitConsumeRequest(std::list<MessageExt*>& pMsgs,
-                                ProcessQueue* pProcessQueue,
-                                const MessageQueue& messageQueue,
-                                bool dispathToConsume);
-
-      void updateCorePoolSize(int corePoolSize);
-
-      std::string& getConsumerGroup();
-      MessageListenerConcurrently* getMessageListener();
-      DefaultMQPushConsumerImpl* getDefaultMQPushConsumerImpl();
-
-  private:
-      DefaultMQPushConsumerImpl* m_pDefaultMQPushConsumerImpl;
-      DefaultMQPushConsumer* m_pDefaultMQPushConsumer;
-      MessageListenerConcurrently* m_pMessageListener;
-      std::string m_consumerGroup;
-      kpr::ThreadPoolPtr m_pConsumeExecutor;
-      kpr::TimerThreadPtr m_pScheduledExecutorService;
-      kpr::TimerThreadPtr m_pCleanExpireMsgExecutors;
-      kpr::TimerHandler* m_pCleanExpireMsgTask;
-  };
-}
-
-#endif


[11/17] incubator-rocketmq-externals git commit: Polish cpp module

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/consumer/DefaultMQPushConsumerImpl.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/consumer/DefaultMQPushConsumerImpl.cpp b/rocketmq-client4cpp/src/consumer/DefaultMQPushConsumerImpl.cpp
deleted file mode 100755
index 8d7f8a1..0000000
--- a/rocketmq-client4cpp/src/consumer/DefaultMQPushConsumerImpl.cpp
+++ /dev/null
@@ -1,1018 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#include "DefaultMQPushConsumerImpl.h"
-
-#include <string>
-#include <set>
-#include "DefaultMQPushConsumer.h"
-#include "ConsumerStatManage.h"
-#include "DefaultMQPullConsumer.h"
-#include "DefaultMQProducer.h"
-#include "MQClientFactory.h"
-#include "MQAdminImpl.h"
-#include "RebalancePushImpl.h"
-#include "MQClientAPIImpl.h"
-#include "OffsetStore.h"
-#include "MixAll.h"
-#include "MQClientManager.h"
-#include "LocalFileOffsetStore.h"
-#include "RemoteBrokerOffsetStore.h"
-#include "PullSysFlag.h"
-#include "FilterAPI.h"
-#include "PullAPIWrapper.h"
-#include "MQClientException.h"
-#include "Validators.h"
-#include "MessageListener.h"
-#include "ConsumeMessageHook.h"
-#include "PullMessageService.h"
-#include "ConsumeMessageOrderlyService.h"
-#include "ConsumeMessageConcurrentlyService.h"
-#include "KPRUtil.h"
-#include "TimerThread.h"
-
-namespace rmq
-{
-
-/* RemoveProcessQueueLater */
-class RemoveProcessQueueLater : public kpr::TimerHandler
-{
-public:
-    RemoveProcessQueueLater(DefaultMQPushConsumerImpl* pConsumerImp, PullRequest* pPullRequest)
-        : m_pConsumerImp(pConsumerImp), m_pPullRequest(pPullRequest)
-    {
-    }
-
-    void OnTimeOut(unsigned int timerID)
-    {
-    	try
-    	{
-            m_pConsumerImp->getOffsetStore()->updateOffset(m_pPullRequest->getMessageQueue(), m_pPullRequest->getNextOffset(), false);
-            m_pConsumerImp->getOffsetStore()->persist(m_pPullRequest->getMessageQueue());
-            m_pConsumerImp->getRebalanceImpl()->removeProcessQueue(m_pPullRequest->getMessageQueue());
-
-            RMQ_WARN("fix the pull request offset, {%s}", m_pPullRequest->toString().c_str());
-        }
-        catch(...)
-        {
-        	RMQ_ERROR("RemoveProcessQueueLater OnTimeOut Exception");
-        }
-
-        delete this;
-    }
-
-private:
-	DefaultMQPushConsumerImpl* m_pConsumerImp;
-    PullRequest* m_pPullRequest;
-};
-
-
-/* DefaultMQPushConsumerImplCallback */
-class DefaultMQPushConsumerImplCallback : public PullCallback
-{
-public:
-    DefaultMQPushConsumerImplCallback(SubscriptionData& subscriptionData,
-        DefaultMQPushConsumerImpl* pDefaultMQPushConsumerImpl,
-        PullRequest* pPullRequest)
-	    : m_subscriptionData(subscriptionData),
-	      m_pDefaultMQPushConsumerImpl(pDefaultMQPushConsumerImpl),
-	      m_pPullRequest(pPullRequest)
-	{
-	    m_beginTimestamp = KPRUtil::GetCurrentTimeMillis();
-	}
-
-    void onSuccess(PullResult& pullResult)
-	{
-		RMQ_DEBUG("onSuccess begin: %s", pullResult.toString().c_str());
-	    PullResult* pPullResult = &pullResult;
-	    if (pPullResult != NULL)
-	    {
-	        pPullResult =
-	            m_pDefaultMQPushConsumerImpl->m_pPullAPIWrapper->processPullResult(
-	                m_pPullRequest->getMessageQueue(), *pPullResult, m_subscriptionData);
-
-	        switch (pPullResult->pullStatus)
-	        {
-	            case FOUND:
-	            {
-	                m_pPullRequest->setNextOffset(pPullResult->nextBeginOffset);
-
-	                long long pullRT = KPRUtil::GetCurrentTimeMillis() - m_beginTimestamp;
-	                m_pDefaultMQPushConsumerImpl->getConsumerStatManager()->getConsumertat()
-	                .pullTimesTotal++;
-	                m_pDefaultMQPushConsumerImpl->getConsumerStatManager()->getConsumertat()
-	                .pullRTTotal.fetchAndAdd(pullRT);
-
-	                ProcessQueue* processQueue = m_pPullRequest->getProcessQueue();
-	                bool dispatchToConsume = processQueue->putMessage(pPullResult->msgFoundList);
-
-	                m_pDefaultMQPushConsumerImpl->m_pConsumeMessageService->submitConsumeRequest(//
-	                    pPullResult->msgFoundList, //
-	                    processQueue, //
-	                    m_pPullRequest->getMessageQueue(), //
-	                    dispatchToConsume);
-
-	                if (m_pDefaultMQPushConsumerImpl->m_pDefaultMQPushConsumer->getPullInterval() > 0)
-	                {
-	                    m_pDefaultMQPushConsumerImpl->executePullRequestLater(m_pPullRequest,
-	                            m_pDefaultMQPushConsumerImpl->m_pDefaultMQPushConsumer->getPullInterval());
-	                }
-	                else
-	                {
-	                    m_pDefaultMQPushConsumerImpl->executePullRequestImmediately(m_pPullRequest);
-	                }
-	            }
-	            break;
-	            case NO_NEW_MSG:
-	                m_pPullRequest->setNextOffset(pPullResult->nextBeginOffset);
-	                m_pDefaultMQPushConsumerImpl->correctTagsOffset(*m_pPullRequest);
-	                m_pDefaultMQPushConsumerImpl->executePullRequestImmediately(m_pPullRequest);
-	                break;
-	            case NO_MATCHED_MSG:
-	                m_pPullRequest->setNextOffset(pPullResult->nextBeginOffset);
-	                m_pDefaultMQPushConsumerImpl->correctTagsOffset(*m_pPullRequest);
-	                m_pDefaultMQPushConsumerImpl->executePullRequestImmediately(m_pPullRequest);
-	                break;
-	            case OFFSET_ILLEGAL:
-	                RMQ_WARN("the pull request offset illegal, %s, %s",
-	                         m_pPullRequest->toString().c_str(), pPullResult->toString().c_str());
-
-	                /*
-	                if (m_pPullRequest->getNextOffset() < pPullResult->minOffset)
-	                {
-	                    m_pPullRequest->setNextOffset(pPullResult->minOffset);
-	                }
-	                else if (m_pPullRequest->getNextOffset() > pPullResult->maxOffset)
-	                {
-	                    m_pPullRequest->setNextOffset(pPullResult->maxOffset);
-	                }
-	                m_pDefaultMQPushConsumerImpl->m_pOffsetStore->updateOffset(
-	                    m_pPullRequest->getMessageQueue(), m_pPullRequest->getNextOffset(), false);
-	                m_pDefaultMQPushConsumerImpl->executePullRequestImmediately(m_pPullRequest);
-	                */
-
-	                // todo
-	                m_pPullRequest->setNextOffset(pPullResult->nextBeginOffset);
-					m_pPullRequest->getProcessQueue()->setDropped(true);
-
-					m_pDefaultMQPushConsumerImpl->executeTaskLater(new RemoveProcessQueueLater(
-						m_pDefaultMQPushConsumerImpl, m_pPullRequest), 10000);
-		            break;
-	            default:
-	                break;
-	        }
-	    }
-	    else
-	    {
-	        RMQ_WARN("Warning: PullRequest is null!");
-	    }
-	    RMQ_DEBUG("onSuccess end");
-	}
-
-	void onException(MQException& e)
-	{
-	    std::string topic = m_pPullRequest->getMessageQueue().getTopic();
-	    if (topic.find(MixAll::RETRY_GROUP_TOPIC_PREFIX) != std::string::npos)
-	    {
-	        RMQ_WARN("execute the pull request exception:%s", e.what());
-	    }
-
-	    m_pDefaultMQPushConsumerImpl->executePullRequestLater(m_pPullRequest,
-	            DefaultMQPushConsumerImpl::s_PullTimeDelayMillsWhenException);
-	}
-
-private:
-    SubscriptionData m_subscriptionData;
-    DefaultMQPushConsumerImpl* m_pDefaultMQPushConsumerImpl;
-    PullRequest* m_pPullRequest;
-    unsigned long long m_beginTimestamp;
-};
-
-
-DefaultMQPushConsumerImpl::DefaultMQPushConsumerImpl(DefaultMQPushConsumer* pDefaultMQPushConsumer)
-{
-    m_pDefaultMQPushConsumer = pDefaultMQPushConsumer;
-    m_serviceState = CREATE_JUST;
-    flowControlTimes1 = 0;
-    flowControlTimes2 = 0;
-    m_pause = false;
-    m_consumeOrderly = false;
-
-    m_pMQClientFactory = NULL;
-    m_pPullAPIWrapper = NULL;
-    m_pMessageListenerInner = NULL;
-    m_pOffsetStore = NULL;
-    m_pRebalanceImpl = new RebalancePushImpl(this);
-    m_pConsumerStatManager = new ConsumerStatManager();
-    m_pConsumeMessageService = NULL;
-}
-
-DefaultMQPushConsumerImpl::~DefaultMQPushConsumerImpl()
-{
-    //delete m_pMessageListenerInner;
-    if (m_pPullAPIWrapper)
-		delete m_pPullAPIWrapper;
-	if (m_pRebalanceImpl)
-    	delete m_pRebalanceImpl;
-    if (m_pConsumerStatManager)
-    	delete m_pConsumerStatManager;
-    if (m_pConsumeMessageService)
-    	delete m_pConsumeMessageService;
-    if (m_pOffsetStore)
-    	delete m_pOffsetStore;
-    //delete m_pMQClientFactory;
-}
-
-void DefaultMQPushConsumerImpl::start()
-{
-    RMQ_DEBUG("DefaultMQPushConsumerImpl::start()");
-    switch (m_serviceState)
-    {
-        case CREATE_JUST:
-        {
-        	RMQ_INFO("the consumer [{%s}] start beginning. messageModel={%s}",
-                m_pDefaultMQPushConsumer->getConsumerGroup().c_str(),
-                getMessageModelString(m_pDefaultMQPushConsumer->getMessageModel()));
-
-            m_serviceState = START_FAILED;
-            checkConfig();
-            copySubscription();
-
-            if (m_pDefaultMQPushConsumer->getMessageModel() == CLUSTERING)
-            {
-                m_pDefaultMQPushConsumer->changeInstanceNameToPID();
-            }
-
-            m_pMQClientFactory = MQClientManager::getInstance()->getAndCreateMQClientFactory(*m_pDefaultMQPushConsumer);
-
-            m_pRebalanceImpl->setConsumerGroup(m_pDefaultMQPushConsumer->getConsumerGroup());
-            m_pRebalanceImpl->setMessageModel(m_pDefaultMQPushConsumer->getMessageModel());
-            m_pRebalanceImpl->setAllocateMessageQueueStrategy(m_pDefaultMQPushConsumer->getAllocateMessageQueueStrategy());
-            m_pRebalanceImpl->setmQClientFactory(m_pMQClientFactory);
-
-            m_pPullAPIWrapper = new PullAPIWrapper(m_pMQClientFactory, m_pDefaultMQPushConsumer->getConsumerGroup());
-
-            if (m_pDefaultMQPushConsumer->getOffsetStore() != NULL)
-            {
-                m_pOffsetStore = m_pDefaultMQPushConsumer->getOffsetStore();
-            }
-            else
-            {
-                switch (m_pDefaultMQPushConsumer->getMessageModel())
-                {
-                    case BROADCASTING:
-                        m_pOffsetStore = new LocalFileOffsetStore(m_pMQClientFactory, m_pDefaultMQPushConsumer->getConsumerGroup());
-                        break;
-                    case CLUSTERING:
-                        m_pOffsetStore = new RemoteBrokerOffsetStore(m_pMQClientFactory, m_pDefaultMQPushConsumer->getConsumerGroup());
-                        break;
-                    default:
-                        break;
-                }
-            }
-
-            m_pOffsetStore->load();
-
-            if (dynamic_cast<MessageListenerOrderly*>(m_pMessageListenerInner) != NULL)
-            {
-                m_consumeOrderly = true;
-                m_pConsumeMessageService =
-                    new ConsumeMessageOrderlyService(this, (MessageListenerOrderly*)m_pMessageListenerInner);
-            }
-            else if (dynamic_cast<MessageListenerConcurrently*>(m_pMessageListenerInner) != NULL)
-            {
-                m_consumeOrderly = false;
-                m_pConsumeMessageService =
-                    new ConsumeMessageConcurrentlyService(this, (MessageListenerConcurrently*)m_pMessageListenerInner);
-            }
-            m_pConsumeMessageService->start();
-
-            bool registerOK = m_pMQClientFactory->registerConsumer(m_pDefaultMQPushConsumer->getConsumerGroup(), this);
-            if (!registerOK)
-            {
-                m_serviceState = CREATE_JUST;
-                m_pConsumeMessageService->shutdown();
-                std::string str = "The consumer group[" + m_pDefaultMQPushConsumer->getConsumerGroup();
-                str += "] has been created before, specify another name please.";
-                THROW_MQEXCEPTION(MQClientException, str, -1);
-            }
-            m_pMQClientFactory->start();
-
-			RMQ_INFO("the consumer [%s] start OK.", m_pDefaultMQPushConsumer->getConsumerGroup().c_str());
-            m_serviceState = RUNNING;
-        }
-        break;
-        case RUNNING:
-        case START_FAILED:
-        case SHUTDOWN_ALREADY:
-            THROW_MQEXCEPTION(MQClientException, "The PullConsumer service state not OK, maybe started once, ", -1);
-        default:
-            break;
-    }
-
-    updateTopicSubscribeInfoWhenSubscriptionChanged();
-    m_pMQClientFactory->sendHeartbeatToAllBrokerWithLock();
-    m_pMQClientFactory->rebalanceImmediately();
-}
-
-
-void DefaultMQPushConsumerImpl::shutdown()
-{
-    RMQ_DEBUG("DefaultMQPushConsumerImpl::shutdown()");
-    switch (m_serviceState)
-    {
-        case CREATE_JUST:
-            break;
-        case RUNNING:
-            m_pConsumeMessageService->shutdown();
-            persistConsumerOffset();
-            m_pMQClientFactory->unregisterConsumer(m_pDefaultMQPushConsumer->getConsumerGroup());
-            m_pMQClientFactory->shutdown();
-
-            m_serviceState = SHUTDOWN_ALREADY;
-            break;
-        case SHUTDOWN_ALREADY:
-            break;
-        default:
-            break;
-    }
-}
-
-
-
-
-bool DefaultMQPushConsumerImpl::hasHook()
-{
-    return !m_hookList.empty();
-}
-
-void DefaultMQPushConsumerImpl::registerHook(ConsumeMessageHook* pHook)
-{
-    m_hookList.push_back(pHook);
-}
-
-void DefaultMQPushConsumerImpl::executeHookBefore(ConsumeMessageContext& context)
-{
-    std::list<ConsumeMessageHook*>::iterator it = m_hookList.begin();
-    for (; it != m_hookList.end(); it++)
-    {
-        try
-        {
-            (*it)->consumeMessageBefore(context);
-        }
-        catch (...)
-        {
-        	RMQ_WARN("consumeMessageBefore exception");
-        }
-    }
-}
-
-void DefaultMQPushConsumerImpl::executeHookAfter(ConsumeMessageContext& context)
-{
-    std::list<ConsumeMessageHook*>::iterator it = m_hookList.begin();
-    for (; it != m_hookList.end(); it++)
-    {
-        try
-        {
-            (*it)->consumeMessageAfter(context);
-        }
-        catch (...)
-        {
-        	RMQ_WARN("consumeMessageAfter exception");
-        }
-    }
-}
-
-void DefaultMQPushConsumerImpl::createTopic(const std::string& key, const std::string& newTopic, int queueNum)
-{
-    m_pMQClientFactory->getMQAdminImpl()->createTopic(key, newTopic, queueNum);
-}
-
-std::set<MessageQueue>* DefaultMQPushConsumerImpl::fetchSubscribeMessageQueues(const std::string& topic)
-{
-    std::map<std::string, std::set<MessageQueue> >& mqs =  m_pRebalanceImpl->getTopicSubscribeInfoTable();
-    std::map<std::string, std::set<MessageQueue> >::iterator it = mqs.find(topic);
-
-    if (it == mqs.end())
-    {
-        m_pMQClientFactory->updateTopicRouteInfoFromNameServer(topic);
-        mqs =  m_pRebalanceImpl->getTopicSubscribeInfoTable();
-        it = mqs.find(topic);
-    }
-
-    if (it == mqs.end())
-    {
-        THROW_MQEXCEPTION(MQClientException, "The topic[" + topic + "] not exist", -1);
-    }
-
-    std::set<MessageQueue>* result = new std::set<MessageQueue>(it->second.begin(), it->second.end());
-    return result;
-}
-
-DefaultMQPushConsumer* DefaultMQPushConsumerImpl::getDefaultMQPushConsumer()
-{
-    return m_pDefaultMQPushConsumer;
-}
-
-long long DefaultMQPushConsumerImpl::earliestMsgStoreTime(const MessageQueue& mq)
-{
-    return m_pMQClientFactory->getMQAdminImpl()->earliestMsgStoreTime(mq);
-}
-
-long long DefaultMQPushConsumerImpl::maxOffset(const MessageQueue& mq)
-{
-    return m_pMQClientFactory->getMQAdminImpl()->maxOffset(mq);
-}
-
-long long DefaultMQPushConsumerImpl::minOffset(const MessageQueue& mq)
-{
-    return m_pMQClientFactory->getMQAdminImpl()->minOffset(mq);
-}
-
-OffsetStore* DefaultMQPushConsumerImpl::getOffsetStore()
-{
-    return m_pOffsetStore;
-}
-
-void DefaultMQPushConsumerImpl::setOffsetStore(OffsetStore* pOffsetStore)
-{
-    m_pOffsetStore = pOffsetStore;
-}
-
-//MQConsumerInner
-std::string DefaultMQPushConsumerImpl::groupName()
-{
-    return m_pDefaultMQPushConsumer->getConsumerGroup();
-}
-
-MessageModel DefaultMQPushConsumerImpl::messageModel()
-{
-    return m_pDefaultMQPushConsumer->getMessageModel();
-}
-
-ConsumeType DefaultMQPushConsumerImpl::consumeType()
-{
-    return CONSUME_PASSIVELY;
-}
-
-ConsumeFromWhere DefaultMQPushConsumerImpl::consumeFromWhere()
-{
-    return m_pDefaultMQPushConsumer->getConsumeFromWhere();
-}
-
-std::set<SubscriptionData> DefaultMQPushConsumerImpl::subscriptions()
-{
-    std::set<SubscriptionData> sds;
-    std::map<std::string, SubscriptionData>& subscription = m_pRebalanceImpl->getSubscriptionInner();
-    std::map<std::string, SubscriptionData>::iterator it = subscription.begin();
-    for (; it != subscription.end(); it++)
-    {
-        sds.insert(it->second);
-    }
-
-    return sds;
-}
-
-void DefaultMQPushConsumerImpl::doRebalance()
-{
-    if (m_pRebalanceImpl != NULL)
-    {
-        m_pRebalanceImpl->doRebalance();
-    }
-}
-
-void DefaultMQPushConsumerImpl::persistConsumerOffset()
-{
-    try
-    {
-        makeSureStateOK();
-
-        std::set<MessageQueue> mqs;
-        {
-	        kpr::ScopedRLock<kpr::RWMutex> lock(m_pRebalanceImpl->getProcessQueueTableLock());
-	        std::map<MessageQueue, ProcessQueue*>& processQueueTable = m_pRebalanceImpl->getProcessQueueTable();
-	        RMQ_FOR_EACH(processQueueTable, it)
-	        {
-	            mqs.insert(it->first);
-	        }
-        }
-
-        m_pOffsetStore->persistAll(mqs);
-    }
-    catch (...)
-    {
-    	RMQ_ERROR("persistConsumerOffset exception, group: %s",
-    		m_pDefaultMQPushConsumer->getConsumerGroup().c_str());
-    }
-}
-
-void DefaultMQPushConsumerImpl::updateTopicSubscribeInfo(const std::string& topic, const std::set<MessageQueue>& info)
-{
-    std::map<std::string, SubscriptionData>& subTable = getSubscriptionInner();
-
-    if (subTable.find(topic) != subTable.end())
-    {
-        m_pRebalanceImpl->getTopicSubscribeInfoTable().insert(std::pair<std::string, std::set<MessageQueue> >(topic, info));
-    }
-}
-
-std::map<std::string, SubscriptionData>& DefaultMQPushConsumerImpl::getSubscriptionInner()
-{
-    return m_pRebalanceImpl->getSubscriptionInner();
-}
-
-bool DefaultMQPushConsumerImpl::isSubscribeTopicNeedUpdate(const std::string& topic)
-{
-    std::map<std::string, SubscriptionData>& subTable = getSubscriptionInner();
-
-    if (subTable.find(topic) != subTable.end())
-    {
-        std::map<std::string, std::set<MessageQueue> >& mqs =
-            m_pRebalanceImpl->getTopicSubscribeInfoTable();
-
-        return mqs.find(topic) == mqs.end();
-    }
-
-    return false;
-}
-
-bool DefaultMQPushConsumerImpl::isPause()
-{
-    return m_pause;
-}
-
-void DefaultMQPushConsumerImpl::setPause(bool pause)
-{
-    m_pause = pause;
-}
-
-
-void DefaultMQPushConsumerImpl::correctTagsOffset(PullRequest& pullRequest)
-{
-    if (pullRequest.getProcessQueue()->getMsgCount().get() == 0)
-    {
-        m_pOffsetStore->updateOffset(pullRequest.getMessageQueue(), pullRequest.getNextOffset(), true);
-    }
-}
-
-void DefaultMQPushConsumerImpl::pullMessage(PullRequest* pPullRequest)
-{
-	RMQ_DEBUG("pullMessage begin: %s", pPullRequest->toString().c_str());
-
-    ProcessQueue* processQueue = pPullRequest->getProcessQueue();
-    if (processQueue->isDropped())
-    {
-        RMQ_WARN("the pull request[%s] is dropped.", pPullRequest->toString().c_str());
-        delete pPullRequest;
-        return;
-    }
-
-    pPullRequest->getProcessQueue()->setLastPullTimestamp(KPRUtil::GetCurrentTimeMillis());
-
-    try
-    {
-        makeSureStateOK();
-    }
-    catch (const MQException& e)
-    {
-        RMQ_WARN("pullMessage exception [%s], consumer state not ok", e.what());
-        executePullRequestLater(pPullRequest, s_PullTimeDelayMillsWhenException);
-        return;
-    }
-
-    if (isPause())
-    {
-    	RMQ_WARN("consumer was paused, execute pull request later. instanceName={%s}",
-                m_pDefaultMQPushConsumer->getInstanceName().c_str());
-        executePullRequestLater(pPullRequest, s_PullTimeDelayMillsWhenSuspend);
-        return;
-    }
-
-    long size = processQueue->getMsgCount().get();
-    if (size > m_pDefaultMQPushConsumer->getPullThresholdForQueue())
-    {
-        executePullRequestLater(pPullRequest, s_PullTimeDelayMillsWhenFlowControl);
-        if ((flowControlTimes1++ % 3000) == 0)
-        {
-            RMQ_WARN("the consumer message buffer is full, so do flow control, {%ld} {%s} {%lld}", size,
-                    pPullRequest->toString().c_str(), flowControlTimes1);
-        }
-        return;
-    }
-
-    if (!m_consumeOrderly)
-    {
-        if (processQueue->getMaxSpan() > m_pDefaultMQPushConsumer->getConsumeConcurrentlyMaxSpan())
-        {
-            executePullRequestLater(pPullRequest, s_PullTimeDelayMillsWhenFlowControl);
-            if ((flowControlTimes2++ % 3000) == 0)
-            {
-                RMQ_WARN("the queue's messages, span too long, so do flow control, size: {%ld}, pullRequest: {%s}, times: {%lld}, maxspan: {%lld}",
-                	size, pPullRequest->toString().c_str(), flowControlTimes2, processQueue->getMaxSpan());
-            }
-            return;
-        }
-    }
-
-    std::map<std::string, SubscriptionData>& subTable = getSubscriptionInner();
-    std::string topic = pPullRequest->getMessageQueue().getTopic();
-    std::map<std::string, SubscriptionData>::iterator it = subTable.find(topic);
-    if (it == subTable.end())
-    {
-        executePullRequestLater(pPullRequest, s_PullTimeDelayMillsWhenException);
-        RMQ_WARN("find the consumer's subscription failed, {%s}", pPullRequest->toString().c_str());
-        return;
-    }
-
-    SubscriptionData subscriptionData = it->second;
-    PullCallback* pullCallback = new DefaultMQPushConsumerImplCallback(subTable[topic], this, pPullRequest);
-
-    bool commitOffsetEnable = false;
-    long commitOffsetValue = 0L;
-    if (CLUSTERING == m_pDefaultMQPushConsumer->getMessageModel())
-    {
-        commitOffsetValue = m_pOffsetStore->readOffset(pPullRequest->getMessageQueue(),
-                            READ_FROM_MEMORY);
-        if (commitOffsetValue > 0)
-        {
-            commitOffsetEnable = true;
-        }
-    }
-
-    int sysFlag = PullSysFlag::buildSysFlag(
-                      commitOffsetEnable, // commitOffset
-                      true, // suspend
-                      false// subscription
-                  );
-    try
-    {
-        m_pPullAPIWrapper->pullKernelImpl(
-            pPullRequest->getMessageQueue(), // 1
-            "", // 2
-            subscriptionData.getSubVersion(), // 3
-            pPullRequest->getNextOffset(), // 4
-            m_pDefaultMQPushConsumer->getPullBatchSize(), // 5
-            sysFlag, // 6
-            commitOffsetValue,// 7
-            s_BrokerSuspendMaxTimeMillis, // 8
-            s_ConsumerTimeoutMillisWhenSuspend, // 9
-            ASYNC, // 10
-            pullCallback// 11
-        );
-    }
-    catch (...)
-    {
-        RMQ_ERROR("pullKernelImpl exception");
-        executePullRequestLater(pPullRequest, s_PullTimeDelayMillsWhenException);
-    }
-
-    RMQ_DEBUG("pullMessage end");
-}
-
-void DefaultMQPushConsumerImpl::executePullRequestImmediately(PullRequest* pullRequest)
-{
-    m_pMQClientFactory->getPullMessageService()->executePullRequestImmediately(pullRequest);
-}
-
-void DefaultMQPushConsumerImpl::executePullRequestLater(PullRequest* pullRequest, long timeDelay)
-{
-    m_pMQClientFactory->getPullMessageService()->executePullRequestLater(pullRequest, timeDelay);
-}
-
-void DefaultMQPushConsumerImpl::executeTaskLater(kpr::TimerHandler* handler, long timeDelay)
-{
-    m_pMQClientFactory->getPullMessageService()->executeTaskLater(handler, timeDelay);
-}
-
-
-void DefaultMQPushConsumerImpl::makeSureStateOK()
-{
-    if (m_serviceState != RUNNING)
-    {
-        THROW_MQEXCEPTION(MQClientException, "The consumer service state not OK, ", -1);
-    }
-}
-
-ConsumerStatManager* DefaultMQPushConsumerImpl::getConsumerStatManager()
-{
-    return m_pConsumerStatManager;
-}
-
-QueryResult DefaultMQPushConsumerImpl::queryMessage(const std::string& topic,
-        const std::string&  key,
-        int maxNum,
-        long long begin,
-        long long end)
-{
-    return m_pMQClientFactory->getMQAdminImpl()->queryMessage(topic, key, maxNum, begin, end);
-}
-
-void DefaultMQPushConsumerImpl::registerMessageListener(MessageListener* pMessageListener)
-{
-    m_pMessageListenerInner = pMessageListener;
-}
-
-void DefaultMQPushConsumerImpl::resume()
-{
-    m_pause = false;
-}
-
-long long DefaultMQPushConsumerImpl::searchOffset(const MessageQueue& mq, long long timestamp)
-{
-    return m_pMQClientFactory->getMQAdminImpl()->searchOffset(mq, timestamp);
-}
-
-void DefaultMQPushConsumerImpl::sendMessageBack(MessageExt& msg, int delayLevel, const std::string& brokerName)
-{
-    try
-    {
-    	std::string brokerAddr = brokerName.empty() ?
-    		socketAddress2IPPort(msg.getStoreHost()) : m_pMQClientFactory->findBrokerAddressInPublish(brokerName);
-
-        m_pMQClientFactory->getMQClientAPIImpl()->consumerSendMessageBack(brokerAddr, msg,
-                m_pDefaultMQPushConsumer->getConsumerGroup(),
-                delayLevel,
-                5000);
-    }
-    catch (...)
-    {
-    	RMQ_ERROR("sendMessageBack Exception, group: %s", m_pDefaultMQPushConsumer->getConsumerGroup().c_str());
-        Message newMsg(MixAll::getRetryTopic(m_pDefaultMQPushConsumer->getConsumerGroup()),
-                       msg.getBody(), msg.getBodyLen());
-
-		std::string originMsgId = msg.getProperty(Message::PROPERTY_ORIGIN_MESSAGE_ID);
-		newMsg.putProperty(Message::PROPERTY_ORIGIN_MESSAGE_ID, UtilAll::isBlank(originMsgId) ? msg.getMsgId()
-                    : originMsgId);
-
-        newMsg.setFlag(msg.getFlag());
-        newMsg.setProperties(msg.getProperties());
-        newMsg.putProperty(Message::PROPERTY_RETRY_TOPIC, msg.getTopic());
-
-        int reTimes = msg.getReconsumeTimes() + 1;
-        newMsg.putProperty(Message::PROPERTY_RECONSUME_TIME, UtilAll::toString(reTimes));
-        newMsg.putProperty(Message::PROPERTY_MAX_RECONSUME_TIMES, UtilAll::toString(m_pDefaultMQPushConsumer->getMaxReconsumeTimes()));
-        newMsg.setDelayTimeLevel(3 + reTimes);
-
-        m_pMQClientFactory->getDefaultMQProducer()->send(newMsg);
-    }
-}
-
-void DefaultMQPushConsumerImpl::checkConfig()
-{
-    // consumerGroup check
-    Validators::checkGroup(m_pDefaultMQPushConsumer->getConsumerGroup());
-
-    // consumerGroup
-    if (m_pDefaultMQPushConsumer->getConsumerGroup() == MixAll::DEFAULT_CONSUMER_GROUP)
-    {
-        THROW_MQEXCEPTION(MQClientException, "consumerGroup can not equal "
-                          + MixAll::DEFAULT_CONSUMER_GROUP //
-                          + ", please specify another one.", -1);
-    }
-
-    if (m_pDefaultMQPushConsumer->getMessageModel() != BROADCASTING
-        && m_pDefaultMQPushConsumer->getMessageModel() != CLUSTERING)
-    {
-        THROW_MQEXCEPTION(MQClientException, "messageModel is invalid ", -1);
-    }
-
-    // allocateMessageQueueStrategy
-    if (m_pDefaultMQPushConsumer->getAllocateMessageQueueStrategy() == NULL)
-    {
-        THROW_MQEXCEPTION(MQClientException, "allocateMessageQueueStrategy is null", -1);
-    }
-
-    // consumeFromWhereOffset
-    if (m_pDefaultMQPushConsumer->getConsumeFromWhere() < CONSUME_FROM_LAST_OFFSET
-        || m_pDefaultMQPushConsumer->getConsumeFromWhere() > CONSUME_FROM_MAX_OFFSET)
-    {
-        THROW_MQEXCEPTION(MQClientException, "consumeFromWhere is invalid", -1);
-    }
-
-    // subscription
-    /*
-    if (m_pDefaultMQPushConsumer->getSubscription().size() == 0)
-    {
-      THROW_MQEXCEPTION(MQClientException,"subscription is null" ,-1);
-    }
-    */
-
-    // messageListener
-    if (m_pDefaultMQPushConsumer->getMessageListener() == NULL)
-    {
-        THROW_MQEXCEPTION(MQClientException, "messageListener is null", -1);
-    }
-
-    MessageListener* listener = m_pDefaultMQPushConsumer->getMessageListener();
-    MessageListener* orderly = (dynamic_cast<MessageListenerOrderly*>(listener)) ;
-    MessageListener* concurrently = (dynamic_cast<MessageListenerConcurrently*>(listener)) ;
-
-    if (!orderly && !concurrently)
-    {
-        THROW_MQEXCEPTION(MQClientException,
-                          "messageListener must be instanceof MessageListenerOrderly or MessageListenerConcurrently" ,
-                          -1);
-    }
-
-    // consumeThreadMin
-    if (m_pDefaultMQPushConsumer->getConsumeThreadMin() < 1
-        || m_pDefaultMQPushConsumer->getConsumeThreadMin() > 1000
-        || m_pDefaultMQPushConsumer->getConsumeThreadMin() > m_pDefaultMQPushConsumer->getConsumeThreadMax()
-       )
-    {
-        THROW_MQEXCEPTION(MQClientException, "consumeThreadMin Out of range [1, 1000]", -1);
-    }
-
-    // consumeThreadMax
-    if (m_pDefaultMQPushConsumer->getConsumeThreadMax() < 1
-        || m_pDefaultMQPushConsumer->getConsumeThreadMax() > 1000)
-    {
-        THROW_MQEXCEPTION(MQClientException, "consumeThreadMax Out of range [1, 1000]", -1);
-    }
-
-    // consumeConcurrentlyMaxSpan
-    if (m_pDefaultMQPushConsumer->getConsumeConcurrentlyMaxSpan() < 1
-        || m_pDefaultMQPushConsumer->getConsumeConcurrentlyMaxSpan() > 65535)
-    {
-        THROW_MQEXCEPTION(MQClientException, "consumeConcurrentlyMaxSpan Out of range [1, 65535]" , -1);
-    }
-
-    // pullThresholdForQueue
-    if (m_pDefaultMQPushConsumer->getPullThresholdForQueue() < 1
-        || m_pDefaultMQPushConsumer->getPullThresholdForQueue() > 65535)
-    {
-        THROW_MQEXCEPTION(MQClientException, "pullThresholdForQueue Out of range [1, 65535]", -1);
-    }
-
-    // pullInterval
-    if (m_pDefaultMQPushConsumer->getPullInterval() < 0
-        || m_pDefaultMQPushConsumer->getPullInterval() > 65535)
-    {
-        THROW_MQEXCEPTION(MQClientException, "pullInterval Out of range [0, 65535]", -1);
-    }
-
-    // consumeMessageBatchMaxSize
-    if (m_pDefaultMQPushConsumer->getConsumeMessageBatchMaxSize() < 1
-        || m_pDefaultMQPushConsumer->getConsumeMessageBatchMaxSize() > 1024)
-    {
-        THROW_MQEXCEPTION(MQClientException, "consumeMessageBatchMaxSize Out of range [1, 1024]", -1);
-    }
-
-    // pullBatchSize
-    if (m_pDefaultMQPushConsumer->getPullBatchSize() < 1
-        || m_pDefaultMQPushConsumer->getPullBatchSize() > 1024)
-    {
-        THROW_MQEXCEPTION(MQClientException, "pullBatchSize Out of range [1, 1024]", -1);
-    }
-}
-
-void DefaultMQPushConsumerImpl::copySubscription()
-{
-    try
-    {
-        std::map<std::string, std::string>& sub = m_pDefaultMQPushConsumer->getSubscription();
-        std::map<std::string, std::string>::iterator it = sub.begin();
-        for (; it != sub.end(); it++)
-        {
-            SubscriptionDataPtr subscriptionData = FilterAPI::buildSubscriptionData(it->first, it->second);
-            m_pRebalanceImpl->getSubscriptionInner()[it->first] = *subscriptionData;
-        }
-
-        if (m_pMessageListenerInner == NULL)
-        {
-            m_pMessageListenerInner = m_pDefaultMQPushConsumer->getMessageListener();
-        }
-
-        switch (m_pDefaultMQPushConsumer->getMessageModel())
-        {
-            case BROADCASTING:
-                break;
-            case CLUSTERING:
-            {
-                std::string retryTopic = MixAll::getRetryTopic(m_pDefaultMQPushConsumer->getConsumerGroup());
-                SubscriptionDataPtr subscriptionData =
-                    FilterAPI::buildSubscriptionData(retryTopic, SubscriptionData::SUB_ALL);
-                m_pRebalanceImpl->getSubscriptionInner()[retryTopic] = *subscriptionData;
-            }
-
-            break;
-            default:
-                break;
-        }
-    }
-    catch (...)
-    {
-        THROW_MQEXCEPTION(MQClientException, "subscription exception", -1);
-    }
-}
-
-void DefaultMQPushConsumerImpl::updateTopicSubscribeInfoWhenSubscriptionChanged()
-{
-    std::map<std::string, SubscriptionData> subTable = getSubscriptionInner();
-    std::map<std::string, SubscriptionData>::iterator it = subTable.begin();
-    for (; it != subTable.end(); it++)
-    {
-        m_pMQClientFactory->updateTopicRouteInfoFromNameServer(it->first);
-    }
-}
-
-MessageListener* DefaultMQPushConsumerImpl::getMessageListenerInner()
-{
-    return m_pMessageListenerInner;
-}
-
-void DefaultMQPushConsumerImpl::subscribe(const std::string& topic, const std::string& subExpression)
-{
-    try
-    {
-        SubscriptionDataPtr subscriptionData = FilterAPI::buildSubscriptionData(topic, subExpression);
-        m_pRebalanceImpl->getSubscriptionInner()[topic] = *subscriptionData;
-
-        if (m_pMQClientFactory)
-        {
-            m_pMQClientFactory->sendHeartbeatToAllBrokerWithLock();
-        }
-    }
-    catch (...)
-    {
-        THROW_MQEXCEPTION(MQClientException, "subscription exception", -1);
-    }
-}
-
-void DefaultMQPushConsumerImpl::suspend()
-{
-    m_pause = true;
-}
-
-void DefaultMQPushConsumerImpl::unsubscribe(const std::string& topic)
-{
-    m_pRebalanceImpl->getSubscriptionInner().erase(topic);
-}
-
-void DefaultMQPushConsumerImpl::updateConsumeOffset(MessageQueue& mq, long long offset)
-{
-    m_pOffsetStore->updateOffset(mq, offset, false);
-}
-
-void DefaultMQPushConsumerImpl::updateCorePoolSize(int corePoolSize)
-{
-    m_pConsumeMessageService->updateCorePoolSize(corePoolSize);
-}
-
-MessageExt* DefaultMQPushConsumerImpl::viewMessage(const std::string& msgId)
-{
-    return m_pMQClientFactory->getMQAdminImpl()->viewMessage(msgId);
-}
-
-RebalanceImpl* DefaultMQPushConsumerImpl::getRebalanceImpl()
-{
-    return m_pRebalanceImpl;
-}
-
-bool DefaultMQPushConsumerImpl::isConsumeOrderly()
-{
-    return m_consumeOrderly;
-}
-
-void DefaultMQPushConsumerImpl::setConsumeOrderly(bool consumeOrderly)
-{
-    m_consumeOrderly = consumeOrderly;
-}
-
-
-MQClientFactory* DefaultMQPushConsumerImpl::getmQClientFactory()
-{
-    return m_pMQClientFactory;
-}
-
-void DefaultMQPushConsumerImpl::setmQClientFactory(MQClientFactory* mQClientFactory)
-{
-    m_pMQClientFactory = mQClientFactory;
-}
-
-
-ServiceState DefaultMQPushConsumerImpl::getServiceState()
-{
-    return m_serviceState;
-}
-
-void DefaultMQPushConsumerImpl::setServiceState(ServiceState serviceState)
-{
-    m_serviceState = serviceState;
-}
-
-}
-

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/consumer/DefaultMQPushConsumerImpl.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/consumer/DefaultMQPushConsumerImpl.h b/rocketmq-client4cpp/src/consumer/DefaultMQPushConsumerImpl.h
deleted file mode 100755
index 5370586..0000000
--- a/rocketmq-client4cpp/src/consumer/DefaultMQPushConsumerImpl.h
+++ /dev/null
@@ -1,169 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __DEFAULTMQPUSHCONSUMERIMPL_H__
-#define __DEFAULTMQPUSHCONSUMERIMPL_H__
-
-#include <string>
-#include <set>
-#include <map>
-
-#include "MQConsumerInner.h"
-#include "MessageExt.h"
-#include "QueryResult.h"
-#include "ServiceState.h"
-#include "PullResult.h"
-#include "ConsumeMessageHook.h"
-#include "MixAll.h"
-#include "PullCallback.h"
-#include "TimerThread.h"
-
-namespace rmq
-{
-    class DefaultMQPushConsumer;
-    class ConsumeMessageHook;
-    class OffsetStore;
-    class RebalanceImpl;
-    class ConsumerStatManager;
-    class ConsumeMessageService;
-    class MessageListener;
-    class PullRequest;
-    class MQClientFactory;
-    class PullAPIWrapper;
-    class PullMessageService;
-    class DefaultMQPushConsumerImplCallback;
-	class MQException;
-
-    /**
-    * Push Consumer Impl
-    *
-    */
-    class DefaultMQPushConsumerImpl : public  MQConsumerInner
-    {
-    public:
-        DefaultMQPushConsumerImpl(DefaultMQPushConsumer* pDefaultMQPushConsumer);
-		~DefaultMQPushConsumerImpl();
-
-        void start();
-        void suspend();
-        void resume();
-        void shutdown();
-        bool isPause();
-        void setPause(bool pause);
-
-        bool hasHook();
-        void registerHook(ConsumeMessageHook* pHook);
-        void executeHookBefore(ConsumeMessageContext& context);
-        void executeHookAfter(ConsumeMessageContext& context);
-
-        void createTopic(const std::string& key, const std::string& newTopic, int queueNum);
-        std::set<MessageQueue>* fetchSubscribeMessageQueues(const std::string& topic);
-
-        long long earliestMsgStoreTime(const MessageQueue& mq);
-        long long maxOffset(const MessageQueue& mq);
-        long long minOffset(const MessageQueue& mq);
-        OffsetStore* getOffsetStore() ;
-        void setOffsetStore(OffsetStore* pOffsetStore);
-
-        //MQConsumerInner
-        std::string groupName() ;
-        MessageModel messageModel() ;
-        ConsumeType consumeType();
-        ConsumeFromWhere consumeFromWhere();
-        std::set<SubscriptionData> subscriptions();
-        void doRebalance() ;
-        void persistConsumerOffset() ;
-        void updateTopicSubscribeInfo(const std::string& topic, const std::set<MessageQueue>& info);
-        std::map<std::string, SubscriptionData>& getSubscriptionInner() ;
-        bool isSubscribeTopicNeedUpdate(const std::string& topic);
-
-        MessageExt* viewMessage(const std::string& msgId);
-        QueryResult queryMessage(const std::string& topic,
-                                 const std::string&  key,
-                                 int maxNum,
-                                 long long begin,
-                                 long long end);
-
-        void registerMessageListener(MessageListener* pMessageListener);
-        long long searchOffset(const MessageQueue& mq, long long timestamp);
-        void sendMessageBack(MessageExt& msg, int delayLevel, const std::string& brokerName);
-
-        void subscribe(const std::string& topic, const std::string& subExpression);
-        void unsubscribe(const std::string& topic);
-
-        void updateConsumeOffset(MessageQueue& mq, long long offset);
-        void updateCorePoolSize(int corePoolSize);
-        bool isConsumeOrderly();
-        void setConsumeOrderly(bool consumeOrderly);
-
-        RebalanceImpl* getRebalanceImpl() ;
-        MessageListener* getMessageListenerInner();
-        DefaultMQPushConsumer* getDefaultMQPushConsumer() ;
-        ConsumerStatManager* getConsumerStatManager();
-
-		MQClientFactory* getmQClientFactory();
-		void setmQClientFactory(MQClientFactory* mQClientFactory);
-
-		ServiceState getServiceState();
-		void setServiceState(ServiceState serviceState);
-
-    private:
-        void correctTagsOffset(PullRequest& pullRequest) ;
-
-        void pullMessage(PullRequest* pPullRequest);
-
-
-        void executePullRequestImmediately(PullRequest* pullRequest);
-
-
-        void executePullRequestLater(PullRequest* pullRequest, long timeDelay);
-		void executeTaskLater(kpr::TimerHandler* handler, long timeDelay);
-
-        void makeSureStateOK();
-        void checkConfig();
-        void copySubscription() ;
-        void updateTopicSubscribeInfoWhenSubscriptionChanged();
-
-    private:
-		static const int s_PullTimeDelayMillsWhenException = 3000;
-		static const int s_PullTimeDelayMillsWhenFlowControl = 50;
-		static const int s_PullTimeDelayMillsWhenSuspend = 1000;
-		static const int s_BrokerSuspendMaxTimeMillis = 15000;
-		static const int s_ConsumerTimeoutMillisWhenSuspend = 30000;
-
-        long long flowControlTimes1;
-        long long flowControlTimes2;
-        ServiceState m_serviceState;
-        volatile bool m_pause;
-        bool m_consumeOrderly;
-        DefaultMQPushConsumer* m_pDefaultMQPushConsumer;
-        MQClientFactory* m_pMQClientFactory;
-        PullAPIWrapper* m_pPullAPIWrapper;
-        MessageListener* m_pMessageListenerInner;
-        OffsetStore* m_pOffsetStore;
-        RebalanceImpl* m_pRebalanceImpl;
-        ConsumerStatManager* m_pConsumerStatManager;
-        ConsumeMessageService* m_pConsumeMessageService;
-
-        std::list<ConsumeMessageHook*> m_hookList;
-        friend class PullMessageService;
-        friend class RebalancePushImpl;
-        friend class DefaultMQPushConsumerImplCallback;
-    };
-}
-
-#endif
-

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/consumer/LocalFileOffsetStore.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/consumer/LocalFileOffsetStore.cpp b/rocketmq-client4cpp/src/consumer/LocalFileOffsetStore.cpp
deleted file mode 100755
index 40e9d65..0000000
--- a/rocketmq-client4cpp/src/consumer/LocalFileOffsetStore.cpp
+++ /dev/null
@@ -1,257 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#include "LocalFileOffsetStore.h"
-
-#include "MQClientFactory.h"
-#include "OffsetSerializeWrapper.h"
-#include "ScopedLock.h"
-#include "FileUtil.h"
-#include "MixAll.h"
-#include "Exception.h"
-#include "MQClientException.h"
-
-namespace rmq
-{
-
-LocalFileOffsetStore::LocalFileOffsetStore(MQClientFactory* pMQClientFactory,
-        const std::string& groupName)
-{
-    m_pMQClientFactory = pMQClientFactory;
-    m_groupName = groupName;
-    std::string homePath = getenv("HOME");
-    m_storePath = homePath + "/.rocketmq_offsets/" + m_pMQClientFactory->getClientId()
-                  + "/" + m_groupName + "/offsets.json";
-}
-
-void  LocalFileOffsetStore::load()
-{
-    OffsetSerializeWrapperPtr offsetSerializeWrapper = this->readLocalOffset();
-    if (offsetSerializeWrapper.ptr() != NULL
-        && offsetSerializeWrapper->getOffsetTable().size() > 0)
-    {
-        kpr::ScopedWLock<kpr::RWMutex> lock(m_tableMutex);
-        m_offsetTable = offsetSerializeWrapper->getOffsetTable();
-        RMQ_FOR_EACH(m_offsetTable, it)
-        {
-            const MessageQueue& mq = it->first;
-            const kpr::AtomicLong& offset = it->second;
-            RMQ_INFO("load consumer's offset, {%s} {%s} {%lld}",
-                     m_groupName.c_str(),
-                     mq.toString().c_str(),
-                     offset.get());
-        }
-    }
-}
-
-
-void  LocalFileOffsetStore::updateOffset(const MessageQueue& mq, long long offset, bool increaseOnly)
-{
-    RMQ_DEBUG("updateOffset, MQ:%s, offset:%lld", mq.toString().c_str(), offset);
-    kpr::ScopedWLock<kpr::RWMutex> lock(m_tableMutex);
-    typeof(m_offsetTable.begin()) it = m_offsetTable.find(mq);
-    if (it == m_offsetTable.end())
-    {
-        m_offsetTable[mq] = offset;
-        it = m_offsetTable.find(mq);
-    }
-
-    kpr::AtomicLong& offsetOld = it->second;
-    if (increaseOnly)
-    {
-        MixAll::compareAndIncreaseOnly(offsetOld, offset);
-    }
-    else
-    {
-        offsetOld.set(offset);
-    }
-}
-
-long long  LocalFileOffsetStore::readOffset(const MessageQueue& mq, ReadOffsetType type)
-{
-    RMQ_DEBUG("readOffset, MQ:%s, type:%d", mq.toString().c_str(), type);
-    switch (type)
-    {
-        case MEMORY_FIRST_THEN_STORE:
-        case READ_FROM_MEMORY:
-        {
-            kpr::ScopedRLock<kpr::RWMutex> lock(m_tableMutex);
-            typeof(m_offsetTable.begin()) it = m_offsetTable.find(mq);
-            if (it != m_offsetTable.end())
-            {
-                return it->second.get();
-            }
-            else if (READ_FROM_MEMORY == type)
-            {
-                RMQ_WARN("No offset in memory, MQ:%s", mq.toString().c_str());
-                return -1;
-            }
-        }
-        case READ_FROM_STORE:
-        {
-            OffsetSerializeWrapperPtr offsetSerializeWrapper;
-            try
-            {
-                offsetSerializeWrapper = this->readLocalOffset();
-            }
-            catch (std::exception& e)
-            {
-                RMQ_WARN("load offset file fail, MQ:%s, exception:%s", mq.toString().c_str(), e.what());
-                return -1;
-            }
-
-            if (offsetSerializeWrapper.ptr() != NULL)
-            {
-                std::map<MessageQueue, kpr::AtomicLong>& offsetTable = offsetSerializeWrapper->getOffsetTable();
-                typeof(offsetTable.begin()) it = offsetTable.find(mq);
-                if (it != offsetTable.end())
-                {
-                    kpr::ScopedWLock<kpr::RWMutex> lock(m_tableMutex);
-                    m_offsetTable[mq] = it->second.get();
-                    return it->second.get();
-                }
-            }
-            return -1;
-        }
-        default:
-            break;
-    }
-
-    return -1;
-}
-
-
-void  LocalFileOffsetStore::persistAll(std::set<MessageQueue>& mqs)
-{
-    RMQ_DEBUG("persistAll, mqs.size={%u}, mqs=%s",
-              (unsigned)mqs.size(), UtilAll::toString(mqs).c_str());
-    if (mqs.empty())
-    {
-        return;
-    }
-    RMQ_DEBUG("persistAll, m_offsetTable.size={%u}, m_offsetTable=%s",
-              (unsigned)m_offsetTable.size(), UtilAll::toString(m_offsetTable).c_str());
-
-    OffsetSerializeWrapper offsetSerializeWrapper;
-    std::map<MessageQueue, kpr::AtomicLong>& offsetTable = offsetSerializeWrapper.getOffsetTable();
-    {
-        kpr::ScopedRLock<kpr::RWMutex> lock(m_tableMutex);
-        RMQ_FOR_EACH(m_offsetTable, it)
-        {
-            MessageQueue mq = it->first;
-            kpr::AtomicLong& offset = it->second;
-            if (mqs.find(mq) != mqs.end())
-            {
-                offsetTable[mq] = offset;
-            }
-        }
-    }
-
-    RMQ_DEBUG("persistAll, offsetTable.size={%u}, offsetTable=%s",
-              (unsigned)offsetTable.size(), UtilAll::toString(offsetTable).c_str());
-
-    std::string jsonString;
-    offsetSerializeWrapper.encode(jsonString);
-    RMQ_DEBUG("persistAll, json=%s", jsonString.c_str());
-
-    if (!jsonString.empty())
-    {
-        try
-        {
-            kpr::FileUtil::makeDirRecursive(kpr::FileUtil::extractFilePath(m_storePath));
-            MixAll::string2File(m_storePath, jsonString);
-        }
-        catch (const std::exception& e)
-        {
-            RMQ_ERROR("persistAll consumer offset Exception, %s, %s", m_storePath.c_str(), e.what());
-        }
-    }
-}
-
-void  LocalFileOffsetStore::persist(const MessageQueue& mq)
-{
-}
-
-void  LocalFileOffsetStore::removeOffset(const MessageQueue& mq)
-{
-}
-
-
-std::map<MessageQueue, long long> LocalFileOffsetStore::cloneOffsetTable(const std::string& topic)
-{
-    kpr::ScopedRLock<kpr::RWMutex> lock(m_tableMutex);
-    std::map<MessageQueue, long long> cloneOffsetTable;
-    RMQ_FOR_EACH(m_offsetTable, it)
-    {
-        MessageQueue mq = it->first;
-        kpr::AtomicLong& offset = it->second;
-        if (topic == mq.getTopic())
-        {
-            cloneOffsetTable[mq] = offset.get();
-        }
-    }
-
-    return cloneOffsetTable;
-}
-
-
-OffsetSerializeWrapper* LocalFileOffsetStore::readLocalOffset()
-{
-    std::string content = MixAll::file2String(m_storePath);
-    if (content.length() == 0)
-    {
-        return this->readLocalOffsetBak();
-    }
-    else
-    {
-        OffsetSerializeWrapper* offsetSerializeWrapper = NULL;
-        try
-        {
-            offsetSerializeWrapper = OffsetSerializeWrapper::decode(content.c_str(), content.size());
-        }
-        catch (const MQException& e)
-        {
-            RMQ_WARN("readLocalOffset Exception, and try to correct, %s", e.what());
-            return this->readLocalOffsetBak();
-        }
-
-        return offsetSerializeWrapper;
-    }
-}
-
-
-OffsetSerializeWrapper* LocalFileOffsetStore::readLocalOffsetBak()
-{
-    std::string content = MixAll::file2String(m_storePath + ".bak");
-    if (content.length() > 0)
-    {
-        OffsetSerializeWrapper* offsetSerializeWrapper = NULL;
-        try
-        {
-            offsetSerializeWrapper = OffsetSerializeWrapper::decode(content.c_str(), content.size());
-        }
-        catch (const MQException& e)
-        {
-            RMQ_WARN("readLocalOffset Exception, maybe json content invalid, %s", e.what());
-        }
-
-        return offsetSerializeWrapper;
-    }
-
-    return NULL;
-}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/consumer/LocalFileOffsetStore.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/consumer/LocalFileOffsetStore.h b/rocketmq-client4cpp/src/consumer/LocalFileOffsetStore.h
deleted file mode 100755
index c4efb76..0000000
--- a/rocketmq-client4cpp/src/consumer/LocalFileOffsetStore.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
-* Copyright (C) 2013 suwenkuang ,hooligan_520@qq.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __LOCALFILEOFFSETSTORE_H__
-#define __LOCALFILEOFFSETSTORE_H__
-#include <map>
-#include <string>
-#include <set>
-
-#include "RocketMQClient.h"
-#include "OffsetStore.h"
-#include "MessageQueue.h"
-#include "AtomicValue.h"
-#include "Mutex.h"
-
-namespace rmq
-{
-    class MQClientFactory;
-    class MessageQueue;
-    class OffsetSerializeWrapper;
-
-    class LocalFileOffsetStore : public OffsetStore
-    {
-    public:
-        LocalFileOffsetStore(MQClientFactory* pMQClientFactory, const std::string& groupName);
-
-        void load();
-        void updateOffset(const MessageQueue& mq, long long offset, bool increaseOnly);
-        long long readOffset(const MessageQueue& mq, ReadOffsetType type);
-        void persistAll(std::set<MessageQueue>& mqs);
-        void persist(const MessageQueue& mq);
-        void removeOffset(const MessageQueue& mq) ;
-        std::map<MessageQueue, long long> cloneOffsetTable(const std::string& topic);
-
-    private:
-        OffsetSerializeWrapper* readLocalOffset();
-        OffsetSerializeWrapper* readLocalOffsetBak();
-
-    private:
-        MQClientFactory* m_pMQClientFactory;
-        std::string m_groupName;
-        std::string m_storePath;
-        std::map<MessageQueue, kpr::AtomicLong> m_offsetTable;
-        kpr::RWMutex m_tableMutex;
-    };
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/consumer/MQConsumerInner.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/consumer/MQConsumerInner.h b/rocketmq-client4cpp/src/consumer/MQConsumerInner.h
deleted file mode 100755
index ed83621..0000000
--- a/rocketmq-client4cpp/src/consumer/MQConsumerInner.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * Copyright (C) 2013 kangliqiang ,kangliq@163.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __MQCONSUMERINNER_H__
-#define __MQCONSUMERINNER_H__
-
-#include <string>
-#include <set>
-
-#include "ConsumeType.h"
-#include "SubscriptionData.h"
-
-namespace rmq
-{
-    class MessageQueue;
-
-    class MQConsumerInner
-    {
-    public:
-        virtual ~MQConsumerInner() {}
-        virtual std::string groupName() = 0;
-        virtual MessageModel messageModel() = 0;
-        virtual ConsumeType consumeType() = 0;
-        virtual ConsumeFromWhere consumeFromWhere() = 0;
-        virtual std::set<SubscriptionData> subscriptions() = 0;
-        virtual void doRebalance() = 0;
-        virtual void persistConsumerOffset() = 0;
-        virtual void updateTopicSubscribeInfo(const std::string& topic, const std::set<MessageQueue>& info) = 0;
-        virtual bool isSubscribeTopicNeedUpdate(const std::string& topic) = 0;
-    };
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/consumer/MessageQueueLock.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/consumer/MessageQueueLock.h b/rocketmq-client4cpp/src/consumer/MessageQueueLock.h
deleted file mode 100755
index 65af99e..0000000
--- a/rocketmq-client4cpp/src/consumer/MessageQueueLock.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __MESSAGEQUEUELOCK_H__
-#define __MESSAGEQUEUELOCK_H__
-
-#include <map>
-#include "Mutex.h"
-#include "ScopedLock.h"
-#include "MessageQueue.h"
-
-namespace rmq
-{
-    class MessageQueueLock
-    {
-    public:
-        MessageQueueLock()
-        {
-
-        }
-
-        ~MessageQueueLock()
-        {
-            std::map<MessageQueue, kpr::Mutex*>::iterator it = m_mqLockTable.begin();
-
-            for (; it != m_mqLockTable.end(); it++)
-            {
-                delete it->second;
-            }
-        }
-
-        kpr::Mutex* fetchLockObject(MessageQueue& mq)
-        {
-            kpr::ScopedLock<kpr::Mutex> lock(m_lock);
-            std::map<MessageQueue, kpr::Mutex*>::iterator it = m_mqLockTable.find(mq);
-            kpr::Mutex* objLock;
-            if (it == m_mqLockTable.end())
-            {
-                objLock = new kpr::Mutex();
-                m_mqLockTable[mq] = objLock;
-            }
-            else
-            {
-                objLock = it->second;
-            }
-
-            return objLock;
-        }
-
-    private:
-        std::map<MessageQueue, kpr::Mutex*> m_mqLockTable;
-        kpr::Mutex m_lock;
-    };
-}
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/consumer/ProcessQueue.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/consumer/ProcessQueue.cpp b/rocketmq-client4cpp/src/consumer/ProcessQueue.cpp
deleted file mode 100755
index f90e502..0000000
--- a/rocketmq-client4cpp/src/consumer/ProcessQueue.cpp
+++ /dev/null
@@ -1,445 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#include "ProcessQueue.h"
-#include "MessageExt.h"
-#include "KPRUtil.h"
-#include "UtilAll.h"
-#include "ScopedLock.h"
-#include "DefaultMQPushConsumer.h"
-#include "DefaultMQPushConsumerImpl.h"
-
-namespace rmq
-{
-
-ProcessQueue::ProcessQueue()
-{
-    m_lastPullTimestamp = KPRUtil::GetCurrentTimeMillis();
-    m_lastConsumeTimestamp = KPRUtil::GetCurrentTimeMillis();
-    m_queueOffsetMax = 0L;
-    m_msgCount = 0;
-    m_dropped = false;
-    m_locked = false;
-    m_lastLockTimestamp = KPRUtil::GetCurrentTimeMillis();
-    m_consuming = false;
-}
-
-bool ProcessQueue::isLockExpired()
-{
-    bool result = (KPRUtil::GetCurrentTimeMillis() - m_lastLockTimestamp) >
-                  s_RebalanceLockMaxLiveTime;
-    return result;
-}
-
-bool ProcessQueue::isPullExpired()
-{
-    bool result = (KPRUtil::GetCurrentTimeMillis() - m_lastPullTimestamp) >
-                  s_PullMaxIdleTime;
-    return result;
-}
-
-
-void ProcessQueue::cleanExpiredMsg(DefaultMQPushConsumer* pPushConsumer)
-{
-    if (pPushConsumer->getDefaultMQPushConsumerImpl()->isConsumeOrderly())
-    {
-        return;
-    }
-
-	long long now = KPRUtil::GetCurrentTimeMillis();
-    int loop = m_msgTreeMap.size() < 16 ? m_msgTreeMap.size() : 16;
-    for (int i = 0; i < loop; i++)
-    {
-        MessageExt* msg = NULL;
-        try
-        {
-            kpr::ScopedRLock<kpr::RWMutex> lock(m_lockTreeMap);
-            if (m_msgTreeMap.empty())
-            {
-            	return;
-            }
-
-            MessageExt* firstMsg = m_msgTreeMap.begin()->second;
-            long long startTimestamp = UtilAll::str2ll(firstMsg->getProperty(Message::PROPERTY_CONSUME_START_TIMESTAMP).c_str());
-            if (startTimestamp > 0 && (now - startTimestamp) > (pPushConsumer->getConsumeTimeout() * 60 * 1000))
-            {
-                msg = firstMsg;
-            }
-            else
-            {
-                return;
-            }
-        }
-        catch (...)
-        {
-            RMQ_ERROR("getExpiredMsg exception");
-        }
-
-        try
-        {
-            pPushConsumer->sendMessageBack((*msg), 3);
-            RMQ_WARN("send expire msg back. topic={%s}, msgId={%s}, storeHost={%s}, queueId={%d}, queueOffset={%lld}",
-                     msg->getTopic().c_str(), msg->getMsgId().c_str(), msg->getStoreHostString().c_str(),
-                     msg->getQueueId(), msg->getQueueOffset());
-
-            try
-            {
-                kpr::ScopedWLock<kpr::RWMutex> lock(m_lockTreeMap);
-                if (!m_msgTreeMap.empty() && msg->getQueueOffset() == m_msgTreeMap.begin()->first)
-                {
-                    try
-                    {
-                        m_msgTreeMap.erase(m_msgTreeMap.begin());
-                        m_msgCount -= 1;
-                        // if free msg, may be coredump
-                        //delete msg;
-                    }
-                    catch (...)
-                    {
-                        RMQ_ERROR("send expired msg exception");
-                    }
-                }
-
-            }
-            catch (...)
-            {
-                RMQ_ERROR("delExpiredMsg exception");
-            }
-        }
-        catch (...)
-        {
-            RMQ_ERROR("send expired msg exception");
-        }
-    }
-}
-
-
-bool ProcessQueue::putMessage(const std::list<MessageExt *> &msgs)
-{
-    bool dispathToConsume = false;
-
-    try
-    {
-        kpr::ScopedWLock<kpr::RWMutex> lock(m_lockTreeMap);
-        int validMsgCnt = 0;
-        std::list<MessageExt *>::const_iterator it = msgs.begin();
-
-        for (; it != msgs.end(); it++)
-        {
-            MessageExt *msg = (*it);
-
-            if (m_msgTreeMap.find(msg->getQueueOffset()) == m_msgTreeMap.end())
-            {
-                validMsgCnt++;
-                m_queueOffsetMax = msg->getQueueOffset();
-            }
-
-            m_msgTreeMap[msg->getQueueOffset()] = msg;
-        }
-
-        m_msgCount += validMsgCnt;
-
-        if (!m_msgTreeMap.empty() && !m_consuming)
-        {
-            dispathToConsume = true;
-            m_consuming = true;
-        }
-    }
-    catch (...)
-    {
-        RMQ_ERROR("putMessage exception");
-    }
-
-    return dispathToConsume;
-}
-
-long long ProcessQueue::getMaxSpan()
-{
-    try
-    {
-        kpr::ScopedRLock<kpr::RWMutex> lock(m_lockTreeMap);
-
-        if (!m_msgTreeMap.empty())
-        {
-            std::map<long long, MessageExt *>::iterator it1 = m_msgTreeMap.begin();
-            std::map<long long, MessageExt *>::iterator it2 = m_msgTreeMap.end();
-            it2--;
-            return it2->first - it1->first;
-        }
-    }
-    catch (...)
-    {
-        RMQ_ERROR("getMaxSpan exception");
-    }
-
-    return 0;
-}
-
-long long ProcessQueue::removeMessage(std::list<MessageExt *> &msgs)
-{
-    long long result = -1;
-    unsigned long long now = KPRUtil::GetCurrentTimeMillis();
-
-    try
-    {
-        kpr::ScopedWLock<kpr::RWMutex> lock(m_lockTreeMap);
-        m_lastConsumeTimestamp = now;
-
-        if (!m_msgTreeMap.empty())
-        {
-            result = m_queueOffsetMax + 1;
-            int removedCnt = 0;
-            std::list<MessageExt *>::iterator it = msgs.begin();
-
-            for (; it != msgs.end();)
-            {
-                MessageExt *msg = (*it);
-
-                if (m_msgTreeMap.find(msg->getQueueOffset()) != m_msgTreeMap.end())
-                {
-                    removedCnt++;
-                }
-
-                m_msgTreeMap.erase(msg->getQueueOffset());
-                //TODO delete message?
-                it = msgs.erase(it);
-                delete msg;
-            }
-
-            m_msgCount -= removedCnt;
-
-            if (!m_msgTreeMap.empty())
-            {
-                std::map<long long, MessageExt *>::iterator it = m_msgTreeMap.begin();
-                result = it->first;
-            }
-        }
-    }
-    catch (...)
-    {
-        RMQ_ERROR("removeMessage exception");
-    }
-
-    return result;
-}
-
-
-void ProcessQueue::clear()
-{
-    try
-    {
-        kpr::ScopedWLock<kpr::RWMutex> lock(m_lockTreeMap);
-        m_msgTreeMap.clear();
-        m_msgTreeMapTemp.clear();
-        m_msgCount.set(0);
-        m_queueOffsetMax = 0;
-    }
-    catch (...)
-    {
-        RMQ_ERROR("clear exception");
-    }
-
-    return;
-}
-
-
-std::map<long long, MessageExt *> ProcessQueue::getMsgTreeMap()
-{
-    return m_msgTreeMap;
-}
-
-kpr::AtomicInteger ProcessQueue::getMsgCount()
-{
-    return m_msgCount;
-}
-
-bool ProcessQueue::isDropped()
-{
-    return m_dropped;
-}
-
-void ProcessQueue::setDropped(bool dropped)
-{
-    m_dropped = dropped;
-}
-
-unsigned long long ProcessQueue::getLastPullTimestamp()
-{
-    return m_lastPullTimestamp;
-}
-
-
-void ProcessQueue::setLastPullTimestamp(unsigned long long lastPullTimestamp)
-{
-    m_lastPullTimestamp = lastPullTimestamp;
-}
-
-
-unsigned long long ProcessQueue::getLastConsumeTimestamp()
-{
-    return m_lastConsumeTimestamp;
-}
-
-
-void ProcessQueue::setLastConsumeTimestamp(unsigned long long
-        lastConsumeTimestamp)
-{
-    m_lastConsumeTimestamp = lastConsumeTimestamp;
-}
-
-
-/**
-* ========================================================================
-*/
-kpr::Mutex &ProcessQueue::getLockConsume()
-{
-    return m_lockConsume;
-}
-
-void ProcessQueue::setLocked(bool locked)
-{
-    m_locked = locked;
-}
-
-bool ProcessQueue::isLocked()
-{
-    return m_locked;
-}
-
-long long ProcessQueue::getTryUnlockTimes()
-{
-    return m_tryUnlockTimes.get();
-}
-
-void ProcessQueue::incTryUnlockTimes()
-{
-    m_tryUnlockTimes++;
-}
-
-
-void ProcessQueue::rollback()
-{
-    try
-    {
-        kpr::ScopedWLock<kpr::RWMutex> lock(m_lockTreeMap);
-        m_msgTreeMap = m_msgTreeMapTemp;
-        m_msgTreeMapTemp.clear();
-    }
-    catch (...)
-    {
-        RMQ_ERROR("rollback exception");
-    }
-}
-
-long long ProcessQueue::commit()
-{
-    try
-    {
-        kpr::ScopedWLock<kpr::RWMutex> lock(m_lockTreeMap);
-
-        if (!m_msgTreeMapTemp.empty())
-        {
-            std::map<long long, MessageExt *>::iterator it = m_msgTreeMapTemp.end();
-            it--;
-            long long offset = it->first;
-            m_msgCount -= m_msgTreeMapTemp.size();
-            m_msgTreeMapTemp.clear();
-            return offset + 1;
-        }
-    }
-    catch (...)
-    {
-        RMQ_ERROR("commit exception");
-    }
-
-    return -1;
-}
-
-void ProcessQueue::makeMessageToCosumeAgain(const std::list<MessageExt *> &msgs)
-{
-    try
-    {
-        kpr::ScopedWLock<kpr::RWMutex> lock(m_lockTreeMap);
-        std::list<MessageExt *>::const_iterator it = msgs.begin();
-
-        for (; it != msgs.end(); it++)
-        {
-            MessageExt *msg = (*it);
-            m_msgTreeMapTemp.erase(msg->getQueueOffset());
-            m_msgTreeMap[msg->getQueueOffset()] = msg;
-        }
-    }
-    catch (...)
-    {
-        RMQ_ERROR("makeMessageToCosumeAgain exception");
-    }
-}
-
-std::list<MessageExt *> ProcessQueue::takeMessages(int batchSize)
-{
-    std::list<MessageExt *> result;
-    unsigned long long now = KPRUtil::GetCurrentTimeMillis();
-
-    try
-    {
-        kpr::ScopedWLock<kpr::RWMutex> lock(m_lockTreeMap);
-        m_lastConsumeTimestamp = now;
-
-        if (!m_msgTreeMap.empty())
-        {
-            for (int i = 0; i < batchSize; i++)
-            {
-                std::map<long long, MessageExt *>::iterator it = m_msgTreeMap.begin();
-
-                if (it != m_msgTreeMap.end())
-                {
-                    result.push_back(it->second);
-                    m_msgTreeMapTemp[it->first] = it->second;
-                    m_msgTreeMap.erase(it);
-                }
-                else
-                {
-                    break;
-                }
-            }
-
-            if (result.empty())
-            {
-                m_consuming = false;
-            }
-        }
-    }
-    catch (...)
-    {
-        RMQ_ERROR("takeMessags exception");
-    }
-
-    return result;
-}
-
-long long ProcessQueue::getLastLockTimestamp()
-{
-    return m_lastLockTimestamp;
-}
-
-void ProcessQueue::setLastLockTimestamp(long long lastLockTimestamp)
-{
-    m_lastLockTimestamp = lastLockTimestamp;
-}
-
-
-}
-

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/consumer/ProcessQueue.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/consumer/ProcessQueue.h b/rocketmq-client4cpp/src/consumer/ProcessQueue.h
deleted file mode 100755
index 559dd7f..0000000
--- a/rocketmq-client4cpp/src/consumer/ProcessQueue.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __PROCESSQUEUE_H__
-#define __PROCESSQUEUE_H__
-
-#include <list>
-#include <map>
-#include "Mutex.h"
-#include "AtomicValue.h"
-
-namespace rmq
-{
-    class MessageExt;
-	class DefaultMQPushConsumer;
-
-    class ProcessQueue
-    {
-    public:
-		static const unsigned int s_RebalanceLockMaxLiveTime = 30000;
-		static const unsigned int s_RebalanceLockInterval = 20000;
-		static const unsigned int s_PullMaxIdleTime = 120000;
-
-    public:
-        ProcessQueue();
-
-        bool isLockExpired();
-		bool isPullExpired();
-
-		void cleanExpiredMsg(DefaultMQPushConsumer* pPushConsumer);
-        bool putMessage(const std::list<MessageExt*>& msgs);
-
-        long long getMaxSpan();
-        long long removeMessage(std::list<MessageExt*>& msgs);
-
-		void clear();
-
-        std::map<long long, MessageExt*> getMsgTreeMap();
-        kpr::AtomicInteger getMsgCount();
-        bool isDropped();
-        void setDropped(bool dropped);
-
-		unsigned long long getLastPullTimestamp();
-		void setLastPullTimestamp(unsigned long long lastPullTimestamp);
-
-		unsigned long long getLastConsumeTimestamp();
-		void setLastConsumeTimestamp(unsigned long long lastConsumeTimestamp);
-
-        /**
-        * ========================================================================
-        */
-		kpr::Mutex& getLockConsume();
-        void setLocked(bool locked);
-        bool isLocked();
-		long long getTryUnlockTimes();
-		void incTryUnlockTimes();
-
-        void rollback();
-        long long commit();
-        void makeMessageToCosumeAgain(const std::list<MessageExt*>& msgs);
-
-        std::list<MessageExt*> takeMessages(int batchSize);
-
-        long long getLastLockTimestamp();
-        void setLastLockTimestamp(long long lastLockTimestamp);
-
-
-    private:
-        kpr::RWMutex m_lockTreeMap;
-        std::map<long long, MessageExt*> m_msgTreeMap;
-        volatile long long m_queueOffsetMax ;
-        kpr::AtomicInteger m_msgCount;
-        volatile bool m_dropped;
-        volatile unsigned long long m_lastPullTimestamp;
-		volatile unsigned long long m_lastConsumeTimestamp;
-
-        /**
-        * order message
-        */
-        kpr::Mutex m_lockConsume;
-        volatile bool m_locked;
-        volatile unsigned long long m_lastLockTimestamp;
-        volatile bool m_consuming;
-        std::map<long long, MessageExt*> m_msgTreeMapTemp;
-        kpr::AtomicInteger m_tryUnlockTimes;
-    };
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/consumer/PullAPIWrapper.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/consumer/PullAPIWrapper.cpp b/rocketmq-client4cpp/src/consumer/PullAPIWrapper.cpp
deleted file mode 100755
index c520e4c..0000000
--- a/rocketmq-client4cpp/src/consumer/PullAPIWrapper.cpp
+++ /dev/null
@@ -1,222 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#include "PullAPIWrapper.h"
-
-#include <stdlib.h>
-#include <list>
-#include <set>
-#include "ScopedLock.h"
-#include "MQClientFactory.h"
-#include "PullCallback.h"
-#include "MixAll.h"
-#include "PullSysFlag.h"
-#include "CommandCustomHeader.h"
-#include "MQClientAPIImpl.h"
-#include "MQClientException.h"
-#include "SubscriptionData.h"
-#include "UtilAll.h"
-#include "MessageExt.h"
-#include "PullResultExt.h"
-#include "MessageDecoder.h"
-#include "VirtualEnvUtil.h"
-
-namespace rmq
-{
-
-PullAPIWrapper::PullAPIWrapper(MQClientFactory* pMQClientFactory, const std::string& consumerGroup)
-{
-    m_pMQClientFactory = pMQClientFactory;
-    m_consumerGroup = consumerGroup;
-}
-
-void  PullAPIWrapper::updatePullFromWhichNode(MessageQueue& mq, long brokerId)
-{
-    std::map<MessageQueue, kpr::AtomicInteger>::iterator it;
-    {
-        kpr::ScopedRLock<kpr::RWMutex> lock(m_pullFromWhichNodeTableLock);
-        it = m_pullFromWhichNodeTable.find(mq);
-        if (it != m_pullFromWhichNodeTable.end())
-        {
-            it->second.set(brokerId);
-            return;
-        }
-    }
-
-    kpr::ScopedWLock<kpr::RWMutex> lock(m_pullFromWhichNodeTableLock);
-    m_pullFromWhichNodeTable[mq] = kpr::AtomicInteger(brokerId);
-}
-
-PullResult* PullAPIWrapper::processPullResult(MessageQueue& mq,
-        PullResult& pullResult,
-        SubscriptionData& subscriptionData)
-{
-    std::string projectGroupPrefix = m_pMQClientFactory->getMQClientAPIImpl()->getProjectGroupPrefix();
-    PullResultExt& pullResultExt = (PullResultExt&) pullResult;
-
-    updatePullFromWhichNode(mq, pullResultExt.suggestWhichBrokerId);
-
-    if (pullResult.pullStatus == FOUND)
-    {
-        std::list<MessageExt*> msgList =
-            MessageDecoder::decodes(pullResultExt.messageBinary, pullResultExt.messageBinaryLen);
-
-        std::list<MessageExt*> msgListFilterAgain;
-
-        if (!subscriptionData.getTagsSet().empty())
-        {
-            std::list<MessageExt*>::iterator it = msgList.begin();
-            for (; it != msgList.end();)
-            {
-                MessageExt* msg = *it;
-                if (!msg->getTags().empty())
-                {
-                    std::set<std::string>& tags = subscriptionData.getTagsSet();
-                    if (tags.find(msg->getTags()) != tags.end())
-                    {
-                        msgListFilterAgain.push_back(msg);
-                        it = msgList.erase(it);
-                    }
-                    else
-                    {
-                        it++;
-                    }
-                }
-            }
-        }
-        else
-        {
-            msgListFilterAgain.assign(msgList.begin(), msgList.end());
-            msgList.clear();
-        }
-
-        if (!UtilAll::isBlank(projectGroupPrefix))
-        {
-            subscriptionData.setTopic(VirtualEnvUtil::clearProjectGroup(subscriptionData.getTopic(),
-                                      projectGroupPrefix));
-            mq.setTopic(VirtualEnvUtil::clearProjectGroup(mq.getTopic(), projectGroupPrefix));
-
-            std::list<MessageExt*>::iterator it = msgListFilterAgain.begin();
-            for (; it != msgListFilterAgain.end(); it++)
-            {
-                MessageExt* msg = *it;
-                msg->setTopic(VirtualEnvUtil::clearProjectGroup(msg->getTopic(), projectGroupPrefix));
-
-                msg->putProperty(Message::PROPERTY_MIN_OFFSET, UtilAll::toString(pullResult.minOffset));
-                msg->putProperty(Message::PROPERTY_MAX_OFFSET, UtilAll::toString(pullResult.maxOffset));
-            }
-        }
-        else
-        {
-            std::list<MessageExt*>::iterator it = msgListFilterAgain.begin();
-            for (; it != msgListFilterAgain.end(); it++)
-            {
-                MessageExt* msg = *it;
-
-                msg->putProperty(Message::PROPERTY_MIN_OFFSET, UtilAll::toString(pullResult.minOffset));
-                msg->putProperty(Message::PROPERTY_MAX_OFFSET, UtilAll::toString(pullResult.maxOffset));
-            }
-        }
-
-        std::list<MessageExt*>::iterator it = msgListFilterAgain.begin();
-        for (; it != msgListFilterAgain.end(); it++)
-        {
-            pullResultExt.msgFoundList.push_back(*it);
-        }
-
-        it = msgList.begin();
-        for (; it != msgList.end(); it++)
-        {
-            delete *it;
-        }
-
-        delete[] pullResultExt.messageBinary;
-        pullResultExt.messageBinary = NULL;
-        pullResultExt.messageBinaryLen = 0;
-    }
-
-    return &pullResult;
-}
-
-long PullAPIWrapper::recalculatePullFromWhichNode(MessageQueue& mq)
-{
-    kpr::ScopedRLock<kpr::RWMutex> lock(m_pullFromWhichNodeTableLock);
-    std::map<MessageQueue, kpr::AtomicInteger>::iterator it = m_pullFromWhichNodeTable.find(mq);
-    if (it != m_pullFromWhichNodeTable.end())
-    {
-        return it->second.get();
-    }
-
-    return MixAll::MASTER_ID;
-}
-
-PullResult* PullAPIWrapper::pullKernelImpl(MessageQueue& mq,
-        const std::string& subExpression,
-        long long subVersion,
-        long long offset,
-        int maxNums,
-        int sysFlag,
-        long long commitOffset,
-        long long brokerSuspendMaxTimeMillis,
-        int timeoutMillis,
-        CommunicationMode communicationMode,
-        PullCallback* pPullCallback)
-{
-    FindBrokerResult findBrokerResult =
-        m_pMQClientFactory->findBrokerAddressInSubscribe(mq.getBrokerName(),
-                recalculatePullFromWhichNode(mq), false);
-    if (findBrokerResult.brokerAddr.empty())
-    {
-        m_pMQClientFactory->updateTopicRouteInfoFromNameServer(mq.getTopic());
-        findBrokerResult = m_pMQClientFactory->findBrokerAddressInSubscribe(mq.getBrokerName(),
-                           recalculatePullFromWhichNode(mq), false);
-    }
-
-    if (!findBrokerResult.brokerAddr.empty())
-    {
-        int sysFlagInner = sysFlag;
-
-        if (findBrokerResult.slave)
-        {
-            sysFlagInner = PullSysFlag::clearCommitOffsetFlag(sysFlagInner);
-        }
-
-        PullMessageRequestHeader* requestHeader = new PullMessageRequestHeader();
-        requestHeader->consumerGroup = m_consumerGroup;
-        requestHeader->topic = mq.getTopic();
-        requestHeader->queueId = mq.getQueueId();
-        requestHeader->queueOffset = offset;
-        requestHeader->maxMsgNums = maxNums;
-        requestHeader->sysFlag = sysFlagInner;
-        requestHeader->commitOffset = commitOffset;
-        requestHeader->suspendTimeoutMillis = brokerSuspendMaxTimeMillis;
-        requestHeader->subscription = subExpression;
-        requestHeader->subVersion = subVersion;
-
-        PullResult* pullResult = m_pMQClientFactory->getMQClientAPIImpl()->pullMessage(//
-                                     findBrokerResult.brokerAddr,//
-                                     requestHeader,//
-                                     timeoutMillis,//
-                                     communicationMode,//
-                                     pPullCallback);
-
-        return pullResult;
-    }
-
-    THROW_MQEXCEPTION(MQClientException, "The broker[" + mq.getBrokerName() + "] not exist", -1);
-}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/consumer/PullAPIWrapper.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/consumer/PullAPIWrapper.h b/rocketmq-client4cpp/src/consumer/PullAPIWrapper.h
deleted file mode 100755
index d5ec787..0000000
--- a/rocketmq-client4cpp/src/consumer/PullAPIWrapper.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __PULLAPIWRAPPER_H__
-#define __PULLAPIWRAPPER_H__
-
-#include <string>
-#include <map>
-
-#include "AtomicValue.h"
-#include "PullResult.h"
-#include "MessageQueue.h"
-#include "CommunicationMode.h"
-#include "Mutex.h"
-
-namespace rmq
-{
-  class MQClientFactory;
-  class PullCallback;
-  class SubscriptionData;
-
-  class PullAPIWrapper
-  {
-  public:
-      PullAPIWrapper(MQClientFactory* pMQClientFactory, const std::string& consumerGroup);
-      void updatePullFromWhichNode(MessageQueue& mq, long brokerId);
-
-
-      PullResult* processPullResult(MessageQueue& mq,
-                                    PullResult& pullResult,
-                                    SubscriptionData& subscriptionData);
-      long recalculatePullFromWhichNode(MessageQueue& mq);
-
-      PullResult* pullKernelImpl(MessageQueue& mq,
-                                 const std::string& subExpression,
-                                 long long subVersion,
-                                 long long offset,
-                                 int maxNums,
-                                 int sysFlag,
-                                 long long commitOffset,
-                                 long long brokerSuspendMaxTimeMillis,
-                                 int timeoutMillis,
-                                 CommunicationMode communicationMode,
-                                 PullCallback* pPullCallback);
-
-  private:
-      std::map<MessageQueue, kpr::AtomicInteger> m_pullFromWhichNodeTable;
-      kpr::RWMutex m_pullFromWhichNodeTableLock;
-      MQClientFactory* m_pMQClientFactory;
-      std::string m_consumerGroup;
-  };
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/consumer/PullMessageService.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/consumer/PullMessageService.cpp b/rocketmq-client4cpp/src/consumer/PullMessageService.cpp
deleted file mode 100755
index 6d9972e..0000000
--- a/rocketmq-client4cpp/src/consumer/PullMessageService.cpp
+++ /dev/null
@@ -1,171 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#include "PullMessageService.h"
-#include <list>
-#include "MQClientFactory.h"
-#include "MQConsumerInner.h"
-#include "PullRequest.h"
-#include "DefaultMQPushConsumerImpl.h"
-#include "ScopedLock.h"
-
-namespace rmq
-{
-
-class SubmitPullRequestLater : public kpr::TimerHandler
-{
-public:
-    SubmitPullRequestLater(PullMessageService* pService, PullRequest* pPullRequest)
-        : m_pService(pService), m_pPullRequest(pPullRequest)
-    {
-
-    }
-
-    void OnTimeOut(unsigned int timerID)
-    {
-    	try
-    	{
-        	m_pService->executePullRequestImmediately(m_pPullRequest);
-        }
-        catch(...)
-        {
-        	RMQ_ERROR("SubmitPullRequestLater OnTimeOut exception");
-        }
-
-        delete this;
-    }
-
-private:
-    PullMessageService* m_pService;
-    PullRequest* m_pPullRequest;
-};
-
-
-PullMessageService::PullMessageService(MQClientFactory* pMQClientFactory)
-    : ServiceThread("PullMessageService"),
-      m_pMQClientFactory(pMQClientFactory)
-{
-    m_TimerThread = new kpr::TimerThread("PullMessageService-timer", 10);
-    m_TimerThread->Start();
-}
-
-
-PullMessageService::~PullMessageService()
-{
-
-}
-
-
-void PullMessageService::executePullRequestLater(PullRequest* pPullRequest, long timeDelay)
-{
-    SubmitPullRequestLater* pHandler = new SubmitPullRequestLater(this, pPullRequest);
-    m_TimerThread->RegisterTimer(0, timeDelay, pHandler, false);
-}
-
-
-void PullMessageService::executeTaskLater(kpr::TimerHandler* pHandler, long timeDelay)
-{
-    m_TimerThread->RegisterTimer(0, timeDelay, pHandler, false);
-}
-
-
-void PullMessageService::executePullRequestImmediately(PullRequest* pPullRequest)
-{
-    try
-    {
-        {
-            kpr::ScopedLock<kpr::Mutex> lock(m_lock);
-            m_pullRequestQueue.push_back(pPullRequest);
-        }
-
-        wakeup();
-    }
-    catch (...)
-    {
-    	RMQ_ERROR("executePullRequestImmediately pullRequestQueue.push");
-    }
-}
-
-void PullMessageService::Run()
-{
-	RMQ_INFO("%s service started", getServiceName().c_str());
-
-    while (!m_stoped)
-    {
-        try
-        {
-            bool wait = false;
-            {
-                kpr::ScopedLock<kpr::Mutex> lock(m_lock);
-                if (m_pullRequestQueue.empty())
-                {
-                    wait = true;
-                }
-            }
-
-            if (wait)
-            {
-                waitForRunning(5000);
-            }
-
-            PullRequest* pullRequest = NULL;
-            {
-                kpr::ScopedLock<kpr::Mutex> lock(m_lock);
-                if (!m_pullRequestQueue.empty())
-                {
-                    pullRequest = m_pullRequestQueue.front();
-                    m_pullRequestQueue.pop_front();
-                }
-            }
-
-            if (pullRequest != NULL)
-            {
-                pullMessage(pullRequest);
-            }
-        }
-        catch (...)
-        {
-			RMQ_ERROR("Pull Message Service Run Method exception");
-        }
-    }
-
-    m_TimerThread->Stop();
-    m_TimerThread->Join();
-
-    RMQ_INFO("%s service end", getServiceName().c_str());
-}
-
-std::string PullMessageService::getServiceName()
-{
-    return "PullMessageService";
-}
-
-
-void PullMessageService::pullMessage(PullRequest* pPullRequest)
-{
-    MQConsumerInner* consumer = m_pMQClientFactory->selectConsumer(pPullRequest->getConsumerGroup());
-    if (consumer != NULL)
-    {
-        DefaultMQPushConsumerImpl* impl = (DefaultMQPushConsumerImpl*) consumer;
-        impl->pullMessage(pPullRequest);
-    }
-    else
-    {
-        RMQ_WARN("No matched consumer for the PullRequest {%s}, drop it", pPullRequest->toString().c_str());
-    }
-}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/consumer/PullMessageService.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/consumer/PullMessageService.h b/rocketmq-client4cpp/src/consumer/PullMessageService.h
deleted file mode 100755
index d6ebcee..0000000
--- a/rocketmq-client4cpp/src/consumer/PullMessageService.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#ifndef __PULLMESSAGESERVICE_H__
-#define __PULLMESSAGESERVICE_H__
-
-#include <list>
-#include "RocketMQClient.h"
-#include "ServiceThread.h"
-#include "TimerThread.h"
-#include "PullRequest.h"
-
-namespace rmq
-{
-    class MQClientFactory;
-    class MQConsumerInner;
-    class PullRequest;
-
-    class PullMessageService : public ServiceThread
-    {
-    public:
-        PullMessageService(MQClientFactory* pMQClientFactory);
-        ~PullMessageService();
-
-        void executePullRequestLater(PullRequest* pPullRequest, long timeDelay);
-		void executeTaskLater(kpr::TimerHandler* pHandler, long timeDelay);
-
-        void executePullRequestImmediately(PullRequest* pPullRequest);
-        std::string getServiceName();
-
-        void Run();
-    private:
-        void pullMessage(PullRequest* pPullRequest);
-
-    private:
-        std::list<PullRequest*> m_pullRequestQueue;
-        kpr::Mutex m_lock;
-        MQClientFactory* m_pMQClientFactory;
-        kpr::TimerThreadPtr m_TimerThread;
-    };
-	typedef kpr::RefHandleT<PullMessageService> PullMessageServicePtr;
-}
-
-#endif



[02/17] incubator-rocketmq-externals git commit: Polish cpp module

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/protocol/RemotingCommand.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/protocol/RemotingCommand.cpp b/rocketmq-client4cpp/src/protocol/RemotingCommand.cpp
deleted file mode 100755
index 2f58d20..0000000
--- a/rocketmq-client4cpp/src/protocol/RemotingCommand.cpp
+++ /dev/null
@@ -1,421 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#include "RemotingCommand.h"
-
-#include <sstream>
-#include <string>
-#include <stdlib.h>
-#include <string.h>
-#include <json/json.h>
-#include "SocketUtil.h"
-#include "CommandCustomHeader.h"
-#include "MQVersion.h"
-
-namespace rmq
-{
-
-kpr::AtomicInteger RemotingCommand::s_seqNumber = 0;
-volatile int RemotingCommand::s_configVersion = MQVersion::s_CurrentVersion;
-
-RemotingCommand::RemotingCommand(int code)
-    : m_code(code), m_language("CPP"), m_version(0), m_opaque(s_seqNumber++),
-      m_flag(0), m_remark(""), m_pCustomHeader(NULL),
-      m_dataLen(0), m_pData(NULL), m_bodyLen(0), m_pBody(NULL), m_releaseBody(false)
-{
-}
-
-RemotingCommand::RemotingCommand(int code,
-                                 const std::string& language,
-                                 int version,
-                                 int opaque,
-                                 int flag,
-                                 const std::string& remark,
-                                 CommandCustomHeader* pCustomHeader)
-    : m_code(code), m_language(language), m_version(version), m_opaque(opaque),
-      m_flag(flag), m_remark(remark), m_pCustomHeader(pCustomHeader),
-      m_dataLen(0), m_pData(NULL), m_bodyLen(0), m_pBody(NULL), m_releaseBody(false)
-{
-
-}
-
-RemotingCommand::~RemotingCommand()
-{
-	if (m_pData)
-	{
-    	delete[] m_pData;
-    }
-
-    if (m_releaseBody)
-    {
-        delete[] m_pBody;
-        m_bodyLen = 0;
-        m_pBody = NULL;
-    }
-
-    // TODO: maybe memleak
-    if (m_pCustomHeader)
-    {
-        delete m_pCustomHeader;
-        m_pCustomHeader = NULL;
-    }
-}
-
-void RemotingCommand::encode()
-{
-    std::string extHeader = "{}";
-    if (m_pCustomHeader)
-    {
-        m_pCustomHeader->encode(extHeader);
-    }
-
-    std::stringstream ss;
-    ss << "{"
-       << CODE_STRING << m_code << ","
-       << language_STRING << "\"CPP\","
-       << version_STRING << m_version << ","
-       << opaque_STRING << m_opaque << ","
-       << flag_STRING << m_flag << ","
-       << remark_STRING << "\"" << m_remark << "\","
-       << extFields_STRING << extHeader
-       << "}";
-
-	/* protocol:
-	 * | 4        | 4           | headerlen    | bodylen    |
-	 * | 1-length | 2-headerlen | 3-headerdata | 4-bodydata |
-	 */
-    int headLen = ss.str().size();
-    m_dataLen = 8 + headLen + m_bodyLen;
-    m_pData = new char[m_dataLen];
-
-	//length = len(2 + 3 + 4)
-    int tmp = htonl(4 + headLen + m_bodyLen);
-    memcpy(m_pData, &tmp, 4);
-
-	//headerlength = len(3)
-    tmp = htonl(headLen);
-    memcpy(m_pData + 4, &tmp, 4);
-
-    //headerdata
-    memcpy(m_pData + 8, ss.str().c_str(), headLen);
-
-    //bodydata
-    if (m_pBody)
-    {
-    	memcpy(m_pData + 8 + headLen, m_pBody, m_bodyLen);
-    }
-
-    //RMQ_DEBUG("encode|%s%s", ss.str().c_str(), m_pBody ? std::string(m_pBody, m_bodyLen).c_str() : "");
-}
-
-std::string RemotingCommand::toString() const
-{
-	std::string extHeader;
-    if (m_pCustomHeader)
-    {
-        m_pCustomHeader->encode(extHeader);
-    }
-
-    std::stringstream ss;
-    ss << "{"
-       << CODE_STRING << m_code << ","
-       << language_STRING << "\"CPP\","
-       << version_STRING << m_version << ","
-       << opaque_STRING << m_opaque << ","
-       << flag_STRING << m_flag << ","
-       << remark_STRING << "\"" << m_remark << "\"";
-    if (!extHeader.empty())
-    {
-        ss << "," << extFields_STRING << extHeader;
-    }
-    ss << "}";
-
-    if (m_pBody)
-    {
-        ss << "|" << m_bodyLen << "|" << std::string(m_pBody, m_bodyLen);
-    }
-
-    return ss.str();
-}
-
-
-const char* RemotingCommand::getData()
-{
-    return m_pData;
-}
-
-int RemotingCommand::getDataLen()
-{
-    return m_dataLen;
-}
-
-const char* RemotingCommand::getBody()
-{
-    return m_pBody;
-}
-
-int RemotingCommand::getBodyLen()
-{
-    return m_bodyLen;
-}
-
-void RemotingCommand::setBody(char* pData, int len, bool copy)
-{
-    m_releaseBody = copy;
-
-    if (copy)
-    {
-        m_pBody = new char[len];
-        m_bodyLen = len;
-        memcpy(m_pBody, pData, len);
-    }
-    else
-    {
-        m_pBody = pData;
-        m_bodyLen = len;
-    }
-}
-
-RemotingCommand* RemotingCommand::decode(const char* pData, int len)
-{
-    Json::Reader reader;
-    Json::Value object;
-
-    int headLen;
-    memcpy(&headLen, pData + 4, 4);
-    headLen = ntohl(headLen);
-
-    //RMQ_DEBUG("decode[%d,%d,%d]|%s%s", len, headLen, len - 8 - headLen, std::string(pData + 8, headLen).c_str(),
-    //          std::string(pData + 8 + headLen, len - 8 - headLen).c_str());
-
-    if (!reader.parse(pData + 8, pData + 8 + headLen, object))
-    {
-        RMQ_ERROR("parse header fail, %s", std::string(pData + 8, headLen).c_str());
-        return NULL;
-    }
-
-    int code = object["code"].asInt();
-    std::string language = object["language"].asString();
-    int version = object["version"].asInt();
-    int opaque = object["opaque"].asInt();
-    int flag = object["flag"].asInt();
-
-    Json::Value v = object["remark"];
-    std::string remark = "";
-    if (!v.isNull())
-    {
-        remark = object["remark"].asString();
-    }
-
-    RemotingCommand* cmd = new RemotingCommand(code,
-            language,
-            version,
-            opaque,
-            flag,
-            remark,
-            NULL);
-
-    int bodyLen = len - 8 - headLen;
-    if (bodyLen > 0)
-    {
-        cmd->setBody((char*)(pData + 8 + headLen), bodyLen, true);
-    }
-
-    return cmd;
-}
-
-CommandCustomHeader* RemotingCommand::makeCustomHeader(int code, const char* pData, int len)
-{
-    Json::Reader reader;
-    Json::Value object;
-
-    int headLen;
-    memcpy(&headLen, pData + 4, 4);
-    headLen = ntohl(headLen);
-
-    if (!reader.parse(pData + 8, pData + 8 + headLen, object))
-    {
-        RMQ_ERROR("parse header fail, %s", std::string(pData + 8, headLen).c_str());
-        return NULL;
-    }
-
-    if (object.isMember("extFields") && object["extFields"].isObject() && object["extFields"].size() > 0)
-    {
-        CommandCustomHeader* pCustomHeader = CommandCustomHeader::decode(
-        	code, object["extFields"], isResponseType());
-        if (pCustomHeader == NULL)
-        {
-        	RMQ_WARN("invalid extFields, %d, %s", code, std::string(pData + 8, headLen).c_str());
-        }
-
-        setCommandCustomHeader(pCustomHeader);
-        return pCustomHeader;
-    }
-
-    return NULL;
-}
-
-
-RemotingCommand* RemotingCommand::createRequestCommand(int code, CommandCustomHeader* pCustomHeader)
-{
-    RemotingCommand* cmd = new RemotingCommand(code);
-    cmd->setCommandCustomHeader(pCustomHeader);
-    setCmdVersion(cmd);
-
-    return cmd;
-}
-
-RemotingCommand* RemotingCommand::createResponseCommand(int code, const std::string& remark)
-{
-	return createResponseCommand(code, remark, NULL);
-}
-
-
-RemotingCommand* RemotingCommand::createResponseCommand(int code, const std::string& remark,
-	CommandCustomHeader* pCustomHeader)
-{
-    RemotingCommand* cmd = new RemotingCommand(code);
-    cmd->markResponseType();
-    cmd->setRemark(remark);
-    setCmdVersion(cmd);
-
-    if (pCustomHeader)
-    {
-    	cmd->setCommandCustomHeader(pCustomHeader);
-    }
-
-    return cmd;
-}
-
-
-void RemotingCommand::markResponseType()
-{
-    int bits = 1 << RPC_TYPE;
-    m_flag |= bits;
-}
-
-bool RemotingCommand::isResponseType()
-{
-    int bits = 1 << RPC_TYPE;
-    return (m_flag & bits) == bits;
-}
-
-void RemotingCommand::markOnewayRPC()
-{
-    int bits = 1 << RPC_ONEWAY;
-    m_flag |= bits;
-}
-
-bool RemotingCommand::isOnewayRPC()
-{
-    int bits = 1 << RPC_ONEWAY;
-    return (m_flag & bits) == bits;
-}
-
-void RemotingCommand::setCmdVersion(RemotingCommand* pCmd)
-{
-    if (s_configVersion >= 0)
-    {
-        pCmd->setVersion(s_configVersion);
-    }
-    else
-    {
-        int value = MQVersion::s_CurrentVersion;
-        pCmd->setVersion(value);
-        s_configVersion = value;
-    }
-}
-
-int RemotingCommand::getCode()
-{
-    return m_code;
-}
-
-void RemotingCommand::setCode(int code)
-{
-    m_code = code;
-}
-
-std::string RemotingCommand::getLanguage()
-{
-    return m_language;
-}
-
-void RemotingCommand::setLanguage(const std::string& language)
-{
-    m_language = language;
-}
-
-int RemotingCommand::getVersion()
-{
-    return m_version;
-}
-
-void RemotingCommand::setVersion(int version)
-{
-    m_version = version;
-}
-
-int RemotingCommand::getOpaque()
-{
-    return m_opaque;
-}
-
-void RemotingCommand::setOpaque(int opaque)
-{
-    m_opaque = opaque;
-}
-
-int RemotingCommand::getFlag()
-{
-    return m_flag;
-}
-
-void RemotingCommand::setFlag(int flag)
-{
-    m_flag = flag;
-}
-
-std::string RemotingCommand::getRemark()
-{
-    return m_remark;
-}
-
-void RemotingCommand::setRemark(const std::string& remark)
-{
-    m_remark = remark;
-}
-
-void RemotingCommand::setCommandCustomHeader(CommandCustomHeader* pCommandCustomHeader)
-{
-    m_pCustomHeader = pCommandCustomHeader;
-}
-
-CommandCustomHeader* RemotingCommand::getCommandCustomHeader()
-{
-    return m_pCustomHeader;
-}
-
-RemotingCommandType RemotingCommand::getType()
-{
-    if (isResponseType())
-    {
-        return RESPONSE_COMMAND;
-    }
-
-    return REQUEST_COMMAND;
-}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/protocol/RemotingCommand.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/protocol/RemotingCommand.h b/rocketmq-client4cpp/src/protocol/RemotingCommand.h
deleted file mode 100755
index c51fcfd..0000000
--- a/rocketmq-client4cpp/src/protocol/RemotingCommand.h
+++ /dev/null
@@ -1,153 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __REMOTINGCOMMAND_H__
-#define __REMOTINGCOMMAND_H__
-
-#include <sstream>
-#include <string>
-
-#include "RocketMQClient.h"
-#include "AtomicValue.h"
-#include "RefHandle.h"
-
-namespace rmq
-{
-    const std::string CODE_STRING = "\"code\":";
-    const std::string language_STRING = "\"language\":";
-    const std::string version_STRING = "\"version\":";
-    const std::string opaque_STRING = "\"opaque\":";
-    const std::string flag_STRING = "\"flag\":";
-    const std::string remark_STRING = "\"remark\":";
-    const std::string extFields_STRING = "\"extFields\":";
-
-    const std::string RemotingVersionKey = "rocketmq.remoting.version";
-
-    class CommandCustomHeader;
-
-    typedef enum
-    {
-        REQUEST_COMMAND,
-        RESPONSE_COMMAND
-    } RemotingCommandType;
-
-    typedef enum
-    {
-        SUCCESS_VALUE = 0,
-        SYSTEM_ERROR_VALUE,
-        SYSTEM_BUSY_VALUE,
-        REQUEST_CODE_NOT_SUPPORTED_VALUE,
-    } ResponseCode;
-
-    typedef enum
-    {
-        JAVA,
-        CPP,
-        DOTNET,
-        PYTHON,
-        DELPHI,
-        ERLANG,
-        RUBY,
-        OTHER,
-    } LanguageCode;
-
-    const int RPC_TYPE = 0; // 0, REQUEST_COMMAND // 1, RESPONSE_COMMAND
-    const int RPC_ONEWAY = 1; // 0, RPC // 1, Oneway
-
-    class RemotingCommand : public kpr::RefCount
-    {
-    public:
-        RemotingCommand(int code);
-        RemotingCommand(int code,
-                        const std::string& language,
-                        int version,
-                        int opaque,
-                        int flag,
-                        const std::string& remark,
-                        CommandCustomHeader* pCustomHeader);
-        ~RemotingCommand();
-
-        void encode();
-        std::string toString() const;
-
-        const char* getData();
-        int getDataLen();
-
-        const char* getBody();
-        int getBodyLen();
-        void setBody(char* pData, int len, bool copy);
-        CommandCustomHeader* makeCustomHeader(int code, const char* pData, int len);
-
-        int getCode();
-        void setCode(int code);
-
-        std::string getLanguage();
-        void setLanguage(const std::string& language);
-
-        int getVersion();
-        void setVersion(int version);
-
-        int getOpaque();
-        void setOpaque(int opaque);
-
-        int getFlag();
-        void setFlag(int flag);
-
-        std::string getRemark();
-        void setRemark(const std::string& remark);
-
-        void setCommandCustomHeader(CommandCustomHeader* pCommandCustomHeader);
-        CommandCustomHeader* getCommandCustomHeader();
-
-        RemotingCommandType getType();
-        void markResponseType();
-        bool isResponseType() ;
-        void markOnewayRPC();
-        bool isOnewayRPC();
-
-        static void setCmdVersion(RemotingCommand* pCmd);
-		static RemotingCommand* decode(const char* pData, int len);
-        static RemotingCommand* createRequestCommand(int code, CommandCustomHeader* pCustomHeader);
-		static RemotingCommand* createResponseCommand(int code, const std::string& remark);
-		static RemotingCommand* createResponseCommand(int code, const std::string& remark, CommandCustomHeader* pCustomHeader);
-
-
-    private:
-        static volatile int s_configVersion;
-
-    private:
-        int m_code;
-        std::string m_language;
-        int m_version;
-        int m_opaque;
-        int m_flag;
-        std::string m_remark;
-        CommandCustomHeader* m_pCustomHeader;
-
-        int m_dataLen;
-        char* m_pData;
-
-        int m_bodyLen;
-        char* m_pBody;
-
-        bool m_releaseBody;
-
-        static kpr::AtomicInteger s_seqNumber;
-    };
-    typedef kpr::RefHandleT<RemotingCommand> RemotingCommandPtr;
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/protocol/RemotingSerializable.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/protocol/RemotingSerializable.h b/rocketmq-client4cpp/src/protocol/RemotingSerializable.h
deleted file mode 100755
index 8e50ab0..0000000
--- a/rocketmq-client4cpp/src/protocol/RemotingSerializable.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __REMOTINGSERIALIZABLE_H__
-#define __REMOTINGSERIALIZABLE_H__
-
-#include "RocketMQClient.h"
-#include "RefHandle.h"
-
-namespace rmq
-{
-	class RemotingSerializable : public kpr::RefCount
-	{
-	public:
-	    virtual ~RemotingSerializable() {};
-	    virtual void encode(std::string& outData) = 0;
-	};
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/protocol/TopicList.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/protocol/TopicList.h b/rocketmq-client4cpp/src/protocol/TopicList.h
deleted file mode 100755
index e827540..0000000
--- a/rocketmq-client4cpp/src/protocol/TopicList.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#ifndef __TOPICLIST_H__
-#define __TOPICLIST_H__
-
-#include <set>
-#include <string>
-#include <UtilAll.h>
-
-namespace rmq
-{
-    class TopicList : public RemotingSerializable
-    {
-    public:
-        static TopicList* decode(const char* pData, int len)
-        {
-            return new TopicList();
-        }
-
-        void encode(std::string& outData)
-        {
-        }
-
-		std::string toString() const
-		{
-			std::stringstream ss;
-			ss << "{topicList=" << UtilAll::toString(m_topicList)
-			   << "}";
-			return ss.str();
-		}
-
-        const std::set<std::string>& getTopicList()
-        {
-            return m_topicList;
-        }
-
-        void setTopicList(const std::set<std::string>& topicList)
-        {
-            m_topicList = topicList;
-        }
-
-    private:
-        std::set<std::string> m_topicList;
-    };
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/protocol/TopicRouteData.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/protocol/TopicRouteData.h b/rocketmq-client4cpp/src/protocol/TopicRouteData.h
deleted file mode 100755
index a40ef7d..0000000
--- a/rocketmq-client4cpp/src/protocol/TopicRouteData.h
+++ /dev/null
@@ -1,279 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#ifndef __TOPICROUTEDATA_H__
-#define __TOPICROUTEDATA_H__
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <iostream>
-#include <list>
-#include <map>
-#include <string>
-#include <sstream>
-#include "RocketMQClient.h"
-#include "RemotingSerializable.h"
-#include "UtilAll.h"
-#include "MixAll.h"
-#include "json/json.h"
-
-namespace rmq
-{
-    struct QueueData
-    {
-        std::string brokerName;
-        int readQueueNums;
-        int writeQueueNums;
-        int perm;
-
-        bool operator < (const QueueData& other)
-        {
-            return brokerName < other.brokerName;
-        }
-
-        bool operator==(const QueueData& other)const
-        {
-            if (brokerName == other.brokerName
-                && readQueueNums == other.readQueueNums
-                && writeQueueNums == other.writeQueueNums
-                && perm == other.perm)
-            {
-                return true;
-            }
-
-            return false;
-        }
-
-        std::string toString() const
-        {
-            std::stringstream ss;
-            ss << "{brokerName=" << brokerName
-               << ",readQueueNums=" << readQueueNums
-               << ",writeQueueNums=" << writeQueueNums
-               << ",perm=" << perm
-               << "}";
-            return ss.str();
-        }
-    };
-    inline std::ostream& operator<<(std::ostream& os, const QueueData& obj)
-    {
-        os << obj.toString();
-        return os;
-    }
-
-
-    struct BrokerData
-    {
-        std::string brokerName;
-        std::map<int, std::string> brokerAddrs;
-
-        bool operator < (const BrokerData& other)
-        {
-            return brokerName < other.brokerName;
-        }
-
-        bool operator == (const BrokerData& other)const
-        {
-            if (brokerName == other.brokerName
-                && brokerAddrs == other.brokerAddrs)
-            {
-                return true;
-            }
-
-            return false;
-        }
-
-        std::string toString() const
-        {
-            std::stringstream ss;
-            ss << "{brokerName=" << brokerName
-               << ",brokerAddrs=" << UtilAll::toString(brokerAddrs)
-               << "}";
-            return ss.str();
-        }
-    };
-
-
-    inline std::ostream& operator<<(std::ostream& os, const BrokerData& obj)
-    {
-        os << obj.toString();
-        return os;
-    }
-
-
-    class TopicRouteData : public RemotingSerializable
-    {
-    public:
-        void encode(std::string& outData)
-        {
-
-        }
-
-        static TopicRouteData* encode(const char* pData, int len)
-        {
-            /*
-            {
-                "orderTopicConf":"",
-                "brokerDatas":[
-                    {"brokerAddrs":{0:"10.134.143.77:10911"},"brokerName":"broker-a"}
-                ],
-                "filterServerTable":{},
-                "queueDatas":[
-                    {"brokerName":"broker-a","perm":6,"readQueueNums":4,"topicSynFlag":0,"writeQueueNums":4}
-                ]
-            }
-            */
-            Json::Reader reader;
-            Json::Value object;
-
-            if (!reader.parse(pData, pData + len, object))
-            {
-                RMQ_ERROR("parse fail:%s", reader.getFormattedErrorMessages().c_str());
-                return NULL;
-            }
-
-            TopicRouteData* trd = new TopicRouteData();
-            trd->setOrderTopicConf(object["orderTopicConf"].asString());
-
-            Json::Value qds = object["queueDatas"];
-            for (size_t i = 0; i < qds.size(); i++)
-            {
-                QueueData d;
-                Json::Value qd = qds[i];
-                d.brokerName = qd["brokerName"].asString();
-                d.readQueueNums = qd["readQueueNums"].asInt();
-                d.writeQueueNums = qd["writeQueueNums"].asInt();
-                d.perm = qd["perm"].asInt();
-
-                trd->getQueueDatas().push_back(d);
-            }
-
-            Json::Value bds = object["brokerDatas"];
-            for (size_t i = 0; i < bds.size(); i++)
-            {
-                BrokerData d;
-                Json::Value bd = bds[i];
-                d.brokerName = bd["brokerName"].asString();
-
-                Json::Value bas = bd["brokerAddrs"];
-                Json::Value::Members mbs = bas.getMemberNames();
-                for (size_t i = 0; i < mbs.size(); i++)
-                {
-                    std::string key = mbs.at(i);
-                    d.brokerAddrs[atoi(key.c_str())] = bas[key].asString();
-                }
-
-                trd->getBrokerDatas().push_back(d);
-            }
-
-            return trd;
-        }
-
-        static std::string selectBrokerAddr(BrokerData& data)
-        {
-            std::map<int, std::string>::iterator it = data.brokerAddrs.find(MixAll::MASTER_ID);
-            std::string value = "";
-            if (it == data.brokerAddrs.end())
-            {
-                it = data.brokerAddrs.begin();
-                if (it != data.brokerAddrs.end())
-                {
-                    value = it->second;
-                }
-            }
-            else
-            {
-                value = it->second;
-            }
-
-            return value;
-        }
-
-        std::list<QueueData>& getQueueDatas()
-        {
-            return m_queueDatas;
-        }
-
-        void setQueueDatas(const std::list<QueueData>& queueDatas)
-        {
-            m_queueDatas = queueDatas;
-        }
-
-        std::list<BrokerData>& getBrokerDatas()
-        {
-            return m_brokerDatas;
-        }
-
-        void setBrokerDatas(const std::list<BrokerData>& brokerDatas)
-        {
-            m_brokerDatas = brokerDatas;
-        }
-
-        const std::string& getOrderTopicConf()
-        {
-            return m_orderTopicConf;
-        }
-
-        void setOrderTopicConf(const std::string& orderTopicConf)
-        {
-            m_orderTopicConf = orderTopicConf;
-        }
-
-        bool operator ==(const TopicRouteData& other)
-        {
-            if (m_brokerDatas != other.m_brokerDatas)
-            {
-                return false;
-            }
-
-            if (m_orderTopicConf != other.m_orderTopicConf)
-            {
-                return false;
-            }
-
-            if (m_queueDatas != other.m_queueDatas)
-            {
-                return false;
-            }
-
-            return true;
-        }
-
-        std::string toString() const
-        {
-            std::stringstream ss;
-            ss << "{orderTopicConf=" << m_orderTopicConf
-               << ",queueDatas=" << UtilAll::toString(m_queueDatas)
-               << ",brokerDatas=" << UtilAll::toString(m_brokerDatas)
-               << "}";
-            return ss.str();
-        }
-
-    private:
-        std::string m_orderTopicConf;
-        std::list<QueueData> m_queueDatas;
-        std::list<BrokerData> m_brokerDatas;
-    };
-	typedef kpr::RefHandleT<TopicRouteData> TopicRouteDataPtr;
-
-    inline std::ostream& operator<<(std::ostream& os, const TopicRouteData& obj)
-    {
-        os << obj.toString();
-        return os;
-    }
-
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/transport/InvokeCallback.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/transport/InvokeCallback.h b/rocketmq-client4cpp/src/transport/InvokeCallback.h
deleted file mode 100755
index 4b5b3c7..0000000
--- a/rocketmq-client4cpp/src/transport/InvokeCallback.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __INVOKECALLBACK_H__
-#define __INVOKECALLBACK_H__
-
-#include "ResponseFuture.h"
-
-namespace rmq
-{
-	class InvokeCallback
-	{
-	public:
-	    virtual ~InvokeCallback() {}
-	    virtual void operationComplete(ResponseFuturePtr pResponseFuture) = 0;
-	};
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/transport/RemoteClientConfig.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/transport/RemoteClientConfig.h b/rocketmq-client4cpp/src/transport/RemoteClientConfig.h
deleted file mode 100755
index 930fc78..0000000
--- a/rocketmq-client4cpp/src/transport/RemoteClientConfig.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- * Copyright (C) 2013 kangliqiang ,kangliq@163.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __REMOTECLIENTCONFIG_H__
-#define __REMOTECLIENTCONFIG_H__
-
-#include <unistd.h>
-#include <sys/sysinfo.h>
-
-namespace rmq
-{
-    /**
-     * remote client config
-     *
-     */
-    class RemoteClientConfig
-    {
-    public:
-        RemoteClientConfig()
-        {
-            clientWorkerThreads = 4;
-            clientCallbackExecutorThreads = get_nprocs();
-            clientSelectorThreads = 1;
-            clientOnewaySemaphoreValue = 2048;
-            clientAsyncSemaphoreValue = 2048;
-            connectTimeoutMillis = 3000;
-            channelNotActiveInterval = 1000 * 60;
-            clientChannelMaxIdleTimeSeconds = 120;
-			clientSocketSndBufSize = 65535;
-			clientSocketRcvBufSize = 65535;
-
-			nsL5ModId = 0;
-			nsL5CmdId = 0;
-        }
-
-        // Server Response/Request
-        int clientWorkerThreads;
-        int clientCallbackExecutorThreads;
-        int clientSelectorThreads;
-        int clientOnewaySemaphoreValue;
-        int clientAsyncSemaphoreValue;
-        int connectTimeoutMillis;
-
-        int channelNotActiveInterval;
-        int clientChannelMaxIdleTimeSeconds;
-		int clientSocketSndBufSize;
-		int clientSocketRcvBufSize;
-
-		int nsL5ModId;
-		int nsL5CmdId;
-    };
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/transport/ResponseFuture.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/transport/ResponseFuture.cpp b/rocketmq-client4cpp/src/transport/ResponseFuture.cpp
deleted file mode 100755
index c80fb84..0000000
--- a/rocketmq-client4cpp/src/transport/ResponseFuture.cpp
+++ /dev/null
@@ -1,183 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#include "ResponseFuture.h"
-
-#include "RocketMQClient.h"
-#include "KPRUtil.h"
-#include "InvokeCallback.h"
-#include "Monitor.h"
-#include "Semaphore.h"
-#include "ScopedLock.h"
-
-namespace rmq
-{
-
-ResponseFuture::ResponseFuture(int requestCode, int opaque, int timeoutMillis,
-	InvokeCallback* pInvokeCallback, bool block, kpr::Semaphore* pSem)
-{
-    m_requestCode = requestCode;
-    m_opaque = opaque;
-    m_timeoutMillis = timeoutMillis;
-    m_pInvokeCallback = pInvokeCallback;
-    m_beginTimestamp = KPRUtil::GetCurrentTimeMillis();
-    m_pResponseCommand = NULL;
-    m_notifyFlag = false;
-    m_pMonitor = NULL;
-    m_sendRequestOK = false;
-    m_exec = 0;
-
-	m_pSemaphore = pSem;
-    m_released = 0;
-
-    if (block)
-    {
-        m_pMonitor = new kpr::Monitor();
-    }
-}
-
-ResponseFuture::~ResponseFuture()
-{
-    if (m_pMonitor)
-    {
-        delete m_pMonitor;
-    }
-}
-
-void  ResponseFuture::executeInvokeCallback()
-{
-    if (m_pInvokeCallback != NULL)
-    {
-    	if (m_exec.compareAndSet(0, 1))
-    	{
-    		try
-    		{
-        		m_pInvokeCallback->operationComplete(this);
-        	}
-        	catch(std::exception& e)
-        	{
-        		RMQ_ERROR("executeInvokeCallback exception: %s", e.what());
-        	}
-        	catch(...)
-        	{
-        		RMQ_ERROR("executeInvokeCallback exception");
-        	}
-        }
-    }
-}
-
-void ResponseFuture::release()
-{
-    if (m_pSemaphore != NULL)
-	{
-        if (m_released.compareAndSet(0, 1))
-		{
-            m_pSemaphore->Release();
-        }
-    }
-}
-
-bool ResponseFuture::isTimeout()
-{
-    long long diff = KPRUtil::GetCurrentTimeMillis() - m_beginTimestamp;
-    return diff > m_timeoutMillis;
-}
-
-RemotingCommand* ResponseFuture::waitResponse(int timeoutMillis)
-{
-    if (m_pMonitor)
-    {
-        kpr::ScopedLock<kpr::Monitor> lock(*m_pMonitor);
-        if (!m_notifyFlag)
-        {
-            m_pMonitor->Wait(timeoutMillis);
-        }
-    }
-
-    return m_pResponseCommand;
-}
-
-void  ResponseFuture::putResponse(RemotingCommand* pResponseCommand)
-{
-    m_pResponseCommand = pResponseCommand;
-    if (m_pMonitor)
-    {
-        kpr::ScopedLock<kpr::Monitor> lock(*m_pMonitor);
-        m_notifyFlag = true;
-        m_pMonitor->Notify();
-    }
-}
-
-long long  ResponseFuture::getBeginTimestamp()
-{
-    return m_beginTimestamp;
-}
-
-bool  ResponseFuture::isSendRequestOK()
-{
-    return m_sendRequestOK;
-}
-
-void  ResponseFuture::setSendRequestOK(bool sendRequestOK)
-{
-    m_sendRequestOK = sendRequestOK;
-}
-
-long long  ResponseFuture::getTimeoutMillis()
-{
-    return m_timeoutMillis;
-}
-
-InvokeCallback*  ResponseFuture::getInvokeCallback()
-{
-    return m_pInvokeCallback;
-}
-
-RemotingCommand*  ResponseFuture::getResponseCommand()
-{
-    return m_pResponseCommand;
-}
-
-void  ResponseFuture::setResponseCommand(RemotingCommand* pResponseCommand)
-{
-    m_pResponseCommand = pResponseCommand;
-}
-
-int  ResponseFuture::getOpaque()
-{
-    return m_opaque;
-}
-
-int ResponseFuture::getRequestCode()
-{
-    return m_requestCode;
-}
-
-void ResponseFuture::setRequestCode(int requestCode)
-{
-    m_requestCode = requestCode;
-}
-
-std::string ResponseFuture::toString() const
-{
-	std::stringstream oss;
-	oss << "{responseCommand=" << m_pResponseCommand << ",sendRequestOK=" << m_sendRequestOK
-        << ",opaque=" << m_opaque << ",timeoutMillis=" << m_timeoutMillis
-        << ",invokeCallback=" << m_pInvokeCallback << ",beginTimestamp=" << m_beginTimestamp
-		<< "}";
-	return oss.str();
-}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/transport/ResponseFuture.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/transport/ResponseFuture.h b/rocketmq-client4cpp/src/transport/ResponseFuture.h
deleted file mode 100755
index f1dfc01..0000000
--- a/rocketmq-client4cpp/src/transport/ResponseFuture.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __RESPONSEFUTURE_H__
-#define __RESPONSEFUTURE_H__
-
-#include <string>
-#include "AtomicValue.h"
-#include "RefHandle.h"
-
-namespace kpr
-{
-class Monitor;
-class Semaphore;
-}
-
-namespace rmq
-{
-    class InvokeCallback;
-    class RemotingCommand;
-
-    class ResponseFuture : public kpr::RefCount
-    {
-    public:
-        ResponseFuture(int requestCode, int opaque, int timeoutMillis, InvokeCallback* pInvokeCallback,
-			bool block, kpr::Semaphore* pSem);
-        ~ResponseFuture();
-        void executeInvokeCallback();
-		void release();
-        bool isTimeout();
-        RemotingCommand* waitResponse(int timeoutMillis);
-        void putResponse(RemotingCommand* pResponseCommand);
-        long long getBeginTimestamp();
-        bool isSendRequestOK();
-        void setSendRequestOK(bool sendRequestOK);
-        int getRequestCode();
-        void setRequestCode(int requestCode);
-        long long getTimeoutMillis();
-        InvokeCallback* getInvokeCallback();
-        RemotingCommand* getResponseCommand();
-        void setResponseCommand(RemotingCommand* pResponseCommand);
-        int getOpaque();
-		std::string toString() const;
-
-    private:
-        RemotingCommand* m_pResponseCommand;
-        volatile bool m_sendRequestOK;
-        int m_requestCode;
-        int m_opaque;
-        long long m_timeoutMillis;
-        InvokeCallback* m_pInvokeCallback;
-        long long m_beginTimestamp;
-        kpr::Monitor* m_pMonitor;
-        bool m_notifyFlag;
-
-        kpr::AtomicInteger m_exec;
-
-		kpr::Semaphore* m_pSemaphore;
-		kpr::AtomicInteger m_released;
-    };
-	typedef kpr::RefHandleT<ResponseFuture> ResponseFuturePtr;
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/transport/SocketUtil.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/transport/SocketUtil.cpp b/rocketmq-client4cpp/src/transport/SocketUtil.cpp
deleted file mode 100755
index a1e0d57..0000000
--- a/rocketmq-client4cpp/src/transport/SocketUtil.cpp
+++ /dev/null
@@ -1,250 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#include "SocketUtil.h"
-#include "MixAll.h"
-#include "MQClientException.h"
-
-
-namespace rmq
-{
-
-int SocketInit()
-{
-    signal(SIGPIPE, SIG_IGN);
-
-    return 0;
-}
-
-int MakeSocketNonblocking(SOCKET fd)
-{
-    int flags = fcntl(fd, F_GETFL, 0);
-    assert(flags != -1);
-    flags = (flags | O_NONBLOCK);
-    return fcntl(fd, F_SETFL, flags);
-}
-
-int SetTcpNoDelay(SOCKET fd)
-{
-    int flag = 1;
-    return setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (const char*)&flag, sizeof(flag));
-}
-
-bool SplitURL(const std::string& serverURL, std::string& addr, short& nPort)
-{
-    size_t pos = serverURL.find(':');
-    if (pos == std::string::npos)
-    {
-        return false;
-    }
-
-    addr = serverURL.substr(0, pos);
-    if (0 == addr.compare("localhost"))
-    {
-        addr = "127.0.0.1";
-    }
-    pos++;
-
-    std::string port = serverURL.substr(pos, serverURL.length() - pos);
-    nPort = atoi(port.c_str());
-    return true;
-}
-
-sockaddr string2SocketAddress(const std::string& addrString)
-{
-    std::string strAddr;
-    short port;
-    SplitURL(addrString, strAddr, port);
-
-    struct sockaddr_in sa;
-    sa.sin_family = AF_INET;
-    sa.sin_port = htons(port);
-
-    sa.sin_addr.s_addr = inet_addr(strAddr.c_str());
-
-    sockaddr addr;
-    memcpy(&addr, &sa, sizeof(sockaddr));
-
-    return addr;
-}
-
-std::string socketAddress2String(sockaddr addr)
-{
-    sockaddr_in in;
-    memcpy(&in, &addr, sizeof(sockaddr));
-
-	std::stringstream ss;
-    ss << inet_ntoa(in.sin_addr) << ":" << in.sin_port;
-
-    return ss.str();
-}
-
-void GetLocalAddrs(std::vector<unsigned int>& addrs)
-{
-    addrs.clear();
-
-    struct ifconf ifc;
-    ifc.ifc_buf = NULL;
-    ifc.ifc_len = 0;
-
-    int sfd = socket(AF_INET, SOCK_DGRAM, 0);
-    if (sfd != INVALID_SOCKET)
-    {
-        int ret = ioctl(sfd, SIOCGIFCONF, (char*)&ifc);
-
-        if (ret != -1)
-        {
-            ifc.ifc_req = (struct ifreq*)malloc(ifc.ifc_len);
-            ret = ioctl(sfd, SIOCGIFCONF, (char*)&ifc);
-            if (ret != -1)
-            {
-                for (size_t i = 0; i < ifc.ifc_len / sizeof(struct ifreq); i++)
-                {
-                    struct sockaddr* sa = (struct sockaddr*) & (ifc.ifc_req[i].ifr_addr);
-                    if (AF_INET == sa->sa_family)
-                    {
-                        unsigned int addr = ((struct sockaddr_in*)sa)->sin_addr.s_addr;
-                        addrs.push_back(htonl(addr));
-                    }
-                }
-            }
-
-            free(ifc.ifc_req);
-            ifc.ifc_req = NULL;
-        }
-
-        close(sfd);
-    }
-
-    if (addrs.empty())
-    {
-        char hostname[1024];
-
-        int ret = gethostname(hostname, sizeof(hostname));
-        if (ret == 0)
-        {
-            struct addrinfo* result = NULL;
-            struct addrinfo* ptr = NULL;
-            struct addrinfo hints;
-
-            memset(&hints, 0, sizeof(hints));
-            hints.ai_family = AF_INET;
-            hints.ai_socktype = SOCK_STREAM;
-            hints.ai_protocol = IPPROTO_TCP;
-
-            ret = getaddrinfo(hostname, NULL, &hints, &result);
-            if (ret == 0)
-            {
-                for (ptr = result; ptr != NULL ; ptr = ptr->ai_next)
-                {
-
-                    struct sockaddr_in*  sockaddr_ipv4 = (struct sockaddr_in*) ptr->ai_addr;
-                    addrs.push_back(ntohl(sockaddr_ipv4->sin_addr.s_addr));
-                }
-            }
-
-            freeaddrinfo(result);
-        }
-    }
-
-    std::vector<unsigned int>::iterator it = addrs.begin();
-    for (; it != addrs.end();)
-    {
-        if (*it >= 0x7F000000U && *it < 0x80000000U)
-        {
-            it = addrs.erase(it);
-        }
-        else
-        {
-            it++;
-        }
-    }
-
-    if (addrs.empty())
-    {
-        addrs.push_back(INADDR_LOOPBACK);
-    }
-}
-
-std::string getLocalAddress()
-{
-    std::vector<unsigned int> addrs;
-    GetLocalAddrs(addrs);
-    struct in_addr addr;
-    addr.s_addr = htonl(addrs[0]);
-
-    return inet_ntoa(addr);
-}
-
-std::string getHostName(sockaddr addr)
-{
-    sockaddr_in in;
-    memcpy(&in, &addr, sizeof(sockaddr));
-
-    struct hostent* remoteHost = gethostbyaddr((char*) & (in.sin_addr), 4, AF_INET);
-    char** alias = remoteHost->h_aliases;
-    if (*alias != 0)
-    {
-        return *alias;
-    }
-    else
-    {
-        return inet_ntoa(in.sin_addr);
-    }
-}
-
-
-unsigned long long swapll(unsigned long long v)
-{
-#ifdef ENDIANMODE_BIG
-    return v;
-#else
-    unsigned long long ret = ((v << 56)
-                              | ((v & 0xff00) << 40)
-                              | ((v & 0xff0000) << 24)
-                              | ((v & 0xff000000) << 8)
-                              | ((v >> 8) & 0xff000000)
-                              | ((v >> 24) & 0xff0000)
-                              | ((v >> 40) & 0xff00)
-                              | (v >> 56));
-
-    return ret;
-#endif
-}
-
-unsigned long long h2nll(unsigned long long v)
-{
-    return swapll(v);
-}
-
-unsigned long long n2hll(unsigned long long v)
-{
-    return swapll(v);
-}
-
-std::string socketAddress2IPPort(sockaddr addr)
-{
-    sockaddr_in in;
-    memcpy(&in, &addr, sizeof(sockaddr));
-
-    char tmp[32];
-    snprintf(tmp, sizeof(tmp), "%s:%d", inet_ntoa(in.sin_addr), ntohs(in.sin_port));
-
-    std::string ipport = tmp;
-    return ipport;
-}
-
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/transport/SocketUtil.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/transport/SocketUtil.h b/rocketmq-client4cpp/src/transport/SocketUtil.h
deleted file mode 100755
index bfd86d8..0000000
--- a/rocketmq-client4cpp/src/transport/SocketUtil.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#ifndef __SOCKETUTIL_H__
-#define __SOCKETUTIL_H__
-
-#include <unistd.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/select.h>
-#include <sys/ioctl.h>
-#include <netdb.h>
-#include <netinet/in.h>
-#include <net/if.h>
-#include <netinet/tcp.h>
-#include <arpa/inet.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <signal.h>
-#include <string>
-#include <stdlib.h>
-#include <assert.h>
-#include <string.h>
-#include <sstream>
-#include <vector>
-#include <iostream>
-
-#include "RocketMQClient.h"
-
-
-#define NET_ERROR errno
-#define SOCKET_ERROR -1
-#define INVALID_SOCKET -1
-#define WSAECONNRESET ECONNRESET
-#define WSAEWOULDBLOCK EWOULDBLOCK
-#define WSAEINPROGRESS EINPROGRESS
-#define WSAEBADF EBADF
-#define closesocket close
-#define SD_SEND SHUT_WR
-#define SD_RECEIVE SHUT_RD
-#define SD_BOTH SHUT_RDWR
-typedef int SOCKET;
-#define SocketUninit()
-
-namespace rmq
-{
-	int SocketInit();
-	int MakeSocketNonblocking(SOCKET fd);
-	int SetTcpNoDelay(SOCKET fd);
-
-	bool SplitURL(const std::string& serverURL, std::string& addr, short& nPort);
-	sockaddr string2SocketAddress(const std::string& addr);
-	std::string socketAddress2String(sockaddr addr);
-	std::string socketAddress2IPPort(sockaddr addr);
-	std::string getHostName(sockaddr addr);
-	std::string getLocalAddress();
-
-	unsigned long long h2nll(unsigned long long v);
-	unsigned long long n2hll(unsigned long long v);
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/transport/TcpRemotingClient.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/transport/TcpRemotingClient.cpp b/rocketmq-client4cpp/src/transport/TcpRemotingClient.cpp
deleted file mode 100755
index 03b8ca7..0000000
--- a/rocketmq-client4cpp/src/transport/TcpRemotingClient.cpp
+++ /dev/null
@@ -1,841 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#include "TcpRemotingClient.h"
-#include "MQClientException.h"
-#include "TcpRequestProcessor.h"
-#include "MQProtos.h"
-#include "ThreadPoolWork.h"
-
-namespace rmq
-{
-
-
-ProcessDataWork::ProcessDataWork(TcpRemotingClient* pClient, TcpTransport* pTts, std::string* pData)
-    : m_pClient(pClient), m_pTts(pTts), m_pData(pData)
-{
-}
-
-ProcessDataWork::~ProcessDataWork()
-{
-	delete m_pData;
-}
-
-void ProcessDataWork::Do()
-{
-    try
-    {
-        m_pClient->processData(m_pTts, m_pData);
-    }
-    catch (std::exception& e)
-    {
-    	RMQ_ERROR("processDataWork catch Exception: %s", e.what());
-    }
-    catch (...)
-    {
-    	RMQ_ERROR("processDataWork catch Exception");
-    }
-}
-
-TcpRemotingClient::TcpRemotingClient(const RemoteClientConfig& config)
-    : m_stop(false), m_epoller(false), m_config(config),
-      m_semaphoreOneway(s_ClientOnewaySemaphoreValue), m_semaphoreAsync(s_ClientAsyncSemaphoreValue)
-{
-    m_pNetThreadPool = new kpr::ThreadPool("NetClientThreadPool", 5, 5, 20);
-    m_pEventThread = new EventThread(*this);
-    SocketInit();
-    m_epoller.create(10240);
-}
-
-TcpRemotingClient::~TcpRemotingClient()
-{
-    SocketUninit();
-}
-
-void TcpRemotingClient::start()
-{
-    RMQ_DEBUG("TcpRemotingClient::start()");
-    m_pEventThread->Start();
-}
-
-void TcpRemotingClient::shutdown()
-{
-    RMQ_DEBUG("TcpRemotingClient::shutdown()");
-    m_stop = true;
-    m_pNetThreadPool->Destroy();
-    m_pEventThread->Join();
-}
-
-/*
-void printMsg(const std::string& prefix, const char* pData, int len)
-{
-	int headLen;
-    memcpy(&headLen, pData + 4, 4);
-    headLen = ntohl(headLen);
-
-    RMQ_DEBUG("%s|decode[%d,%d,%d]|%s%s", prefix.c_str(), len, headLen, len - 8 - headLen, std::string(pData + 8, headLen).c_str(),
-              std::string(pData + 8 + headLen, len - 8 - headLen).c_str());
-}
-*/
-
-void TcpRemotingClient::run()
-{
-    RMQ_INFO("EventThread run begin: %lld", KPRUtil::GetCurrentTimeMillis());
-    do
-    {
-        try
-        {
-            int nfds = m_epoller.wait(500);
-            if (nfds > 0)
-            {
-                int ret = 0;
-                std::vector<TcpTransport*> errTts;
-                for (int i = 0; i < nfds && !m_stop; ++i)
-                {
-                    const epoll_event& ev = m_epoller.get(i);
-                    std::map<std::string , TcpTransport*>::iterator it;
-                    {
-                        kpr::ScopedRLock<kpr::RWMutex> lock(m_transportTableLock);
-                        it = m_transportTable.find((char*)ev.data.ptr);
-                        if (it == m_transportTable.end())
-                        {
-                            continue;
-                        }
-                    }
-
-                    TcpTransport* pTts = it->second;
-                    if (ev.events & EPOLLERR || ev.events & EPOLLHUP)
-                    {
-                    	RMQ_ERROR("recvData fail, err=%d(%s), pts=%p", errno, strerror(errno), pTts);
-                        errTts.push_back(pTts);
-                    }
-
-                    if (ev.events & EPOLLIN)
-                    {
-                    	std::list<std::string*> dataList;
-                        ret = pTts->recvData(dataList);
-                        if (ret < 0)
-                        {
-                        	RMQ_ERROR("recvData fail, ret=%d, errno=%d, pts=%p", ret, NET_ERROR, pTts);
-                            errTts.push_back(pTts);
-                        }
-
-                        if (dataList.size() > 0)
-                        {
-                        	for (typeof(dataList.begin()) it = dataList.begin();
-                        		it != dataList.end(); it++)
-                        	{
-                        		//printMsg("run", (*it)->c_str(), (*it)->size());
-                        		kpr::ThreadPoolWorkPtr work = new ProcessDataWork(this, pTts, *it);
-								m_pNetThreadPool->AddWork(work);
-							}
-                        }
-                    }
-                }
-
-                std::vector<TcpTransport*>::iterator itErr = errTts.begin();
-                for (; itErr != errTts.end(); itErr++)
-                {
-                    removeTTS(*itErr, true);
-                }
-            }
-
-            handleTimerEvent();
-        }
-        catch (...)
-        {
-			RMQ_ERROR("TcpRemotingClient.run catch exception");
-        }
-    }
-    while (!m_stop);
-    handleTimerEvent();
-
-    RMQ_INFO("EventThread run end: %lld", KPRUtil::GetCurrentTimeMillis());
-}
-
-
-void TcpRemotingClient::updateNameServerAddressList(const std::vector<std::string>& addrs)
-{
-    m_namesrvAddrList = addrs;
-    m_namesrvIndex = 0;
-}
-
-std::vector<std::string> TcpRemotingClient::getNameServerAddressList()
-{
-    return m_namesrvAddrList;
-}
-
-void TcpRemotingClient::registerProcessor(int requestCode, TcpRequestProcessor* pProcessor)
-{
-    m_processorTable[requestCode] = pProcessor;
-}
-
-
-RemotingCommand* TcpRemotingClient::invokeSync(const std::string& addr,
-        RemotingCommand* pRequest,
-        int timeoutMillis)
-{
-    TcpTransport* pTts = getAndCreateTransport(addr, timeoutMillis);
-    if (pTts != NULL && pTts->isConnected())
-    {
-    	RemotingCommand* pResponse = NULL;
-    	try
-    	{
-        	pResponse = invokeSyncImpl(pTts, pRequest, timeoutMillis);
-        }
-        catch(const RemotingSendRequestException& e)
-        {
-			RMQ_WARN("invokeSync: send pRequest exception, so close the channel[{%s}]",
-				pTts->getServerAddr().c_str());
-            removeTTS(pTts, false);
-            throw e;
-        }
-        catch(const RemotingTimeoutException& e)
-        {
-			RMQ_WARN("invokeSync: wait response timeout exception, the channel[{%s}], timeout=%d",
-				pTts->getServerAddr().c_str(), timeoutMillis);
-			throw e;
-        }
-
-        return pResponse;
-    }
-    else
-    {
-        removeTTS(pTts, false);
-        THROW_MQEXCEPTION(RemotingConnectException, "connect fail", -1);
-        //return NULL;
-    }
-}
-
-void TcpRemotingClient::invokeAsync(const std::string& addr,
-                                   RemotingCommand* pRequest,
-                                   int timeoutMillis,
-                                   InvokeCallback* pInvokeCallback)
-{
-    TcpTransport* pTts = getAndCreateTransport(addr, timeoutMillis);
-    if (pTts != NULL && pTts->isConnected())
-    {
-    	try
-    	{
-        	this->invokeAsyncImpl(pTts, pRequest, timeoutMillis, pInvokeCallback);
-        }
-        catch (const RemotingSendRequestException& e)
-        {
-			RMQ_WARN("invokeAsync: send pRequest exception, so close the channel[{%s}]", addr.c_str());
-            removeTTS(pTts, false);
-            throw e;
-        }
-
-        return;
-    }
-    else
-    {
-        removeTTS(pTts, false);
-        std::string msg;msg.append("connect to <").append(addr).append("> failed");
-        THROW_MQEXCEPTION(RemotingConnectException, msg, -1);
-    }
-}
-
-int TcpRemotingClient::invokeOneway(const std::string& addr,
-                                    RemotingCommand* pRequest,
-                                    int timeoutMillis)
-{
-    TcpTransport* pTts = getAndCreateTransport(addr, timeoutMillis);
-    if (pTts != NULL && pTts->isConnected())
-    {
-        return invokeOnewayImpl(pTts, pRequest, timeoutMillis);
-    }
-    else
-    {
-        removeTTS(pTts, false);
-        return -1;
-    }
-}
-
-
-TcpTransport* TcpRemotingClient::getAndCreateTransport(const std::string& addr, int timeoutMillis)
-{
-	if (addr.empty())
-	{
-    	return getAndCreateNameserverTransport(timeoutMillis);
-    }
-
-	{
-        kpr::ScopedRLock<kpr::RWMutex> lock(m_transportTableLock);
-        std::map<std::string , TcpTransport*>::iterator it = m_transportTable.find(addr);
-        if (it != m_transportTable.end())
-        {
-            return it->second;
-        }
-    }
-
-    return this->createTransport(addr, timeoutMillis);
-}
-
-
-TcpTransport* TcpRemotingClient::createTransport(const std::string& addr, int timeoutMillis)
-{
-	TcpTransport* pTts = NULL;
-	{
-		kpr::ScopedRLock<kpr::RWMutex> lock(m_transportTableLock);
-		std::map<std::string , TcpTransport*>::iterator it = m_transportTable.find(addr);
-        if (it != m_transportTable.end())
-        {
-            return it->second;
-        }
-    }
-
-	if (m_transportTableLock.TryWriteLock(s_LockTimeoutMillis))
-	{
-		std::map<std::string , TcpTransport*>::iterator it = m_transportTable.find(addr);
-        if (it != m_transportTable.end())
-        {
-            return it->second;
-        }
-
-	    std::map<std::string , std::string> config;
-	    pTts = new TcpTransport(config);
-	    if (pTts->connect(addr, timeoutMillis) != CLIENT_ERROR_SUCCESS)
-	    {
-	        delete pTts;
-	        pTts = NULL;
-
-	        RMQ_INFO("[NETWORK]: CONNECT {%s} failed", addr.c_str());
-	    }
-	    else
-	    {
-		    m_transportTable[addr] = pTts;
-	        m_epoller.add(pTts->getSocket(), (long long)((pTts->getServerAddr()).c_str()), EPOLLIN);
-
-	        RMQ_INFO("[NETWORK]: CONNECT => {%s} success", addr.c_str());
-        }
-        m_transportTableLock.Unlock();
-    }
-    else
-    {
-    	RMQ_WARN("createTransport: try to lock m_transportTable, but timeout, {%d}ms", timeoutMillis);
-    }
-
-    return pTts;
-}
-
-
-TcpTransport* TcpRemotingClient::getAndCreateNameserverTransport(int timeoutMillis)
-{
-	TcpTransport* pTts = NULL;
-
-	if (m_namesrvAddrChoosed.get() != NULL)
-	{
-		std::string addr = *m_namesrvAddrChoosed;
-		if (!addr.empty())
-		{
-			pTts = getAndCreateTransport(addr, timeoutMillis);
-	        if (pTts != NULL)
-	        {
-	        	return pTts;
-	        }
-		}
-	}
-
-	if (m_namesrvAddrChoosedLock.TryLock(s_LockTimeoutMillis))
-	{
-    	if (m_namesrvAddrChoosed.get() != NULL)
-    	{
-	    	std::string addr = *m_namesrvAddrChoosed;
-	    	if (!addr.empty())
-			{
-				pTts = getAndCreateTransport(addr, timeoutMillis);
-		        if (pTts != NULL)
-		        {
-		        	m_namesrvAddrChoosedLock.Unlock();
-		        	return pTts;
-		        }
-			}
-		}
-
-		if (!m_namesrvAddrList.empty())
-    	{
-	        for (size_t i = 0; i < m_namesrvAddrList.size(); i++)
-	        {
-	            int index = abs(++m_namesrvIndex) % m_namesrvAddrList.size();
-	            std::string& newAddr = m_namesrvAddrList.at(index);
-	            m_namesrvAddrChoosed.set(&newAddr);
-	            TcpTransport* pTts = getAndCreateTransport(newAddr, timeoutMillis);
-	            if (pTts != NULL)
-	            {
-	            	m_namesrvAddrChoosedLock.Unlock();
-	            	return pTts;
-	            }
-	        }
-        }
-
-        m_namesrvAddrChoosedLock.Unlock();
-	}
-
-	return NULL;
-}
-
-
-void TcpRemotingClient::handleTimerEvent()
-{
-	// every 1000ms
-	static unsigned long long lastTime = 0;
-	if (!m_stop && (int)(KPRUtil::GetCurrentTimeMillis() - lastTime) < s_CheckIntervalMillis)
-	{
-		return;
-	}
-
-    try
-    {
-    	lastTime = KPRUtil::GetCurrentTimeMillis();
-
-    	this->scanResponseTable();
-
-    	this->scanCloseTransportTable();
-    }
-    catch(...)
-    {
-    	RMQ_ERROR("scanResponseTable exception");
-    }
-}
-
-
-void TcpRemotingClient::scanCloseTransportTable()
-{
-	if (m_closeTransportTable.empty())
-	{
-		return;
-	}
-
-	if (m_closeTransportTableLock.TryLock())
-	{
-		std::list<TcpTransport*>::iterator it;
-		for( it = m_closeTransportTable.begin(); it != m_closeTransportTable.end(); )
-		{
-			TcpTransport* pTts = *it;
-			long long diffTime = KPRUtil::GetCurrentTimeMillis() - pTts->getLastSendRecvTime();
-			if (m_stop || (diffTime > 5000))
-			{
-				RMQ_WARN("remove close connection, %lld, {%s}", diffTime, pTts->getServerAddr().c_str());
-				it = m_closeTransportTable.erase(it);
-				delete pTts;
-			}
-			else
-			{
-				it++;
-			}
-		}
-		m_closeTransportTableLock.Unlock();
-	}
-	else
-	{
-		RMQ_WARN("m_closeTransportTableLock TryLock fail");
-	}
-}
-
-
-void TcpRemotingClient::scanResponseTable()
-{
-	kpr::ScopedWLock<kpr::RWMutex> lock(m_responseTableLock);
-	for(typeof(m_responseTable.begin()) it = m_responseTable.begin();it != m_responseTable.end();)
-	{
-		long long diffTime = KPRUtil::GetCurrentTimeMillis() - it->second->getBeginTimestamp();
-		if (m_stop || (diffTime > it->second->getTimeoutMillis() + 2000))
-		{
-			RMQ_WARN("remove timeout request, %lld, %s", diffTime, it->second->toString().c_str());
-			try
-			{
-				it->second->executeInvokeCallback();
-			}
-			catch(...)
-			{
-				RMQ_WARN("scanResponseTable, operationComplete Exception");
-			}
-			it->second->release();
-			m_responseTable.erase(it++);
-		}
-		else
-		{
-			it++;
-		}
-	}
-}
-
-void TcpRemotingClient::processData(TcpTransport* pTts, std::string* pData)
-{
-	//printMsg("processData", pData->c_str(), pData->size());
-    RemotingCommand* pCmd = RemotingCommand::decode(pData->data(), (int)pData->size());
-	if (pCmd == NULL)
-	{
-		RMQ_ERROR("invalid data format, len:%d, data: %s", (int)pData->size(), pData->c_str());
-		return;
-	}
-
-    int code = 0;
-    if (pCmd->isResponseType())
-    {
-        kpr::ScopedRLock<kpr::RWMutex> lock(m_responseTableLock);
-        std::map<int, ResponseFuturePtr>::iterator it = m_responseTable.find(pCmd->getOpaque());
-        if (it != m_responseTable.end())
-        {
-            code = it->second->getRequestCode();
-        }
-        else
-        {
-            RMQ_WARN("receive response, but not matched any request, maybe timeout or oneway, pCmd: %s", pCmd->toString().c_str());
-            delete pCmd;
-            return;
-        }
-    }
-    else
-    {
-        code = pCmd->getCode();
-    }
-
-    pCmd->makeCustomHeader(code, pData->data(), (int)pData->size());
-    if (pCmd->isResponseType())
-    {
-	    RMQ_DEBUG("[NETWORK]: RECV => {%s}, {opaque=%d, requst.code=%s(%d), response.code=%s(%d)}, %s",
-	    	pTts->getServerAddr().c_str(), pCmd->getOpaque(), getMQRequestCodeString(code), code,
-	    	getMQResponseCodeString(pCmd->getCode()), pCmd->getCode(), pCmd->toString().c_str());
-    }
-    else
-    {
-    	RMQ_DEBUG("[NETWORK]: RECV => {%s}, {opaque=%d, requst.code=%s(%d)}, %s",
-	    	pTts->getServerAddr().c_str(), pCmd->getOpaque(),
-	    	getMQRequestCodeString(code), code,	pCmd->toString().c_str());
-    }
-
-    processMessageReceived(pTts, pCmd);
-}
-
-RemotingCommand* TcpRemotingClient::invokeSyncImpl(TcpTransport* pTts,
-        RemotingCommand* pRequest,
-        int timeoutMillis)
-{
-    ResponseFuturePtr pResponseFuture = new ResponseFuture(
-    	pRequest->getCode(), pRequest->getOpaque(), timeoutMillis,
-        NULL, true, NULL);
-    {
-        kpr::ScopedWLock<kpr::RWMutex> lock(m_responseTableLock);
-        m_responseTable.insert(std::pair<int, ResponseFuturePtr>(pRequest->getOpaque(), pResponseFuture));
-    }
-
-    int ret = sendCmd(pTts, pRequest, timeoutMillis);
-    if (ret == 0)
-    {
-        pResponseFuture->setSendRequestOK(true);
-    }
-    else
-    {
-    	pResponseFuture->setSendRequestOK(false);
-    	pResponseFuture->putResponse(NULL);
-    	RMQ_WARN("send a pRequest command to channel <%s> failed.", pTts->getServerAddr().c_str());
-    }
-
-    RemotingCommand* pResponse = pResponseFuture->waitResponse(timeoutMillis);
-    {
-        kpr::ScopedWLock<kpr::RWMutex> lock(m_responseTableLock);
-        std::map<int, ResponseFuturePtr>::iterator it = m_responseTable.find(pRequest->getOpaque());
-        if (it != m_responseTable.end())
-        {
-            m_responseTable.erase(it);
-        }
-    }
-
-    if (pResponse == NULL)
-    {
-        if (ret == 0)
-        {
-            std::stringstream oss;
-            oss << "wait response on the channel <" << pTts->getServerAddr() << "> timeout," << timeoutMillis << "ms";
-            THROW_MQEXCEPTION(RemotingTimeoutException, oss.str(), -1);
-        }
-        else
-        {
-            std::stringstream oss;
-            oss << "send request to <" << pTts->getServerAddr() << "> failed";
-            THROW_MQEXCEPTION(RemotingSendRequestException, oss.str(), -1);
-        }
-    }
-
-    return pResponse;
-}
-
-void TcpRemotingClient::invokeAsyncImpl(TcpTransport* pTts,
-                                       RemotingCommand* pRequest,
-                                       int timeoutMillis,
-                                       InvokeCallback* pInvokeCallback)
-{
-	bool acquired = m_semaphoreAsync.Wait(timeoutMillis);
-	if (acquired)
-	{
-	    ResponseFuturePtr pResponseFuture = new ResponseFuture(
-	    	pRequest->getCode(), pRequest->getOpaque(), timeoutMillis,
-        	pInvokeCallback, false, &m_semaphoreAsync);
-	    {
-	        kpr::ScopedWLock<kpr::RWMutex> lock(m_responseTableLock);
-	        m_responseTable.insert(std::pair<int, ResponseFuturePtr>(pRequest->getOpaque(), pResponseFuture));
-	    }
-
-	    int ret = sendCmd(pTts, pRequest, timeoutMillis);
-	    if (ret == 0)
-	    {
-	        pResponseFuture->setSendRequestOK(true);
-	    }
-	    else
-	    {
-	    	pResponseFuture->setSendRequestOK(false);
-	    	pResponseFuture->putResponse(NULL);
-			{
-		        kpr::ScopedWLock<kpr::RWMutex> lock(m_responseTableLock);
-		        std::map<int, ResponseFuturePtr>::iterator it = m_responseTable.find(pRequest->getOpaque());
-		        if (it != m_responseTable.end())
-		        {
-		            m_responseTable.erase(it);
-		        }
-	        }
-
-	    	try
-	    	{
-	    		pResponseFuture->executeInvokeCallback();
-	    	}
-	    	catch (...)
-	    	{
-	            RMQ_WARN("executeInvokeCallback exception");
-	        }
-	        pResponseFuture->release();
-
-	    	RMQ_WARN("send a pRequest command to channel <%s> failed, requet: %s",
-	    		pTts->getServerAddr().c_str(), pRequest->toString().c_str());
-	    }
-    }
-    else
-    {
-    	if (timeoutMillis <= 0)
-    	{
-            THROW_MQEXCEPTION(RemotingTooMuchRequestException, "invokeAsyncImpl invoke too fast", -1);
-        }
-        else
-        {
-        	std::string info = RocketMQUtil::str2fmt(
-        		"invokeAsyncImpl wait semaphore timeout, %dms, semaphoreAsyncValue: %d, request: %s",
-                timeoutMillis,
-                m_semaphoreAsync.GetValue(),
-                pRequest->toString().c_str()
-            );
-            RMQ_WARN("%s", info.c_str());
-            THROW_MQEXCEPTION(RemotingTimeoutException, info, -1);
-        }
-    }
-
-    return;
-}
-
-int TcpRemotingClient::invokeOnewayImpl(TcpTransport* pTts,
-                                        RemotingCommand* pRequest,
-                                        int timeoutMillis)
-{
-	pRequest->markOnewayRPC();
-
-	bool acquired = m_semaphoreOneway.Wait(timeoutMillis);
-	if (acquired)
-	{
-		int ret = sendCmd(pTts, pRequest, timeoutMillis);
-		m_semaphoreOneway.Release();
-	    if (ret != 0)
-	    {
-	    	RMQ_WARN("send a pRequest command to channel <%s> failed, requet: %s",
-	    		pTts->getServerAddr().c_str(), pRequest->toString().c_str());
-	    	THROW_MQEXCEPTION(RemotingSendRequestException, std::string("send request to <") + pTts->getServerAddr() + "> fail", -1);
-	    }
-    }
-	else
-	{
-		if (timeoutMillis <= 0)
-		{
-			THROW_MQEXCEPTION(RemotingTooMuchRequestException, "invokeOnewayImpl invoke too fast", -1);
-		}
-		else
-		{
-			std::string info = RocketMQUtil::str2fmt(
-				"invokeOnewayImpl wait semaphore timeout, %dms, semaphoreAsyncValue: %d, request: %s",
-				timeoutMillis,
-				m_semaphoreAsync.GetValue(),
-				pRequest->toString().c_str()
-			);
-			RMQ_WARN("%s", info.c_str());
-			THROW_MQEXCEPTION(RemotingTimeoutException, info, -1);
-		}
-	}
-
-    return 0;
-}
-
-void TcpRemotingClient::processMessageReceived(TcpTransport* pTts, RemotingCommand* pCmd)
-{
-    try
-    {
-        switch (pCmd->getType())
-        {
-            case REQUEST_COMMAND:
-                processRequestCommand(pTts, pCmd);
-                break;
-            case RESPONSE_COMMAND:
-                processResponseCommand(pTts, pCmd);
-                break;
-            default:
-                break;
-        }
-    }
-    catch (std::exception& e)
-    {
-    	RMQ_ERROR("processMessageReceived catch Exception: %s", e.what());
-    }
-    catch (...)
-    {
-    	RMQ_ERROR("processMessageReceived catch Exception");
-    }
-}
-
-void TcpRemotingClient::processRequestCommand(TcpTransport* pTts, RemotingCommand* pCmd)
-{
-	RMQ_DEBUG("receive request from server, cmd: %s", pCmd->toString().c_str());
-	RemotingCommandPtr pResponse = NULL;
-	std::map<int, TcpRequestProcessor*>::iterator it = m_processorTable.find(pCmd->getCode());
-    if (it != m_processorTable.end())
-    {
-    	try
-    	{
-	        pResponse = it->second->processRequest(pTts, pCmd);
-	        if (!pCmd->isOnewayRPC())
-	        {
-	        	if (pResponse.ptr() != NULL)
-	        	{
-	        		pResponse->setOpaque(pCmd->getOpaque());
-	                pResponse->markResponseType();
-	                int ret = this->sendCmd(pTts, pResponse, 3000);
-	                if (ret != 0)
-	                {
-	                	RMQ_ERROR("process request over, but response failed");
-	                }
-	        	}
-	        	else
-	        	{
-                    // ignore
-	        	}
-	        }
-		}
-		catch (const std::exception& e)
-		{
-			RMQ_ERROR("process request exception:%s", e.what());
-			if (!pCmd->isOnewayRPC())
-			{
-				pResponse = RemotingCommand::createResponseCommand(
-					SYSTEM_ERROR_VALUE, e.what(), NULL);
-				pResponse->setOpaque(pCmd->getOpaque());
-				int ret = this->sendCmd(pTts, pResponse, 3000);
-				if (ret != 0)
-                {
-                	RMQ_ERROR("process request over, but response failed");
-                }
-			}
-		}
-    }
-    else
-    {
-    	pResponse = RemotingCommand::createResponseCommand(
-					REQUEST_CODE_NOT_SUPPORTED_VALUE, "request type not supported", NULL);
-		pResponse->setOpaque(pCmd->getOpaque());
-		int ret = this->sendCmd(pTts, pResponse, 3000);
-		if (ret != 0)
-        {
-        	RMQ_ERROR("process request over, but pResponse failed");
-        }
-    }
-	delete pCmd;
-}
-
-void TcpRemotingClient::processResponseCommand(TcpTransport* pTts, RemotingCommand* pCmd)
-{
-    ResponseFuturePtr res = NULL;
-    {
-        kpr::ScopedWLock<kpr::RWMutex> lock(m_responseTableLock);
-        std::map<int, ResponseFuturePtr>::iterator it = m_responseTable.find(pCmd->getOpaque());
-        if (it != m_responseTable.end())
-        {
-            res = it->second;
-            res->release();
-            m_responseTable.erase(it);
-        }
-    }
-
-    if (res)
-    {
-        res->putResponse(pCmd);
-        res->executeInvokeCallback();
-    }
-    else
-    {
-        RMQ_WARN("receive response, but not matched any request, cmd: %s", pCmd->toString().c_str());
-        delete pCmd;
-    }
-}
-
-int TcpRemotingClient::sendCmd(TcpTransport* pTts, RemotingCommand* pRequest, int timeoutMillis)
-{
-    pRequest->encode();
-    int ret = pTts->sendData(pRequest->getData(), pRequest->getDataLen(), timeoutMillis);
-
-    RMQ_DEBUG("[NETWORK]: SEND => {%s}, {opaque=%d, request.code=%s(%d), ret=%d, timeout=%d}, %s",
-    	pTts->getServerAddr().c_str(), pRequest->getOpaque(),
-    	getMQRequestCodeString(pRequest->getCode()), pRequest->getCode(),
-    	ret, timeoutMillis, pRequest->toString().c_str());
-
-    return ret;
-}
-
-void TcpRemotingClient::removeTTS(TcpTransport* pTts, bool isDisConnected)
-{
-    if (pTts)
-    {
-    	RMQ_INFO("[NETWORK]: %s  => {%s}", isDisConnected ? "DISCONNECT" : "CLOSE",
-    		pTts->getServerAddr().c_str());
-
-		bool bNeedClear = false;
-        m_epoller.del(pTts->getSocket(), (long long)(pTts->getServerAddr().c_str()), 0);
-        {
-            kpr::ScopedWLock<kpr::RWMutex> lock(m_transportTableLock);
-            std::map<std::string , TcpTransport*>::iterator it = m_transportTable.find(pTts->getServerAddr());
-            if (it != m_transportTable.end())
-            {
-            	if (it->second == pTts)
-            	{
-            		m_transportTable.erase(it);
-            		bNeedClear = true;
-            	}
-            }
-        }
-
-        if (bNeedClear)
-        {
-        	kpr::ScopedLock<kpr::Mutex> lock(m_closeTransportTableLock);
-        	m_closeTransportTable.push_back(pTts);
-        }
-    }
-}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/transport/TcpRemotingClient.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/transport/TcpRemotingClient.h b/rocketmq-client4cpp/src/transport/TcpRemotingClient.h
deleted file mode 100755
index d8bbf96..0000000
--- a/rocketmq-client4cpp/src/transport/TcpRemotingClient.h
+++ /dev/null
@@ -1,152 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __TCPREMOTINGCLIENT_H__
-#define __TCPREMOTINGCLIENT_H__
-
-#include <map>
-#include <string>
-#include <list>
-
-#include "RocketMQClient.h"
-#include "SocketUtil.h"
-#include "Epoller.h"
-#include "RemotingCommand.h"
-#include "Thread.h"
-#include "ThreadPool.h"
-#include "ThreadPoolWork.h"
-#include "RemoteClientConfig.h"
-#include "TcpTransport.h"
-#include "ScopedLock.h"
-#include "KPRUtil.h"
-#include "Semaphore.h"
-#include "ResponseFuture.h"
-
-namespace rmq
-{
-    class TcpTransport;
-    class InvokeCallback;
-    class TcpRemotingClient;
-    class ResponseFuture;
-    class TcpRequestProcessor;
-
-    class ProcessDataWork : public kpr::ThreadPoolWork
-    {
-    public:
-        ProcessDataWork(TcpRemotingClient* pClient, TcpTransport* pTts, std::string* pData);
-        virtual ~ProcessDataWork();
-        virtual void Do();
-
-    private:
-        TcpRemotingClient* m_pClient;
-		TcpTransport* m_pTts;
-        std::string* m_pData;
-    };
-	typedef kpr::RefHandleT<ProcessDataWork> ProcessDataWorkPtr;
-
-    class TcpRemotingClient
-    {
-		class EventThread : public kpr::Thread
-        {
-        public:
-            EventThread(TcpRemotingClient& client)
-                : Thread("NetThread"), m_client(client)
-            {
-            }
-
-            void Run()
-            {
-                m_client.run();
-            }
-
-        private :
-            TcpRemotingClient& m_client;
-        };
-        friend class EventThread;
-        friend class ProcessDataWork;
-
-	public:
-		static const int s_LockTimeoutMillis = 3000;
-		static const int s_CheckIntervalMillis = 1000;
-		static const int s_ClientOnewaySemaphoreValue = 2048;
-		static const int s_ClientAsyncSemaphoreValue = 2048;
-
-    public:
-        TcpRemotingClient(const RemoteClientConfig& config);
-        virtual ~TcpRemotingClient();
-        virtual void start();
-        virtual void shutdown();
-
-        void updateNameServerAddressList(const std::vector<std::string>& addrs);
-        std::vector<std::string> getNameServerAddressList();
-		void registerProcessor(int requestCode, TcpRequestProcessor* pProcessor);
-
-        RemotingCommand* invokeSync(const std::string& addr, RemotingCommand* pRequest, int timeoutMillis) ;
-        void invokeAsync(const std::string& addr, RemotingCommand* pRequest, int timeoutMillis, InvokeCallback* invokeCallback);
-        int invokeOneway(const std::string& addr, RemotingCommand* pRequest, int timeoutMillis);
-
-    private:
-		void run();
-        int  sendCmd(TcpTransport* pTts, RemotingCommand* pRequest, int timeoutMillis);
-        void removeTTS(TcpTransport* pTts, bool isDisConnected = false);
-        void processData(TcpTransport* pTts, std::string* data);
-        void handleTimerEvent();
-		void scanResponseTable();
-		void scanCloseTransportTable();
-
-        void processMessageReceived(TcpTransport* pTts, RemotingCommand* pCmd);
-        void processRequestCommand(TcpTransport* pTts, RemotingCommand* pCmd);
-        void processResponseCommand(TcpTransport* pTts, RemotingCommand* pCmd);
-
-        TcpTransport* getAndCreateTransport(const std::string& addr, int timeoutMillis);
-		TcpTransport* getAndCreateNameserverTransport(int timeoutMillis);
-		TcpTransport* createTransport(const std::string& addr, int timeoutMillis);
-
-        RemotingCommand* invokeSyncImpl(TcpTransport* pTts, RemotingCommand* pRequest, int timeoutMillis) ;
-        void invokeAsyncImpl(TcpTransport* pTts, RemotingCommand* pRequest, int timeoutMillis, InvokeCallback* pInvokeCallback);
-        int invokeOnewayImpl(TcpTransport* pTts, RemotingCommand* pRequest, int timeoutMillis);
-
-    private:
-        bool m_stop;
-        kpr::Epoller m_epoller;
-        RemoteClientConfig m_config;
-
-		kpr::Semaphore m_semaphoreOneway;
-		kpr::Semaphore m_semaphoreAsync;
-
-        std::map<std::string , TcpTransport*> m_transportTable;
-        kpr::RWMutex m_transportTableLock;
-
-		std::list<TcpTransport*> m_closeTransportTable;
-		kpr::Mutex m_closeTransportTableLock;
-
-        std::map<int, ResponseFuturePtr> m_responseTable;
-        kpr::RWMutex m_responseTableLock;
-
-        std::vector<std::string> m_namesrvAddrList;
-		kpr::AtomicInteger m_namesrvIndex;
-		kpr::AtomicReference<std::string> m_namesrvAddrChoosed;
-		kpr::Mutex m_namesrvAddrChoosedLock;
-
-        kpr::ThreadPoolPtr m_pNetThreadPool;
-		kpr::ThreadPtr m_pEventThread;
-
-        TcpRequestProcessor* m_pDefaultRequestProcessor;
-        std::map<int, TcpRequestProcessor*> m_processorTable;
-    };
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/transport/TcpRequestProcessor.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/transport/TcpRequestProcessor.h b/rocketmq-client4cpp/src/transport/TcpRequestProcessor.h
deleted file mode 100755
index 6ac02d1..0000000
--- a/rocketmq-client4cpp/src/transport/TcpRequestProcessor.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * Copyright (C) 2013 kangliqiang ,kangliq@163.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef __TCPREQUESTPROCESSOR_H__
-#define __TCPREQUESTPROCESSOR_H__
-
-namespace rmq
-{
-	class RemotingCommand;
-	class TcpTransport;
-
-	class TcpRequestProcessor
-	{
-	public:
-	    virtual ~TcpRequestProcessor() {}
-	    virtual RemotingCommand* processRequest(TcpTransport* pTts, RemotingCommand* pRequest) = 0;
-	};
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/transport/TcpTransport.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/transport/TcpTransport.cpp b/rocketmq-client4cpp/src/transport/TcpTransport.cpp
deleted file mode 100755
index 858adf3..0000000
--- a/rocketmq-client4cpp/src/transport/TcpTransport.cpp
+++ /dev/null
@@ -1,387 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#include "TcpTransport.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <memory.h>
-#include <errno.h>
-#include <assert.h>
-#include "KPRUtil.h"
-#include "SocketUtil.h"
-#include "Epoller.h"
-#include "ScopedLock.h"
-
-namespace rmq
-{
-
-const int DEFAULT_SHRINK_COUNT = 32;
-const int DEFAULT_RECV_BUFFER_SIZE = 1024 * 16;
-
-TcpTransport::TcpTransport(std::map<std::string, std::string>& config)
-    : m_sfd(-1),
-      m_state(CLIENT_STATE_UNINIT),
-      m_pRecvBuf(NULL),
-      m_recvBufSize(DEFAULT_RECV_BUFFER_SIZE),
-      m_recvBufUsed(0),
-      m_shrinkMax(DEFAULT_RECV_BUFFER_SIZE),
-      m_shrinkCheckCnt(DEFAULT_SHRINK_COUNT)
-{
-    std::map<std::string, std::string>::iterator it = config.find("tcp.transport.recvBufferSize");
-    if (it != config.end())
-    {
-        m_recvBufSize = atoi(it->second.c_str());
-    }
-
-    it = config.find("tcp.transport.shrinkCheckMax");
-    if (it != config.end())
-    {
-        m_shrinkCheckCnt = atoi(it->second.c_str());
-    }
-
-    if (SocketInit() != 0)
-    {
-        m_state = CLIENT_STATE_UNINIT;
-    }
-
-    m_pRecvBuf = (char*)malloc(m_recvBufSize);
-    m_state = (NULL == m_pRecvBuf) ? CLIENT_STATE_UNINIT : CLIENT_STATE_INITED;
-    m_lastSendRecvTime = KPRUtil::GetCurrentTimeMillis();
-}
-
-TcpTransport::~TcpTransport()
-{
-    close();
-
-    if (m_sfd != INVALID_SOCKET)
-    {
-        ::shutdown(m_sfd, SD_BOTH);
-        ::closesocket(m_sfd);
-        m_sfd = INVALID_SOCKET;
-    }
-
-    if (m_pRecvBuf)
-    {
-        free(m_pRecvBuf);
-    }
-
-    SocketUninit();
-}
-
-
-int TcpTransport::connect(const std::string& serverAddr, int timeoutMillis)
-{
-    long long endTime = KPRUtil::GetCurrentTimeMillis() + timeoutMillis;
-    if (m_state == CLIENT_STATE_UNINIT)
-    {
-        return CLIENT_ERROR_INIT;
-    }
-
-    if (isConnected())
-    {
-        if (serverAddr.compare(m_serverAddr) == 0)
-        {
-            return CLIENT_ERROR_SUCCESS;
-        }
-        else
-        {
-            close();
-        }
-    }
-
-    short port;
-    std::string strAddr;
-
-    if (!SplitURL(serverAddr, strAddr, port))
-    {
-        return CLIENT_ERROR_INVALID_URL;
-    }
-
-    struct sockaddr_in sa;
-    sa.sin_family = AF_INET;
-    sa.sin_port = htons(port);
-
-    sa.sin_addr.s_addr = inet_addr(strAddr.c_str());
-    m_sfd = (int)socket(AF_INET, SOCK_STREAM, 0);
-
-    if (MakeSocketNonblocking(m_sfd) == -1)
-    {
-    	::closesocket(m_sfd);
-        return CLIENT_ERROR_CONNECT;
-    }
-
-    if (SetTcpNoDelay(m_sfd) == -1)
-    {
-        ::closesocket(m_sfd);
-        return CLIENT_ERROR_CONNECT;
-    }
-
-    if (::connect(m_sfd, (struct sockaddr*)&sa, sizeof(sockaddr)) == -1)
-    {
-        int err = NET_ERROR;
-        if (err == WSAEWOULDBLOCK || err == WSAEINPROGRESS)
-        {
-            kpr::Epoller epoller(false);
-            epoller.create(1);
-            epoller.add(m_sfd, 0, EPOLLOUT);
-            int iRetCode = epoller.wait(endTime - KPRUtil::GetCurrentTimeMillis());
-            if (iRetCode <= 0)
-            {
-                ::closesocket(m_sfd);
-                return CLIENT_ERROR_CONNECT;
-            }
-            else if (iRetCode == 0)
-            {
-                ::closesocket(m_sfd);
-                return CLIENT_ERROR_CONNECT;
-            }
-
-            const epoll_event& ev = epoller.get(0);
-            if (ev.events & EPOLLERR || ev.events & EPOLLHUP)
-            {
-                ::closesocket(m_sfd);
-                return CLIENT_ERROR_CONNECT;
-            }
-
-            int opterr = 0;
-            socklen_t errlen = sizeof(opterr);
-            if (getsockopt(m_sfd, SOL_SOCKET, SO_ERROR, &opterr, &errlen) == -1 || opterr)
-            {
-                ::closesocket(m_sfd);
-                return CLIENT_ERROR_CONNECT;
-            }
-        }
-        else
-        {
-            ::closesocket(m_sfd);
-            return CLIENT_ERROR_CONNECT;
-        }
-    }
-
-    m_serverAddr = serverAddr;
-    m_state = CLIENT_STATE_CONNECTED;
-    m_recvBufUsed = 0;
-    m_lastSendRecvTime = KPRUtil::GetCurrentTimeMillis();
-
-    return CLIENT_ERROR_SUCCESS;
-}
-
-
-bool TcpTransport::isConnected()
-{
-    return m_state == CLIENT_STATE_CONNECTED;
-}
-
-void TcpTransport::close()
-{
-    if (m_state == CLIENT_STATE_CONNECTED)
-    {
-        m_state = CLIENT_STATE_DISCONNECT;
-    }
-}
-
-int TcpTransport::sendData(const char* pBuffer, int len, int timeOut)
-{
-    kpr::ScopedLock<kpr::Mutex> lock(m_sendLock);
-    return sendOneMsg(pBuffer, len, timeOut > 0 ? timeOut : 0);
-}
-
-int TcpTransport::sendOneMsg(const char* pBuffer, int len, int nTimeOut)
-{
-    int pos = 0;
-    long long endTime = KPRUtil::GetCurrentTimeMillis() + nTimeOut;
-
-    while (len > 0 && m_state == CLIENT_STATE_CONNECTED)
-    {
-        int ret = send(m_sfd, pBuffer + pos, len, 0);
-        if (ret > 0)
-        {
-            len -= ret;
-            pos += ret;
-        }
-        else if (ret == 0)
-        {
-            close();
-            break;
-        }
-        else
-        {
-            int err = NET_ERROR;
-            if (err == WSAEWOULDBLOCK || err == EAGAIN)
-            {
-                kpr::Epoller epoller(false);
-                epoller.create(1);
-                epoller.add(m_sfd, 0, EPOLLOUT);
-                int iRetCode = epoller.wait(endTime - KPRUtil::GetCurrentTimeMillis());
-                if (iRetCode <= 0)
-                {
-                    close();
-                    break;
-                }
-                else if (iRetCode == 0)
-                {
-                    close();
-                    break;
-                }
-
-                const epoll_event& ev = epoller.get(0);
-                if (ev.events & EPOLLERR || ev.events & EPOLLHUP)
-                {
-                    close();
-                    break;
-                }
-            }
-            else
-            {
-                close();
-                break;
-            }
-        }
-    }
-    m_lastSendRecvTime = KPRUtil::GetCurrentTimeMillis();
-
-    return (len == 0) ? 0 : -1;
-}
-
-
-int TcpTransport::recvMsg()
-{
-    int ret = recv(m_sfd, m_pRecvBuf + m_recvBufUsed, m_recvBufSize - m_recvBufUsed, 0);
-
-    if (ret > 0)
-    {
-        m_recvBufUsed += ret;
-    }
-    else if (ret == 0)
-    {
-        close();
-        ret = -1;
-    }
-    else if (ret < 0)
-    {
-        int err = NET_ERROR;
-        if (err == WSAEWOULDBLOCK || err == EAGAIN || err == EINTR)
-        {
-            ret = 0;
-        }
-        else
-        {
-            close();
-        }
-    }
-    m_lastSendRecvTime = KPRUtil::GetCurrentTimeMillis();
-
-    return ret;
-}
-
-bool TcpTransport::resizeBuf(int nNewSize)
-{
-    char* newbuf = (char*)realloc(m_pRecvBuf, nNewSize);
-    if (!newbuf)
-    {
-        return false;
-    }
-
-    m_pRecvBuf = newbuf;
-    m_recvBufSize = nNewSize;
-
-    return true;
-}
-
-void TcpTransport::tryShrink(int MsgLen)
-{
-    m_shrinkMax = MsgLen > m_shrinkMax ? MsgLen : m_shrinkMax;
-    if (m_shrinkCheckCnt == 0)
-    {
-        m_shrinkCheckCnt = DEFAULT_SHRINK_COUNT;
-        if (m_recvBufSize > m_shrinkMax)
-        {
-            resizeBuf(m_shrinkMax);
-        }
-    }
-    else
-    {
-        m_shrinkCheckCnt--;
-    }
-}
-
-int TcpTransport::getMsgSize(const char* pBuf)
-{
-    int len = 0;
-    memcpy(&len, pBuf, sizeof(int));
-
-    return ntohl(len) + 4;
-}
-
-int TcpTransport::recvData(std::list<std::string*>& dataList)
-{
-    int ret = recvMsg();
-    processData(dataList);
-    return ret;
-}
-
-void TcpTransport::processData(std::list<std::string*>& dataList)
-{
-    while (m_recvBufUsed > int(sizeof(int)))
-    {
-        int msgLen = 0;
-        msgLen = getMsgSize(m_pRecvBuf);
-        if (msgLen > m_recvBufSize)
-        {
-            if (resizeBuf(msgLen))
-            {
-                m_shrinkCheckCnt = DEFAULT_SHRINK_COUNT;
-            }
-            break;
-        }
-        else
-        {
-            tryShrink(msgLen);
-        }
-
-        if (m_recvBufUsed >= msgLen)
-        {
-            std::string* data = new std::string;
-            data->assign(m_pRecvBuf, msgLen);
-            dataList.push_back(data);
-            m_recvBufUsed -= msgLen;
-
-            memmove(m_pRecvBuf, m_pRecvBuf + msgLen, m_recvBufUsed);
-        }
-        else
-        {
-            break;
-        }
-    }
-}
-
-SOCKET TcpTransport::getSocket()
-{
-    return m_sfd;
-}
-
-std::string& TcpTransport::getServerAddr()
-{
-    return m_serverAddr;
-}
-
-unsigned long long TcpTransport::getLastSendRecvTime()
-{
-	return m_lastSendRecvTime;
-}
-
-
-}



[03/17] incubator-rocketmq-externals git commit: Polish cpp module

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/protocol/CommandCustomHeader.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/protocol/CommandCustomHeader.cpp b/rocketmq-client4cpp/src/protocol/CommandCustomHeader.cpp
deleted file mode 100755
index fb2d2a6..0000000
--- a/rocketmq-client4cpp/src/protocol/CommandCustomHeader.cpp
+++ /dev/null
@@ -1,672 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#include "CommandCustomHeader.h"
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <arpa/inet.h>
-#include <sstream>
-#include <string>
-#include <cstdlib>
-#include "RemotingCommand.h"
-#include "MQProtos.h"
-#include "KPRUtil.h"
-#include "UtilAll.h"
-
-#include "json/json.h"
-
-namespace rmq
-{
-
-
-CommandCustomHeader* CommandCustomHeader::decode(int code, Json::Value& data, bool isResponseType)
-{
-	CommandCustomHeader* pCustomHeader = NULL;
-
-	try
-	{
-	    if (isResponseType)
-	    {
-	        switch (code)
-	        {
-	            case SEND_MESSAGE_VALUE:
-	            case SEND_MESSAGE_V2_VALUE:
-	                pCustomHeader = SendMessageResponseHeader::decode(data);
-	                break;
-	            case PULL_MESSAGE_VALUE:
-	                pCustomHeader = PullMessageResponseHeader::decode(data);
-	                break;
-	            case QUERY_CONSUMER_OFFSET_VALUE:
-	                pCustomHeader = QueryConsumerOffsetResponseHeader::decode(data);
-	                break;
-	            case SEARCH_OFFSET_BY_TIMESTAMP_VALUE:
-	            	pCustomHeader = SearchOffsetResponseHeader::decode(data);
-	            	break;
-	           	case GET_MAX_OFFSET_VALUE:
-	            	pCustomHeader = GetMaxOffsetResponseHeader::decode(data);
-	            	break;
-	            case GET_MIN_OFFSET_VALUE:
-	            	pCustomHeader = GetMinOffsetResponseHeader::decode(data);
-	            	break;
-	            case GET_EARLIEST_MSG_STORETIME_VALUE:
-	            	pCustomHeader = GetEarliestMsgStoretimeResponseHeader::decode(data);
-	            	break;
-	            case QUERY_MESSAGE_VALUE:
-	            	pCustomHeader = QueryMessageResponseHeader::decode(data);
-	            	break;
-	            case GET_KV_CONFIG_VALUE:
-	            	pCustomHeader = GetKVConfigResponseHeader::decode(data);
-	            	break;
-
-	            default:
-	                break;
-	        }
-	    }
-	    else
-	    {
-			switch (code)
-	        {
-	            case NOTIFY_CONSUMER_IDS_CHANGED_VALUE:
-	                pCustomHeader = NotifyConsumerIdsChangedRequestHeader::decode(data);
-	                break;
-	            case GET_CONSUMER_RUNNING_INFO_VALUE:
-	            	pCustomHeader = GetConsumerRunningInfoRequestHeader::decode(data);
-	            	break;
-	            default:
-	                break;
-	        }
-	    }
-    }
-    catch(std::exception& e)
-    {
-    	if (pCustomHeader != NULL)
-    	{
-    		delete pCustomHeader;
-    		pCustomHeader = NULL;
-    	}
-    	RMQ_ERROR("CommandCustomHeader decode exception, %d, %d, %s, %s",
-    		code, isResponseType, UtilAll::toString(data).c_str(), e.what());
-    }
-    catch(...)
-    {
-    	if (pCustomHeader != NULL)
-    	{
-    		delete pCustomHeader;
-    		pCustomHeader = NULL;
-    	}
-    	RMQ_ERROR("CommandCustomHeader decode exception, %d, %d, %s",
-    		code, isResponseType, UtilAll::toString(data).c_str());
-    }
-
-    return pCustomHeader;
-}
-
-
-////////////////////////////////////////////////////////////////////////////////
-//GET_ROUTEINTO_BY_TOPIC_VALUE
-////////////////////////////////////////////////////////////////////////////////
-void GetRouteInfoRequestHeader::encode(std::string& outData)
-{
-    std::stringstream ss;
-    ss << "{"
-       << "\"topic\":\"" << topic << "\""
-       << "}";
-
-    outData = ss.str();
-}
-
-
-////////////////////////////////////////////////////////////////////////////////
-// UPDATE_AND_CREATE_TOPIC_VALUE
-////////////////////////////////////////////////////////////////////////////////
-void CreateTopicRequestHeader::encode(std::string& outData)
-{
-    std::stringstream ss;
-
-    ss << "{"
-       << "\"topic\":\"" << topic << "\","
-       << "\"defaultTopic\":\"" << defaultTopic << "\","
-	   << "\"readQueueNums\":\"" << readQueueNums << "\","
-	   << "\"writeQueueNums\":\"" << writeQueueNums << "\","
-	   << "\"perm\":\"" << perm << "\","
-	   << "\"topicFilterType\":\"" << topicFilterType << "\","
-	   << "\"topicSysFlag\":\"" << topicFilterType << "\","
-	   << "\"order\":\"" << topicFilterType << "\""
-       << "}";
-
-    outData = ss.str();
-}
-
-
-////////////////////////////////////////////////////////////////////////////////
-// SEND_MESSAGE_VALUE/SEND_MESSAGE_V2_VALUE
-////////////////////////////////////////////////////////////////////////////////
-void SendMessageRequestHeader::encode(std::string& outData)
-{
-    std::stringstream ss;
-
-    ss << "{"
-       << "\"producerGroup\":\"" << producerGroup << "\","
-       << "\"topic\":\"" << topic << "\","
-       << "\"defaultTopic\":\"" << defaultTopic << "\","
-       << "\"defaultTopicQueueNums\":" << defaultTopicQueueNums << ","
-       << "\"queueId\":" << queueId << ","
-       << "\"sysFlag\":" << sysFlag << ","
-       << "\"bornTimestamp\":" << bornTimestamp << ","
-       << "\"flag\":" << flag << ","
-       << "\"properties\":\"" << properties << "\","
-       << "\"reconsumeTimes\":" << reconsumeTimes
-       << "}";
-
-    outData = ss.str();
-}
-
-void SendMessageRequestHeaderV2::encode(std::string& outData)
-{
-    std::stringstream ss;
-
-    ss << "{"
-       << "\"a\":\"" << a << "\","
-       << "\"b\":\"" << b << "\","
-       << "\"c\":\"" << c << "\","
-       << "\"d\":\"" << d << "\","
-       << "\"e\":\"" << e << "\","
-       << "\"f\":\"" << f << "\","
-       << "\"g\":\"" << g << "\","
-       << "\"h\":\"" << h << "\","
-       << "\"i\":\"" << i << "\","
-       << "\"j\":\"" << j << "\""
-       << "}";
-
-    outData = ss.str();
-}
-
-SendMessageRequestHeader* SendMessageRequestHeaderV2::createSendMessageRequestHeaderV1(
-	const SendMessageRequestHeaderV2* v2)
-{
-    SendMessageRequestHeader* v1 = new SendMessageRequestHeader();
-    v1->producerGroup = v2->a;
-    v1->topic = v2->b;
-    v1->defaultTopic = v2->c;
-    v1->defaultTopicQueueNums = v2->d;
-    v1->queueId = v2->e;
-    v1->sysFlag = v2->f;
-    v1->bornTimestamp = v2->g;
-    v1->flag = v2->h;
-    v1->properties = v2->i;
-    v1->reconsumeTimes = v2->j;
-
-    return v1;
-}
-
-SendMessageRequestHeaderV2* SendMessageRequestHeaderV2::createSendMessageRequestHeaderV2(
-	const SendMessageRequestHeader* v1)
-{
-    SendMessageRequestHeaderV2* v2 = new SendMessageRequestHeaderV2();
-    v2->a = v1->producerGroup;
-    v2->b = v1->topic;
-    v2->c = v1->defaultTopic;
-    v2->d = v1->defaultTopicQueueNums;
-    v2->e = v1->queueId;
-    v2->f = v1->sysFlag;
-    v2->g = v1->bornTimestamp;
-    v2->h = v1->flag;
-    v2->i = v1->properties;
-    v2->j = v1->reconsumeTimes;
-
-    return v2;
-}
-
-void SendMessageResponseHeader::encode(std::string& outData)
-{
-}
-
-CommandCustomHeader* SendMessageResponseHeader::decode(Json::Value& data)
-{
-    std::string msgId = data["msgId"].asString();
-    int queueId = atoi(data["queueId"].asCString());
-    long long queueOffset = KPRUtil::str2ll(data["queueOffset"].asCString());
-
-    SendMessageResponseHeader* h = new SendMessageResponseHeader();
-
-    h->msgId = msgId;
-    h->queueId = queueId;
-    h->queueOffset = queueOffset;
-
-    return h;
-}
-
-
-////////////////////////////////////////////////////////////////////////////////
-// PULL_MESSAGE_VALUE
-////////////////////////////////////////////////////////////////////////////////
-void PullMessageRequestHeader::encode(std::string& outData)
-{
-    std::stringstream ss;
-
-    ss << "{"
-       << "\"consumerGroup\":\"" << consumerGroup << "\","
-       << "\"topic\":\"" << topic << "\","
-       << "\"queueId\":\"" << queueId << "\","
-       << "\"queueOffset\":\"" << queueOffset << "\","
-       << "\"maxMsgNums\":\"" << maxMsgNums << "\","
-       << "\"sysFlag\":\"" << sysFlag << "\","
-       << "\"commitOffset\":\"" << commitOffset << "\","
-       << "\"suspendTimeoutMillis\":\"" << suspendTimeoutMillis << "\","
-       << "\"subscription\":\"" << subscription << "\","
-       << "\"subVersion\":\"" << subVersion << "\""
-       << "}";
-
-    outData = ss.str();
-}
-
-void PullMessageResponseHeader::encode(std::string& outData)
-{
-	std::stringstream ss;
-    ss  << "{"
-        << "\"suggestWhichBrokerId\":\"" << suggestWhichBrokerId << "\","
-        << "\"nextBeginOffset\":\"" << nextBeginOffset << "\","
-        << "\"minOffset\":\"" << minOffset << "\","
-        << "\"maxOffset\":\"" << maxOffset << "\""
-        << "}";
-    outData = ss.str();
-}
-
-CommandCustomHeader* PullMessageResponseHeader::decode(Json::Value& data)
-{
-    long long suggestWhichBrokerId = KPRUtil::str2ll(data["suggestWhichBrokerId"].asCString());
-    long long nextBeginOffset = KPRUtil::str2ll(data["nextBeginOffset"].asCString());
-    long long minOffset = KPRUtil::str2ll(data["minOffset"].asCString());
-    long long maxOffset = KPRUtil::str2ll(data["maxOffset"].asCString());
-
-    PullMessageResponseHeader* h = new PullMessageResponseHeader();
-    h->suggestWhichBrokerId = suggestWhichBrokerId;
-    h->nextBeginOffset = nextBeginOffset;
-    h->minOffset = minOffset;
-    h->maxOffset = maxOffset;
-
-    return h;
-}
-
-
-
-////////////////////////////////////////////////////////////////////////////////
-// GET_CONSUMER_LIST_BY_GROUP_VALUE
-////////////////////////////////////////////////////////////////////////////////
-void GetConsumerListByGroupRequestHeader::encode(std::string& outData)
-{
-    std::stringstream ss;
-
-    ss << "{"
-       << "\"consumerGroup\":\"" << consumerGroup << "\""
-       << "}";
-
-    outData = ss.str();
-}
-
-
-////////////////////////////////////////////////////////////////////////////////
-// CONSUMER_SEND_MSG_BACK_VALUE
-////////////////////////////////////////////////////////////////////////////////
-void ConsumerSendMsgBackRequestHeader::encode(std::string& outData)
-{
-    std::stringstream ss;
-
-    ss << "{"
-       << "\"offset\":\"" << offset << "\","
-       << "\"group\":\"" << group << "\","
-       << "\"delayLevel\":\"" << delayLevel << "\""
-       << "}";
-
-    outData = ss.str();
-}
-
-
-////////////////////////////////////////////////////////////////////////////////
-// QUERY_CONSUMER_OFFSET_VALUE
-////////////////////////////////////////////////////////////////////////////////
-void QueryConsumerOffsetRequestHeader::encode(std::string& outData)
-{
-    std::stringstream ss;
-    ss  << "{"
-        << "\"consumerGroup\":\"" << consumerGroup << "\","
-        << "\"topic\":\"" << topic << "\","
-        << "\"queueId\":\"" << queueId << "\""
-        << "}";
-    outData = ss.str();
-}
-
-void QueryConsumerOffsetResponseHeader::encode(std::string& outData)
-{
-	std::stringstream ss;
-    ss  << "{"
-        << "\"offset\":\"" << offset << "\""
-        << "}";
-    outData = ss.str();
-}
-
-CommandCustomHeader* QueryConsumerOffsetResponseHeader::decode(Json::Value& data)
-{
-	long long offset = -1;
-
-	if (data.isMember("offset"))
-	{
-    	offset = KPRUtil::str2ll(data["offset"].asCString());
-    }
-
-    QueryConsumerOffsetResponseHeader* h = new QueryConsumerOffsetResponseHeader();
-    h->offset = offset;
-
-    return h;
-}
-
-
-////////////////////////////////////////////////////////////////////////////////
-// UPDATE_CONSUMER_OFFSET_VALUE
-////////////////////////////////////////////////////////////////////////////////
-void UpdateConsumerOffsetRequestHeader::encode(std::string& outData)
-{
-    std::stringstream ss;
-    ss  << "{"
-        << "\"consumerGroup\":\"" << consumerGroup << "\","
-        << "\"topic\":\"" << topic << "\","
-        << "\"queueId\":\"" << queueId << "\","
-        << "\"commitOffset\":\"" << commitOffset << "\""
-        << "}";
-    outData = ss.str();
-}
-
-
-////////////////////////////////////////////////////////////////////////////////
-// UNREGISTER_CLIENT_VALUE
-////////////////////////////////////////////////////////////////////////////////
-void UnregisterClientRequestHeader::encode(std::string& outData)
-{
-    std::stringstream ss;
-    ss  << "{"
-        << "\"producerGroup\":\"" << producerGroup << "\","
-        << "\"consumerGroup\":\"" << consumerGroup << "\","
-        << "\"clientID\":\"" << clientID << "\""
-        << "}";
-    outData = ss.str();
-}
-
-
-///////////////////////////////////////////////////////////////////////
-// VIEW_MESSAGE_BY_ID_VALUE
-///////////////////////////////////////////////////////////////////////
-void ViewMessageRequestHeader::encode(std::string& outData)
-{
-    std::stringstream ss;
-    ss  << "{"
-        << "\"offset\":" << offset
-        << "}";
-    outData = ss.str();
-}
-
-
-///////////////////////////////////////////////////////////////////////
-// SEARCH_OFFSET_BY_TIMESTAMP_VALUE
-///////////////////////////////////////////////////////////////////////
-void SearchOffsetRequestHeader::encode(std::string& outData)
-{
-    std::stringstream ss;
-    ss  << "{"
-        << "\"topic\":\"" << topic << "\","
-        << "\"queueId\":\"" << queueId << "\","
-        << "\"timestamp\":\"" << timestamp << "\""
-        << "}";
-    outData = ss.str();
-}
-
-void SearchOffsetResponseHeader::encode(std::string& outData)
-{
-	std::stringstream ss;
-    ss  << "{"
-        << "\"offset\":\"" << offset << "\""
-        << "}";
-    outData = ss.str();
-}
-
-CommandCustomHeader* SearchOffsetResponseHeader::decode(Json::Value& data)
-{
-    long long offset = KPRUtil::str2ll(data["offset"].asCString());
-
-    SearchOffsetResponseHeader* h = new SearchOffsetResponseHeader();
-    h->offset = offset;
-
-    return h;
-}
-
-
-///////////////////////////////////////////////////////////////////////
-// GET_MAX_OFFSET_VALUE
-///////////////////////////////////////////////////////////////////////
-void GetMaxOffsetRequestHeader::encode(std::string& outData)
-{
-    std::stringstream ss;
-    ss  << "{"
-        << "\"topic\":\"" << topic << "\","
-        << "\"queueId\":\"" << queueId << "\""
-        << "}";
-    outData = ss.str();
-}
-
-void GetMaxOffsetResponseHeader::encode(std::string& outData)
-{
-	std::stringstream ss;
-    ss  << "{"
-        << "\"offset\":\"" << offset << "\""
-        << "}";
-    outData = ss.str();
-}
-
-CommandCustomHeader* GetMaxOffsetResponseHeader::decode(Json::Value& data)
-{
-    long long offset = KPRUtil::str2ll(data["offset"].asCString());
-
-    GetMaxOffsetResponseHeader* h = new GetMaxOffsetResponseHeader();
-    h->offset = offset;
-
-    return h;
-}
-
-
-///////////////////////////////////////////////////////////////////////
-// GET_MIN_OFFSET_VALUE
-///////////////////////////////////////////////////////////////////////
-void GetMinOffsetRequestHeader::encode(std::string& outData)
-{
-    std::stringstream ss;
-    ss  << "{"
-        << "\"topic\":\"" << topic << "\","
-        << "\"queueId\":\"" << queueId << "\""
-        << "}";
-    outData = ss.str();
-}
-
-void GetMinOffsetResponseHeader::encode(std::string& outData)
-{
-	std::stringstream ss;
-    ss  << "{"
-        << "\"offset\":\"" << offset << "\""
-        << "}";
-    outData = ss.str();
-}
-
-CommandCustomHeader* GetMinOffsetResponseHeader::decode(Json::Value& data)
-{
-    long long offset = KPRUtil::str2ll(data["offset"].asCString());
-
-    GetMinOffsetResponseHeader* h = new GetMinOffsetResponseHeader();
-    h->offset = offset;
-
-    return h;
-}
-
-
-
-///////////////////////////////////////////////////////////////////////
-// GET_EARLIEST_MSG_STORETIME_VALUE
-///////////////////////////////////////////////////////////////////////
-void GetEarliestMsgStoretimeRequestHeader::encode(std::string& outData)
-{
-    std::stringstream ss;
-    ss  << "{"
-        << "\"topic\":\"" << topic << "\","
-        << "\"queueId\":\"" << queueId << "\""
-        << "}";
-    outData = ss.str();
-}
-
-void GetEarliestMsgStoretimeResponseHeader::encode(std::string& outData)
-{
-	std::stringstream ss;
-    ss  << "{"
-        << "\"timestamp\":\"" << timestamp << "\""
-        << "}";
-    outData = ss.str();
-}
-
-
-CommandCustomHeader* GetEarliestMsgStoretimeResponseHeader::decode(Json::Value& data)
-{
-    long long timestamp = KPRUtil::str2ll(data["timestamp"].asCString());
-
-    GetEarliestMsgStoretimeResponseHeader* h = new GetEarliestMsgStoretimeResponseHeader();
-    h->timestamp = timestamp;
-
-    return h;
-}
-
-
-///////////////////////////////////////////////////////////////////////
-// QUERY_MESSAGE_VALUE
-///////////////////////////////////////////////////////////////////////
-void QueryMessageRequestHeader::encode(std::string& outData)
-{
-    std::stringstream ss;
-    ss  << "{"
-        << "\"topic\":\"" << topic << "\","
-        << "\"key\":\"" << key << "\","
-        << "\"maxNum\":\"" << maxNum << "\","
-        << "\"beginTimestamp\":\"" << beginTimestamp << "\","
-        << "\"endTimestamp\":\"" << endTimestamp << "\""
-        << "}";
-    outData = ss.str();
-}
-
-void QueryMessageResponseHeader::encode(std::string& outData)
-{
-	std::stringstream ss;
-    ss  << "{"
-        << "\"indexLastUpdateTimestamp\":\"" << indexLastUpdateTimestamp << "\","
-        << "\"indexLastUpdatePhyoffset\":\"" << indexLastUpdatePhyoffset << "\""
-        << "}";
-    outData = ss.str();
-}
-
-CommandCustomHeader* QueryMessageResponseHeader::decode(Json::Value& data)
-{
-    long long indexLastUpdateTimestamp = KPRUtil::str2ll(data["indexLastUpdateTimestamp"].asCString());
-    long long indexLastUpdatePhyoffset = KPRUtil::str2ll(data["indexLastUpdatePhyoffset"].asCString());
-
-    QueryMessageResponseHeader* h = new QueryMessageResponseHeader();
-    h->indexLastUpdateTimestamp = indexLastUpdateTimestamp;
-    h->indexLastUpdatePhyoffset = indexLastUpdatePhyoffset;
-
-    return h;
-}
-
-
-///////////////////////////////////////////////////////////////////////
-// GET_KV_CONFIG_VALUE
-///////////////////////////////////////////////////////////////////////
-void GetKVConfigRequestHeader::encode(std::string& outData)
-{
-    std::stringstream ss;
-    ss  << "{"
-        << "\"namespace\":\"" << namespace_ << "\","
-        << "\"key\":\"" << key << "\""
-        << "}";
-    outData = ss.str();
-}
-
-void GetKVConfigResponseHeader::encode(std::string& outData)
-{
-	std::stringstream ss;
-    ss  << "{"
-        << "\"value\":\"" << value << "\""
-        << "}";
-    outData = ss.str();
-}
-
-CommandCustomHeader* GetKVConfigResponseHeader::decode(Json::Value& data)
-{
-    GetKVConfigResponseHeader* h = new GetKVConfigResponseHeader();
-    h->value = data["value"].asString();
-
-    return h;
-}
-
-
-///////////////////////////////////////////////////////////////////////
-// NOTIFY_CONSUMER_IDS_CHANGED_VALUE
-///////////////////////////////////////////////////////////////////////
-void NotifyConsumerIdsChangedRequestHeader::encode(std::string& outData)
-{
-    std::stringstream ss;
-    ss  << "{"
-        << "\"consumerGroup\":\"" << consumerGroup << "\""
-        << "}";
-    outData = ss.str();
-}
-
-CommandCustomHeader* NotifyConsumerIdsChangedRequestHeader::decode(Json::Value& data)
-{
-    NotifyConsumerIdsChangedRequestHeader* h = new NotifyConsumerIdsChangedRequestHeader();
-    h->consumerGroup = data["consumerGroup"].asString();
-
-    return h;
-}
-
-
-///////////////////////////////////////////////////////////////////////
-// GET_CONSUMER_RUNNING_INFO_VALUE
-///////////////////////////////////////////////////////////////////////
-void GetConsumerRunningInfoRequestHeader::encode(std::string& outData)
-{
-    std::stringstream ss;
-    ss  << "{"
-        << "\"consumerGroup\":\"" << consumerGroup << "\","
-        << "\"clientId\":\"" << clientId << "\","
-        << "\"jstackEnable\":\"" << jstackEnable << "\","
-        << "}";
-    outData = ss.str();
-}
-
-CommandCustomHeader* GetConsumerRunningInfoRequestHeader::decode(Json::Value& data)
-{
-    GetConsumerRunningInfoRequestHeader* h = new GetConsumerRunningInfoRequestHeader();
-    h->consumerGroup = data["consumerGroup"].asString();
-    h->clientId = data["clientId"].asString();
-    h->jstackEnable = false;//not support
-
-    return h;
-}
-
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/protocol/CommandCustomHeader.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/protocol/CommandCustomHeader.h b/rocketmq-client4cpp/src/protocol/CommandCustomHeader.h
deleted file mode 100755
index 93f811a..0000000
--- a/rocketmq-client4cpp/src/protocol/CommandCustomHeader.h
+++ /dev/null
@@ -1,604 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __COMMANDCUSTOMHEADER_H__
-#define __COMMANDCUSTOMHEADER_H__
-
-#include <string>
-#include <json/json.h>
-
-namespace rmq
-{
-    /**
-    * RemotingCommand custom header
-    *
-    */
-    class CommandCustomHeader
-    {
-    public :
-        virtual ~CommandCustomHeader() {}
-        virtual void encode(std::string& outData) = 0;
-        static CommandCustomHeader* decode(int code, Json::Value& data, bool isResponseType);
-    };
-
-	///////////////////////////////////////////////////////////////////////
-	// GET_ROUTEINTO_BY_TOPIC_VALUE
-	///////////////////////////////////////////////////////////////////////
-    class GetRouteInfoRequestHeader : public CommandCustomHeader
-    {
-    public:
-        GetRouteInfoRequestHeader()
-		{
-		};
-        ~GetRouteInfoRequestHeader() {};
-        virtual void encode(std::string& outData);
-        static CommandCustomHeader* decode(Json::Value& data);
-
-    public:
-        std::string topic;
-    };
-
-	///////////////////////////////////////////////////////////////////////
-	// UPDATE_AND_CREATE_TOPIC_VALUE
-	///////////////////////////////////////////////////////////////////////
-    class CreateTopicRequestHeader : public CommandCustomHeader
-    {
-    public:
-        CreateTopicRequestHeader()
-		{
-			readQueueNums = 0;
-			writeQueueNums = 0;
-			perm = 0;
-			topicSysFlag = 0;
-			order = false;
-		};
-        ~CreateTopicRequestHeader() {};
-        virtual void encode(std::string& outData);
-        static CommandCustomHeader* decode(Json::Value& data);
-
-    public:
-        std::string topic;
-        std::string defaultTopic;
-        int readQueueNums;
-        int writeQueueNums;
-        int perm;
-        std::string topicFilterType;
-		int topicSysFlag;
-		bool order;
-    };
-
-	///////////////////////////////////////////////////////////////////////
-	// SEND_MESSAGE_VALUE/SEND_MESSAGE_V2_VALUE
-	///////////////////////////////////////////////////////////////////////
-    class SendMessageRequestHeader: public CommandCustomHeader
-    {
-    public:
-        SendMessageRequestHeader()
-			: defaultTopicQueueNums(0),queueId(0),sysFlag(0),
-			bornTimestamp(0),flag(0),reconsumeTimes(0)
-		{
-		};
-        ~SendMessageRequestHeader() {};
-        virtual void encode(std::string& outData);
-        static CommandCustomHeader* decode(Json::Value& data);
-
-    public:
-        std::string producerGroup;
-        std::string topic;
-        std::string defaultTopic;
-        int defaultTopicQueueNums;
-        int queueId;
-        int sysFlag;
-        long long bornTimestamp;
-        int flag;
-        std::string properties;
-        int reconsumeTimes;
-    };
-
-	class SendMessageRequestHeaderV2: public CommandCustomHeader
-	{
-	public:
-		SendMessageRequestHeaderV2()
-			: d(0),e(0),f(0),
-			g(0),h(0),j(0)
-		{
-		};
-		~SendMessageRequestHeaderV2() {};
-
-		virtual void encode(std::string& outData);
-		static CommandCustomHeader* decode(Json::Value& data);
-		static SendMessageRequestHeader* createSendMessageRequestHeaderV1(const SendMessageRequestHeaderV2* v2);
-		static SendMessageRequestHeaderV2* createSendMessageRequestHeaderV2(const SendMessageRequestHeader* v1);
-	public:
-		std::string a;	//producerGroup
-		std::string b;	//topic
-		std::string c;	//defaultTopic
-		int d;			//defaultTopicQueueNums
-		int e;			//queueId
-		int f;			//sysFlag
-		long long g;	//bornTimestamp
-		int h;			//flag
-		std::string i;	//properties
-		int j;			//reconsumeTimes
-	};
-
-    class SendMessageResponseHeader: public CommandCustomHeader
-    {
-    public:
-        SendMessageResponseHeader()
-		{
-			queueId = 0;
-			queueOffset = 0;
-		};
-        ~SendMessageResponseHeader() {};
-        virtual void encode(std::string& outData);
-        static CommandCustomHeader* decode(Json::Value& data);
-
-    public:
-        std::string msgId;
-        int queueId;
-        long long queueOffset;
-    };
-
-
-	///////////////////////////////////////////////////////////////////////
-	// PULL_MESSAGE_VALUE
-	///////////////////////////////////////////////////////////////////////
-    class PullMessageRequestHeader: public CommandCustomHeader
-    {
-    public:
-        PullMessageRequestHeader()
-		{
-			queueId = 0;
-			queueOffset = 0;
-			maxMsgNums = 0;
-			sysFlag = 0;
-			commitOffset = 0;
-			suspendTimeoutMillis = 0;
-			subVersion = 0;
-		};
-        ~PullMessageRequestHeader() {};
-        virtual void encode(std::string& outData);
-        static CommandCustomHeader* decode(Json::Value& data);
-
-    public:
-        std::string consumerGroup;
-        std::string topic;
-        int queueId;
-        long long queueOffset;
-        int maxMsgNums;
-        int sysFlag;
-        long long commitOffset;
-        long long suspendTimeoutMillis;
-        std::string subscription;
-        long long subVersion;
-    };
-
-    class PullMessageResponseHeader: public CommandCustomHeader
-    {
-    public:
-        PullMessageResponseHeader()
-		{
-			suggestWhichBrokerId = 0;
-			nextBeginOffset = 0;
-			minOffset = 0;
-			maxOffset = 0;
-		};
-        ~PullMessageResponseHeader() {};
-        virtual void encode(std::string& outData);
-        static CommandCustomHeader* decode(Json::Value& data);
-
-    public:
-        long long suggestWhichBrokerId;
-        long long nextBeginOffset;
-        long long minOffset;
-        long long maxOffset;
-    };
-
-	///////////////////////////////////////////////////////////////////////
-	// GET_CONSUMER_LIST_BY_GROUP_VALUE
-	///////////////////////////////////////////////////////////////////////
-    class GetConsumerListByGroupRequestHeader : public CommandCustomHeader
-    {
-    public:
-        GetConsumerListByGroupRequestHeader() {};
-        ~GetConsumerListByGroupRequestHeader() {};
-        virtual void encode(std::string& outData);
-        static CommandCustomHeader* decode(Json::Value& data);
-
-    public:
-        std::string consumerGroup;
-    };
-
-
-	///////////////////////////////////////////////////////////////////////
-	// CONSUMER_SEND_MSG_BACK_VALUE
-	///////////////////////////////////////////////////////////////////////
-    class ConsumerSendMsgBackRequestHeader : public CommandCustomHeader
-    {
-    public:
-        ConsumerSendMsgBackRequestHeader()
-		{
-			offset = 0;
-			delayLevel = 0;
-		};
-        ~ConsumerSendMsgBackRequestHeader() {};
-
-        virtual void encode(std::string& outData);
-        static CommandCustomHeader* decode(Json::Value& data);
-
-    public:
-        long long offset;
-        std::string group;
-        int delayLevel;
-    };
-
-
-	///////////////////////////////////////////////////////////////////////
-	// QUERY_CONSUMER_OFFSET_VALUE
-	///////////////////////////////////////////////////////////////////////
-    class QueryConsumerOffsetRequestHeader : public CommandCustomHeader
-    {
-    public:
-        QueryConsumerOffsetRequestHeader()
-		{
-			queueId = 0;
-		};
-        ~QueryConsumerOffsetRequestHeader() {};
-
-        virtual void encode(std::string& outData);
-        static CommandCustomHeader* decode(Json::Value& data);
-
-    public:
-        std::string consumerGroup;
-        std::string topic;
-        int queueId;
-    };
-
-    class QueryConsumerOffsetResponseHeader : public CommandCustomHeader
-    {
-    public:
-        QueryConsumerOffsetResponseHeader()
-		{
-			offset = 0;
-		};
-        ~QueryConsumerOffsetResponseHeader() {};
-
-        virtual void encode(std::string& outData);
-        static CommandCustomHeader* decode(Json::Value& data);
-
-    public:
-        long long offset;
-    };
-
-	///////////////////////////////////////////////////////////////////////
-	// UPDATE_CONSUMER_OFFSET_VALUE
-	///////////////////////////////////////////////////////////////////////
-    class UpdateConsumerOffsetRequestHeader : public CommandCustomHeader
-    {
-    public:
-        UpdateConsumerOffsetRequestHeader()
-		{
-			queueId = 0;
-			commitOffset = 0;
-		};
-        ~UpdateConsumerOffsetRequestHeader() {};
-
-        virtual void encode(std::string& outData);
-        static CommandCustomHeader* decode(Json::Value& data);
-
-    public:
-        std::string consumerGroup;
-        std::string topic;
-        int queueId;
-        long long commitOffset;
-    };
-
-	///////////////////////////////////////////////////////////////////////
-	// UNREGISTER_CLIENT_VALUE
-	///////////////////////////////////////////////////////////////////////
-    class UnregisterClientRequestHeader : public CommandCustomHeader
-    {
-    public:
-        UnregisterClientRequestHeader() {};
-        ~UnregisterClientRequestHeader() {};
-
-        virtual void encode(std::string& outData);
-        static CommandCustomHeader* decode(Json::Value& data);
-
-    public:
-        std::string clientID;
-        std::string producerGroup;
-        std::string consumerGroup;
-    };
-
-
-	///////////////////////////////////////////////////////////////////////
-	// VIEW_MESSAGE_BY_ID_VALUE
-	///////////////////////////////////////////////////////////////////////
-	class ViewMessageRequestHeader : public CommandCustomHeader
-    {
-    public:
-        ViewMessageRequestHeader()
-		{
-			offset = 0;
-		};
-        ~ViewMessageRequestHeader() {};
-
-        virtual void encode(std::string& outData);
-        static CommandCustomHeader* decode(Json::Value& data);
-
-    public:
-        long long offset;
-    };
-
-	///////////////////////////////////////////////////////////////////////
-	// SEARCH_OFFSET_BY_TIMESTAMP_VALUE
-	///////////////////////////////////////////////////////////////////////
-	class SearchOffsetRequestHeader : public CommandCustomHeader
-    {
-    public:
-        SearchOffsetRequestHeader()
-		{
-			queueId = 0;
-			timestamp = 0;
-		};
-        ~SearchOffsetRequestHeader() {};
-
-        virtual void encode(std::string& outData);
-        static CommandCustomHeader* decode(Json::Value& data);
-
-    public:
-        std::string topic;
-        int queueId;
-        long long timestamp;
-    };
-
-	class SearchOffsetResponseHeader : public CommandCustomHeader
-	{
-	public:
-		SearchOffsetResponseHeader()
-		{
-			offset = 0;
-		};
-		~SearchOffsetResponseHeader() {};
-
-		virtual void encode(std::string& outData);
-		static CommandCustomHeader* decode(Json::Value& data);
-
-	public:
-		long long offset;
-	};
-
-	///////////////////////////////////////////////////////////////////////
-	// GET_MAX_OFFSET_VALUE
-	///////////////////////////////////////////////////////////////////////
-	class GetMaxOffsetRequestHeader : public CommandCustomHeader
-    {
-    public:
-        GetMaxOffsetRequestHeader()
-		{
-			queueId = 0;
-		};
-        ~GetMaxOffsetRequestHeader() {};
-
-        virtual void encode(std::string& outData);
-        static CommandCustomHeader* decode(Json::Value& data);
-
-    public:
-        std::string topic;
-        int queueId;
-    };
-
-	class GetMaxOffsetResponseHeader : public CommandCustomHeader
-	{
-	public:
-		GetMaxOffsetResponseHeader()
-		{
-			offset = 0;
-		};
-		~GetMaxOffsetResponseHeader() {};
-
-		virtual void encode(std::string& outData);
-		static CommandCustomHeader* decode(Json::Value& data);
-
-	public:
-		long long offset;
-	};
-
-	///////////////////////////////////////////////////////////////////////
-	// GET_MIN_OFFSET_VALUE
-	///////////////////////////////////////////////////////////////////////
-	class GetMinOffsetRequestHeader : public CommandCustomHeader
-    {
-    public:
-        GetMinOffsetRequestHeader()
-		{
-			queueId = 0;
-		};
-        ~GetMinOffsetRequestHeader() {};
-
-        virtual void encode(std::string& outData);
-        static CommandCustomHeader* decode(Json::Value& data);
-
-    public:
-        std::string topic;
-        int queueId;
-    };
-
-	class GetMinOffsetResponseHeader : public CommandCustomHeader
-	{
-	public:
-		GetMinOffsetResponseHeader()
-		{
-			offset = 0;
-		};
-		~GetMinOffsetResponseHeader() {};
-
-		virtual void encode(std::string& outData);
-		static CommandCustomHeader* decode(Json::Value& data);
-
-	public:
-		long long offset;
-	};
-
-
-	///////////////////////////////////////////////////////////////////////
-	// GET_EARLIEST_MSG_STORETIME_VALUE
-	///////////////////////////////////////////////////////////////////////
-	class GetEarliestMsgStoretimeRequestHeader : public CommandCustomHeader
-    {
-    public:
-        GetEarliestMsgStoretimeRequestHeader()
-		{
-			queueId = 0;
-		};
-        ~GetEarliestMsgStoretimeRequestHeader() {};
-
-        virtual void encode(std::string& outData);
-        static CommandCustomHeader* decode(Json::Value& data);
-
-    public:
-        std::string topic;
-        int queueId;
-    };
-
-	class GetEarliestMsgStoretimeResponseHeader : public CommandCustomHeader
-	{
-	public:
-		GetEarliestMsgStoretimeResponseHeader()
-		{
-			timestamp = 0;
-		};
-		~GetEarliestMsgStoretimeResponseHeader() {};
-
-		virtual void encode(std::string& outData);
-		static CommandCustomHeader* decode(Json::Value& data);
-
-	public:
-		long long timestamp;
-	};
-
-	///////////////////////////////////////////////////////////////////////
-	// QUERY_MESSAGE_VALUE
-	///////////////////////////////////////////////////////////////////////
-	class QueryMessageRequestHeader : public CommandCustomHeader
-    {
-    public:
-        QueryMessageRequestHeader()
-		{
-			maxNum = 0;
-			beginTimestamp = 0;
-			endTimestamp = 0;
-		};
-        ~QueryMessageRequestHeader() {};
-
-        virtual void encode(std::string& outData);
-        static CommandCustomHeader* decode(Json::Value& data);
-
-    public:
-        std::string topic;
-        std::string key;
-		int maxNum;
-		long long beginTimestamp;
-		long long endTimestamp;
-    };
-
-	class QueryMessageResponseHeader : public CommandCustomHeader
-	{
-	public:
-		QueryMessageResponseHeader()
-		{
-			indexLastUpdateTimestamp = 0;
-			indexLastUpdatePhyoffset = 0;
-		};
-		~QueryMessageResponseHeader() {};
-
-		virtual void encode(std::string& outData);
-		static CommandCustomHeader* decode(Json::Value& data);
-
-	public:
-		long long indexLastUpdateTimestamp;
-		long long indexLastUpdatePhyoffset;
-	};
-
-	///////////////////////////////////////////////////////////////////////
-	// GET_KV_CONFIG_VALUE
-	///////////////////////////////////////////////////////////////////////
-	class GetKVConfigRequestHeader : public CommandCustomHeader
-    {
-    public:
-        GetKVConfigRequestHeader() {};
-        ~GetKVConfigRequestHeader() {};
-
-        virtual void encode(std::string& outData);
-        static CommandCustomHeader* decode(Json::Value& data);
-
-    public:
-        std::string namespace_;
-        std::string key;
-    };
-
-	class GetKVConfigResponseHeader : public CommandCustomHeader
-	{
-	public:
-		GetKVConfigResponseHeader() {};
-		~GetKVConfigResponseHeader() {};
-
-		virtual void encode(std::string& outData);
-		static CommandCustomHeader* decode(Json::Value& data);
-
-	public:
-		std::string value;
-	};
-
-	///////////////////////////////////////////////////////////////////////
-	// NOTIFY_CONSUMER_IDS_CHANGED_VALUE
-	///////////////////////////////////////////////////////////////////////
-	class NotifyConsumerIdsChangedRequestHeader : public CommandCustomHeader
-    {
-    public:
-        NotifyConsumerIdsChangedRequestHeader() {};
-        ~NotifyConsumerIdsChangedRequestHeader() {};
-
-        virtual void encode(std::string& outData);
-        static CommandCustomHeader* decode(Json::Value& data);
-
-    public:
-        std::string consumerGroup;
-    };
-
-
-	///////////////////////////////////////////////////////////////////////
-	// GET_CONSUMER_RUNNING_INFO_VALUE
-	///////////////////////////////////////////////////////////////////////
-	class GetConsumerRunningInfoRequestHeader : public CommandCustomHeader
-    {
-    public:
-        GetConsumerRunningInfoRequestHeader() {};
-        ~GetConsumerRunningInfoRequestHeader() {};
-
-        virtual void encode(std::string& outData);
-        static CommandCustomHeader* decode(Json::Value& data);
-
-    public:
-        std::string consumerGroup;
-		std::string clientId;
-		bool jstackEnable;
-    };
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/protocol/ConsumerRunningInfo.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/protocol/ConsumerRunningInfo.cpp b/rocketmq-client4cpp/src/protocol/ConsumerRunningInfo.cpp
deleted file mode 100755
index 58cecde..0000000
--- a/rocketmq-client4cpp/src/protocol/ConsumerRunningInfo.cpp
+++ /dev/null
@@ -1,168 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#include "ConsumerRunningInfo.h"
-
-namespace rmq
-{
-
-const std::string ConsumerRunningInfo::PROP_NAMESERVER_ADDR = "PROP_NAMESERVER_ADDR";
-const std::string ConsumerRunningInfo::PROP_THREADPOOL_CORE_SIZE = "PROP_THREADPOOL_CORE_SIZE";
-const std::string ConsumerRunningInfo::PROP_CONSUME_ORDERLY = "PROP_CONSUMEORDERLY";
-const std::string ConsumerRunningInfo::PROP_CONSUME_TYPE = "PROP_CONSUME_TYPE";
-const std::string ConsumerRunningInfo::PROP_CLIENT_VERSION = "PROP_CLIENT_VERSION";
-const std::string ConsumerRunningInfo::PROP_CONSUMER_START_TIMESTAMP = "PROP_CONSUMER_START_TIMESTAMP";
-
-
-ConsumerRunningInfo::ConsumerRunningInfo()
-{
-}
-
-ConsumerRunningInfo::~ConsumerRunningInfo()
-{
-}
-
-void ConsumerRunningInfo::encode(std::string& outData)
-{
-    std::stringstream ss;
-    ss  << "{"
-        << "}";
-    outData = ss.str();
-}
-
-
-std::string ConsumerRunningInfo::formatString()
-{
-	std::string sb = "rocketmq-client4cpp not suppport this feature";
-
-	/*
-	// 1
-	{
-		sb.append("#Consumer Properties#\n");
-		Iterator<Entry<Object, Object>> it = m_properties.entrySet().iterator();
-		while (it.hasNext()) {
-			Entry<Object, Object> next = it.next();
-			String item =
-					String.format("%-40s: %s\n", next.getKey().toString(), next.getValue().toString());
-			sb.append(item);
-		}
-	}
-
-	// 2
-	{
-		sb.append("\n\n#Consumer Subscription#\n");
-
-		Iterator<SubscriptionData> it = m_subscriptionSet.iterator();
-		int i = 0;
-		while (it.hasNext()) {
-			SubscriptionData next = it.next();
-			String item = String.format("%03d Topic: %-40s ClassFilter: %-8s SubExpression: %s\n", //
-				++i,//
-				next.getTopic(),//
-				next.isClassFilterMode(),//
-				next.getSubString());
-
-			sb.append(item);
-		}
-	}
-
-	// 3
-	{
-		sb.append("\n\n#Consumer Offset#\n");
-		sb.append(String.format("%-32s  %-32s  %-4s  %-20s\n",//
-			"#Topic",//
-			"#Broker Name",//
-			"#QID",//
-			"#Consumer Offset"//
-		));
-
-		Iterator<Entry<MessageQueue, ProcessQueueInfo>> it = m_mqTable.entrySet().iterator();
-		while (it.hasNext()) {
-			Entry<MessageQueue, ProcessQueueInfo> next = it.next();
-			String item = String.format("%-32s  %-32s  %-4d  %-20d\n",//
-				next.getKey().getTopic(),//
-				next.getKey().getBrokerName(),//
-				next.getKey().getQueueId(),//
-				next.getValue().getCommitOffset());
-
-			sb.append(item);
-		}
-	}
-
-	// 4
-	{
-		sb.append("\n\n#Consumer MQ Detail#\n");
-		sb.append(String.format("%-32s  %-32s  %-4s  %-20s\n",//
-			"#Topic",//
-			"#Broker Name",//
-			"#QID",//
-			"#ProcessQueueInfo"//
-		));
-
-		Iterator<Entry<MessageQueue, ProcessQueueInfo>> it = m_mqTable.entrySet().iterator();
-		while (it.hasNext()) {
-			Entry<MessageQueue, ProcessQueueInfo> next = it.next();
-			String item = String.format("%-32s  %-32s  %-4d  %s\n",//
-				next.getKey().getTopic(),//
-				next.getKey().getBrokerName(),//
-				next.getKey().getQueueId(),//
-				next.getValue().toString());
-
-			sb.append(item);
-		}
-	}
-
-	// 5
-	{
-		sb.append("\n\n#Consumer RT&TPS#\n");
-		sb.append(String.format("%-32s  %14s %14s %14s %14s %18s %25s\n",//
-			"#Topic",//
-			"#Pull RT",//
-			"#Pull TPS",//
-			"#Consume RT",//
-			"#ConsumeOK TPS",//
-			"#ConsumeFailed TPS",//
-			"#ConsumeFailedMsgsInHour"//
-		));
-
-		Iterator<Entry<String, ConsumeStatus>> it = m_statusTable.entrySet().iterator();
-		while (it.hasNext()) {
-			Entry<String, ConsumeStatus> next = it.next();
-			String item = String.format("%-32s  %14.2f %14.2f %14.2f %14.2f %18.2f %25d\n",//
-				next.getKey(),//
-				next.getValue().getPullRT(),//
-				next.getValue().getPullTPS(),//
-				next.getValue().getConsumeRT(),//
-				next.getValue().getConsumeOKTPS(),//
-				next.getValue().getConsumeFailedTPS(),//
-				next.getValue().getConsumeFailedMsgs()//
-				);
-
-			sb.append(item);
-		}
-	}
-
-	// 6
-	if (m_jstack != null) {
-		sb.append("\n\n#Consumer jstack#\n");
-		sb.append(m_jstack);
-	}
-	*/
-
-	return sb;
-}
-
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/protocol/ConsumerRunningInfo.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/protocol/ConsumerRunningInfo.h b/rocketmq-client4cpp/src/protocol/ConsumerRunningInfo.h
deleted file mode 100755
index 588bf07..0000000
--- a/rocketmq-client4cpp/src/protocol/ConsumerRunningInfo.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __ConsumerRunningInfo_H__
-#define __ConsumerRunningInfo_H__
-
-#include <string>
-#include <set>
-#include <map>
-
-#include "RemotingSerializable.h"
-#include "MessageQueue.h"
-#include "SubscriptionData.h"
-#include "ConsumerStatManage.h"
-
-namespace rmq
-{
-    class ConsumerRunningInfo : public RemotingSerializable
-    {
-    public:
-        ConsumerRunningInfo();
-        ~ConsumerRunningInfo();
-
-		/*
-		std::map<std::string, std::string>& getProperties()
-		{
-			return m_properties;
-		}
-        void setProperties(const std::map<std::string, std::string>& properties)
-		{
-			m_properties = properties;
-		}
-
-        std::map<MessageQueue, ProcessQueueInfo>& getMqTable()
-		{
-			return m_mqTable;
-		}
-        void setMqTable(const std::map<MessageQueue, ProcessQueueInfo>& mqTable)
-		{
-			m_mqTable = mqTable;
-		}
-
-        std::map<std::string, ConsumeStatus>& getStatusTable()
-		{
-			return m_statusTable;
-		}
-        void setStatusTable(const std::map<std::string, ConsumeStatus>& statusTable)
-		{
-		    m_statusTable = statusTable;
-		}
-
-        std::set<SubscriptionData>& getSubscriptionSet()
-		{
-			return m_subscriptionSet;
-		}
-        void setSubscriptionSet(const std::set<SubscriptionData>& subscriptionSet)
-		{
-			m_subscriptionSet = subscriptionSet;
-		}
-		*/
-
-		void encode(std::string& outData);
-		std::string formatString();
-
-	public:
-		static const std::string PROP_NAMESERVER_ADDR;
-		static const std::string PROP_THREADPOOL_CORE_SIZE;
-		static const std::string PROP_CONSUME_ORDERLY;
-		static const std::string PROP_CONSUME_TYPE;
-		static const std::string PROP_CLIENT_VERSION;
-		static const std::string PROP_CONSUMER_START_TIMESTAMP;
-
-    private:
-		/*
-		std::map<std::string, std::string> m_properties;
-		std::set<SubscriptionData> m_subscriptionSet;
-		std::map<MessageQueue, ProcessQueueInfo> m_mqTable;
-		std::map<string, ConsumerStat> m_statusTable;
-		std::string m_jstack;
-		*/
-    };
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/protocol/GetConsumerListByGroupResponseBody.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/protocol/GetConsumerListByGroupResponseBody.h b/rocketmq-client4cpp/src/protocol/GetConsumerListByGroupResponseBody.h
deleted file mode 100755
index 0ea19da..0000000
--- a/rocketmq-client4cpp/src/protocol/GetConsumerListByGroupResponseBody.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __GETCONSUMERLISTBYGROUPRESPONSEBODY_H__
-#define __GETCONSUMERLISTBYGROUPRESPONSEBODY_H__
-
-#include <string>
-#include <sstream>
-#include <list>
-#include "UtilAll.h"
-#include "RemotingSerializable.h"
-
-namespace rmq
-{
-    class GetConsumerListByGroupResponseBody : public RemotingSerializable
-    {
-    public:
-        GetConsumerListByGroupResponseBody()
-        {
-
-        }
-
-        ~GetConsumerListByGroupResponseBody()
-        {
-
-        }
-
-        void encode(std::string& outData)
-        {
-
-        }
-
-        static GetConsumerListByGroupResponseBody* decode(const char* pData, int len)
-        {
-            /*
-            {"consumerIdList":["10.12.22.213@DEFAULT", "10.12.22.213@xxx"]}
-            */
-            //RMQ_DEBUG("GET_CONSUMER_LIST_BY_GROUP_VALUE:%s", pData);
-
-            Json::Reader reader;
-            Json::Value object;
-            if (!reader.parse(pData, pData + len, object))
-            {
-                RMQ_ERROR("parse fail: %s", reader.getFormattedErrorMessages().c_str());
-                return NULL;
-            }
-
-            GetConsumerListByGroupResponseBody* rsp =  new GetConsumerListByGroupResponseBody();
-            Json::Value cidList = object["consumerIdList"];
-            for (size_t i = 0; i < cidList.size(); i++)
-            {
-                Json::Value cid = cidList[i];
-                if (cid != Json::Value::null)
-                {
-                    rsp->m_consumerIdList.push_back(cid.asString());
-                }
-            }
-
-            return rsp;
-        }
-
-        std::list<std::string>& getConsumerIdList()
-        {
-            return m_consumerIdList;
-        }
-
-        void setConsumerIdList(const std::list<std::string>& consumerIdList)
-        {
-            m_consumerIdList = consumerIdList;
-        }
-
-        std::string toString() const
-        {
-            std::stringstream ss;
-            ss << "{consumerIdList=" << UtilAll::toString(m_consumerIdList) << "}";
-            return ss.str();
-        }
-
-    private:
-        std::list<std::string> m_consumerIdList;
-    };
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/protocol/HeartbeatData.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/protocol/HeartbeatData.cpp b/rocketmq-client4cpp/src/protocol/HeartbeatData.cpp
deleted file mode 100755
index 73f197a..0000000
--- a/rocketmq-client4cpp/src/protocol/HeartbeatData.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#include "HeartbeatData.h"
-
-namespace rmq
-{
-
-void HeartbeatData::encode(std::string& outData)
-{
-    //{"clientID":"10.6.223.90@16164","consumerDataSet":[{"consumeFromWhere":"CONSUME_FROM_LAST_OFFSET","consumeType":"CONSUME_ACTIVELY","groupName":"please_rename_unique_group_name_5","messageModel":"CLUSTERING","subscriptionDataSet":[],"unitMode":false}],"producerDataSet":[{"groupName":"CLIENT_INNER_PRODUCER"}]}
-    Json::Value obj;
-    obj["clientID"] = m_clientID;
-
-    Json::Value consumerDataSet(Json::arrayValue);
-    for (typeof(m_consumerDataSet.begin()) it = m_consumerDataSet.begin(); it != m_consumerDataSet.end(); it++)
-    {
-        Json::Value o;
-        (*it).toJson(o);
-        consumerDataSet.append(o);
-    }
-    obj["consumerDataSet"] = consumerDataSet;
-
-    Json::Value producerDataSet(Json::arrayValue);
-    for (typeof(m_producerDataSet.begin()) it = m_producerDataSet.begin(); it != m_producerDataSet.end(); it++)
-    {
-        Json::Value o;
-        it->toJson(o);
-        producerDataSet.append(o);
-    }
-    obj["producerDataSet"] = producerDataSet;
-
-    Json::FastWriter outer;
-    outData = outer.write(obj);
-}
-
-
-
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/protocol/HeartbeatData.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/protocol/HeartbeatData.h b/rocketmq-client4cpp/src/protocol/HeartbeatData.h
deleted file mode 100755
index cb0f720..0000000
--- a/rocketmq-client4cpp/src/protocol/HeartbeatData.h
+++ /dev/null
@@ -1,157 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#ifndef __HEARTBEATDATA_H__
-#define __HEARTBEATDATA_H__
-
-#include <string>
-#include <set>
-#include <sstream>
-
-#include "RocketMQClient.h"
-#include "ConsumeType.h"
-#include "SubscriptionData.h"
-#include "RemotingSerializable.h"
-#include "UtilAll.h"
-
-namespace rmq
-{
-    struct ConsumerData
-    {
-        std::string groupName;
-        ConsumeType consumeType;
-        MessageModel messageModel;
-        ConsumeFromWhere consumeFromWhere;
-        std::set<SubscriptionData> subscriptionDataSet;
-        bool operator < (const ConsumerData& cd)const
-        {
-            return groupName < cd.groupName;
-        }
-
-        void toJson(Json::Value& obj) const
-        {
-            //{"consumeFromWhere":"CONSUME_FROM_LAST_OFFSET","consumeType":"CONSUME_ACTIVELY","groupName":"please_rename_unique_group_name_5","messageModel":"CLUSTERING","subscriptionDataSet":[],"unitMode":false}
-            obj["groupName"] = groupName;
-            obj["messageModel"] = getMessageModelString(messageModel);
-            obj["consumeFromWhere"] = getConsumeFromWhereString(consumeFromWhere);
-            obj["consumeType"] = getConsumeTypeString(consumeType);
-            obj["unitMode"] = false;
-
-            Json::Value objSub(Json::arrayValue);
-            RMQ_FOR_EACH(subscriptionDataSet, it)
-            {
-                Json::Value o;
-                (*it).toJson(o);
-                objSub.append(o);
-            }
-            obj["subscriptionDataSet"] = objSub;
-        }
-
-		std::string toString() const
-        {
-            std::stringstream ss;
-            ss << "{groupName=" << groupName
-               << ",messageModel=" << getMessageModelString(messageModel)
-               << ",consumeFromWhere=" << getConsumeFromWhereString(consumeFromWhere)
-               << ",consumeType=" << getConsumeTypeString(consumeType)
-               << ",subscriptionDataSet=" << UtilAll::toString(subscriptionDataSet)
-               << "}";
-            return ss.str();
-        }
-    };
-	inline std::ostream& operator<<(std::ostream& os, const ConsumerData& obj)
-	{
-	    os << obj.toString();
-	    return os;
-	}
-
-    struct ProducerData
-    {
-        std::string groupName;
-        bool operator < (const ProducerData& pd)const
-        {
-            return groupName < pd.groupName;
-        }
-        void toJson(Json::Value& obj) const
-        {
-            obj["groupName"] = groupName;
-        }
-
-		std::string toString() const
-        {
-            std::stringstream ss;
-            ss << "{groupName=" << groupName << "}";
-            return ss.str();
-        }
-    };
-	inline std::ostream& operator<<(std::ostream& os, const ProducerData& obj)
-	{
-	    os << obj.toString();
-	    return os;
-	}
-
-
-    class HeartbeatData : public RemotingSerializable
-    {
-    public:
-        void encode(std::string& outData);
-
-        std::string getClientID()
-        {
-            return m_clientID;
-        }
-
-        void setClientID(const std::string& clientID)
-        {
-            m_clientID = clientID;
-        }
-
-        std::set<ProducerData>& getProducerDataSet()
-        {
-            return m_producerDataSet;
-        }
-
-        void setProducerDataSet(const std::set<ProducerData>& producerDataSet)
-        {
-            m_producerDataSet = producerDataSet;
-        }
-
-        std::set<ConsumerData>& getConsumerDataSet()
-        {
-            return m_consumerDataSet;
-        }
-
-        void setConsumerDataSet(const std::set<ConsumerData>& consumerDataSet)
-        {
-            m_consumerDataSet = consumerDataSet;
-        }
-
-		std::string toString() const
-		{
-		    std::stringstream ss;
-		    ss << "{clientID=" << m_clientID
-		       << ",producerDataSet=" << UtilAll::toString(m_producerDataSet)
-		       << ",consumerDataSet=" << UtilAll::toString(m_consumerDataSet) << "}";
-		    return ss.str();
-		}
-
-    private:
-        std::string m_clientID;
-        std::set<ProducerData> m_producerDataSet;
-        std::set<ConsumerData> m_consumerDataSet;
-    };
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/protocol/KVTable.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/protocol/KVTable.h b/rocketmq-client4cpp/src/protocol/KVTable.h
deleted file mode 100755
index 726b872..0000000
--- a/rocketmq-client4cpp/src/protocol/KVTable.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __KVTABLE_H__
-#define __KVTABLE_H__
-
-#include <map>
-#include <string>
-#include "RemotingSerializable.h"
-#include "UtilAll.h"
-
-namespace rmq
-{
-    class KVTable : public RemotingSerializable
-    {
-    public:
-        void encode(std::string& outData)
-        {
-
-        }
-
-		std::string toString() const
-		{
-			std::stringstream ss;
-			ss << "{table=" << UtilAll::toString(m_table)
-			   << "}";
-			return ss.str();
-		}
-
-        const std::map<std::string, std::string>& getTable()
-        {
-            return m_table;
-        }
-
-        void setTable(const std::map<std::string, std::string>& table)
-        {
-            m_table = table;
-        }
-
-    private:
-        std::map<std::string, std::string> m_table ;
-    };
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/protocol/LockBatchBody.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/protocol/LockBatchBody.cpp b/rocketmq-client4cpp/src/protocol/LockBatchBody.cpp
deleted file mode 100755
index 947abe2..0000000
--- a/rocketmq-client4cpp/src/protocol/LockBatchBody.cpp
+++ /dev/null
@@ -1,112 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#include "LockBatchBody.h"
-#include "UtilAll.h"
-
-namespace rmq
-{
-
-LockBatchRequestBody::LockBatchRequestBody()
-{
-}
-
-LockBatchRequestBody::~LockBatchRequestBody()
-{
-}
-
-void LockBatchRequestBody::encode(std::string& outData)
-{
-
-}
-
-std::string LockBatchRequestBody::toString() const
-{
-	std::stringstream ss;
-	ss << "{consumerGroup=" << m_consumerGroup
-	   << ",clientId=" << m_clientId
-	   << ",mqSet=" << UtilAll::toString(m_mqSet)
-	   << "}";
-	return ss.str();
-}
-
-
-std::string LockBatchRequestBody::getConsumerGroup()
-{
-    return m_consumerGroup;
-}
-
-void LockBatchRequestBody::setConsumerGroup(const std::string& consumerGroup)
-{
-    m_consumerGroup = consumerGroup;
-}
-
-std::string LockBatchRequestBody::getClientId()
-{
-    return m_clientId;
-}
-
-void LockBatchRequestBody::setClientId(const std::string& clientId)
-{
-    m_clientId = clientId;
-}
-
-std::set<MessageQueue>& LockBatchRequestBody::getMqSet()
-{
-    return m_mqSet;
-}
-
-void LockBatchRequestBody::setMqSet(const std::set<MessageQueue>& mqSet)
-{
-    m_mqSet = mqSet;
-}
-
-LockBatchResponseBody::LockBatchResponseBody()
-{
-}
-
-LockBatchResponseBody::~LockBatchResponseBody()
-{
-}
-
-void LockBatchResponseBody::encode(std::string& outData)
-{
-}
-
-std::string LockBatchResponseBody::toString() const
-{
-	std::stringstream ss;
-	ss << "{consumerGroup=" << UtilAll::toString(m_lockOKMQSet)
-	   << "}";
-	return ss.str();
-}
-
-
-LockBatchResponseBody* LockBatchResponseBody::decode(const char* pData, int len)
-{
-    return new LockBatchResponseBody();
-}
-
-std::set<MessageQueue> LockBatchResponseBody::getLockOKMQSet()
-{
-    return m_lockOKMQSet;
-}
-
-void LockBatchResponseBody::setLockOKMQSet(const std::set<MessageQueue>& lockOKMQSet)
-{
-    m_lockOKMQSet = lockOKMQSet;
-}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/protocol/LockBatchBody.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/protocol/LockBatchBody.h b/rocketmq-client4cpp/src/protocol/LockBatchBody.h
deleted file mode 100755
index ab9ee02..0000000
--- a/rocketmq-client4cpp/src/protocol/LockBatchBody.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __LOCKBATCHBODY_H__
-#define __LOCKBATCHBODY_H__
-
-#include <string>
-#include <set>
-
-#include "RemotingSerializable.h"
-#include "MessageQueue.h"
-
-namespace rmq
-{
-    class LockBatchRequestBody : public RemotingSerializable
-    {
-    public:
-        LockBatchRequestBody();
-        ~LockBatchRequestBody();
-
-        void encode(std::string& outData);
-		std::string toString() const;
-
-        std::string getConsumerGroup();
-        void setConsumerGroup(const std::string& consumerGroup);
-
-        std::string getClientId();
-        void setClientId(const std::string& clientId);
-
-        std::set<MessageQueue>& getMqSet();
-        void setMqSet(const std::set<MessageQueue>& mqSet);
-
-    private:
-        std::string m_consumerGroup;
-        std::string m_clientId;
-        std::set<MessageQueue> m_mqSet;
-    };
-
-    class LockBatchResponseBody : public RemotingSerializable
-    {
-    public:
-        LockBatchResponseBody();
-        ~LockBatchResponseBody();
-
-        void encode(std::string& outData);
-		std::string toString() const;
-
-        static LockBatchResponseBody* decode(const char* pData, int len);
-
-        std::set<MessageQueue> getLockOKMQSet();
-        void setLockOKMQSet(const std::set<MessageQueue>& lockOKMQSet);
-
-    private:
-        std::set<MessageQueue> m_lockOKMQSet;
-    };
-
-    typedef LockBatchRequestBody UnlockBatchRequestBody;
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/protocol/MQProtos.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/protocol/MQProtos.cpp b/rocketmq-client4cpp/src/protocol/MQProtos.cpp
deleted file mode 100755
index 052c104..0000000
--- a/rocketmq-client4cpp/src/protocol/MQProtos.cpp
+++ /dev/null
@@ -1,248 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#include "MQProtos.h"
-
-namespace rmq
-{
-
-const char* getMQRequestCodeString(int code)
-{
-    switch (code)
-    {
-		case SEND_MESSAGE_VALUE:
-			return "SEND_MESSAGE_VALUE";
-		case PULL_MESSAGE_VALUE:
-			return "PULL_MESSAGE_VALUE";
-		case QUERY_MESSAGE_VALUE:
-			return "QUERY_MESSAGE_VALUE";
-		case QUERY_BROKER_OFFSET_VALUE:
-			return "QUERY_BROKER_OFFSET_VALUE";
-		case QUERY_CONSUMER_OFFSET_VALUE:
-			return "QUERY_CONSUMER_OFFSET_VALUE";
-		case UPDATE_CONSUMER_OFFSET_VALUE:
-			return "UPDATE_CONSUMER_OFFSET_VALUE";
-		case UPDATE_AND_CREATE_TOPIC_VALUE:
-			return "UPDATE_AND_CREATE_TOPIC_VALUE";
-		case GET_ALL_TOPIC_CONFIG_VALUE:
-			return "GET_ALL_TOPIC_CONFIG_VALUE";
-		case GET_TOPIC_CONFIG_LIST_VALUE:
-			return "GET_TOPIC_CONFIG_LIST_VALUE";
-		case GET_TOPIC_NAME_LIST_VALUE:
-			return "GET_TOPIC_NAME_LIST_VALUE";
-		case UPDATE_BROKER_CONFIG_VALUE:
-			return "UPDATE_BROKER_CONFIG_VALUE";
-		case GET_BROKER_CONFIG_VALUE:
-			return "GET_BROKER_CONFIG_VALUE";
-		case TRIGGER_DELETE_FILES_VALUE:
-			return "TRIGGER_DELETE_FILES_VALUE";
-		case GET_BROKER_RUNTIME_INFO_VALUE:
-			return "GET_BROKER_RUNTIME_INFO_VALUE";
-		case SEARCH_OFFSET_BY_TIMESTAMP_VALUE:
-			return "SEARCH_OFFSET_BY_TIMESTAMP_VALUE";
-		case GET_MAX_OFFSET_VALUE:
-			return "GET_MAX_OFFSET_VALUE";
-		case GET_MIN_OFFSET_VALUE:
-			return "GET_MIN_OFFSET_VALUE";
-		case GET_EARLIEST_MSG_STORETIME_VALUE:
-			return "GET_EARLIEST_MSG_STORETIME_VALUE";
-		case VIEW_MESSAGE_BY_ID_VALUE:
-			return "VIEW_MESSAGE_BY_ID_VALUE";
-		case HEART_BEAT_VALUE:
-			return "HEART_BEAT_VALUE";
-		case UNREGISTER_CLIENT_VALUE:
-			return "UNREGISTER_CLIENT_VALUE";
-		case CONSUMER_SEND_MSG_BACK_VALUE:
-			return "CONSUMER_SEND_MSG_BACK_VALUE";
-		case END_TRANSACTION_VALUE:
-			return "END_TRANSACTION_VALUE";
-		case GET_CONSUMER_LIST_BY_GROUP_VALUE:
-			return "GET_CONSUMER_LIST_BY_GROUP_VALUE";
-		case CHECK_TRANSACTION_STATE_VALUE:
-			return "CHECK_TRANSACTION_STATE_VALUE";
-		case NOTIFY_CONSUMER_IDS_CHANGED_VALUE:
-			return "NOTIFY_CONSUMER_IDS_CHANGED_VALUE";
-		case LOCK_BATCH_MQ_VALUE:
-			return "LOCK_BATCH_MQ_VALUE";
-		case UNLOCK_BATCH_MQ_VALUE:
-			return "UNLOCK_BATCH_MQ_VALUE";
-		case GET_ALL_CONSUMER_OFFSET_VALUE:
-			return "GET_ALL_CONSUMER_OFFSET_VALUE";
-		case GET_ALL_DELAY_OFFSET_VALUE:
-			return "GET_ALL_DELAY_OFFSET_VALUE";
-		case PUT_KV_CONFIG_VALUE:
-			return "PUT_KV_CONFIG_VALUE";
-		case GET_KV_CONFIG_VALUE:
-			return "GET_KV_CONFIG_VALUE";
-		case DELETE_KV_CONFIG_VALUE:
-			return "DELETE_KV_CONFIG_VALUE";
-		case REGISTER_BROKER_VALUE:
-			return "REGISTER_BROKER_VALUE";
-		case UNREGISTER_BROKER_VALUE:
-			return "UNREGISTER_BROKER_VALUE";
-		case GET_ROUTEINTO_BY_TOPIC_VALUE:
-			return "GET_ROUTEINTO_BY_TOPIC_VALUE";
-		case GET_BROKER_CLUSTER_INFO_VALUE:
-			return "GET_BROKER_CLUSTER_INFO_VALUE";
-		case UPDATE_AND_CREATE_SUBSCRIPTIONGROUP_VALUE:
-			return "UPDATE_AND_CREATE_SUBSCRIPTIONGROUP_VALUE";
-		case GET_ALL_SUBSCRIPTIONGROUP_CONFIG_VALUE:
-			return "GET_ALL_SUBSCRIPTIONGROUP_CONFIG_VALUE";
-		case GET_TOPIC_STATS_INFO_VALUE:
-			return "GET_TOPIC_STATS_INFO_VALUE";
-		case GET_CONSUMER_CONNECTION_LIST_VALUE:
-			return "GET_CONSUMER_CONNECTION_LIST_VALUE";
-		case GET_PRODUCER_CONNECTION_LIST_VALUE:
-			return "GET_PRODUCER_CONNECTION_LIST_VALUE";
-		case WIPE_WRITE_PERM_OF_BROKER_VALUE:
-			return "WIPE_WRITE_PERM_OF_BROKER_VALUE";
-		case GET_ALL_TOPIC_LIST_FROM_NAMESERVER_VALUE:
-			return "GET_ALL_TOPIC_LIST_FROM_NAMESERVER_VALUE";
-		case DELETE_SUBSCRIPTIONGROUP_VALUE:
-			return "DELETE_SUBSCRIPTIONGROUP_VALUE";
-		case GET_CONSUME_STATS_VALUE:
-			return "GET_CONSUME_STATS_VALUE";
-		case SUSPEND_CONSUMER_VALUE:
-			return "SUSPEND_CONSUMER_VALUE";
-		case RESUME_CONSUMER_VALUE:
-			return "RESUME_CONSUMER_VALUE";
-		case RESET_CONSUMER_OFFSET_IN_CONSUMER_VALUE:
-			return "RESET_CONSUMER_OFFSET_IN_CONSUMER_VALUE";
-		case RESET_CONSUMER_OFFSET_IN_BROKER_VALUE:
-			return "RESET_CONSUMER_OFFSET_IN_BROKER_VALUE";
-		case ADJUST_CONSUMER_THREAD_POOL_VALUE:
-			return "ADJUST_CONSUMER_THREAD_POOL_VALUE";
-		case WHO_CONSUME_THE_MESSAGE_VALUE:
-			return "WHO_CONSUME_THE_MESSAGE_VALUE";
-		case DELETE_TOPIC_IN_BROKER_VALUE:
-			return "DELETE_TOPIC_IN_BROKER_VALUE";
-		case DELETE_TOPIC_IN_NAMESRV_VALUE:
-			return "DELETE_TOPIC_IN_NAMESRV_VALUE";
-		case GET_KV_CONFIG_BY_VALUE_VALUE:
-			return "GET_KV_CONFIG_BY_VALUE_VALUE";
-		case DELETE_KV_CONFIG_BY_VALUE_VALUE:
-			return "DELETE_KV_CONFIG_BY_VALUE_VALUE";
-		case GET_KVLIST_BY_NAMESPACE_VALUE:
-			return "GET_KVLIST_BY_NAMESPACE_VALUE";
-		case RESET_CONSUMER_CLIENT_OFFSET_VALUE:
-			return "RESET_CONSUMER_CLIENT_OFFSET_VALUE";
-		case GET_CONSUMER_STATUS_FROM_CLIENT_VALUE:
-			return "GET_CONSUMER_STATUS_FROM_CLIENT_VALUE";
-		case INVOKE_BROKER_TO_RESET_OFFSET_VALUE:
-			return "INVOKE_BROKER_TO_RESET_OFFSET_VALUE";
-		case INVOKE_BROKER_TO_GET_CONSUMER_STATUS_VALUE:
-			return "INVOKE_BROKER_TO_GET_CONSUMER_STATUS_VALUE";
-		case QUERY_TOPIC_CONSUME_BY_WHO_VALUE:
-			return "QUERY_TOPIC_CONSUME_BY_WHO_VALUE";
-		case GET_TOPICS_BY_CLUSTER_VALUE:
-			return "GET_TOPICS_BY_CLUSTER_VALUE";
-		case REGISTER_FILTER_SERVER_VALUE:
-			return "REGISTER_FILTER_SERVER_VALUE";
-		case REGISTER_MESSAGE_FILTER_CLASS_VALUE:
-			return "REGISTER_MESSAGE_FILTER_CLASS_VALUE";
-		case QUERY_CONSUME_TIME_SPAN_VALUE:
-			return "QUERY_CONSUME_TIME_SPAN_VALUE";
-		case GET_SYSTEM_TOPIC_LIST_FROM_NS_VALUE:
-			return "GET_SYSTEM_TOPIC_LIST_FROM_NS_VALUE";
-		case GET_SYSTEM_TOPIC_LIST_FROM_BROKER_VALUE:
-			return "GET_SYSTEM_TOPIC_LIST_FROM_BROKER_VALUE";
-		case CLEAN_EXPIRED_CONSUMEQUEUE_VALUE:
-			return "CLEAN_EXPIRED_CONSUMEQUEUE_VALUE";
-		case GET_CONSUMER_RUNNING_INFO_VALUE:
-			return "GET_CONSUMER_RUNNING_INFO_VALUE";
-		case QUERY_CORRECTION_OFFSET_VALUE:
-			return "QUERY_CORRECTION_OFFSET_VALUE";
-		case CONSUME_MESSAGE_DIRECTLY_VALUE:
-			return "CONSUME_MESSAGE_DIRECTLY_VALUE";
-		case SEND_MESSAGE_V2_VALUE:
-			return "SEND_MESSAGE_V2_VALUE";
-		case GET_UNIT_TOPIC_LIST_VALUE:
-			return "GET_UNIT_TOPIC_LIST_VALUE";
-		case GET_HAS_UNIT_SUB_TOPIC_LIST_VALUE:
-			return "GET_HAS_UNIT_SUB_TOPIC_LIST_VALUE";
-		case GET_HAS_UNIT_SUB_UNUNIT_TOPIC_LIST_VALUE:
-			return "GET_HAS_UNIT_SUB_UNUNIT_TOPIC_LIST_VALUE";
-		case CLONE_GROUP_OFFSET_VALUE:
-			return "CLONE_GROUP_OFFSET_VALUE";
-		case VIEW_BROKER_STATS_DATA_VALUE:
-			return "VIEW_BROKER_STATS_DATA_VALUE";
-    }
-
-    return "UnknowMQRequestCode";
-}
-
-const char* getMQResponseCodeString(int code)
-{
-    switch (code)
-    {
-		case 0:
-			return "OK";
-		case FLUSH_DISK_TIMEOUT_VALUE:
-			return "FLUSH_DISK_TIMEOUT_VALUE";
-		case SLAVE_NOT_AVAILABLE_VALUE:
-			return "SLAVE_NOT_AVAILABLE_VALUE";
-		case FLUSH_SLAVE_TIMEOUT_VALUE:
-			return "FLUSH_SLAVE_TIMEOUT_VALUE";
-		case MESSAGE_ILLEGAL_VALUE:
-			return "MESSAGE_ILLEGAL_VALUE";
-		case SERVICE_NOT_AVAILABLE_VALUE:
-			return "SERVICE_NOT_AVAILABLE_VALUE";
-		case VERSION_NOT_SUPPORTED_VALUE:
-			return "VERSION_NOT_SUPPORTED_VALUE";
-		case NO_PERMISSION_VALUE:
-			return "NO_PERMISSION_VALUE";
-		case TOPIC_NOT_EXIST_VALUE:
-			return "TOPIC_NOT_EXIST_VALUE";
-		case TOPIC_EXIST_ALREADY_VALUE:
-			return "TOPIC_EXIST_ALREADY_VALUE";
-		case PULL_NOT_FOUND_VALUE:
-			return "PULL_NOT_FOUND_VALUE";
-		case PULL_RETRY_IMMEDIATELY_VALUE:
-			return "PULL_RETRY_IMMEDIATELY_VALUE";
-		case PULL_OFFSET_MOVED_VALUE:
-			return "PULL_OFFSET_MOVED_VALUE";
-		case QUERY_NOT_FOUND_VALUE:
-			return "QUERY_NOT_FOUND_VALUE";
-		case SUBSCRIPTION_PARSE_FAILED_VALUE:
-			return "SUBSCRIPTION_PARSE_FAILED_VALUE";
-		case SUBSCRIPTION_NOT_EXIST_VALUE:
-			return "SUBSCRIPTION_NOT_EXIST_VALUE";
-		case SUBSCRIPTION_NOT_LATEST_VALUE:
-			return "SUBSCRIPTION_NOT_LATEST_VALUE";
-		case SUBSCRIPTION_GROUP_NOT_EXIST_VALUE:
-			return "SUBSCRIPTION_GROUP_NOT_EXIST_VALUE";
-		case TRANSACTION_SHOULD_COMMIT_VALUE:
-			return "TRANSACTION_SHOULD_COMMIT_VALUE";
-		case TRANSACTION_SHOULD_ROLLBACK_VALUE:
-			return "TRANSACTION_SHOULD_ROLLBACK_VALUE";
-		case TRANSACTION_STATE_UNKNOW_VALUE:
-			return "TRANSACTION_STATE_UNKNOW_VALUE";
-		case TRANSACTION_STATE_GROUP_WRONG_VALUE:
-			return "TRANSACTION_STATE_GROUP_WRONG_VALUE";
-		case NO_BUYER_ID_VALUE:
-			return "NO_BUYER_ID_VALUE";
-		case NOT_IN_CURRENT_UNIT_VALUE:
-			return "NOT_IN_CURRENT_UNIT_VALUE";
-		case CONSUMER_NOT_ONLINE_VALUE:
-			return "CONSUMER_NOT_ONLINE_VALUE";
-		case CONSUME_MSG_TIMEOUT_VALUE:
-			return "CONSUME_MSG_TIMEOUT_VALUE";
-    }
-
-    return "UnknowMQResponseCode";
-}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/protocol/MQProtos.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/protocol/MQProtos.h b/rocketmq-client4cpp/src/protocol/MQProtos.h
deleted file mode 100755
index 94167ea..0000000
--- a/rocketmq-client4cpp/src/protocol/MQProtos.h
+++ /dev/null
@@ -1,150 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#ifndef __MQPROTOS_H__
-#define __MQPROTOS_H__
-
-namespace rmq
-{
-    enum MQRequestCode
-    {
-        // broker
-        SEND_MESSAGE_VALUE = 10,
-        PULL_MESSAGE_VALUE = 11,
-        QUERY_MESSAGE_VALUE = 12,
-        QUERY_BROKER_OFFSET_VALUE = 13,
-        QUERY_CONSUMER_OFFSET_VALUE = 14,
-        UPDATE_CONSUMER_OFFSET_VALUE = 15,
-        UPDATE_AND_CREATE_TOPIC_VALUE = 17,
-
-        GET_ALL_TOPIC_CONFIG_VALUE = 21,
-        GET_TOPIC_CONFIG_LIST_VALUE = 22,
-        GET_TOPIC_NAME_LIST_VALUE = 23,
-        UPDATE_BROKER_CONFIG_VALUE = 25,
-        GET_BROKER_CONFIG_VALUE = 26,
-        TRIGGER_DELETE_FILES_VALUE = 27,
-        GET_BROKER_RUNTIME_INFO_VALUE = 28,
-        SEARCH_OFFSET_BY_TIMESTAMP_VALUE = 29,
-
-        GET_MAX_OFFSET_VALUE = 30,
-        GET_MIN_OFFSET_VALUE = 31,
-        GET_EARLIEST_MSG_STORETIME_VALUE = 32,
-        VIEW_MESSAGE_BY_ID_VALUE = 33,
-        HEART_BEAT_VALUE = 34,
-        UNREGISTER_CLIENT_VALUE = 35,
-        CONSUMER_SEND_MSG_BACK_VALUE = 36,
-        END_TRANSACTION_VALUE = 37,
-        GET_CONSUMER_LIST_BY_GROUP_VALUE = 38,
-        CHECK_TRANSACTION_STATE_VALUE = 39,
-
-        NOTIFY_CONSUMER_IDS_CHANGED_VALUE = 40,
-        LOCK_BATCH_MQ_VALUE = 41,
-        UNLOCK_BATCH_MQ_VALUE = 42,
-        GET_ALL_CONSUMER_OFFSET_VALUE = 43,
-        GET_ALL_DELAY_OFFSET_VALUE = 45,
-
-        // Namesrv
-        PUT_KV_CONFIG_VALUE = 100,
-        GET_KV_CONFIG_VALUE = 101,
-        DELETE_KV_CONFIG_VALUE = 102,
-        REGISTER_BROKER_VALUE = 103,
-        UNREGISTER_BROKER_VALUE = 104,
-        GET_ROUTEINTO_BY_TOPIC_VALUE = 105,
-        GET_BROKER_CLUSTER_INFO_VALUE = 106,
-
-        // broker && namesrv
-        UPDATE_AND_CREATE_SUBSCRIPTIONGROUP_VALUE = 200,
-        GET_ALL_SUBSCRIPTIONGROUP_CONFIG_VALUE = 201,
-        GET_TOPIC_STATS_INFO_VALUE = 202,
-        GET_CONSUMER_CONNECTION_LIST_VALUE = 203,
-        GET_PRODUCER_CONNECTION_LIST_VALUE = 204,
-        WIPE_WRITE_PERM_OF_BROKER_VALUE = 205,
-        GET_ALL_TOPIC_LIST_FROM_NAMESERVER_VALUE = 206,
-        DELETE_SUBSCRIPTIONGROUP_VALUE = 207,
-        GET_CONSUME_STATS_VALUE = 208,
-        SUSPEND_CONSUMER_VALUE = 209,
-
-        RESUME_CONSUMER_VALUE = 210,
-        RESET_CONSUMER_OFFSET_IN_CONSUMER_VALUE = 211,
-        RESET_CONSUMER_OFFSET_IN_BROKER_VALUE = 212,
-        ADJUST_CONSUMER_THREAD_POOL_VALUE = 213,
-        WHO_CONSUME_THE_MESSAGE_VALUE = 214,
-        DELETE_TOPIC_IN_BROKER_VALUE = 215,
-        DELETE_TOPIC_IN_NAMESRV_VALUE = 216,
-        GET_KV_CONFIG_BY_VALUE_VALUE = 217,
-        DELETE_KV_CONFIG_BY_VALUE_VALUE = 218,
-        GET_KVLIST_BY_NAMESPACE_VALUE = 219,
-
-        RESET_CONSUMER_CLIENT_OFFSET_VALUE = 220,
-        GET_CONSUMER_STATUS_FROM_CLIENT_VALUE = 221,
-        INVOKE_BROKER_TO_RESET_OFFSET_VALUE = 222,
-        INVOKE_BROKER_TO_GET_CONSUMER_STATUS_VALUE = 223,
-        GET_TOPICS_BY_CLUSTER_VALUE = 224,
-
-        QUERY_TOPIC_CONSUME_BY_WHO_VALUE = 300,
-        REGISTER_FILTER_SERVER_VALUE = 301,
-        REGISTER_MESSAGE_FILTER_CLASS_VALUE = 302,
-        QUERY_CONSUME_TIME_SPAN_VALUE = 303,
-        GET_SYSTEM_TOPIC_LIST_FROM_NS_VALUE = 304,
-        GET_SYSTEM_TOPIC_LIST_FROM_BROKER_VALUE = 305,
-        CLEAN_EXPIRED_CONSUMEQUEUE_VALUE = 306,
-        GET_CONSUMER_RUNNING_INFO_VALUE = 307,
-        QUERY_CORRECTION_OFFSET_VALUE = 308,
-        CONSUME_MESSAGE_DIRECTLY_VALUE = 309,
-
-        SEND_MESSAGE_V2_VALUE = 310,
-        GET_UNIT_TOPIC_LIST_VALUE = 311,
-        GET_HAS_UNIT_SUB_TOPIC_LIST_VALUE = 312,
-        GET_HAS_UNIT_SUB_UNUNIT_TOPIC_LIST_VALUE = 313,
-        CLONE_GROUP_OFFSET_VALUE = 314,
-        VIEW_BROKER_STATS_DATA_VALUE = 315,
-    };
-
-    enum MQResponseCode
-    {
-        FLUSH_DISK_TIMEOUT_VALUE = 10,
-        SLAVE_NOT_AVAILABLE_VALUE = 11,
-        FLUSH_SLAVE_TIMEOUT_VALUE = 12,
-        MESSAGE_ILLEGAL_VALUE = 13,
-        SERVICE_NOT_AVAILABLE_VALUE = 14,
-        VERSION_NOT_SUPPORTED_VALUE = 15,
-        NO_PERMISSION_VALUE = 16,
-        TOPIC_NOT_EXIST_VALUE = 17,
-        TOPIC_EXIST_ALREADY_VALUE = 18,
-        PULL_NOT_FOUND_VALUE = 19,
-
-        PULL_RETRY_IMMEDIATELY_VALUE = 20,
-        PULL_OFFSET_MOVED_VALUE = 21,
-        QUERY_NOT_FOUND_VALUE = 22,
-        SUBSCRIPTION_PARSE_FAILED_VALUE = 23,
-        SUBSCRIPTION_NOT_EXIST_VALUE = 24,
-        SUBSCRIPTION_NOT_LATEST_VALUE = 25,
-        SUBSCRIPTION_GROUP_NOT_EXIST_VALUE = 26,
-
-        TRANSACTION_SHOULD_COMMIT_VALUE = 200,
-        TRANSACTION_SHOULD_ROLLBACK_VALUE = 201,
-        TRANSACTION_STATE_UNKNOW_VALUE = 202,
-        TRANSACTION_STATE_GROUP_WRONG_VALUE = 203,
-		NO_BUYER_ID_VALUE = 204,
-		NOT_IN_CURRENT_UNIT_VALUE = 205,
-		CONSUMER_NOT_ONLINE_VALUE = 206,
-		CONSUME_MSG_TIMEOUT_VALUE = 207,
-    };
-
-	const char* getMQRequestCodeString(int code);
-	const char* getMQResponseCodeString(int code);
-}
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/protocol/OffsetSerializeWrapper.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/protocol/OffsetSerializeWrapper.h b/rocketmq-client4cpp/src/protocol/OffsetSerializeWrapper.h
deleted file mode 100755
index 56ee4e4..0000000
--- a/rocketmq-client4cpp/src/protocol/OffsetSerializeWrapper.h
+++ /dev/null
@@ -1,135 +0,0 @@
-/**
-* Copyright (C) 2013 kangliqiang ,kangliq@163.com
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef __OFFSETSERIALIZEWRAPPER_H__
-#define __OFFSETSERIALIZEWRAPPER_H__
-
-#include <map>
-#include <string>
-#include "RemotingSerializable.h"
-#include "MessageQueue.h"
-#include "AtomicValue.h"
-#include "UtilAll.h"
-#include "json/json.h"
-
-
-namespace rmq
-{
-    class OffsetSerializeWrapper : public RemotingSerializable
-    {
-    public:
-        void encode(std::string& outData)
-        {
-            Json::Value offsetTable;
-            RMQ_FOR_EACH(m_offsetTable, it)
-            {
-                MessageQueue mq = it->first;
-                kpr::AtomicLong& offset = it->second;
-
-                std::string mqStr = mq.toJsonString();
-                offsetTable[mqStr] = offset.get();
-            }
-
-            Json::Value obj;
-            obj["offsetTable"] = offsetTable;
-
-            Json::FastWriter writer;
-            outData = writer.write(obj);
-        }
-        static OffsetSerializeWrapper* decode(const char* pData, int len)
-        {
-            /*
-            {
-                "offsetTable":{
-                    '{"brokerName":"broker-a","queueId":3,"topic":"TopicTest"}':0,
-                    '{"brokerName":"broker-a","queueId":2,"topic":"TopicTest"}':0
-                }
-
-            }
-            */
-
-            RMQ_DEBUG("decode, data:%s", pData);
-
-            Json::Reader reader;
-            Json::Value obj;
-            if (!reader.parse(pData, pData + len, obj))
-            {
-                return NULL;
-            }
-
-            RMQ_DEBUG("decode ok");
-
-            if (obj.isObject())
-            {
-                Json::Value objOffsetTable = obj["offsetTable"];
-                if (objOffsetTable.isObject())
-                {
-                    std::map<MessageQueue, kpr::AtomicLong> offsetTable;
-                    OffsetSerializeWrapper* offsetWrapper = new OffsetSerializeWrapper();
-
-                    Json::Value::Members members = objOffsetTable.getMemberNames();
-                    for (typeof(members.begin()) it = members.begin(); it != members.end(); it++)
-                    {
-                        std::string key = *it;
-                        Json::Value objMq;
-                        RMQ_DEBUG("decode, key:%s", key.c_str());
-                        if (!reader.parse(key, objMq))
-                        {
-                            continue;
-                        }
-                        RMQ_DEBUG("decode, key ok");
-
-                        MessageQueue mq(objMq["topic"].asString(), objMq["brokerName"].asString(),
-                                        objMq["queueId"].asInt());
-                        long long offset = objOffsetTable[key].asInt64();
-
-                        offsetTable[mq] = kpr::AtomicLong(offset);
-                    }
-                    offsetWrapper->setOffsetTable(offsetTable);
-
-                    return offsetWrapper;
-                }
-            }
-
-            return NULL;
-        }
-
-		std::string toString() const
-		{
-			std::stringstream ss;
-			ss << "{offsetTable=" << UtilAll::toString(m_offsetTable)
-			   << "}";
-			return ss.str();
-		}
-
-        std::map<MessageQueue, kpr::AtomicLong>& getOffsetTable()
-        {
-            return m_offsetTable;
-        }
-
-        void setOffsetTable(const std::map<MessageQueue, kpr::AtomicLong>& table)
-        {
-            m_offsetTable = table;
-        }
-
-    private:
-        std::map<MessageQueue, kpr::AtomicLong> m_offsetTable;
-    };
-
-    typedef kpr::RefHandleT<OffsetSerializeWrapper> OffsetSerializeWrapperPtr;
-}
-
-#endif


[08/17] incubator-rocketmq-externals git commit: Polish cpp module

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/jsoncpp/json_reader.cpp
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/jsoncpp/json_reader.cpp b/rocketmq-client4cpp/src/jsoncpp/json_reader.cpp
deleted file mode 100755
index d6f87e6..0000000
--- a/rocketmq-client4cpp/src/jsoncpp/json_reader.cpp
+++ /dev/null
@@ -1,2042 +0,0 @@
-// Copyright 2007-2011 Baptiste Lepilleur
-// Distributed under MIT license, or public domain if desired and
-// recognized in your jurisdiction.
-// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
-
-#if !defined(JSON_IS_AMALGAMATION)
-#include <json/assertions.h>
-#include <json/reader.h>
-#include <json/value.h>
-#include "json_tool.h"
-#endif // if !defined(JSON_IS_AMALGAMATION)
-#include <utility>
-#include <cstdio>
-#include <cassert>
-#include <cstring>
-#include <istream>
-#include <sstream>
-#include <memory>
-#include <set>
-#include <limits>
-
-#if defined(_MSC_VER)
-#if !defined(WINCE) && defined(__STDC_SECURE_LIB__) && _MSC_VER >= 1500 // VC++ 9.0 and above 
-#define snprintf sprintf_s
-#elif _MSC_VER >= 1900 // VC++ 14.0 and above
-#define snprintf std::snprintf
-#else
-#define snprintf _snprintf
-#endif
-#elif defined(__ANDROID__) || defined(__QNXNTO__)
-#define snprintf snprintf
-#elif __cplusplus >= 201103L
-#if !defined(__MINGW32__) && !defined(__CYGWIN__)
-#define snprintf std::snprintf
-#endif
-#endif
-
-#if defined(__QNXNTO__)
-#define sscanf std::sscanf
-#endif
-
-#if defined(_MSC_VER) && _MSC_VER >= 1400 // VC++ 8.0
-// Disable warning about strdup being deprecated.
-#pragma warning(disable : 4996)
-#endif
-
-static int const stackLimit_g = 1000;
-static int       stackDepth_g = 0;  // see readValue()
-
-namespace rmq {
-namespace Json {
-
-#if __cplusplus >= 201103L || (defined(_CPPLIB_VER) && _CPPLIB_VER >= 520)
-typedef std::unique_ptr<CharReader> CharReaderPtr;
-#else
-typedef std::auto_ptr<CharReader>   CharReaderPtr;
-#endif
-
-// Implementation of class Features
-// ////////////////////////////////
-
-Features::Features()
-    : allowComments_(true), strictRoot_(false),
-      allowDroppedNullPlaceholders_(false), allowNumericKeys_(true) {}
-
-Features Features::all() { return Features(); }
-
-Features Features::strictMode() {
-  Features features;
-  features.allowComments_ = false;
-  features.strictRoot_ = true;
-  features.allowDroppedNullPlaceholders_ = false;
-  features.allowNumericKeys_ = false;
-  return features;
-}
-
-// Implementation of class Reader
-// ////////////////////////////////
-
-static bool containsNewLine(Reader::Location begin, Reader::Location end) {
-  for (; begin < end; ++begin)
-    if (*begin == '\n' || *begin == '\r')
-      return true;
-  return false;
-}
-
-// Class Reader
-// //////////////////////////////////////////////////////////////////
-
-Reader::Reader()
-    : errors_(), document_(), begin_(), end_(), current_(), lastValueEnd_(),
-      lastValue_(), commentsBefore_(), features_(Features::all()),
-      collectComments_() {}
-
-Reader::Reader(const Features& features)
-    : errors_(), document_(), begin_(), end_(), current_(), lastValueEnd_(),
-      lastValue_(), commentsBefore_(), features_(features), collectComments_() {
-}
-
-bool
-Reader::parse(const std::string& document, Value& root, bool collectComments) {
-  JSONCPP_STRING documentCopy(document.data(), document.data() + document.capacity());
-  std::swap(documentCopy, document_);
-  const char* begin = document_.c_str();
-  const char* end = begin + document_.length();
-  return parse(begin, end, root, collectComments);
-}
-
-bool Reader::parse(std::istream& sin, Value& root, bool collectComments) {
-  // std::istream_iterator<char> begin(sin);
-  // std::istream_iterator<char> end;
-  // Those would allow streamed input from a file, if parse() were a
-  // template function.
-
-  // Since JSONCPP_STRING is reference-counted, this at least does not
-  // create an extra copy.
-  JSONCPP_STRING doc;
-  std::getline(sin, doc, (char)EOF);
-  return parse(doc.data(), doc.data() + doc.size(), root, collectComments);
-}
-
-bool Reader::parse(const char* beginDoc,
-                   const char* endDoc,
-                   Value& root,
-                   bool collectComments) {
-  if (!features_.allowComments_) {
-    collectComments = false;
-  }
-
-  begin_ = beginDoc;
-  end_ = endDoc;
-  collectComments_ = collectComments;
-  current_ = begin_;
-  lastValueEnd_ = 0;
-  lastValue_ = 0;
-  commentsBefore_ = "";
-  errors_.clear();
-  while (!nodes_.empty())
-    nodes_.pop();
-  nodes_.push(&root);
-
-  stackDepth_g = 0;  // Yes, this is bad coding, but options are limited.
-  bool successful = readValue();
-  Token token;
-  skipCommentTokens(token);
-  if (collectComments_ && !commentsBefore_.empty())
-    root.setComment(commentsBefore_, commentAfter);
-  if (features_.strictRoot_) {
-    if (!root.isArray() && !root.isObject()) {
-      // Set error location to start of doc, ideally should be first token found
-      // in doc
-      token.type_ = tokenError;
-      token.start_ = beginDoc;
-      token.end_ = endDoc;
-      addError(
-          "A valid JSON document must be either an array or an object value.",
-          token);
-      return false;
-    }
-  }
-  return successful;
-}
-
-bool Reader::readValue() {
-  // This is a non-reentrant way to support a stackLimit. Terrible!
-  // But this deprecated class has a security problem: Bad input can
-  // cause a seg-fault. This seems like a fair, binary-compatible way
-  // to prevent the problem.
-  if (stackDepth_g >= stackLimit_g) throwRuntimeError("Exceeded stackLimit in readValue().");
-  ++stackDepth_g;
-
-  Token token;
-  skipCommentTokens(token);
-  bool successful = true;
-
-  if (collectComments_ && !commentsBefore_.empty()) {
-    currentValue().setComment(commentsBefore_, commentBefore);
-    commentsBefore_ = "";
-  }
-
-  switch (token.type_) {
-  case tokenObjectBegin:
-    successful = readObject(token);
-    currentValue().setOffsetLimit(current_ - begin_);
-    break;
-  case tokenArrayBegin:
-    successful = readArray(token);
-    currentValue().setOffsetLimit(current_ - begin_);
-    break;
-  case tokenNumber:
-    successful = decodeNumber(token);
-    break;
-  case tokenString:
-    successful = decodeString(token);
-    break;
-  case tokenTrue:
-    {
-    Value v(true);
-    currentValue().swapPayload(v);
-    currentValue().setOffsetStart(token.start_ - begin_);
-    currentValue().setOffsetLimit(token.end_ - begin_);
-    }
-    break;
-  case tokenFalse:
-    {
-    Value v(false);
-    currentValue().swapPayload(v);
-    currentValue().setOffsetStart(token.start_ - begin_);
-    currentValue().setOffsetLimit(token.end_ - begin_);
-    }
-    break;
-  case tokenNull:
-    {
-    Value v;
-    currentValue().swapPayload(v);
-    currentValue().setOffsetStart(token.start_ - begin_);
-    currentValue().setOffsetLimit(token.end_ - begin_);
-    }
-    break;
-  case tokenArraySeparator:
-  case tokenObjectEnd:
-  case tokenArrayEnd:
-    if (features_.allowDroppedNullPlaceholders_) {
-      // "Un-read" the current token and mark the current value as a null
-      // token.
-      current_--;
-      Value v;
-      currentValue().swapPayload(v);
-      currentValue().setOffsetStart(current_ - begin_ - 1);
-      currentValue().setOffsetLimit(current_ - begin_);
-      break;
-    } // Else, fall through...
-  default:
-    currentValue().setOffsetStart(token.start_ - begin_);
-    currentValue().setOffsetLimit(token.end_ - begin_);
-    return addError("Syntax error: value, object or array expected.", token);
-  }
-
-  if (collectComments_) {
-    lastValueEnd_ = current_;
-    lastValue_ = &currentValue();
-  }
-
-  --stackDepth_g;
-  return successful;
-}
-
-void Reader::skipCommentTokens(Token& token) {
-  if (features_.allowComments_) {
-    do {
-      readToken(token);
-    } while (token.type_ == tokenComment);
-  } else {
-    readToken(token);
-  }
-}
-
-bool Reader::readToken(Token& token) {
-  skipSpaces();
-  token.start_ = current_;
-  Char c = getNextChar();
-  bool ok = true;
-  switch (c) {
-  case '{':
-    token.type_ = tokenObjectBegin;
-    break;
-  case '}':
-    token.type_ = tokenObjectEnd;
-    break;
-  case '[':
-    token.type_ = tokenArrayBegin;
-    break;
-  case ']':
-    token.type_ = tokenArrayEnd;
-    break;
-  case '"':
-    token.type_ = tokenString;
-    ok = readString();
-    break;
-  case '/':
-    token.type_ = tokenComment;
-    ok = readComment();
-    break;
-  case '0':
-  case '1':
-  case '2':
-  case '3':
-  case '4':
-  case '5':
-  case '6':
-  case '7':
-  case '8':
-  case '9':
-  case '-':
-    token.type_ = tokenNumber;
-    readNumber();
-    break;
-  case 't':
-    token.type_ = tokenTrue;
-    ok = match("rue", 3);
-    break;
-  case 'f':
-    token.type_ = tokenFalse;
-    ok = match("alse", 4);
-    break;
-  case 'n':
-    token.type_ = tokenNull;
-    ok = match("ull", 3);
-    break;
-  case ',':
-    token.type_ = tokenArraySeparator;
-    break;
-  case ':':
-    token.type_ = tokenMemberSeparator;
-    break;
-  case 0:
-    token.type_ = tokenEndOfStream;
-    break;
-  default:
-    ok = false;
-    break;
-  }
-  if (!ok)
-    token.type_ = tokenError;
-  token.end_ = current_;
-  return true;
-}
-
-void Reader::skipSpaces() {
-  while (current_ != end_) {
-    Char c = *current_;
-    if (c == ' ' || c == '\t' || c == '\r' || c == '\n')
-      ++current_;
-    else
-      break;
-  }
-}
-
-bool Reader::match(Location pattern, int patternLength) {
-  if (end_ - current_ < patternLength)
-    return false;
-  int index = patternLength;
-  while (index--)
-    if (current_[index] != pattern[index])
-      return false;
-  current_ += patternLength;
-  return true;
-}
-
-bool Reader::readComment() {
-  Location commentBegin = current_ - 1;
-  Char c = getNextChar();
-  bool successful = false;
-  if (c == '*')
-    successful = readCStyleComment();
-  else if (c == '/')
-    successful = readCppStyleComment();
-  if (!successful)
-    return false;
-
-  if (collectComments_) {
-    CommentPlacement placement = commentBefore;
-    if (lastValueEnd_ && !containsNewLine(lastValueEnd_, commentBegin)) {
-      if (c != '*' || !containsNewLine(commentBegin, current_))
-        placement = commentAfterOnSameLine;
-    }
-
-    addComment(commentBegin, current_, placement);
-  }
-  return true;
-}
-
-static JSONCPP_STRING normalizeEOL(Reader::Location begin, Reader::Location end) {
-  JSONCPP_STRING normalized;
-  normalized.reserve(static_cast<size_t>(end - begin));
-  Reader::Location current = begin;
-  while (current != end) {
-    char c = *current++;
-    if (c == '\r') {
-      if (current != end && *current == '\n')
-         // convert dos EOL
-         ++current;
-      // convert Mac EOL
-      normalized += '\n';
-    } else {
-      normalized += c;
-    }
-  }
-  return normalized;
-}
-
-void
-Reader::addComment(Location begin, Location end, CommentPlacement placement) {
-  assert(collectComments_);
-  const JSONCPP_STRING& normalized = normalizeEOL(begin, end);
-  if (placement == commentAfterOnSameLine) {
-    assert(lastValue_ != 0);
-    lastValue_->setComment(normalized, placement);
-  } else {
-    commentsBefore_ += normalized;
-  }
-}
-
-bool Reader::readCStyleComment() {
-  while ((current_ + 1) < end_) {
-    Char c = getNextChar();
-    if (c == '*' && *current_ == '/')
-      break;
-  }
-  return getNextChar() == '/';
-}
-
-bool Reader::readCppStyleComment() {
-  while (current_ != end_) {
-    Char c = getNextChar();
-    if (c == '\n')
-      break;
-    if (c == '\r') {
-      // Consume DOS EOL. It will be normalized in addComment.
-      if (current_ != end_ && *current_ == '\n')
-        getNextChar();
-      // Break on Moc OS 9 EOL.
-      break;
-    }
-  }
-  return true;
-}
-
-void Reader::readNumber() {
-  const char *p = current_;
-  char c = '0'; // stopgap for already consumed character
-  // integral part
-  while (c >= '0' && c <= '9')
-    c = (current_ = p) < end_ ? *p++ : '\0';
-  // fractional part
-  if (c == '.') {
-    c = (current_ = p) < end_ ? *p++ : '\0';
-    while (c >= '0' && c <= '9')
-      c = (current_ = p) < end_ ? *p++ : '\0';
-  }
-  // exponential part
-  if (c == 'e' || c == 'E') {
-    c = (current_ = p) < end_ ? *p++ : '\0';
-    if (c == '+' || c == '-')
-      c = (current_ = p) < end_ ? *p++ : '\0';
-    while (c >= '0' && c <= '9')
-      c = (current_ = p) < end_ ? *p++ : '\0';
-  }
-}
-
-bool Reader::readString() {
-  Char c = '\0';
-  while (current_ != end_) {
-    c = getNextChar();
-    if (c == '\\')
-      getNextChar();
-    else if (c == '"')
-      break;
-  }
-  return c == '"';
-}
-
-bool Reader::readObject(Token& tokenStart) {
-  Token tokenName;
-  JSONCPP_STRING name;
-  Value init(objectValue);
-  currentValue().swapPayload(init);
-  currentValue().setOffsetStart(tokenStart.start_ - begin_);
-  while (readToken(tokenName)) {
-    bool initialTokenOk = true;
-    while (tokenName.type_ == tokenComment && initialTokenOk)
-      initialTokenOk = readToken(tokenName);
-    if (!initialTokenOk)
-      break;
-    if (tokenName.type_ == tokenObjectEnd && name.empty()) // empty object
-      return true;
-    name = "";
-    if (tokenName.type_ == tokenString) {
-      if (!decodeString(tokenName, name))
-        return recoverFromError(tokenObjectEnd);
-    } else if (tokenName.type_ == tokenNumber && features_.allowNumericKeys_) {
-      Value numberName;
-      if (!decodeNumber(tokenName, numberName))
-        return recoverFromError(tokenObjectEnd);
-      name = numberName.asString();
-    } else {
-      break;
-    }
-
-    Token colon;
-    if (!readToken(colon) || colon.type_ != tokenMemberSeparator) {
-      return addErrorAndRecover(
-          "Missing ':' after object member name", colon, tokenObjectEnd);
-    }
-    Value& value = currentValue()[name];
-    nodes_.push(&value);
-    bool ok = readValue();
-    nodes_.pop();
-    if (!ok) // error already set
-      return recoverFromError(tokenObjectEnd);
-
-    Token comma;
-    if (!readToken(comma) ||
-        (comma.type_ != tokenObjectEnd && comma.type_ != tokenArraySeparator &&
-         comma.type_ != tokenComment)) {
-      return addErrorAndRecover(
-          "Missing ',' or '}' in object declaration", comma, tokenObjectEnd);
-    }
-    bool finalizeTokenOk = true;
-    while (comma.type_ == tokenComment && finalizeTokenOk)
-      finalizeTokenOk = readToken(comma);
-    if (comma.type_ == tokenObjectEnd)
-      return true;
-  }
-  return addErrorAndRecover(
-      "Missing '}' or object member name", tokenName, tokenObjectEnd);
-}
-
-bool Reader::readArray(Token& tokenStart) {
-  Value init(arrayValue);
-  currentValue().swapPayload(init);
-  currentValue().setOffsetStart(tokenStart.start_ - begin_);
-  skipSpaces();
-  if (current_ != end_ && *current_ == ']') // empty array
-  {
-    Token endArray;
-    readToken(endArray);
-    return true;
-  }
-  int index = 0;
-  for (;;) {
-    Value& value = currentValue()[index++];
-    nodes_.push(&value);
-    bool ok = readValue();
-    nodes_.pop();
-    if (!ok) // error already set
-      return recoverFromError(tokenArrayEnd);
-
-    Token token;
-    // Accept Comment after last item in the array.
-    ok = readToken(token);
-    while (token.type_ == tokenComment && ok) {
-      ok = readToken(token);
-    }
-    bool badTokenType =
-        (token.type_ != tokenArraySeparator && token.type_ != tokenArrayEnd);
-    if (!ok || badTokenType) {
-      return addErrorAndRecover(
-          "Missing ',' or ']' in array declaration", token, tokenArrayEnd);
-    }
-    if (token.type_ == tokenArrayEnd)
-      break;
-  }
-  return true;
-}
-
-bool Reader::decodeNumber(Token& token) {
-  Value decoded;
-  if (!decodeNumber(token, decoded))
-    return false;
-  currentValue().swapPayload(decoded);
-  currentValue().setOffsetStart(token.start_ - begin_);
-  currentValue().setOffsetLimit(token.end_ - begin_);
-  return true;
-}
-
-bool Reader::decodeNumber(Token& token, Value& decoded) {
-  // Attempts to parse the number as an integer. If the number is
-  // larger than the maximum supported value of an integer then
-  // we decode the number as a double.
-  Location current = token.start_;
-  bool isNegative = *current == '-';
-  if (isNegative)
-    ++current;
-  // TODO: Help the compiler do the div and mod at compile time or get rid of them.
-  Value::LargestUInt maxIntegerValue =
-      isNegative ? Value::LargestUInt(Value::maxLargestInt) + 1
-                 : Value::maxLargestUInt;
-  Value::LargestUInt threshold = maxIntegerValue / 10;
-  Value::LargestUInt value = 0;
-  while (current < token.end_) {
-    Char c = *current++;
-    if (c < '0' || c > '9')
-      return decodeDouble(token, decoded);
-    Value::UInt digit(static_cast<Value::UInt>(c - '0'));
-    if (value >= threshold) {
-      // We've hit or exceeded the max value divided by 10 (rounded down). If
-      // a) we've only just touched the limit, b) this is the last digit, and
-      // c) it's small enough to fit in that rounding delta, we're okay.
-      // Otherwise treat this number as a double to avoid overflow.
-      if (value > threshold || current != token.end_ ||
-          digit > maxIntegerValue % 10) {
-        return decodeDouble(token, decoded);
-      }
-    }
-    value = value * 10 + digit;
-  }
-  if (isNegative && value == maxIntegerValue)
-    decoded = Value::minLargestInt;
-  else if (isNegative)
-    decoded = -Value::LargestInt(value);
-  else if (value <= Value::LargestUInt(Value::maxInt))
-    decoded = Value::LargestInt(value);
-  else
-    decoded = value;
-  return true;
-}
-
-bool Reader::decodeDouble(Token& token) {
-  Value decoded;
-  if (!decodeDouble(token, decoded))
-    return false;
-  currentValue().swapPayload(decoded);
-  currentValue().setOffsetStart(token.start_ - begin_);
-  currentValue().setOffsetLimit(token.end_ - begin_);
-  return true;
-}
-
-bool Reader::decodeDouble(Token& token, Value& decoded) {
-  double value = 0;
-  JSONCPP_STRING buffer(token.start_, token.end_);
-  JSONCPP_ISTRINGSTREAM is(buffer);
-  if (!(is >> value))
-    return addError("'" + JSONCPP_STRING(token.start_, token.end_) +
-                        "' is not a number.",
-                    token);
-  decoded = value;
-  return true;
-}
-
-bool Reader::decodeString(Token& token) {
-  JSONCPP_STRING decoded_string;
-  if (!decodeString(token, decoded_string))
-    return false;
-  Value decoded(decoded_string);
-  currentValue().swapPayload(decoded);
-  currentValue().setOffsetStart(token.start_ - begin_);
-  currentValue().setOffsetLimit(token.end_ - begin_);
-  return true;
-}
-
-bool Reader::decodeString(Token& token, JSONCPP_STRING& decoded) {
-  decoded.reserve(static_cast<size_t>(token.end_ - token.start_ - 2));
-  Location current = token.start_ + 1; // skip '"'
-  Location end = token.end_ - 1;       // do not include '"'
-  while (current != end) {
-    Char c = *current++;
-    if (c == '"')
-      break;
-    else if (c == '\\') {
-      if (current == end)
-        return addError("Empty escape sequence in string", token, current);
-      Char escape = *current++;
-      switch (escape) {
-      case '"':
-        decoded += '"';
-        break;
-      case '/':
-        decoded += '/';
-        break;
-      case '\\':
-        decoded += '\\';
-        break;
-      case 'b':
-        decoded += '\b';
-        break;
-      case 'f':
-        decoded += '\f';
-        break;
-      case 'n':
-        decoded += '\n';
-        break;
-      case 'r':
-        decoded += '\r';
-        break;
-      case 't':
-        decoded += '\t';
-        break;
-      case 'u': {
-        unsigned int unicode;
-        if (!decodeUnicodeCodePoint(token, current, end, unicode))
-          return false;
-        decoded += codePointToUTF8(unicode);
-      } break;
-      default:
-        return addError("Bad escape sequence in string", token, current);
-      }
-    } else {
-      decoded += c;
-    }
-  }
-  return true;
-}
-
-bool Reader::decodeUnicodeCodePoint(Token& token,
-                                    Location& current,
-                                    Location end,
-                                    unsigned int& unicode) {
-
-  if (!decodeUnicodeEscapeSequence(token, current, end, unicode))
-    return false;
-  if (unicode >= 0xD800 && unicode <= 0xDBFF) {
-    // surrogate pairs
-    if (end - current < 6)
-      return addError(
-          "additional six characters expected to parse unicode surrogate pair.",
-          token,
-          current);
-    unsigned int surrogatePair;
-    if (*(current++) == '\\' && *(current++) == 'u') {
-      if (decodeUnicodeEscapeSequence(token, current, end, surrogatePair)) {
-        unicode = 0x10000 + ((unicode & 0x3FF) << 10) + (surrogatePair & 0x3FF);
-      } else
-        return false;
-    } else
-      return addError("expecting another \\u token to begin the second half of "
-                      "a unicode surrogate pair",
-                      token,
-                      current);
-  }
-  return true;
-}
-
-bool Reader::decodeUnicodeEscapeSequence(Token& token,
-                                         Location& current,
-                                         Location end,
-                                         unsigned int& ret_unicode) {
-  if (end - current < 4)
-    return addError(
-        "Bad unicode escape sequence in string: four digits expected.",
-        token,
-        current);
-  int unicode = 0;
-  for (int index = 0; index < 4; ++index) {
-    Char c = *current++;
-    unicode *= 16;
-    if (c >= '0' && c <= '9')
-      unicode += c - '0';
-    else if (c >= 'a' && c <= 'f')
-      unicode += c - 'a' + 10;
-    else if (c >= 'A' && c <= 'F')
-      unicode += c - 'A' + 10;
-    else
-      return addError(
-          "Bad unicode escape sequence in string: hexadecimal digit expected.",
-          token,
-          current);
-  }
-  ret_unicode = static_cast<unsigned int>(unicode);
-  return true;
-}
-
-bool
-Reader::addError(const JSONCPP_STRING& message, Token& token, Location extra) {
-  ErrorInfo info;
-  info.token_ = token;
-  info.message_ = message;
-  info.extra_ = extra;
-  errors_.push_back(info);
-  return false;
-}
-
-bool Reader::recoverFromError(TokenType skipUntilToken) {
-  size_t const errorCount = errors_.size();
-  Token skip;
-  for (;;) {
-    if (!readToken(skip))
-      errors_.resize(errorCount); // discard errors caused by recovery
-    if (skip.type_ == skipUntilToken || skip.type_ == tokenEndOfStream)
-      break;
-  }
-  errors_.resize(errorCount);
-  return false;
-}
-
-bool Reader::addErrorAndRecover(const JSONCPP_STRING& message,
-                                Token& token,
-                                TokenType skipUntilToken) {
-  addError(message, token);
-  return recoverFromError(skipUntilToken);
-}
-
-Value& Reader::currentValue() { return *(nodes_.top()); }
-
-Reader::Char Reader::getNextChar() {
-  if (current_ == end_)
-    return 0;
-  return *current_++;
-}
-
-void Reader::getLocationLineAndColumn(Location location,
-                                      int& line,
-                                      int& column) const {
-  Location current = begin_;
-  Location lastLineStart = current;
-  line = 0;
-  while (current < location && current != end_) {
-    Char c = *current++;
-    if (c == '\r') {
-      if (*current == '\n')
-        ++current;
-      lastLineStart = current;
-      ++line;
-    } else if (c == '\n') {
-      lastLineStart = current;
-      ++line;
-    }
-  }
-  // column & line start at 1
-  column = int(location - lastLineStart) + 1;
-  ++line;
-}
-
-JSONCPP_STRING Reader::getLocationLineAndColumn(Location location) const {
-  int line, column;
-  getLocationLineAndColumn(location, line, column);
-  char buffer[18 + 16 + 16 + 1];
-  snprintf(buffer, sizeof(buffer), "Line %d, Column %d", line, column);
-  return buffer;
-}
-
-// Deprecated. Preserved for backward compatibility
-JSONCPP_STRING Reader::getFormatedErrorMessages() const {
-  return getFormattedErrorMessages();
-}
-
-JSONCPP_STRING Reader::getFormattedErrorMessages() const {
-  JSONCPP_STRING formattedMessage;
-  for (Errors::const_iterator itError = errors_.begin();
-       itError != errors_.end();
-       ++itError) {
-    const ErrorInfo& error = *itError;
-    formattedMessage +=
-        "* " + getLocationLineAndColumn(error.token_.start_) + "\n";
-    formattedMessage += "  " + error.message_ + "\n";
-    if (error.extra_)
-      formattedMessage +=
-          "See " + getLocationLineAndColumn(error.extra_) + " for detail.\n";
-  }
-  return formattedMessage;
-}
-
-std::vector<Reader::StructuredError> Reader::getStructuredErrors() const {
-  std::vector<Reader::StructuredError> allErrors;
-  for (Errors::const_iterator itError = errors_.begin();
-       itError != errors_.end();
-       ++itError) {
-    const ErrorInfo& error = *itError;
-    Reader::StructuredError structured;
-    structured.offset_start = error.token_.start_ - begin_;
-    structured.offset_limit = error.token_.end_ - begin_;
-    structured.message = error.message_;
-    allErrors.push_back(structured);
-  }
-  return allErrors;
-}
-
-bool Reader::pushError(const Value& value, const JSONCPP_STRING& message) {
-  ptrdiff_t const length = end_ - begin_;
-  if(value.getOffsetStart() > length
-    || value.getOffsetLimit() > length)
-    return false;
-  Token token;
-  token.type_ = tokenError;
-  token.start_ = begin_ + value.getOffsetStart();
-  token.end_ = end_ + value.getOffsetLimit();
-  ErrorInfo info;
-  info.token_ = token;
-  info.message_ = message;
-  info.extra_ = 0;
-  errors_.push_back(info);
-  return true;
-}
-
-bool Reader::pushError(const Value& value, const JSONCPP_STRING& message, const Value& extra) {
-  ptrdiff_t const length = end_ - begin_;
-  if(value.getOffsetStart() > length
-    || value.getOffsetLimit() > length
-    || extra.getOffsetLimit() > length)
-    return false;
-  Token token;
-  token.type_ = tokenError;
-  token.start_ = begin_ + value.getOffsetStart();
-  token.end_ = begin_ + value.getOffsetLimit();
-  ErrorInfo info;
-  info.token_ = token;
-  info.message_ = message;
-  info.extra_ = begin_ + extra.getOffsetStart();
-  errors_.push_back(info);
-  return true;
-}
-
-bool Reader::good() const {
-  return !errors_.size();
-}
-
-// exact copy of Features
-class OurFeatures {
-public:
-  static OurFeatures all();
-  bool allowComments_;
-  bool strictRoot_;
-  bool allowDroppedNullPlaceholders_;
-  bool allowNumericKeys_;
-  bool allowSingleQuotes_;
-  bool failIfExtra_;
-  bool rejectDupKeys_;
-  bool allowSpecialFloats_;
-  int stackLimit_;
-};  // OurFeatures
-
-// exact copy of Implementation of class Features
-// ////////////////////////////////
-
-OurFeatures OurFeatures::all() { return OurFeatures(); }
-
-// Implementation of class Reader
-// ////////////////////////////////
-
-// exact copy of Reader, renamed to OurReader
-class OurReader {
-public:
-  typedef char Char;
-  typedef const Char* Location;
-  struct StructuredError {
-    ptrdiff_t offset_start;
-    ptrdiff_t offset_limit;
-    JSONCPP_STRING message;
-  };
-
-  OurReader(OurFeatures const& features);
-  bool parse(const char* beginDoc,
-             const char* endDoc,
-             Value& root,
-             bool collectComments = true);
-  JSONCPP_STRING getFormattedErrorMessages() const;
-  std::vector<StructuredError> getStructuredErrors() const;
-  bool pushError(const Value& value, const JSONCPP_STRING& message);
-  bool pushError(const Value& value, const JSONCPP_STRING& message, const Value& extra);
-  bool good() const;
-
-private:
-  OurReader(OurReader const&);  // no impl
-  void operator=(OurReader const&);  // no impl
-
-  enum TokenType {
-    tokenEndOfStream = 0,
-    tokenObjectBegin,
-    tokenObjectEnd,
-    tokenArrayBegin,
-    tokenArrayEnd,
-    tokenString,
-    tokenNumber,
-    tokenTrue,
-    tokenFalse,
-    tokenNull,
-    tokenNaN,
-    tokenPosInf,
-    tokenNegInf,
-    tokenArraySeparator,
-    tokenMemberSeparator,
-    tokenComment,
-    tokenError
-  };
-
-  class Token {
-  public:
-    TokenType type_;
-    Location start_;
-    Location end_;
-  };
-
-  class ErrorInfo {
-  public:
-    Token token_;
-    JSONCPP_STRING message_;
-    Location extra_;
-  };
-
-  typedef std::deque<ErrorInfo> Errors;
-
-  bool readToken(Token& token);
-  void skipSpaces();
-  bool match(Location pattern, int patternLength);
-  bool readComment();
-  bool readCStyleComment();
-  bool readCppStyleComment();
-  bool readString();
-  bool readStringSingleQuote();
-  bool readNumber(bool checkInf);
-  bool readValue();
-  bool readObject(Token& token);
-  bool readArray(Token& token);
-  bool decodeNumber(Token& token);
-  bool decodeNumber(Token& token, Value& decoded);
-  bool decodeString(Token& token);
-  bool decodeString(Token& token, JSONCPP_STRING& decoded);
-  bool decodeDouble(Token& token);
-  bool decodeDouble(Token& token, Value& decoded);
-  bool decodeUnicodeCodePoint(Token& token,
-                              Location& current,
-                              Location end,
-                              unsigned int& unicode);
-  bool decodeUnicodeEscapeSequence(Token& token,
-                                   Location& current,
-                                   Location end,
-                                   unsigned int& unicode);
-  bool addError(const JSONCPP_STRING& message, Token& token, Location extra = 0);
-  bool recoverFromError(TokenType skipUntilToken);
-  bool addErrorAndRecover(const JSONCPP_STRING& message,
-                          Token& token,
-                          TokenType skipUntilToken);
-  void skipUntilSpace();
-  Value& currentValue();
-  Char getNextChar();
-  void
-  getLocationLineAndColumn(Location location, int& line, int& column) const;
-  JSONCPP_STRING getLocationLineAndColumn(Location location) const;
-  void addComment(Location begin, Location end, CommentPlacement placement);
-  void skipCommentTokens(Token& token);
-
-  typedef std::stack<Value*> Nodes;
-  Nodes nodes_;
-  Errors errors_;
-  JSONCPP_STRING document_;
-  Location begin_;
-  Location end_;
-  Location current_;
-  Location lastValueEnd_;
-  Value* lastValue_;
-  JSONCPP_STRING commentsBefore_;
-  int stackDepth_;
-
-  OurFeatures const features_;
-  bool collectComments_;
-};  // OurReader
-
-// complete copy of Read impl, for OurReader
-
-OurReader::OurReader(OurFeatures const& features)
-    : errors_(), document_(), begin_(), end_(), current_(), lastValueEnd_(),
-      lastValue_(), commentsBefore_(),
-      stackDepth_(0),
-      features_(features), collectComments_() {
-}
-
-bool OurReader::parse(const char* beginDoc,
-                   const char* endDoc,
-                   Value& root,
-                   bool collectComments) {
-  if (!features_.allowComments_) {
-    collectComments = false;
-  }
-
-  begin_ = beginDoc;
-  end_ = endDoc;
-  collectComments_ = collectComments;
-  current_ = begin_;
-  lastValueEnd_ = 0;
-  lastValue_ = 0;
-  commentsBefore_ = "";
-  errors_.clear();
-  while (!nodes_.empty())
-    nodes_.pop();
-  nodes_.push(&root);
-
-  stackDepth_ = 0;
-  bool successful = readValue();
-  Token token;
-  skipCommentTokens(token);
-  if (features_.failIfExtra_) {
-    if ((features_.strictRoot_ || token.type_ != tokenError) && token.type_ != tokenEndOfStream) {
-      addError("Extra non-whitespace after JSON value.", token);
-      return false;
-    }
-  }
-  if (collectComments_ && !commentsBefore_.empty())
-    root.setComment(commentsBefore_, commentAfter);
-  if (features_.strictRoot_) {
-    if (!root.isArray() && !root.isObject()) {
-      // Set error location to start of doc, ideally should be first token found
-      // in doc
-      token.type_ = tokenError;
-      token.start_ = beginDoc;
-      token.end_ = endDoc;
-      addError(
-          "A valid JSON document must be either an array or an object value.",
-          token);
-      return false;
-    }
-  }
-  return successful;
-}
-
-bool OurReader::readValue() {
-  if (stackDepth_ >= features_.stackLimit_) throwRuntimeError("Exceeded stackLimit in readValue().");
-  ++stackDepth_;
-  Token token;
-  skipCommentTokens(token);
-  bool successful = true;
-
-  if (collectComments_ && !commentsBefore_.empty()) {
-    currentValue().setComment(commentsBefore_, commentBefore);
-    commentsBefore_ = "";
-  }
-
-  switch (token.type_) {
-  case tokenObjectBegin:
-    successful = readObject(token);
-    currentValue().setOffsetLimit(current_ - begin_);
-    break;
-  case tokenArrayBegin:
-    successful = readArray(token);
-    currentValue().setOffsetLimit(current_ - begin_);
-    break;
-  case tokenNumber:
-    successful = decodeNumber(token);
-    break;
-  case tokenString:
-    successful = decodeString(token);
-    break;
-  case tokenTrue:
-    {
-    Value v(true);
-    currentValue().swapPayload(v);
-    currentValue().setOffsetStart(token.start_ - begin_);
-    currentValue().setOffsetLimit(token.end_ - begin_);
-    }
-    break;
-  case tokenFalse:
-    {
-    Value v(false);
-    currentValue().swapPayload(v);
-    currentValue().setOffsetStart(token.start_ - begin_);
-    currentValue().setOffsetLimit(token.end_ - begin_);
-    }
-    break;
-  case tokenNull:
-    {
-    Value v;
-    currentValue().swapPayload(v);
-    currentValue().setOffsetStart(token.start_ - begin_);
-    currentValue().setOffsetLimit(token.end_ - begin_);
-    }
-    break;
-  case tokenNaN:
-    {
-    Value v(std::numeric_limits<double>::quiet_NaN());
-    currentValue().swapPayload(v);
-    currentValue().setOffsetStart(token.start_ - begin_);
-    currentValue().setOffsetLimit(token.end_ - begin_);
-    }
-    break;
-  case tokenPosInf:
-    {
-    Value v(std::numeric_limits<double>::infinity());
-    currentValue().swapPayload(v);
-    currentValue().setOffsetStart(token.start_ - begin_);
-    currentValue().setOffsetLimit(token.end_ - begin_);
-    }
-    break;
-  case tokenNegInf:
-    {
-    Value v(-std::numeric_limits<double>::infinity());
-    currentValue().swapPayload(v);
-    currentValue().setOffsetStart(token.start_ - begin_);
-    currentValue().setOffsetLimit(token.end_ - begin_);
-    }
-    break;
-  case tokenArraySeparator:
-  case tokenObjectEnd:
-  case tokenArrayEnd:
-    if (features_.allowDroppedNullPlaceholders_) {
-      // "Un-read" the current token and mark the current value as a null
-      // token.
-      current_--;
-      Value v;
-      currentValue().swapPayload(v);
-      currentValue().setOffsetStart(current_ - begin_ - 1);
-      currentValue().setOffsetLimit(current_ - begin_);
-      break;
-    } // else, fall through ...
-  default:
-    currentValue().setOffsetStart(token.start_ - begin_);
-    currentValue().setOffsetLimit(token.end_ - begin_);
-    return addError("Syntax error: value, object or array expected.", token);
-  }
-
-  if (collectComments_) {
-    lastValueEnd_ = current_;
-    lastValue_ = &currentValue();
-  }
-
-  --stackDepth_;
-  return successful;
-}
-
-void OurReader::skipCommentTokens(Token& token) {
-  if (features_.allowComments_) {
-    do {
-      readToken(token);
-    } while (token.type_ == tokenComment);
-  } else {
-    readToken(token);
-  }
-}
-
-bool OurReader::readToken(Token& token) {
-  skipSpaces();
-  token.start_ = current_;
-  Char c = getNextChar();
-  bool ok = true;
-  switch (c) {
-  case '{':
-    token.type_ = tokenObjectBegin;
-    break;
-  case '}':
-    token.type_ = tokenObjectEnd;
-    break;
-  case '[':
-    token.type_ = tokenArrayBegin;
-    break;
-  case ']':
-    token.type_ = tokenArrayEnd;
-    break;
-  case '"':
-    token.type_ = tokenString;
-    ok = readString();
-    break;
-  case '\'':
-    if (features_.allowSingleQuotes_) {
-    token.type_ = tokenString;
-    ok = readStringSingleQuote();
-    break;
-    } // else continue
-  case '/':
-    token.type_ = tokenComment;
-    ok = readComment();
-    break;
-  case '0':
-  case '1':
-  case '2':
-  case '3':
-  case '4':
-  case '5':
-  case '6':
-  case '7':
-  case '8':
-  case '9':
-    token.type_ = tokenNumber;
-    readNumber(false);
-    break;
-  case '-':
-    if (readNumber(true)) {
-      token.type_ = tokenNumber;
-    } else {
-      token.type_ = tokenNegInf;
-      ok = features_.allowSpecialFloats_ && match("nfinity", 7);
-    }
-    break;
-  case 't':
-    token.type_ = tokenTrue;
-    ok = match("rue", 3);
-    break;
-  case 'f':
-    token.type_ = tokenFalse;
-    ok = match("alse", 4);
-    break;
-  case 'n':
-    token.type_ = tokenNull;
-    ok = match("ull", 3);
-    break;
-  case 'N':
-    if (features_.allowSpecialFloats_) {
-      token.type_ = tokenNaN;
-      ok = match("aN", 2);
-    } else {
-      ok = false;
-    }
-    break;
-  case 'I':
-    if (features_.allowSpecialFloats_) {
-      token.type_ = tokenPosInf;
-      ok = match("nfinity", 7);
-    } else {
-      ok = false;
-    }
-    break;
-  case ',':
-    token.type_ = tokenArraySeparator;
-    break;
-  case ':':
-    token.type_ = tokenMemberSeparator;
-    break;
-  case 0:
-    token.type_ = tokenEndOfStream;
-    break;
-  default:
-    ok = false;
-    break;
-  }
-  if (!ok)
-    token.type_ = tokenError;
-  token.end_ = current_;
-  return true;
-}
-
-void OurReader::skipSpaces() {
-  while (current_ != end_) {
-    Char c = *current_;
-    if (c == ' ' || c == '\t' || c == '\r' || c == '\n')
-      ++current_;
-    else
-      break;
-  }
-}
-
-bool OurReader::match(Location pattern, int patternLength) {
-  if (end_ - current_ < patternLength)
-    return false;
-  int index = patternLength;
-  while (index--)
-    if (current_[index] != pattern[index])
-      return false;
-  current_ += patternLength;
-  return true;
-}
-
-bool OurReader::readComment() {
-  Location commentBegin = current_ - 1;
-  Char c = getNextChar();
-  bool successful = false;
-  if (c == '*')
-    successful = readCStyleComment();
-  else if (c == '/')
-    successful = readCppStyleComment();
-  if (!successful)
-    return false;
-
-  if (collectComments_) {
-    CommentPlacement placement = commentBefore;
-    if (lastValueEnd_ && !containsNewLine(lastValueEnd_, commentBegin)) {
-      if (c != '*' || !containsNewLine(commentBegin, current_))
-        placement = commentAfterOnSameLine;
-    }
-
-    addComment(commentBegin, current_, placement);
-  }
-  return true;
-}
-
-void
-OurReader::addComment(Location begin, Location end, CommentPlacement placement) {
-  assert(collectComments_);
-  const JSONCPP_STRING& normalized = normalizeEOL(begin, end);
-  if (placement == commentAfterOnSameLine) {
-    assert(lastValue_ != 0);
-    lastValue_->setComment(normalized, placement);
-  } else {
-    commentsBefore_ += normalized;
-  }
-}
-
-bool OurReader::readCStyleComment() {
-  while ((current_ + 1) < end_) {
-    Char c = getNextChar();
-    if (c == '*' && *current_ == '/')
-      break;
-  }
-  return getNextChar() == '/';
-}
-
-bool OurReader::readCppStyleComment() {
-  while (current_ != end_) {
-    Char c = getNextChar();
-    if (c == '\n')
-      break;
-    if (c == '\r') {
-      // Consume DOS EOL. It will be normalized in addComment.
-      if (current_ != end_ && *current_ == '\n')
-        getNextChar();
-      // Break on Moc OS 9 EOL.
-      break;
-    }
-  }
-  return true;
-}
-
-bool OurReader::readNumber(bool checkInf) {
-  const char *p = current_;
-  if (checkInf && p != end_ && *p == 'I') {
-    current_ = ++p;
-    return false;
-  }
-  char c = '0'; // stopgap for already consumed character
-  // integral part
-  while (c >= '0' && c <= '9')
-    c = (current_ = p) < end_ ? *p++ : '\0';
-  // fractional part
-  if (c == '.') {
-    c = (current_ = p) < end_ ? *p++ : '\0';
-    while (c >= '0' && c <= '9')
-      c = (current_ = p) < end_ ? *p++ : '\0';
-  }
-  // exponential part
-  if (c == 'e' || c == 'E') {
-    c = (current_ = p) < end_ ? *p++ : '\0';
-    if (c == '+' || c == '-')
-      c = (current_ = p) < end_ ? *p++ : '\0';
-    while (c >= '0' && c <= '9')
-      c = (current_ = p) < end_ ? *p++ : '\0';
-  }
-  return true;
-}
-bool OurReader::readString() {
-  Char c = 0;
-  while (current_ != end_) {
-    c = getNextChar();
-    if (c == '\\')
-      getNextChar();
-    else if (c == '"')
-      break;
-  }
-  return c == '"';
-}
-
-
-bool OurReader::readStringSingleQuote() {
-  Char c = 0;
-  while (current_ != end_) {
-    c = getNextChar();
-    if (c == '\\')
-      getNextChar();
-    else if (c == '\'')
-      break;
-  }
-  return c == '\'';
-}
-
-bool OurReader::readObject(Token& tokenStart) {
-  Token tokenName;
-  JSONCPP_STRING name;
-  Value init(objectValue);
-  currentValue().swapPayload(init);
-  currentValue().setOffsetStart(tokenStart.start_ - begin_);
-  while (readToken(tokenName)) {
-    bool initialTokenOk = true;
-    while (tokenName.type_ == tokenComment && initialTokenOk)
-      initialTokenOk = readToken(tokenName);
-    if (!initialTokenOk)
-      break;
-    if (tokenName.type_ == tokenObjectEnd && name.empty()) // empty object
-      return true;
-    name = "";
-    if (tokenName.type_ == tokenString) {
-      if (!decodeString(tokenName, name))
-        return recoverFromError(tokenObjectEnd);
-    } else if (tokenName.type_ == tokenNumber && features_.allowNumericKeys_) {
-      Value numberName;
-      if (!decodeNumber(tokenName, numberName))
-        return recoverFromError(tokenObjectEnd);
-      name = numberName.asString();
-    } else {
-      break;
-    }
-
-    Token colon;
-    if (!readToken(colon) || colon.type_ != tokenMemberSeparator) {
-      return addErrorAndRecover(
-          "Missing ':' after object member name", colon, tokenObjectEnd);
-    }
-    if (name.length() >= (1U<<30)) throwRuntimeError("keylength >= 2^30");
-    if (features_.rejectDupKeys_ && currentValue().isMember(name)) {
-      JSONCPP_STRING msg = "Duplicate key: '" + name + "'";
-      return addErrorAndRecover(
-          msg, tokenName, tokenObjectEnd);
-    }
-    Value& value = currentValue()[name];
-    nodes_.push(&value);
-    bool ok = readValue();
-    nodes_.pop();
-    if (!ok) // error already set
-      return recoverFromError(tokenObjectEnd);
-
-    Token comma;
-    if (!readToken(comma) ||
-        (comma.type_ != tokenObjectEnd && comma.type_ != tokenArraySeparator &&
-         comma.type_ != tokenComment)) {
-      return addErrorAndRecover(
-          "Missing ',' or '}' in object declaration", comma, tokenObjectEnd);
-    }
-    bool finalizeTokenOk = true;
-    while (comma.type_ == tokenComment && finalizeTokenOk)
-      finalizeTokenOk = readToken(comma);
-    if (comma.type_ == tokenObjectEnd)
-      return true;
-  }
-  return addErrorAndRecover(
-      "Missing '}' or object member name", tokenName, tokenObjectEnd);
-}
-
-bool OurReader::readArray(Token& tokenStart) {
-  Value init(arrayValue);
-  currentValue().swapPayload(init);
-  currentValue().setOffsetStart(tokenStart.start_ - begin_);
-  skipSpaces();
-  if (current_ != end_ && *current_ == ']') // empty array
-  {
-    Token endArray;
-    readToken(endArray);
-    return true;
-  }
-  int index = 0;
-  for (;;) {
-    Value& value = currentValue()[index++];
-    nodes_.push(&value);
-    bool ok = readValue();
-    nodes_.pop();
-    if (!ok) // error already set
-      return recoverFromError(tokenArrayEnd);
-
-    Token token;
-    // Accept Comment after last item in the array.
-    ok = readToken(token);
-    while (token.type_ == tokenComment && ok) {
-      ok = readToken(token);
-    }
-    bool badTokenType =
-        (token.type_ != tokenArraySeparator && token.type_ != tokenArrayEnd);
-    if (!ok || badTokenType) {
-      return addErrorAndRecover(
-          "Missing ',' or ']' in array declaration", token, tokenArrayEnd);
-    }
-    if (token.type_ == tokenArrayEnd)
-      break;
-  }
-  return true;
-}
-
-bool OurReader::decodeNumber(Token& token) {
-  Value decoded;
-  if (!decodeNumber(token, decoded))
-    return false;
-  currentValue().swapPayload(decoded);
-  currentValue().setOffsetStart(token.start_ - begin_);
-  currentValue().setOffsetLimit(token.end_ - begin_);
-  return true;
-}
-
-bool OurReader::decodeNumber(Token& token, Value& decoded) {
-  // Attempts to parse the number as an integer. If the number is
-  // larger than the maximum supported value of an integer then
-  // we decode the number as a double.
-  Location current = token.start_;
-  bool isNegative = *current == '-';
-  if (isNegative)
-    ++current;
-  // TODO: Help the compiler do the div and mod at compile time or get rid of them.
-  Value::LargestUInt maxIntegerValue =
-      isNegative ? Value::LargestUInt(-Value::minLargestInt)
-                 : Value::maxLargestUInt;
-  Value::LargestUInt threshold = maxIntegerValue / 10;
-  Value::LargestUInt value = 0;
-  while (current < token.end_) {
-    Char c = *current++;
-    if (c < '0' || c > '9')
-      return decodeDouble(token, decoded);
-    Value::UInt digit(static_cast<Value::UInt>(c - '0'));
-    if (value >= threshold) {
-      // We've hit or exceeded the max value divided by 10 (rounded down). If
-      // a) we've only just touched the limit, b) this is the last digit, and
-      // c) it's small enough to fit in that rounding delta, we're okay.
-      // Otherwise treat this number as a double to avoid overflow.
-      if (value > threshold || current != token.end_ ||
-          digit > maxIntegerValue % 10) {
-        return decodeDouble(token, decoded);
-      }
-    }
-    value = value * 10 + digit;
-  }
-  if (isNegative)
-    decoded = -Value::LargestInt(value);
-  else if (value <= Value::LargestUInt(Value::maxInt))
-    decoded = Value::LargestInt(value);
-  else
-    decoded = value;
-  return true;
-}
-
-bool OurReader::decodeDouble(Token& token) {
-  Value decoded;
-  if (!decodeDouble(token, decoded))
-    return false;
-  currentValue().swapPayload(decoded);
-  currentValue().setOffsetStart(token.start_ - begin_);
-  currentValue().setOffsetLimit(token.end_ - begin_);
-  return true;
-}
-
-bool OurReader::decodeDouble(Token& token, Value& decoded) {
-  double value = 0;
-  const int bufferSize = 32;
-  int count;
-  ptrdiff_t const length = token.end_ - token.start_;
-
-  // Sanity check to avoid buffer overflow exploits.
-  if (length < 0) {
-    return addError("Unable to parse token length", token);
-  }
-  size_t const ulength = static_cast<size_t>(length);
-
-  // Avoid using a string constant for the format control string given to
-  // sscanf, as this can cause hard to debug crashes on OS X. See here for more
-  // info:
-  //
-  //     http://developer.apple.com/library/mac/#DOCUMENTATION/DeveloperTools/gcc-4.0.1/gcc/Incompatibilities.html
-  char format[] = "%lf";
-
-  if (length <= bufferSize) {
-    Char buffer[bufferSize + 1];
-    memcpy(buffer, token.start_, ulength);
-    buffer[length] = 0;
-    fixNumericLocaleInput(buffer, buffer + length);
-    count = sscanf(buffer, format, &value);
-  } else {
-    JSONCPP_STRING buffer(token.start_, token.end_);
-    count = sscanf(buffer.c_str(), format, &value);
-  }
-
-  if (count != 1)
-    return addError("'" + JSONCPP_STRING(token.start_, token.end_) +
-                        "' is not a number.",
-                    token);
-  decoded = value;
-  return true;
-}
-
-bool OurReader::decodeString(Token& token) {
-  JSONCPP_STRING decoded_string;
-  if (!decodeString(token, decoded_string))
-    return false;
-  Value decoded(decoded_string);
-  currentValue().swapPayload(decoded);
-  currentValue().setOffsetStart(token.start_ - begin_);
-  currentValue().setOffsetLimit(token.end_ - begin_);
-  return true;
-}
-
-bool OurReader::decodeString(Token& token, JSONCPP_STRING& decoded) {
-  decoded.reserve(static_cast<size_t>(token.end_ - token.start_ - 2));
-  Location current = token.start_ + 1; // skip '"'
-  Location end = token.end_ - 1;       // do not include '"'
-  while (current != end) {
-    Char c = *current++;
-    if (c == '"')
-      break;
-    else if (c == '\\') {
-      if (current == end)
-        return addError("Empty escape sequence in string", token, current);
-      Char escape = *current++;
-      switch (escape) {
-      case '"':
-        decoded += '"';
-        break;
-      case '/':
-        decoded += '/';
-        break;
-      case '\\':
-        decoded += '\\';
-        break;
-      case 'b':
-        decoded += '\b';
-        break;
-      case 'f':
-        decoded += '\f';
-        break;
-      case 'n':
-        decoded += '\n';
-        break;
-      case 'r':
-        decoded += '\r';
-        break;
-      case 't':
-        decoded += '\t';
-        break;
-      case 'u': {
-        unsigned int unicode;
-        if (!decodeUnicodeCodePoint(token, current, end, unicode))
-          return false;
-        decoded += codePointToUTF8(unicode);
-      } break;
-      default:
-        return addError("Bad escape sequence in string", token, current);
-      }
-    } else {
-      decoded += c;
-    }
-  }
-  return true;
-}
-
-bool OurReader::decodeUnicodeCodePoint(Token& token,
-                                    Location& current,
-                                    Location end,
-                                    unsigned int& unicode) {
-
-  if (!decodeUnicodeEscapeSequence(token, current, end, unicode))
-    return false;
-  if (unicode >= 0xD800 && unicode <= 0xDBFF) {
-    // surrogate pairs
-    if (end - current < 6)
-      return addError(
-          "additional six characters expected to parse unicode surrogate pair.",
-          token,
-          current);
-    unsigned int surrogatePair;
-    if (*(current++) == '\\' && *(current++) == 'u') {
-      if (decodeUnicodeEscapeSequence(token, current, end, surrogatePair)) {
-        unicode = 0x10000 + ((unicode & 0x3FF) << 10) + (surrogatePair & 0x3FF);
-      } else
-        return false;
-    } else
-      return addError("expecting another \\u token to begin the second half of "
-                      "a unicode surrogate pair",
-                      token,
-                      current);
-  }
-  return true;
-}
-
-bool OurReader::decodeUnicodeEscapeSequence(Token& token,
-                                         Location& current,
-                                         Location end,
-                                         unsigned int& ret_unicode) {
-  if (end - current < 4)
-    return addError(
-        "Bad unicode escape sequence in string: four digits expected.",
-        token,
-        current);
-  int unicode = 0;
-  for (int index = 0; index < 4; ++index) {
-    Char c = *current++;
-    unicode *= 16;
-    if (c >= '0' && c <= '9')
-      unicode += c - '0';
-    else if (c >= 'a' && c <= 'f')
-      unicode += c - 'a' + 10;
-    else if (c >= 'A' && c <= 'F')
-      unicode += c - 'A' + 10;
-    else
-      return addError(
-          "Bad unicode escape sequence in string: hexadecimal digit expected.",
-          token,
-          current);
-  }
-  ret_unicode = static_cast<unsigned int>(unicode);
-  return true;
-}
-
-bool
-OurReader::addError(const JSONCPP_STRING& message, Token& token, Location extra) {
-  ErrorInfo info;
-  info.token_ = token;
-  info.message_ = message;
-  info.extra_ = extra;
-  errors_.push_back(info);
-  return false;
-}
-
-bool OurReader::recoverFromError(TokenType skipUntilToken) {
-  size_t errorCount = errors_.size();
-  Token skip;
-  for (;;) {
-    if (!readToken(skip))
-      errors_.resize(errorCount); // discard errors caused by recovery
-    if (skip.type_ == skipUntilToken || skip.type_ == tokenEndOfStream)
-      break;
-  }
-  errors_.resize(errorCount);
-  return false;
-}
-
-bool OurReader::addErrorAndRecover(const JSONCPP_STRING& message,
-                                Token& token,
-                                TokenType skipUntilToken) {
-  addError(message, token);
-  return recoverFromError(skipUntilToken);
-}
-
-Value& OurReader::currentValue() { return *(nodes_.top()); }
-
-OurReader::Char OurReader::getNextChar() {
-  if (current_ == end_)
-    return 0;
-  return *current_++;
-}
-
-void OurReader::getLocationLineAndColumn(Location location,
-                                      int& line,
-                                      int& column) const {
-  Location current = begin_;
-  Location lastLineStart = current;
-  line = 0;
-  while (current < location && current != end_) {
-    Char c = *current++;
-    if (c == '\r') {
-      if (*current == '\n')
-        ++current;
-      lastLineStart = current;
-      ++line;
-    } else if (c == '\n') {
-      lastLineStart = current;
-      ++line;
-    }
-  }
-  // column & line start at 1
-  column = int(location - lastLineStart) + 1;
-  ++line;
-}
-
-JSONCPP_STRING OurReader::getLocationLineAndColumn(Location location) const {
-  int line, column;
-  getLocationLineAndColumn(location, line, column);
-  char buffer[18 + 16 + 16 + 1];
-  snprintf(buffer, sizeof(buffer), "Line %d, Column %d", line, column);
-  return buffer;
-}
-
-JSONCPP_STRING OurReader::getFormattedErrorMessages() const {
-  JSONCPP_STRING formattedMessage;
-  for (Errors::const_iterator itError = errors_.begin();
-       itError != errors_.end();
-       ++itError) {
-    const ErrorInfo& error = *itError;
-    formattedMessage +=
-        "* " + getLocationLineAndColumn(error.token_.start_) + "\n";
-    formattedMessage += "  " + error.message_ + "\n";
-    if (error.extra_)
-      formattedMessage +=
-          "See " + getLocationLineAndColumn(error.extra_) + " for detail.\n";
-  }
-  return formattedMessage;
-}
-
-std::vector<OurReader::StructuredError> OurReader::getStructuredErrors() const {
-  std::vector<OurReader::StructuredError> allErrors;
-  for (Errors::const_iterator itError = errors_.begin();
-       itError != errors_.end();
-       ++itError) {
-    const ErrorInfo& error = *itError;
-    OurReader::StructuredError structured;
-    structured.offset_start = error.token_.start_ - begin_;
-    structured.offset_limit = error.token_.end_ - begin_;
-    structured.message = error.message_;
-    allErrors.push_back(structured);
-  }
-  return allErrors;
-}
-
-bool OurReader::pushError(const Value& value, const JSONCPP_STRING& message) {
-  ptrdiff_t length = end_ - begin_;
-  if(value.getOffsetStart() > length
-    || value.getOffsetLimit() > length)
-    return false;
-  Token token;
-  token.type_ = tokenError;
-  token.start_ = begin_ + value.getOffsetStart();
-  token.end_ = end_ + value.getOffsetLimit();
-  ErrorInfo info;
-  info.token_ = token;
-  info.message_ = message;
-  info.extra_ = 0;
-  errors_.push_back(info);
-  return true;
-}
-
-bool OurReader::pushError(const Value& value, const JSONCPP_STRING& message, const Value& extra) {
-  ptrdiff_t length = end_ - begin_;
-  if(value.getOffsetStart() > length
-    || value.getOffsetLimit() > length
-    || extra.getOffsetLimit() > length)
-    return false;
-  Token token;
-  token.type_ = tokenError;
-  token.start_ = begin_ + value.getOffsetStart();
-  token.end_ = begin_ + value.getOffsetLimit();
-  ErrorInfo info;
-  info.token_ = token;
-  info.message_ = message;
-  info.extra_ = begin_ + extra.getOffsetStart();
-  errors_.push_back(info);
-  return true;
-}
-
-bool OurReader::good() const {
-  return !errors_.size();
-}
-
-
-class OurCharReader : public CharReader {
-  bool const collectComments_;
-  OurReader reader_;
-public:
-  OurCharReader(
-    bool collectComments,
-    OurFeatures const& features)
-  : collectComments_(collectComments)
-  , reader_(features)
-  {}
-  bool parse(
-      char const* beginDoc, char const* endDoc,
-      Value* root, JSONCPP_STRING* errs) JSONCPP_OVERRIDE {
-    bool ok = reader_.parse(beginDoc, endDoc, *root, collectComments_);
-    if (errs) {
-      *errs = reader_.getFormattedErrorMessages();
-    }
-    return ok;
-  }
-};
-
-CharReaderBuilder::CharReaderBuilder()
-{
-  setDefaults(&settings_);
-}
-CharReaderBuilder::~CharReaderBuilder()
-{}
-CharReader* CharReaderBuilder::newCharReader() const
-{
-  bool collectComments = settings_["collectComments"].asBool();
-  OurFeatures features = OurFeatures::all();
-  features.allowComments_ = settings_["allowComments"].asBool();
-  features.strictRoot_ = settings_["strictRoot"].asBool();
-  features.allowDroppedNullPlaceholders_ = settings_["allowDroppedNullPlaceholders"].asBool();
-  features.allowNumericKeys_ = settings_["allowNumericKeys"].asBool();
-  features.allowSingleQuotes_ = settings_["allowSingleQuotes"].asBool();
-  features.stackLimit_ = settings_["stackLimit"].asInt();
-  features.failIfExtra_ = settings_["failIfExtra"].asBool();
-  features.rejectDupKeys_ = settings_["rejectDupKeys"].asBool();
-  features.allowSpecialFloats_ = settings_["allowSpecialFloats"].asBool();
-  return new OurCharReader(collectComments, features);
-}
-static void getValidReaderKeys(std::set<JSONCPP_STRING>* valid_keys)
-{
-  valid_keys->clear();
-  valid_keys->insert("collectComments");
-  valid_keys->insert("allowComments");
-  valid_keys->insert("strictRoot");
-  valid_keys->insert("allowDroppedNullPlaceholders");
-  valid_keys->insert("allowNumericKeys");
-  valid_keys->insert("allowSingleQuotes");
-  valid_keys->insert("stackLimit");
-  valid_keys->insert("failIfExtra");
-  valid_keys->insert("rejectDupKeys");
-  valid_keys->insert("allowSpecialFloats");
-}
-bool CharReaderBuilder::validate(Value* invalid) const
-{
-  Value my_invalid;
-  if (!invalid) invalid = &my_invalid;  // so we do not need to test for NULL
-  Value& inv = *invalid;
-  std::set<JSONCPP_STRING> valid_keys;
-  getValidReaderKeys(&valid_keys);
-  Value::Members keys = settings_.getMemberNames();
-  size_t n = keys.size();
-  for (size_t i = 0; i < n; ++i) {
-    JSONCPP_STRING const& key = keys[i];
-    if (valid_keys.find(key) == valid_keys.end()) {
-      inv[key] = settings_[key];
-    }
-  }
-  return 0u == inv.size();
-}
-Value& CharReaderBuilder::operator[](JSONCPP_STRING key)
-{
-  return settings_[key];
-}
-// static
-void CharReaderBuilder::strictMode(Value* settings)
-{
-//! [CharReaderBuilderStrictMode]
-  (*settings)["allowComments"] = false;
-  (*settings)["strictRoot"] = true;
-  (*settings)["allowDroppedNullPlaceholders"] = false;
-  (*settings)["allowNumericKeys"] = false;
-  (*settings)["allowSingleQuotes"] = false;
-  (*settings)["stackLimit"] = 1000;
-  (*settings)["failIfExtra"] = true;
-  (*settings)["rejectDupKeys"] = true;
-  (*settings)["allowSpecialFloats"] = false;
-//! [CharReaderBuilderStrictMode]
-}
-// static
-void CharReaderBuilder::setDefaults(Value* settings)
-{
-//! [CharReaderBuilderDefaults]
-  (*settings)["collectComments"] = true;
-  (*settings)["allowComments"] = true;
-  (*settings)["strictRoot"] = false;
-  (*settings)["allowDroppedNullPlaceholders"] = false;
-  (*settings)["allowNumericKeys"] = false;
-  (*settings)["allowSingleQuotes"] = false;
-  (*settings)["stackLimit"] = 1000;
-  (*settings)["failIfExtra"] = false;
-  (*settings)["rejectDupKeys"] = false;
-  (*settings)["allowSpecialFloats"] = false;
-//! [CharReaderBuilderDefaults]
-}
-
-//////////////////////////////////
-// global functions
-
-bool parseFromStream(
-    CharReader::Factory const& fact, JSONCPP_ISTREAM& sin,
-    Value* root, JSONCPP_STRING* errs)
-{
-  JSONCPP_OSTRINGSTREAM ssin;
-  ssin << sin.rdbuf();
-  JSONCPP_STRING doc = ssin.str();
-  char const* begin = doc.data();
-  char const* end = begin + doc.size();
-  // Note that we do not actually need a null-terminator.
-  CharReaderPtr const reader(fact.newCharReader());
-  return reader->parse(begin, end, root, errs);
-}
-
-JSONCPP_ISTREAM& operator>>(JSONCPP_ISTREAM& sin, Value& root) {
-  CharReaderBuilder b;
-  JSONCPP_STRING errs;
-  bool ok = parseFromStream(b, sin, &root, &errs);
-  if (!ok) {
-    fprintf(stderr,
-            "Error from reader: %s",
-            errs.c_str());
-
-    throwRuntimeError(errs);
-  }
-  return sin;
-}
-
-} // namespace Json
-} // namespace rmq
-

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/b9bb6cfa/rocketmq-client4cpp/src/jsoncpp/json_tool.h
----------------------------------------------------------------------
diff --git a/rocketmq-client4cpp/src/jsoncpp/json_tool.h b/rocketmq-client4cpp/src/jsoncpp/json_tool.h
deleted file mode 100755
index fa4a473..0000000
--- a/rocketmq-client4cpp/src/jsoncpp/json_tool.h
+++ /dev/null
@@ -1,113 +0,0 @@
-// Copyright 2007-2010 Baptiste Lepilleur
-// Distributed under MIT license, or public domain if desired and
-// recognized in your jurisdiction.
-// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
-
-#ifndef LIB_JSONCPP_JSON_TOOL_H_INCLUDED
-#define LIB_JSONCPP_JSON_TOOL_H_INCLUDED
-
-#ifndef NO_LOCALE_SUPPORT
-#include <clocale>
-#endif
-
-/* This header provides common string manipulation support, such as UTF-8,
- * portable conversion from/to string...
- *
- * It is an internal header that must not be exposed.
- */
-
-namespace rmq {
-namespace Json {
-static char getDecimalPoint() {
-#ifdef NO_LOCALE_SUPPORT
-  return '\0';
-#else
-  struct lconv* lc = localeconv();
-  return lc ? *(lc->decimal_point) : '\0';
-#endif
-}
-
-/// Converts a unicode code-point to UTF-8.
-static inline JSONCPP_STRING codePointToUTF8(unsigned int cp) {
-  JSONCPP_STRING result;
-
-  // based on description from http://en.wikipedia.org/wiki/UTF-8
-
-  if (cp <= 0x7f) {
-    result.resize(1);
-    result[0] = static_cast<char>(cp);
-  } else if (cp <= 0x7FF) {
-    result.resize(2);
-    result[1] = static_cast<char>(0x80 | (0x3f & cp));
-    result[0] = static_cast<char>(0xC0 | (0x1f & (cp >> 6)));
-  } else if (cp <= 0xFFFF) {
-    result.resize(3);
-    result[2] = static_cast<char>(0x80 | (0x3f & cp));
-    result[1] = static_cast<char>(0x80 | (0x3f & (cp >> 6)));
-    result[0] = static_cast<char>(0xE0 | (0xf & (cp >> 12)));
-  } else if (cp <= 0x10FFFF) {
-    result.resize(4);
-    result[3] = static_cast<char>(0x80 | (0x3f & cp));
-    result[2] = static_cast<char>(0x80 | (0x3f & (cp >> 6)));
-    result[1] = static_cast<char>(0x80 | (0x3f & (cp >> 12)));
-    result[0] = static_cast<char>(0xF0 | (0x7 & (cp >> 18)));
-  }
-
-  return result;
-}
-
-/// Returns true if ch is a control character (in range [1,31]).
-static inline bool isControlCharacter(char ch) { return ch > 0 && ch <= 0x1F; }
-
-enum {
-  /// Constant that specify the size of the buffer that must be passed to
-  /// uintToString.
-  uintToStringBufferSize = 3 * sizeof(LargestUInt) + 1
-};
-
-// Defines a char buffer for use with uintToString().
-typedef char UIntToStringBuffer[uintToStringBufferSize];
-
-/** Converts an unsigned integer to string.
- * @param value Unsigned interger to convert to string
- * @param current Input/Output string buffer.
- *        Must have at least uintToStringBufferSize chars free.
- */
-static inline void uintToString(LargestUInt value, char*& current) {
-  *--current = 0;
-  do {
-    *--current = static_cast<char>(value % 10U + static_cast<unsigned>('0'));
-    value /= 10;
-  } while (value != 0);
-}
-
-/** Change ',' to '.' everywhere in buffer.
- *
- * We had a sophisticated way, but it did not work in WinCE.
- * @see https://github.com/open-source-parsers/jsoncpp/pull/9
- */
-static inline void fixNumericLocale(char* begin, char* end) {
-  while (begin < end) {
-    if (*begin == ',') {
-      *begin = '.';
-    }
-    ++begin;
-  }
-}
-
-static inline void fixNumericLocaleInput(char* begin, char* end) {
-  char decimalPoint = getDecimalPoint();
-  if (decimalPoint != '\0' && decimalPoint != '.') {
-    while (begin < end) {
-      if (*begin == '.') {
-        *begin = decimalPoint;
-      }
-      ++begin;
-    }
-  }
-}
-
-} // namespace Json
-} // namespace rmq
-
-#endif // LIB_JSONCPP_JSON_TOOL_H_INCLUDED