diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..261eeb9
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,201 @@
+ 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.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..53e64d6
--- /dev/null
+++ b/README.md
@@ -0,0 +1,156 @@
+# octo-ns
+
+## 背景及概念
+
+ octo-ns
+ 是美团octo服务治理体系中负责命名服务的系列模块,包括[c++ sdk](sdk/mns-sdk/docs/mns_sdk_api.md)、[java
+ sdk](sdk/mns-invoker)、
+ [基础代理sgagent](sg_agent)、[命名服务缓存nsc](nsc)、[健康检查服务scanner](scanner)、[zookeeper](https://zookeeper.apache.org/)
+ ,搭配管理平台 [octo-portal](https://github.com/Meituan-Dianping/octo-portal) 用户能够便捷的进行服务运营交互。
+
+ octo-ns
+ 基于服务描述信息(tags+weight)实现服务注册/发现、路由分组、负载均衡、健康检测等功能,利用这些服务治理功能用户可以专注于业务逻辑开发、能够追踪线上服务状态、快速处置异常风险。octo-ns提升了业务对于服务的运营能力,其总体架构图如下:
+
+
+
+* 服务service
+
+ 通过自定义接口提供给消费端的软件功能,octo目前支持rpc、http服务。
+
+* 服务名 servicename
+
+ 服务标识,可映射到指定服务;octo体系中通过appkey字段表示服务名。
+
+* 服务提供者 service provider
+
+ 是指提供服务的被调用一方。
+
+* 服务消费者 service consumer
+
+ 是指发起对某个服务调用的一方。
+
+* 注册中心
+
+ 注册中心存储服务描述信息用以实现命名服务整个功能。服务在启动时将服务信息上报到注册中心,服务消费者从注册中心获取对应的服务提供者信息。健康检查组件会根据对服务节点的检测结果更新注册中心服务状态信息。
+
+* 服务注册(service registry)
+
+ 服务提供者启用后向注册中心上报服务信息的流程。
+
+* 服务发现(service discovery)
+
+ 服务消费者获取服务提供者信息的流程。
+
+* 权重
+
+ 浮点数,是负载均衡抉择服务端流量配比的重要指标;业务和路由规则会对权重进行调整。
+
+* 服务分组(service group)
+
+ 是业务自定义的服务提供者和服务消费者之间的调用约束关系。
+
+* 健康检查(health check)
+
+ 服务节点的端口/进程存活状态的检查。octo-ns体系中通过scanner执行健康扫描,并更新服务描述信息到注册中心。
+
+## 架构特点
+* 模块解耦功能拆分
+
+ 通信框架(c++版本whale、java版本dorado)、服务治理代理(sgagent)、健康检查服务(scanner)、服务治理平台(octo-portal)。
+
+* 代理模式轻量化框架
+
+ 服务治理策略实现下移到代理组件sgagent,精简框架功能,提升框架稳定性。
+
+
+
+
+
+* 水平扩展的代理模块(sgagent)
+ 如上所述,sgagent实现了服务治理如注册、发现、路由、策略等重要功能,简化服务消费者和服务提供者使用的通信框架。
+
+ 服务治理代理从部署上分为本地和哨兵模式两种,当本地sdk到sgagent不可用时可切换到哨兵集群,保证服务平滑扩展。
+
+* 统一服务状态检查服务(scanner)
+
+ scanner以周期扫描形式对服务进行探活检测,并更新服务状态到注册中心。
+
+* 高可用
+
+ 调用链容灾:octo-ns各组件的本地缓存机制,提升了整体系统的容灾能力。链路中后台的某个组件发生故障时,可以使用缓存正常提供服务治理功能。
+
+ 哨兵模式:本地sgagent不可用时,降级(fallback)到哨兵集群进行服务治理。
+
+## 架构介绍
+
+
+ octo-ns由sdk、sgagent、nsc、scanner和zookeeper组成,使用octo-portal管理端实现可视化服务营运操作,例如更改服务提供者状态、调整权重。服务提供者启动后,通信框架主动发起注册操作,上报服务描述信息接入octo-ns。接下来分模块对octo-ns进行介绍。
+
+
+### 服务治理代理sgagent
+
+ **服务注册/发现**:这是命名服务的基本功能,注册是提供者上报服务描述信息;发现是消费者根据appkey获取对应服务描述信息。分为增量和通用两种方式,通用方式是指添加provider的服务描述信息到对应appkey下面,为服务列表增加新的成员;增量方式是指一个包含多种servicename接口类型的apppkey,通过在注册中心建立servicename和appkey的双向映射,可实现servicename粒度的服务注册/发现功能。
+
+ **服务分组**:根据分组信息,sgagent调整服务节点权重,定制化流量负载。用户可根据需求自定义分组规则,服务分组需要进行事先配置,启动后方能生效。不同分组规则根据优先级排序,优先级高者生效。执行服务分组规则时,对于服务列表中匹配失败的节点进行降权处理,流量极低概率进入降权后的节点(未来管理页面将提供可选按钮,决定降权还是删除规则外服务节点)。目前支持的服务分组策略如下:
+
+ a.自定义路由分组:在服务端配置该策略后,可定向指定上游打入下游规则范围内的服务节点
+
+ b.同机房优先分组:开启后,服务列表中与调用方非同机房的服务节点被降权
+
+ c.同中心优先分组:开启后,服务列表中与调用方非同中心的服务节点被降权
+
+ d.同城市路由分组:开启后,服务列表中与调用方非同城的服务节点被降权
+
+ **标签隔离**:依据服务节点中标识的不同标签,实现灵活的流量和链路隔离。服务注册时在服务描述信息中携带标签信息,服务发现时过滤服务列表中持有标签的服务提供者。例如:用以隔离测试的泳道标签,用以单元化部署和灰度链路的单元化标签。
+
+### 缓存服务nsc
+
+ 缓存注册到octo-ns的服务描述信息,一方面提供批量服务数据缓存与预处理功能,提升服务发现性能;另一方面增强服务治理链路的容灾能力,本地sgagent不可用的场景下该模块通过http形式提供远程哨兵服务列表。
+### 服务健康scanner
+
+ 健康检查模块负责实时检查注册中心的服务提供者健康状况,一旦发现服务提供者不可用就将其置为未启动状态,及时摘除流量;当服务提供者恢复正常时,scanner会及时将服务提供者的状态置为正常状态,恢复流量。服务整个生命周期内,octo-ns利用scanner实现自动化的流量摘除和恢复,无需业务手动介入。为了提高检查的准确性,scanner支持octo自定义的心跳协议来进行应用层检查,octo体系内的通信框架默认支持,无需额外配置。
+
+### 功能流程
+
+* 服务注册
+
+ 业务进程启动后,通信框架发起服务注册,依赖sgagent上报服务描述信息到注册中心。本地sgagent失效时,sdk通过nsc服务获取远程sgagent哨兵机器列表信息,注册请求fallback到哨兵集群完成整个流程。服务提供者服务描述信息数据存入注册中心后,可从octo-portal管理页面进行查阅和修改。
+
+
+
+
+* 服务发现
+
+ octo-ns支持基于http和rpc的服务发现,服务消费者可通过调用sgagent服务发现接口获取服务提供者列表。sgagent会优先从nsc
+ 进行服务发现,从nsc服务发现失败时会降级从zookeeper获取服务提供者数据。
+
+* 健康检查
+
+ scanner运行时会不断扫描注册中心的服务节点,依次检查每个服务提供者状态情况,按需修改服务描述信息。
+
+
+
+## 使用文档
+
+* [快速开始](/docs/ns-quick-start.md)
+
+
+## 未来规划
+
+* 注册中心ap化:将注册中心从目前基于zookeeper的cp系统演进为ap系统,在保证最终一致性的前提下以可用性为优先目标。
+* service mesh:sgagent借鉴时下盛行的mesh理念,进一步简化通信框架和SDK功能逻辑。
+
+
+
+**Copyright and License**
+
+[Apache 2.0 License](/LICENSE)
+
+
+##### 联系我们
+
+ * Mail: inf.octo.os@meituan.com
+- [**Issues**](https://github.com/Meituan-Dianping/octo-ns/issues)
+
+
+
diff --git a/common/gen-cpp/MNSCacheService.cpp b/common/gen-cpp/MNSCacheService.cpp
new file mode 100644
index 0000000..289776a
--- /dev/null
+++ b/common/gen-cpp/MNSCacheService.cpp
@@ -0,0 +1,1786 @@
+/**
+ * Autogenerated by Thrift Compiler (0.8.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ * @generated
+ */
+#include "MNSCacheService.h"
+
+namespace meituan_mns {
+
+uint32_t MNSCacheService_getMNSCache_args::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 1:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->appkey);
+ this->__isset.appkey = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 2:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->version);
+ this->__isset.version = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 3:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->env);
+ this->__isset.env = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t MNSCacheService_getMNSCache_args::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("MNSCacheService_getMNSCache_args");
+ xfer += oprot->writeFieldBegin("appkey", ::apache::thrift::protocol::T_STRING, 1);
+ xfer += oprot->writeString(this->appkey);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("version", ::apache::thrift::protocol::T_STRING, 2);
+ xfer += oprot->writeString(this->version);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("env", ::apache::thrift::protocol::T_STRING, 3);
+ xfer += oprot->writeString(this->env);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+uint32_t MNSCacheService_getMNSCache_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("MNSCacheService_getMNSCache_pargs");
+ xfer += oprot->writeFieldBegin("appkey", ::apache::thrift::protocol::T_STRING, 1);
+ xfer += oprot->writeString((*(this->appkey)));
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("version", ::apache::thrift::protocol::T_STRING, 2);
+ xfer += oprot->writeString((*(this->version)));
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("env", ::apache::thrift::protocol::T_STRING, 3);
+ xfer += oprot->writeString((*(this->env)));
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+uint32_t MNSCacheService_getMNSCache_result::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 0:
+ if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+ xfer += this->success.read(iprot);
+ this->__isset.success = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t MNSCacheService_getMNSCache_result::write(::apache::thrift::protocol::TProtocol* oprot) const {
+
+ uint32_t xfer = 0;
+
+ xfer += oprot->writeStructBegin("MNSCacheService_getMNSCache_result");
+
+ if (this->__isset.success) {
+ xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_STRUCT, 0);
+ xfer += this->success.write(oprot);
+ xfer += oprot->writeFieldEnd();
+ }
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+uint32_t MNSCacheService_getMNSCache_presult::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 0:
+ if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+ xfer += (*(this->success)).read(iprot);
+ this->__isset.success = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t MNSCacheService_getMNSCacheHttp_args::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 1:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->appkey);
+ this->__isset.appkey = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 2:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->version);
+ this->__isset.version = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 3:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->env);
+ this->__isset.env = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t MNSCacheService_getMNSCacheHttp_args::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("MNSCacheService_getMNSCacheHttp_args");
+ xfer += oprot->writeFieldBegin("appkey", ::apache::thrift::protocol::T_STRING, 1);
+ xfer += oprot->writeString(this->appkey);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("version", ::apache::thrift::protocol::T_STRING, 2);
+ xfer += oprot->writeString(this->version);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("env", ::apache::thrift::protocol::T_STRING, 3);
+ xfer += oprot->writeString(this->env);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+uint32_t MNSCacheService_getMNSCacheHttp_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("MNSCacheService_getMNSCacheHttp_pargs");
+ xfer += oprot->writeFieldBegin("appkey", ::apache::thrift::protocol::T_STRING, 1);
+ xfer += oprot->writeString((*(this->appkey)));
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("version", ::apache::thrift::protocol::T_STRING, 2);
+ xfer += oprot->writeString((*(this->version)));
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("env", ::apache::thrift::protocol::T_STRING, 3);
+ xfer += oprot->writeString((*(this->env)));
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+uint32_t MNSCacheService_getMNSCacheHttp_result::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 0:
+ if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+ xfer += this->success.read(iprot);
+ this->__isset.success = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t MNSCacheService_getMNSCacheHttp_result::write(::apache::thrift::protocol::TProtocol* oprot) const {
+
+ uint32_t xfer = 0;
+
+ xfer += oprot->writeStructBegin("MNSCacheService_getMNSCacheHttp_result");
+
+ if (this->__isset.success) {
+ xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_STRUCT, 0);
+ xfer += this->success.write(oprot);
+ xfer += oprot->writeFieldEnd();
+ }
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+uint32_t MNSCacheService_getMNSCacheHttp_presult::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 0:
+ if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+ xfer += (*(this->success)).read(iprot);
+ this->__isset.success = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t MNSCacheService_getMNSCacheWithVersionCheck_args::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 1:
+ if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+ xfer += this->req.read(iprot);
+ this->__isset.req = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t MNSCacheService_getMNSCacheWithVersionCheck_args::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("MNSCacheService_getMNSCacheWithVersionCheck_args");
+ xfer += oprot->writeFieldBegin("req", ::apache::thrift::protocol::T_STRUCT, 1);
+ xfer += this->req.write(oprot);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+uint32_t MNSCacheService_getMNSCacheWithVersionCheck_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("MNSCacheService_getMNSCacheWithVersionCheck_pargs");
+ xfer += oprot->writeFieldBegin("req", ::apache::thrift::protocol::T_STRUCT, 1);
+ xfer += (*(this->req)).write(oprot);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+uint32_t MNSCacheService_getMNSCacheWithVersionCheck_result::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 0:
+ if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+ xfer += this->success.read(iprot);
+ this->__isset.success = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t MNSCacheService_getMNSCacheWithVersionCheck_result::write(::apache::thrift::protocol::TProtocol* oprot) const {
+
+ uint32_t xfer = 0;
+
+ xfer += oprot->writeStructBegin("MNSCacheService_getMNSCacheWithVersionCheck_result");
+
+ if (this->__isset.success) {
+ xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_STRUCT, 0);
+ xfer += this->success.write(oprot);
+ xfer += oprot->writeFieldEnd();
+ }
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+uint32_t MNSCacheService_getMNSCacheWithVersionCheck_presult::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 0:
+ if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+ xfer += (*(this->success)).read(iprot);
+ this->__isset.success = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t MNSCacheService_getMNSCacheByAppkeys_args::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 1:
+ if (ftype == ::apache::thrift::protocol::T_LIST) {
+ {
+ this->appkeys.clear();
+ uint32_t _size0;
+ ::apache::thrift::protocol::TType _etype3;
+ iprot->readListBegin(_etype3, _size0);
+ this->appkeys.resize(_size0);
+ uint32_t _i4;
+ for (_i4 = 0; _i4 < _size0; ++_i4)
+ {
+ xfer += iprot->readString(this->appkeys[_i4]);
+ }
+ iprot->readListEnd();
+ }
+ this->__isset.appkeys = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 2:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->protocol);
+ this->__isset.protocol = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t MNSCacheService_getMNSCacheByAppkeys_args::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("MNSCacheService_getMNSCacheByAppkeys_args");
+ xfer += oprot->writeFieldBegin("appkeys", ::apache::thrift::protocol::T_LIST, 1);
+ {
+ xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast(this->appkeys.size()));
+ std::vector ::const_iterator _iter5;
+ for (_iter5 = this->appkeys.begin(); _iter5 != this->appkeys.end(); ++_iter5)
+ {
+ xfer += oprot->writeString((*_iter5));
+ }
+ xfer += oprot->writeListEnd();
+ }
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("protocol", ::apache::thrift::protocol::T_STRING, 2);
+ xfer += oprot->writeString(this->protocol);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+uint32_t MNSCacheService_getMNSCacheByAppkeys_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("MNSCacheService_getMNSCacheByAppkeys_pargs");
+ xfer += oprot->writeFieldBegin("appkeys", ::apache::thrift::protocol::T_LIST, 1);
+ {
+ xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast((*(this->appkeys)).size()));
+ std::vector ::const_iterator _iter6;
+ for (_iter6 = (*(this->appkeys)).begin(); _iter6 != (*(this->appkeys)).end(); ++_iter6)
+ {
+ xfer += oprot->writeString((*_iter6));
+ }
+ xfer += oprot->writeListEnd();
+ }
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("protocol", ::apache::thrift::protocol::T_STRING, 2);
+ xfer += oprot->writeString((*(this->protocol)));
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+uint32_t MNSCacheService_getMNSCacheByAppkeys_result::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 0:
+ if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+ xfer += this->success.read(iprot);
+ this->__isset.success = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t MNSCacheService_getMNSCacheByAppkeys_result::write(::apache::thrift::protocol::TProtocol* oprot) const {
+
+ uint32_t xfer = 0;
+
+ xfer += oprot->writeStructBegin("MNSCacheService_getMNSCacheByAppkeys_result");
+
+ if (this->__isset.success) {
+ xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_STRUCT, 0);
+ xfer += this->success.write(oprot);
+ xfer += oprot->writeFieldEnd();
+ }
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+uint32_t MNSCacheService_getMNSCacheByAppkeys_presult::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 0:
+ if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+ xfer += (*(this->success)).read(iprot);
+ this->__isset.success = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t MNSCacheService_getProvidersByIP_args::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 1:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->ip);
+ this->__isset.ip = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t MNSCacheService_getProvidersByIP_args::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("MNSCacheService_getProvidersByIP_args");
+ xfer += oprot->writeFieldBegin("ip", ::apache::thrift::protocol::T_STRING, 1);
+ xfer += oprot->writeString(this->ip);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+uint32_t MNSCacheService_getProvidersByIP_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("MNSCacheService_getProvidersByIP_pargs");
+ xfer += oprot->writeFieldBegin("ip", ::apache::thrift::protocol::T_STRING, 1);
+ xfer += oprot->writeString((*(this->ip)));
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+uint32_t MNSCacheService_getProvidersByIP_result::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 0:
+ if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+ xfer += this->success.read(iprot);
+ this->__isset.success = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t MNSCacheService_getProvidersByIP_result::write(::apache::thrift::protocol::TProtocol* oprot) const {
+
+ uint32_t xfer = 0;
+
+ xfer += oprot->writeStructBegin("MNSCacheService_getProvidersByIP_result");
+
+ if (this->__isset.success) {
+ xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_STRUCT, 0);
+ xfer += this->success.write(oprot);
+ xfer += oprot->writeFieldEnd();
+ }
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+uint32_t MNSCacheService_getProvidersByIP_presult::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 0:
+ if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+ xfer += (*(this->success)).read(iprot);
+ this->__isset.success = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t MNSCacheService_getAppkeyListByIP_args::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 1:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->ip);
+ this->__isset.ip = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t MNSCacheService_getAppkeyListByIP_args::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("MNSCacheService_getAppkeyListByIP_args");
+ xfer += oprot->writeFieldBegin("ip", ::apache::thrift::protocol::T_STRING, 1);
+ xfer += oprot->writeString(this->ip);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+uint32_t MNSCacheService_getAppkeyListByIP_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("MNSCacheService_getAppkeyListByIP_pargs");
+ xfer += oprot->writeFieldBegin("ip", ::apache::thrift::protocol::T_STRING, 1);
+ xfer += oprot->writeString((*(this->ip)));
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+uint32_t MNSCacheService_getAppkeyListByIP_result::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 0:
+ if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+ xfer += this->success.read(iprot);
+ this->__isset.success = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t MNSCacheService_getAppkeyListByIP_result::write(::apache::thrift::protocol::TProtocol* oprot) const {
+
+ uint32_t xfer = 0;
+
+ xfer += oprot->writeStructBegin("MNSCacheService_getAppkeyListByIP_result");
+
+ if (this->__isset.success) {
+ xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_STRUCT, 0);
+ xfer += this->success.write(oprot);
+ xfer += oprot->writeFieldEnd();
+ }
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+uint32_t MNSCacheService_getAppkeyListByIP_presult::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 0:
+ if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+ xfer += (*(this->success)).read(iprot);
+ this->__isset.success = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+void MNSCacheServiceClient::getMNSCache(MNSResponse& _return, const std::string& appkey, const std::string& version, const std::string& env)
+{
+ send_getMNSCache(appkey, version, env);
+ recv_getMNSCache(_return);
+}
+
+void MNSCacheServiceClient::send_getMNSCache(const std::string& appkey, const std::string& version, const std::string& env)
+{
+ int32_t cseqid = 0;
+ oprot_->writeMessageBegin("getMNSCache", ::apache::thrift::protocol::T_CALL, cseqid);
+
+ MNSCacheService_getMNSCache_pargs args;
+ args.appkey = &appkey;
+ args.version = &version;
+ args.env = &env;
+ args.write(oprot_);
+
+ oprot_->writeMessageEnd();
+ oprot_->getTransport()->writeEnd();
+ oprot_->getTransport()->flush();
+}
+
+void MNSCacheServiceClient::recv_getMNSCache(MNSResponse& _return)
+{
+
+ int32_t rseqid = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TMessageType mtype;
+
+ iprot_->readMessageBegin(fname, mtype, rseqid);
+ if (mtype == ::apache::thrift::protocol::T_EXCEPTION) {
+ ::apache::thrift::TApplicationException x;
+ x.read(iprot_);
+ iprot_->readMessageEnd();
+ iprot_->getTransport()->readEnd();
+ throw x;
+ }
+ if (mtype != ::apache::thrift::protocol::T_REPLY) {
+ iprot_->skip(::apache::thrift::protocol::T_STRUCT);
+ iprot_->readMessageEnd();
+ iprot_->getTransport()->readEnd();
+ }
+ if (fname.compare("getMNSCache") != 0) {
+ iprot_->skip(::apache::thrift::protocol::T_STRUCT);
+ iprot_->readMessageEnd();
+ iprot_->getTransport()->readEnd();
+ }
+ MNSCacheService_getMNSCache_presult result;
+ result.success = &_return;
+ result.read(iprot_);
+ iprot_->readMessageEnd();
+ iprot_->getTransport()->readEnd();
+
+ if (result.__isset.success) {
+ // _return pointer has now been filled
+ return;
+ }
+ throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "getMNSCache failed: unknown result");
+}
+
+void MNSCacheServiceClient::getMNSCacheHttp(MNSResponse& _return, const std::string& appkey, const std::string& version, const std::string& env)
+{
+ send_getMNSCacheHttp(appkey, version, env);
+ recv_getMNSCacheHttp(_return);
+}
+
+void MNSCacheServiceClient::send_getMNSCacheHttp(const std::string& appkey, const std::string& version, const std::string& env)
+{
+ int32_t cseqid = 0;
+ oprot_->writeMessageBegin("getMNSCacheHttp", ::apache::thrift::protocol::T_CALL, cseqid);
+
+ MNSCacheService_getMNSCacheHttp_pargs args;
+ args.appkey = &appkey;
+ args.version = &version;
+ args.env = &env;
+ args.write(oprot_);
+
+ oprot_->writeMessageEnd();
+ oprot_->getTransport()->writeEnd();
+ oprot_->getTransport()->flush();
+}
+
+void MNSCacheServiceClient::recv_getMNSCacheHttp(MNSResponse& _return)
+{
+
+ int32_t rseqid = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TMessageType mtype;
+
+ iprot_->readMessageBegin(fname, mtype, rseqid);
+ if (mtype == ::apache::thrift::protocol::T_EXCEPTION) {
+ ::apache::thrift::TApplicationException x;
+ x.read(iprot_);
+ iprot_->readMessageEnd();
+ iprot_->getTransport()->readEnd();
+ throw x;
+ }
+ if (mtype != ::apache::thrift::protocol::T_REPLY) {
+ iprot_->skip(::apache::thrift::protocol::T_STRUCT);
+ iprot_->readMessageEnd();
+ iprot_->getTransport()->readEnd();
+ }
+ if (fname.compare("getMNSCacheHttp") != 0) {
+ iprot_->skip(::apache::thrift::protocol::T_STRUCT);
+ iprot_->readMessageEnd();
+ iprot_->getTransport()->readEnd();
+ }
+ MNSCacheService_getMNSCacheHttp_presult result;
+ result.success = &_return;
+ result.read(iprot_);
+ iprot_->readMessageEnd();
+ iprot_->getTransport()->readEnd();
+
+ if (result.__isset.success) {
+ // _return pointer has now been filled
+ return;
+ }
+ throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "getMNSCacheHttp failed: unknown result");
+}
+
+void MNSCacheServiceClient::getMNSCacheWithVersionCheck(MNSResponse& _return, const MnsRequest& req)
+{
+ send_getMNSCacheWithVersionCheck(req);
+ recv_getMNSCacheWithVersionCheck(_return);
+}
+
+void MNSCacheServiceClient::send_getMNSCacheWithVersionCheck(const MnsRequest& req)
+{
+ int32_t cseqid = 0;
+ oprot_->writeMessageBegin("getMNSCacheWithVersionCheck", ::apache::thrift::protocol::T_CALL, cseqid);
+
+ MNSCacheService_getMNSCacheWithVersionCheck_pargs args;
+ args.req = &req;
+ args.write(oprot_);
+
+ oprot_->writeMessageEnd();
+ oprot_->getTransport()->writeEnd();
+ oprot_->getTransport()->flush();
+}
+
+void MNSCacheServiceClient::recv_getMNSCacheWithVersionCheck(MNSResponse& _return)
+{
+
+ int32_t rseqid = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TMessageType mtype;
+
+ iprot_->readMessageBegin(fname, mtype, rseqid);
+ if (mtype == ::apache::thrift::protocol::T_EXCEPTION) {
+ ::apache::thrift::TApplicationException x;
+ x.read(iprot_);
+ iprot_->readMessageEnd();
+ iprot_->getTransport()->readEnd();
+ throw x;
+ }
+ if (mtype != ::apache::thrift::protocol::T_REPLY) {
+ iprot_->skip(::apache::thrift::protocol::T_STRUCT);
+ iprot_->readMessageEnd();
+ iprot_->getTransport()->readEnd();
+ }
+ if (fname.compare("getMNSCacheWithVersionCheck") != 0) {
+ iprot_->skip(::apache::thrift::protocol::T_STRUCT);
+ iprot_->readMessageEnd();
+ iprot_->getTransport()->readEnd();
+ }
+ MNSCacheService_getMNSCacheWithVersionCheck_presult result;
+ result.success = &_return;
+ result.read(iprot_);
+ iprot_->readMessageEnd();
+ iprot_->getTransport()->readEnd();
+
+ if (result.__isset.success) {
+ // _return pointer has now been filled
+ return;
+ }
+ throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "getMNSCacheWithVersionCheck failed: unknown result");
+}
+
+void MNSCacheServiceClient::getMNSCacheByAppkeys(MNSBatchResponse& _return, const std::vector & appkeys, const std::string& protocol)
+{
+ send_getMNSCacheByAppkeys(appkeys, protocol);
+ recv_getMNSCacheByAppkeys(_return);
+}
+
+void MNSCacheServiceClient::send_getMNSCacheByAppkeys(const std::vector & appkeys, const std::string& protocol)
+{
+ int32_t cseqid = 0;
+ oprot_->writeMessageBegin("getMNSCacheByAppkeys", ::apache::thrift::protocol::T_CALL, cseqid);
+
+ MNSCacheService_getMNSCacheByAppkeys_pargs args;
+ args.appkeys = &appkeys;
+ args.protocol = &protocol;
+ args.write(oprot_);
+
+ oprot_->writeMessageEnd();
+ oprot_->getTransport()->writeEnd();
+ oprot_->getTransport()->flush();
+}
+
+void MNSCacheServiceClient::recv_getMNSCacheByAppkeys(MNSBatchResponse& _return)
+{
+
+ int32_t rseqid = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TMessageType mtype;
+
+ iprot_->readMessageBegin(fname, mtype, rseqid);
+ if (mtype == ::apache::thrift::protocol::T_EXCEPTION) {
+ ::apache::thrift::TApplicationException x;
+ x.read(iprot_);
+ iprot_->readMessageEnd();
+ iprot_->getTransport()->readEnd();
+ throw x;
+ }
+ if (mtype != ::apache::thrift::protocol::T_REPLY) {
+ iprot_->skip(::apache::thrift::protocol::T_STRUCT);
+ iprot_->readMessageEnd();
+ iprot_->getTransport()->readEnd();
+ }
+ if (fname.compare("getMNSCacheByAppkeys") != 0) {
+ iprot_->skip(::apache::thrift::protocol::T_STRUCT);
+ iprot_->readMessageEnd();
+ iprot_->getTransport()->readEnd();
+ }
+ MNSCacheService_getMNSCacheByAppkeys_presult result;
+ result.success = &_return;
+ result.read(iprot_);
+ iprot_->readMessageEnd();
+ iprot_->getTransport()->readEnd();
+
+ if (result.__isset.success) {
+ // _return pointer has now been filled
+ return;
+ }
+ throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "getMNSCacheByAppkeys failed: unknown result");
+}
+
+void MNSCacheServiceClient::getProvidersByIP(MNSResponse& _return, const std::string& ip)
+{
+ send_getProvidersByIP(ip);
+ recv_getProvidersByIP(_return);
+}
+
+void MNSCacheServiceClient::send_getProvidersByIP(const std::string& ip)
+{
+ int32_t cseqid = 0;
+ oprot_->writeMessageBegin("getProvidersByIP", ::apache::thrift::protocol::T_CALL, cseqid);
+
+ MNSCacheService_getProvidersByIP_pargs args;
+ args.ip = &ip;
+ args.write(oprot_);
+
+ oprot_->writeMessageEnd();
+ oprot_->getTransport()->writeEnd();
+ oprot_->getTransport()->flush();
+}
+
+void MNSCacheServiceClient::recv_getProvidersByIP(MNSResponse& _return)
+{
+
+ int32_t rseqid = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TMessageType mtype;
+
+ iprot_->readMessageBegin(fname, mtype, rseqid);
+ if (mtype == ::apache::thrift::protocol::T_EXCEPTION) {
+ ::apache::thrift::TApplicationException x;
+ x.read(iprot_);
+ iprot_->readMessageEnd();
+ iprot_->getTransport()->readEnd();
+ throw x;
+ }
+ if (mtype != ::apache::thrift::protocol::T_REPLY) {
+ iprot_->skip(::apache::thrift::protocol::T_STRUCT);
+ iprot_->readMessageEnd();
+ iprot_->getTransport()->readEnd();
+ }
+ if (fname.compare("getProvidersByIP") != 0) {
+ iprot_->skip(::apache::thrift::protocol::T_STRUCT);
+ iprot_->readMessageEnd();
+ iprot_->getTransport()->readEnd();
+ }
+ MNSCacheService_getProvidersByIP_presult result;
+ result.success = &_return;
+ result.read(iprot_);
+ iprot_->readMessageEnd();
+ iprot_->getTransport()->readEnd();
+
+ if (result.__isset.success) {
+ // _return pointer has now been filled
+ return;
+ }
+ throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "getProvidersByIP failed: unknown result");
+}
+
+void MNSCacheServiceClient::getAppkeyListByIP(AppKeyListResponse& _return, const std::string& ip)
+{
+ send_getAppkeyListByIP(ip);
+ recv_getAppkeyListByIP(_return);
+}
+
+void MNSCacheServiceClient::send_getAppkeyListByIP(const std::string& ip)
+{
+ int32_t cseqid = 0;
+ oprot_->writeMessageBegin("getAppkeyListByIP", ::apache::thrift::protocol::T_CALL, cseqid);
+
+ MNSCacheService_getAppkeyListByIP_pargs args;
+ args.ip = &ip;
+ args.write(oprot_);
+
+ oprot_->writeMessageEnd();
+ oprot_->getTransport()->writeEnd();
+ oprot_->getTransport()->flush();
+}
+
+void MNSCacheServiceClient::recv_getAppkeyListByIP(AppKeyListResponse& _return)
+{
+
+ int32_t rseqid = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TMessageType mtype;
+
+ iprot_->readMessageBegin(fname, mtype, rseqid);
+ if (mtype == ::apache::thrift::protocol::T_EXCEPTION) {
+ ::apache::thrift::TApplicationException x;
+ x.read(iprot_);
+ iprot_->readMessageEnd();
+ iprot_->getTransport()->readEnd();
+ throw x;
+ }
+ if (mtype != ::apache::thrift::protocol::T_REPLY) {
+ iprot_->skip(::apache::thrift::protocol::T_STRUCT);
+ iprot_->readMessageEnd();
+ iprot_->getTransport()->readEnd();
+ }
+ if (fname.compare("getAppkeyListByIP") != 0) {
+ iprot_->skip(::apache::thrift::protocol::T_STRUCT);
+ iprot_->readMessageEnd();
+ iprot_->getTransport()->readEnd();
+ }
+ MNSCacheService_getAppkeyListByIP_presult result;
+ result.success = &_return;
+ result.read(iprot_);
+ iprot_->readMessageEnd();
+ iprot_->getTransport()->readEnd();
+
+ if (result.__isset.success) {
+ // _return pointer has now been filled
+ return;
+ }
+ throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "getAppkeyListByIP failed: unknown result");
+}
+
+bool MNSCacheServiceProcessor::process(boost::shared_ptr piprot, boost::shared_ptr poprot, void* callContext) {
+
+ ::apache::thrift::protocol::TProtocol* iprot = piprot.get();
+ ::apache::thrift::protocol::TProtocol* oprot = poprot.get();
+ std::string fname;
+ ::apache::thrift::protocol::TMessageType mtype;
+ int32_t seqid;
+
+ iprot->readMessageBegin(fname, mtype, seqid);
+
+ if (mtype != ::apache::thrift::protocol::T_CALL && mtype != ::apache::thrift::protocol::T_ONEWAY) {
+ iprot->skip(::apache::thrift::protocol::T_STRUCT);
+ iprot->readMessageEnd();
+ iprot->getTransport()->readEnd();
+ ::apache::thrift::TApplicationException x(::apache::thrift::TApplicationException::INVALID_MESSAGE_TYPE);
+ oprot->writeMessageBegin(fname, ::apache::thrift::protocol::T_EXCEPTION, seqid);
+ x.write(oprot);
+ oprot->writeMessageEnd();
+ oprot->getTransport()->writeEnd();
+ oprot->getTransport()->flush();
+ return true;
+ }
+
+ return process_fn(iprot, oprot, fname, seqid, callContext);
+}
+
+bool MNSCacheServiceProcessor::process_fn(apache::thrift::protocol::TProtocol* iprot, apache::thrift::protocol::TProtocol* oprot, std::string& fname, int32_t seqid, void* callContext) {
+ std::map::iterator pfn;
+ pfn = processMap_.find(fname);
+ if (pfn == processMap_.end()) {
+ iprot->skip(apache::thrift::protocol::T_STRUCT);
+ iprot->readMessageEnd();
+ iprot->getTransport()->readEnd();
+ ::apache::thrift::TApplicationException x(::apache::thrift::TApplicationException::UNKNOWN_METHOD, "Invalid method name: '"+fname+"'");
+ oprot->writeMessageBegin(fname, ::apache::thrift::protocol::T_EXCEPTION, seqid);
+ x.write(oprot);
+ oprot->writeMessageEnd();
+ oprot->getTransport()->writeEnd();
+ oprot->getTransport()->flush();
+ return true;
+ }
+ (this->*(pfn->second))(seqid, iprot, oprot, callContext);
+ return true;
+}
+
+void MNSCacheServiceProcessor::process_getMNSCache(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext)
+{
+ void* ctx = NULL;
+ if (this->eventHandler_.get() != NULL) {
+ ctx = this->eventHandler_->getContext("MNSCacheService.getMNSCache", callContext);
+ }
+ apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "MNSCacheService.getMNSCache");
+
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->preRead(ctx, "MNSCacheService.getMNSCache");
+ }
+
+ MNSCacheService_getMNSCache_args args;
+ args.read(iprot);
+ iprot->readMessageEnd();
+ uint32_t bytes = iprot->getTransport()->readEnd();
+
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->postRead(ctx, "MNSCacheService.getMNSCache", bytes);
+ }
+
+ MNSCacheService_getMNSCache_result result;
+ try {
+ iface_->getMNSCache(result.success, args.appkey, args.version, args.env);
+ result.__isset.success = true;
+ } catch (const std::exception& e) {
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->handlerError(ctx, "MNSCacheService.getMNSCache");
+ }
+
+ apache::thrift::TApplicationException x(e.what());
+ oprot->writeMessageBegin("getMNSCache", apache::thrift::protocol::T_EXCEPTION, seqid);
+ x.write(oprot);
+ oprot->writeMessageEnd();
+ oprot->getTransport()->writeEnd();
+ oprot->getTransport()->flush();
+ return;
+ }
+
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->preWrite(ctx, "MNSCacheService.getMNSCache");
+ }
+
+ oprot->writeMessageBegin("getMNSCache", apache::thrift::protocol::T_REPLY, seqid);
+ result.write(oprot);
+ oprot->writeMessageEnd();
+ bytes = oprot->getTransport()->writeEnd();
+ oprot->getTransport()->flush();
+
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->postWrite(ctx, "MNSCacheService.getMNSCache", bytes);
+ }
+}
+
+void MNSCacheServiceProcessor::process_getMNSCacheHttp(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext)
+{
+ void* ctx = NULL;
+ if (this->eventHandler_.get() != NULL) {
+ ctx = this->eventHandler_->getContext("MNSCacheService.getMNSCacheHttp", callContext);
+ }
+ apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "MNSCacheService.getMNSCacheHttp");
+
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->preRead(ctx, "MNSCacheService.getMNSCacheHttp");
+ }
+
+ MNSCacheService_getMNSCacheHttp_args args;
+ args.read(iprot);
+ iprot->readMessageEnd();
+ uint32_t bytes = iprot->getTransport()->readEnd();
+
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->postRead(ctx, "MNSCacheService.getMNSCacheHttp", bytes);
+ }
+
+ MNSCacheService_getMNSCacheHttp_result result;
+ try {
+ iface_->getMNSCacheHttp(result.success, args.appkey, args.version, args.env);
+ result.__isset.success = true;
+ } catch (const std::exception& e) {
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->handlerError(ctx, "MNSCacheService.getMNSCacheHttp");
+ }
+
+ apache::thrift::TApplicationException x(e.what());
+ oprot->writeMessageBegin("getMNSCacheHttp", apache::thrift::protocol::T_EXCEPTION, seqid);
+ x.write(oprot);
+ oprot->writeMessageEnd();
+ oprot->getTransport()->writeEnd();
+ oprot->getTransport()->flush();
+ return;
+ }
+
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->preWrite(ctx, "MNSCacheService.getMNSCacheHttp");
+ }
+
+ oprot->writeMessageBegin("getMNSCacheHttp", apache::thrift::protocol::T_REPLY, seqid);
+ result.write(oprot);
+ oprot->writeMessageEnd();
+ bytes = oprot->getTransport()->writeEnd();
+ oprot->getTransport()->flush();
+
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->postWrite(ctx, "MNSCacheService.getMNSCacheHttp", bytes);
+ }
+}
+
+void MNSCacheServiceProcessor::process_getMNSCacheWithVersionCheck(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext)
+{
+ void* ctx = NULL;
+ if (this->eventHandler_.get() != NULL) {
+ ctx = this->eventHandler_->getContext("MNSCacheService.getMNSCacheWithVersionCheck", callContext);
+ }
+ apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "MNSCacheService.getMNSCacheWithVersionCheck");
+
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->preRead(ctx, "MNSCacheService.getMNSCacheWithVersionCheck");
+ }
+
+ MNSCacheService_getMNSCacheWithVersionCheck_args args;
+ args.read(iprot);
+ iprot->readMessageEnd();
+ uint32_t bytes = iprot->getTransport()->readEnd();
+
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->postRead(ctx, "MNSCacheService.getMNSCacheWithVersionCheck", bytes);
+ }
+
+ MNSCacheService_getMNSCacheWithVersionCheck_result result;
+ try {
+ iface_->getMNSCacheWithVersionCheck(result.success, args.req);
+ result.__isset.success = true;
+ } catch (const std::exception& e) {
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->handlerError(ctx, "MNSCacheService.getMNSCacheWithVersionCheck");
+ }
+
+ apache::thrift::TApplicationException x(e.what());
+ oprot->writeMessageBegin("getMNSCacheWithVersionCheck", apache::thrift::protocol::T_EXCEPTION, seqid);
+ x.write(oprot);
+ oprot->writeMessageEnd();
+ oprot->getTransport()->writeEnd();
+ oprot->getTransport()->flush();
+ return;
+ }
+
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->preWrite(ctx, "MNSCacheService.getMNSCacheWithVersionCheck");
+ }
+
+ oprot->writeMessageBegin("getMNSCacheWithVersionCheck", apache::thrift::protocol::T_REPLY, seqid);
+ result.write(oprot);
+ oprot->writeMessageEnd();
+ bytes = oprot->getTransport()->writeEnd();
+ oprot->getTransport()->flush();
+
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->postWrite(ctx, "MNSCacheService.getMNSCacheWithVersionCheck", bytes);
+ }
+}
+
+void MNSCacheServiceProcessor::process_getMNSCacheByAppkeys(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext)
+{
+ void* ctx = NULL;
+ if (this->eventHandler_.get() != NULL) {
+ ctx = this->eventHandler_->getContext("MNSCacheService.getMNSCacheByAppkeys", callContext);
+ }
+ apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "MNSCacheService.getMNSCacheByAppkeys");
+
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->preRead(ctx, "MNSCacheService.getMNSCacheByAppkeys");
+ }
+
+ MNSCacheService_getMNSCacheByAppkeys_args args;
+ args.read(iprot);
+ iprot->readMessageEnd();
+ uint32_t bytes = iprot->getTransport()->readEnd();
+
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->postRead(ctx, "MNSCacheService.getMNSCacheByAppkeys", bytes);
+ }
+
+ MNSCacheService_getMNSCacheByAppkeys_result result;
+ try {
+ iface_->getMNSCacheByAppkeys(result.success, args.appkeys, args.protocol);
+ result.__isset.success = true;
+ } catch (const std::exception& e) {
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->handlerError(ctx, "MNSCacheService.getMNSCacheByAppkeys");
+ }
+
+ apache::thrift::TApplicationException x(e.what());
+ oprot->writeMessageBegin("getMNSCacheByAppkeys", apache::thrift::protocol::T_EXCEPTION, seqid);
+ x.write(oprot);
+ oprot->writeMessageEnd();
+ oprot->getTransport()->writeEnd();
+ oprot->getTransport()->flush();
+ return;
+ }
+
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->preWrite(ctx, "MNSCacheService.getMNSCacheByAppkeys");
+ }
+
+ oprot->writeMessageBegin("getMNSCacheByAppkeys", apache::thrift::protocol::T_REPLY, seqid);
+ result.write(oprot);
+ oprot->writeMessageEnd();
+ bytes = oprot->getTransport()->writeEnd();
+ oprot->getTransport()->flush();
+
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->postWrite(ctx, "MNSCacheService.getMNSCacheByAppkeys", bytes);
+ }
+}
+
+void MNSCacheServiceProcessor::process_getProvidersByIP(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext)
+{
+ void* ctx = NULL;
+ if (this->eventHandler_.get() != NULL) {
+ ctx = this->eventHandler_->getContext("MNSCacheService.getProvidersByIP", callContext);
+ }
+ apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "MNSCacheService.getProvidersByIP");
+
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->preRead(ctx, "MNSCacheService.getProvidersByIP");
+ }
+
+ MNSCacheService_getProvidersByIP_args args;
+ args.read(iprot);
+ iprot->readMessageEnd();
+ uint32_t bytes = iprot->getTransport()->readEnd();
+
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->postRead(ctx, "MNSCacheService.getProvidersByIP", bytes);
+ }
+
+ MNSCacheService_getProvidersByIP_result result;
+ try {
+ iface_->getProvidersByIP(result.success, args.ip);
+ result.__isset.success = true;
+ } catch (const std::exception& e) {
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->handlerError(ctx, "MNSCacheService.getProvidersByIP");
+ }
+
+ apache::thrift::TApplicationException x(e.what());
+ oprot->writeMessageBegin("getProvidersByIP", apache::thrift::protocol::T_EXCEPTION, seqid);
+ x.write(oprot);
+ oprot->writeMessageEnd();
+ oprot->getTransport()->writeEnd();
+ oprot->getTransport()->flush();
+ return;
+ }
+
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->preWrite(ctx, "MNSCacheService.getProvidersByIP");
+ }
+
+ oprot->writeMessageBegin("getProvidersByIP", apache::thrift::protocol::T_REPLY, seqid);
+ result.write(oprot);
+ oprot->writeMessageEnd();
+ bytes = oprot->getTransport()->writeEnd();
+ oprot->getTransport()->flush();
+
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->postWrite(ctx, "MNSCacheService.getProvidersByIP", bytes);
+ }
+}
+
+void MNSCacheServiceProcessor::process_getAppkeyListByIP(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext)
+{
+ void* ctx = NULL;
+ if (this->eventHandler_.get() != NULL) {
+ ctx = this->eventHandler_->getContext("MNSCacheService.getAppkeyListByIP", callContext);
+ }
+ apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "MNSCacheService.getAppkeyListByIP");
+
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->preRead(ctx, "MNSCacheService.getAppkeyListByIP");
+ }
+
+ MNSCacheService_getAppkeyListByIP_args args;
+ args.read(iprot);
+ iprot->readMessageEnd();
+ uint32_t bytes = iprot->getTransport()->readEnd();
+
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->postRead(ctx, "MNSCacheService.getAppkeyListByIP", bytes);
+ }
+
+ MNSCacheService_getAppkeyListByIP_result result;
+ try {
+ iface_->getAppkeyListByIP(result.success, args.ip);
+ result.__isset.success = true;
+ } catch (const std::exception& e) {
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->handlerError(ctx, "MNSCacheService.getAppkeyListByIP");
+ }
+
+ apache::thrift::TApplicationException x(e.what());
+ oprot->writeMessageBegin("getAppkeyListByIP", apache::thrift::protocol::T_EXCEPTION, seqid);
+ x.write(oprot);
+ oprot->writeMessageEnd();
+ oprot->getTransport()->writeEnd();
+ oprot->getTransport()->flush();
+ return;
+ }
+
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->preWrite(ctx, "MNSCacheService.getAppkeyListByIP");
+ }
+
+ oprot->writeMessageBegin("getAppkeyListByIP", apache::thrift::protocol::T_REPLY, seqid);
+ result.write(oprot);
+ oprot->writeMessageEnd();
+ bytes = oprot->getTransport()->writeEnd();
+ oprot->getTransport()->flush();
+
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->postWrite(ctx, "MNSCacheService.getAppkeyListByIP", bytes);
+ }
+}
+
+::boost::shared_ptr< ::apache::thrift::TProcessor > MNSCacheServiceProcessorFactory::getProcessor(const ::apache::thrift::TConnectionInfo& connInfo) {
+ ::apache::thrift::ReleaseHandler< MNSCacheServiceIfFactory > cleanup(handlerFactory_);
+ ::boost::shared_ptr< MNSCacheServiceIf > handler(handlerFactory_->getHandler(connInfo), cleanup);
+ ::boost::shared_ptr< ::apache::thrift::TProcessor > processor(new MNSCacheServiceProcessor(handler));
+ return processor;
+}
+} // namespace
+
diff --git a/common/gen-cpp/MNSCacheService.h b/common/gen-cpp/MNSCacheService.h
new file mode 100644
index 0000000..0601c18
--- /dev/null
+++ b/common/gen-cpp/MNSCacheService.h
@@ -0,0 +1,937 @@
+/**
+ * Autogenerated by Thrift Compiler (0.8.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ * @generated
+ */
+#ifndef MNSCacheService_H
+#define MNSCacheService_H
+
+#include
+#include "mnsc_service_types.h"
+
+namespace meituan_mns {
+
+class MNSCacheServiceIf {
+ public:
+ virtual ~MNSCacheServiceIf() {}
+ virtual void getMNSCache(MNSResponse& _return, const std::string& appkey, const std::string& version, const std::string& env) = 0;
+ virtual void getMNSCacheHttp(MNSResponse& _return, const std::string& appkey, const std::string& version, const std::string& env) = 0;
+ virtual void getMNSCacheWithVersionCheck(MNSResponse& _return, const MnsRequest& req) = 0;
+ virtual void getMNSCacheByAppkeys(MNSBatchResponse& _return, const std::vector & appkeys, const std::string& protocol) = 0;
+ virtual void getProvidersByIP(MNSResponse& _return, const std::string& ip) = 0;
+ virtual void getAppkeyListByIP(AppKeyListResponse& _return, const std::string& ip) = 0;
+};
+
+class MNSCacheServiceIfFactory {
+ public:
+ typedef MNSCacheServiceIf Handler;
+
+ virtual ~MNSCacheServiceIfFactory() {}
+
+ virtual MNSCacheServiceIf* getHandler(const ::apache::thrift::TConnectionInfo& connInfo) = 0;
+ virtual void releaseHandler(MNSCacheServiceIf* /* handler */) = 0;
+};
+
+class MNSCacheServiceIfSingletonFactory : virtual public MNSCacheServiceIfFactory {
+ public:
+ MNSCacheServiceIfSingletonFactory(const boost::shared_ptr& iface) : iface_(iface) {}
+ virtual ~MNSCacheServiceIfSingletonFactory() {}
+
+ virtual MNSCacheServiceIf* getHandler(const ::apache::thrift::TConnectionInfo&) {
+ return iface_.get();
+ }
+ virtual void releaseHandler(MNSCacheServiceIf* /* handler */) {}
+
+ protected:
+ boost::shared_ptr iface_;
+};
+
+class MNSCacheServiceNull : virtual public MNSCacheServiceIf {
+ public:
+ virtual ~MNSCacheServiceNull() {}
+ void getMNSCache(MNSResponse& /* _return */, const std::string& /* appkey */, const std::string& /* version */, const std::string& /* env */) {
+ return;
+ }
+ void getMNSCacheHttp(MNSResponse& /* _return */, const std::string& /* appkey */, const std::string& /* version */, const std::string& /* env */) {
+ return;
+ }
+ void getMNSCacheWithVersionCheck(MNSResponse& /* _return */, const MnsRequest& /* req */) {
+ return;
+ }
+ void getMNSCacheByAppkeys(MNSBatchResponse& /* _return */, const std::vector & /* appkeys */, const std::string& /* protocol */) {
+ return;
+ }
+ void getProvidersByIP(MNSResponse& /* _return */, const std::string& /* ip */) {
+ return;
+ }
+ void getAppkeyListByIP(AppKeyListResponse& /* _return */, const std::string& /* ip */) {
+ return;
+ }
+};
+
+typedef struct _MNSCacheService_getMNSCache_args__isset {
+ _MNSCacheService_getMNSCache_args__isset() : appkey(false), version(false), env(false) {}
+ bool appkey;
+ bool version;
+ bool env;
+} _MNSCacheService_getMNSCache_args__isset;
+
+class MNSCacheService_getMNSCache_args {
+ public:
+
+ MNSCacheService_getMNSCache_args() : appkey(""), version(""), env("") {
+ }
+
+ virtual ~MNSCacheService_getMNSCache_args() throw() {}
+
+ std::string appkey;
+ std::string version;
+ std::string env;
+
+ _MNSCacheService_getMNSCache_args__isset __isset;
+
+ void __set_appkey(const std::string& val) {
+ appkey = val;
+ }
+
+ void __set_version(const std::string& val) {
+ version = val;
+ }
+
+ void __set_env(const std::string& val) {
+ env = val;
+ }
+
+ bool operator == (const MNSCacheService_getMNSCache_args & rhs) const
+ {
+ if (!(appkey == rhs.appkey))
+ return false;
+ if (!(version == rhs.version))
+ return false;
+ if (!(env == rhs.env))
+ return false;
+ return true;
+ }
+ bool operator != (const MNSCacheService_getMNSCache_args &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const MNSCacheService_getMNSCache_args & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+
+class MNSCacheService_getMNSCache_pargs {
+ public:
+
+
+ virtual ~MNSCacheService_getMNSCache_pargs() throw() {}
+
+ const std::string* appkey;
+ const std::string* version;
+ const std::string* env;
+
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _MNSCacheService_getMNSCache_result__isset {
+ _MNSCacheService_getMNSCache_result__isset() : success(false) {}
+ bool success;
+} _MNSCacheService_getMNSCache_result__isset;
+
+class MNSCacheService_getMNSCache_result {
+ public:
+
+ MNSCacheService_getMNSCache_result() {
+ }
+
+ virtual ~MNSCacheService_getMNSCache_result() throw() {}
+
+ MNSResponse success;
+
+ _MNSCacheService_getMNSCache_result__isset __isset;
+
+ void __set_success(const MNSResponse& val) {
+ success = val;
+ }
+
+ bool operator == (const MNSCacheService_getMNSCache_result & rhs) const
+ {
+ if (!(success == rhs.success))
+ return false;
+ return true;
+ }
+ bool operator != (const MNSCacheService_getMNSCache_result &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const MNSCacheService_getMNSCache_result & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _MNSCacheService_getMNSCache_presult__isset {
+ _MNSCacheService_getMNSCache_presult__isset() : success(false) {}
+ bool success;
+} _MNSCacheService_getMNSCache_presult__isset;
+
+class MNSCacheService_getMNSCache_presult {
+ public:
+
+
+ virtual ~MNSCacheService_getMNSCache_presult() throw() {}
+
+ MNSResponse* success;
+
+ _MNSCacheService_getMNSCache_presult__isset __isset;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+
+};
+
+typedef struct _MNSCacheService_getMNSCacheHttp_args__isset {
+ _MNSCacheService_getMNSCacheHttp_args__isset() : appkey(false), version(false), env(false) {}
+ bool appkey;
+ bool version;
+ bool env;
+} _MNSCacheService_getMNSCacheHttp_args__isset;
+
+class MNSCacheService_getMNSCacheHttp_args {
+ public:
+
+ MNSCacheService_getMNSCacheHttp_args() : appkey(""), version(""), env("") {
+ }
+
+ virtual ~MNSCacheService_getMNSCacheHttp_args() throw() {}
+
+ std::string appkey;
+ std::string version;
+ std::string env;
+
+ _MNSCacheService_getMNSCacheHttp_args__isset __isset;
+
+ void __set_appkey(const std::string& val) {
+ appkey = val;
+ }
+
+ void __set_version(const std::string& val) {
+ version = val;
+ }
+
+ void __set_env(const std::string& val) {
+ env = val;
+ }
+
+ bool operator == (const MNSCacheService_getMNSCacheHttp_args & rhs) const
+ {
+ if (!(appkey == rhs.appkey))
+ return false;
+ if (!(version == rhs.version))
+ return false;
+ if (!(env == rhs.env))
+ return false;
+ return true;
+ }
+ bool operator != (const MNSCacheService_getMNSCacheHttp_args &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const MNSCacheService_getMNSCacheHttp_args & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+
+class MNSCacheService_getMNSCacheHttp_pargs {
+ public:
+
+
+ virtual ~MNSCacheService_getMNSCacheHttp_pargs() throw() {}
+
+ const std::string* appkey;
+ const std::string* version;
+ const std::string* env;
+
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _MNSCacheService_getMNSCacheHttp_result__isset {
+ _MNSCacheService_getMNSCacheHttp_result__isset() : success(false) {}
+ bool success;
+} _MNSCacheService_getMNSCacheHttp_result__isset;
+
+class MNSCacheService_getMNSCacheHttp_result {
+ public:
+
+ MNSCacheService_getMNSCacheHttp_result() {
+ }
+
+ virtual ~MNSCacheService_getMNSCacheHttp_result() throw() {}
+
+ MNSResponse success;
+
+ _MNSCacheService_getMNSCacheHttp_result__isset __isset;
+
+ void __set_success(const MNSResponse& val) {
+ success = val;
+ }
+
+ bool operator == (const MNSCacheService_getMNSCacheHttp_result & rhs) const
+ {
+ if (!(success == rhs.success))
+ return false;
+ return true;
+ }
+ bool operator != (const MNSCacheService_getMNSCacheHttp_result &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const MNSCacheService_getMNSCacheHttp_result & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _MNSCacheService_getMNSCacheHttp_presult__isset {
+ _MNSCacheService_getMNSCacheHttp_presult__isset() : success(false) {}
+ bool success;
+} _MNSCacheService_getMNSCacheHttp_presult__isset;
+
+class MNSCacheService_getMNSCacheHttp_presult {
+ public:
+
+
+ virtual ~MNSCacheService_getMNSCacheHttp_presult() throw() {}
+
+ MNSResponse* success;
+
+ _MNSCacheService_getMNSCacheHttp_presult__isset __isset;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+
+};
+
+typedef struct _MNSCacheService_getMNSCacheWithVersionCheck_args__isset {
+ _MNSCacheService_getMNSCacheWithVersionCheck_args__isset() : req(false) {}
+ bool req;
+} _MNSCacheService_getMNSCacheWithVersionCheck_args__isset;
+
+class MNSCacheService_getMNSCacheWithVersionCheck_args {
+ public:
+
+ MNSCacheService_getMNSCacheWithVersionCheck_args() {
+ }
+
+ virtual ~MNSCacheService_getMNSCacheWithVersionCheck_args() throw() {}
+
+ MnsRequest req;
+
+ _MNSCacheService_getMNSCacheWithVersionCheck_args__isset __isset;
+
+ void __set_req(const MnsRequest& val) {
+ req = val;
+ }
+
+ bool operator == (const MNSCacheService_getMNSCacheWithVersionCheck_args & rhs) const
+ {
+ if (!(req == rhs.req))
+ return false;
+ return true;
+ }
+ bool operator != (const MNSCacheService_getMNSCacheWithVersionCheck_args &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const MNSCacheService_getMNSCacheWithVersionCheck_args & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+
+class MNSCacheService_getMNSCacheWithVersionCheck_pargs {
+ public:
+
+
+ virtual ~MNSCacheService_getMNSCacheWithVersionCheck_pargs() throw() {}
+
+ const MnsRequest* req;
+
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _MNSCacheService_getMNSCacheWithVersionCheck_result__isset {
+ _MNSCacheService_getMNSCacheWithVersionCheck_result__isset() : success(false) {}
+ bool success;
+} _MNSCacheService_getMNSCacheWithVersionCheck_result__isset;
+
+class MNSCacheService_getMNSCacheWithVersionCheck_result {
+ public:
+
+ MNSCacheService_getMNSCacheWithVersionCheck_result() {
+ }
+
+ virtual ~MNSCacheService_getMNSCacheWithVersionCheck_result() throw() {}
+
+ MNSResponse success;
+
+ _MNSCacheService_getMNSCacheWithVersionCheck_result__isset __isset;
+
+ void __set_success(const MNSResponse& val) {
+ success = val;
+ }
+
+ bool operator == (const MNSCacheService_getMNSCacheWithVersionCheck_result & rhs) const
+ {
+ if (!(success == rhs.success))
+ return false;
+ return true;
+ }
+ bool operator != (const MNSCacheService_getMNSCacheWithVersionCheck_result &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const MNSCacheService_getMNSCacheWithVersionCheck_result & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _MNSCacheService_getMNSCacheWithVersionCheck_presult__isset {
+ _MNSCacheService_getMNSCacheWithVersionCheck_presult__isset() : success(false) {}
+ bool success;
+} _MNSCacheService_getMNSCacheWithVersionCheck_presult__isset;
+
+class MNSCacheService_getMNSCacheWithVersionCheck_presult {
+ public:
+
+
+ virtual ~MNSCacheService_getMNSCacheWithVersionCheck_presult() throw() {}
+
+ MNSResponse* success;
+
+ _MNSCacheService_getMNSCacheWithVersionCheck_presult__isset __isset;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+
+};
+
+typedef struct _MNSCacheService_getMNSCacheByAppkeys_args__isset {
+ _MNSCacheService_getMNSCacheByAppkeys_args__isset() : appkeys(false), protocol(false) {}
+ bool appkeys;
+ bool protocol;
+} _MNSCacheService_getMNSCacheByAppkeys_args__isset;
+
+class MNSCacheService_getMNSCacheByAppkeys_args {
+ public:
+
+ MNSCacheService_getMNSCacheByAppkeys_args() : protocol("") {
+ }
+
+ virtual ~MNSCacheService_getMNSCacheByAppkeys_args() throw() {}
+
+ std::vector appkeys;
+ std::string protocol;
+
+ _MNSCacheService_getMNSCacheByAppkeys_args__isset __isset;
+
+ void __set_appkeys(const std::vector & val) {
+ appkeys = val;
+ }
+
+ void __set_protocol(const std::string& val) {
+ protocol = val;
+ }
+
+ bool operator == (const MNSCacheService_getMNSCacheByAppkeys_args & rhs) const
+ {
+ if (!(appkeys == rhs.appkeys))
+ return false;
+ if (!(protocol == rhs.protocol))
+ return false;
+ return true;
+ }
+ bool operator != (const MNSCacheService_getMNSCacheByAppkeys_args &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const MNSCacheService_getMNSCacheByAppkeys_args & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+
+class MNSCacheService_getMNSCacheByAppkeys_pargs {
+ public:
+
+
+ virtual ~MNSCacheService_getMNSCacheByAppkeys_pargs() throw() {}
+
+ const std::vector * appkeys;
+ const std::string* protocol;
+
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _MNSCacheService_getMNSCacheByAppkeys_result__isset {
+ _MNSCacheService_getMNSCacheByAppkeys_result__isset() : success(false) {}
+ bool success;
+} _MNSCacheService_getMNSCacheByAppkeys_result__isset;
+
+class MNSCacheService_getMNSCacheByAppkeys_result {
+ public:
+
+ MNSCacheService_getMNSCacheByAppkeys_result() {
+ }
+
+ virtual ~MNSCacheService_getMNSCacheByAppkeys_result() throw() {}
+
+ MNSBatchResponse success;
+
+ _MNSCacheService_getMNSCacheByAppkeys_result__isset __isset;
+
+ void __set_success(const MNSBatchResponse& val) {
+ success = val;
+ }
+
+ bool operator == (const MNSCacheService_getMNSCacheByAppkeys_result & rhs) const
+ {
+ if (!(success == rhs.success))
+ return false;
+ return true;
+ }
+ bool operator != (const MNSCacheService_getMNSCacheByAppkeys_result &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const MNSCacheService_getMNSCacheByAppkeys_result & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _MNSCacheService_getMNSCacheByAppkeys_presult__isset {
+ _MNSCacheService_getMNSCacheByAppkeys_presult__isset() : success(false) {}
+ bool success;
+} _MNSCacheService_getMNSCacheByAppkeys_presult__isset;
+
+class MNSCacheService_getMNSCacheByAppkeys_presult {
+ public:
+
+
+ virtual ~MNSCacheService_getMNSCacheByAppkeys_presult() throw() {}
+
+ MNSBatchResponse* success;
+
+ _MNSCacheService_getMNSCacheByAppkeys_presult__isset __isset;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+
+};
+
+typedef struct _MNSCacheService_getProvidersByIP_args__isset {
+ _MNSCacheService_getProvidersByIP_args__isset() : ip(false) {}
+ bool ip;
+} _MNSCacheService_getProvidersByIP_args__isset;
+
+class MNSCacheService_getProvidersByIP_args {
+ public:
+
+ MNSCacheService_getProvidersByIP_args() : ip("") {
+ }
+
+ virtual ~MNSCacheService_getProvidersByIP_args() throw() {}
+
+ std::string ip;
+
+ _MNSCacheService_getProvidersByIP_args__isset __isset;
+
+ void __set_ip(const std::string& val) {
+ ip = val;
+ }
+
+ bool operator == (const MNSCacheService_getProvidersByIP_args & rhs) const
+ {
+ if (!(ip == rhs.ip))
+ return false;
+ return true;
+ }
+ bool operator != (const MNSCacheService_getProvidersByIP_args &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const MNSCacheService_getProvidersByIP_args & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+
+class MNSCacheService_getProvidersByIP_pargs {
+ public:
+
+
+ virtual ~MNSCacheService_getProvidersByIP_pargs() throw() {}
+
+ const std::string* ip;
+
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _MNSCacheService_getProvidersByIP_result__isset {
+ _MNSCacheService_getProvidersByIP_result__isset() : success(false) {}
+ bool success;
+} _MNSCacheService_getProvidersByIP_result__isset;
+
+class MNSCacheService_getProvidersByIP_result {
+ public:
+
+ MNSCacheService_getProvidersByIP_result() {
+ }
+
+ virtual ~MNSCacheService_getProvidersByIP_result() throw() {}
+
+ MNSResponse success;
+
+ _MNSCacheService_getProvidersByIP_result__isset __isset;
+
+ void __set_success(const MNSResponse& val) {
+ success = val;
+ }
+
+ bool operator == (const MNSCacheService_getProvidersByIP_result & rhs) const
+ {
+ if (!(success == rhs.success))
+ return false;
+ return true;
+ }
+ bool operator != (const MNSCacheService_getProvidersByIP_result &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const MNSCacheService_getProvidersByIP_result & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _MNSCacheService_getProvidersByIP_presult__isset {
+ _MNSCacheService_getProvidersByIP_presult__isset() : success(false) {}
+ bool success;
+} _MNSCacheService_getProvidersByIP_presult__isset;
+
+class MNSCacheService_getProvidersByIP_presult {
+ public:
+
+
+ virtual ~MNSCacheService_getProvidersByIP_presult() throw() {}
+
+ MNSResponse* success;
+
+ _MNSCacheService_getProvidersByIP_presult__isset __isset;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+
+};
+
+typedef struct _MNSCacheService_getAppkeyListByIP_args__isset {
+ _MNSCacheService_getAppkeyListByIP_args__isset() : ip(false) {}
+ bool ip;
+} _MNSCacheService_getAppkeyListByIP_args__isset;
+
+class MNSCacheService_getAppkeyListByIP_args {
+ public:
+
+ MNSCacheService_getAppkeyListByIP_args() : ip("") {
+ }
+
+ virtual ~MNSCacheService_getAppkeyListByIP_args() throw() {}
+
+ std::string ip;
+
+ _MNSCacheService_getAppkeyListByIP_args__isset __isset;
+
+ void __set_ip(const std::string& val) {
+ ip = val;
+ }
+
+ bool operator == (const MNSCacheService_getAppkeyListByIP_args & rhs) const
+ {
+ if (!(ip == rhs.ip))
+ return false;
+ return true;
+ }
+ bool operator != (const MNSCacheService_getAppkeyListByIP_args &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const MNSCacheService_getAppkeyListByIP_args & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+
+class MNSCacheService_getAppkeyListByIP_pargs {
+ public:
+
+
+ virtual ~MNSCacheService_getAppkeyListByIP_pargs() throw() {}
+
+ const std::string* ip;
+
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _MNSCacheService_getAppkeyListByIP_result__isset {
+ _MNSCacheService_getAppkeyListByIP_result__isset() : success(false) {}
+ bool success;
+} _MNSCacheService_getAppkeyListByIP_result__isset;
+
+class MNSCacheService_getAppkeyListByIP_result {
+ public:
+
+ MNSCacheService_getAppkeyListByIP_result() {
+ }
+
+ virtual ~MNSCacheService_getAppkeyListByIP_result() throw() {}
+
+ AppKeyListResponse success;
+
+ _MNSCacheService_getAppkeyListByIP_result__isset __isset;
+
+ void __set_success(const AppKeyListResponse& val) {
+ success = val;
+ }
+
+ bool operator == (const MNSCacheService_getAppkeyListByIP_result & rhs) const
+ {
+ if (!(success == rhs.success))
+ return false;
+ return true;
+ }
+ bool operator != (const MNSCacheService_getAppkeyListByIP_result &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const MNSCacheService_getAppkeyListByIP_result & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _MNSCacheService_getAppkeyListByIP_presult__isset {
+ _MNSCacheService_getAppkeyListByIP_presult__isset() : success(false) {}
+ bool success;
+} _MNSCacheService_getAppkeyListByIP_presult__isset;
+
+class MNSCacheService_getAppkeyListByIP_presult {
+ public:
+
+
+ virtual ~MNSCacheService_getAppkeyListByIP_presult() throw() {}
+
+ AppKeyListResponse* success;
+
+ _MNSCacheService_getAppkeyListByIP_presult__isset __isset;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+
+};
+
+class MNSCacheServiceClient : virtual public MNSCacheServiceIf {
+ public:
+ MNSCacheServiceClient(boost::shared_ptr< ::apache::thrift::protocol::TProtocol> prot) :
+ piprot_(prot),
+ poprot_(prot) {
+ iprot_ = prot.get();
+ oprot_ = prot.get();
+ }
+ MNSCacheServiceClient(boost::shared_ptr< ::apache::thrift::protocol::TProtocol> iprot, boost::shared_ptr< ::apache::thrift::protocol::TProtocol> oprot) :
+ piprot_(iprot),
+ poprot_(oprot) {
+ iprot_ = iprot.get();
+ oprot_ = oprot.get();
+ }
+ boost::shared_ptr< ::apache::thrift::protocol::TProtocol> getInputProtocol() {
+ return piprot_;
+ }
+ boost::shared_ptr< ::apache::thrift::protocol::TProtocol> getOutputProtocol() {
+ return poprot_;
+ }
+ void getMNSCache(MNSResponse& _return, const std::string& appkey, const std::string& version, const std::string& env);
+ void send_getMNSCache(const std::string& appkey, const std::string& version, const std::string& env);
+ void recv_getMNSCache(MNSResponse& _return);
+ void getMNSCacheHttp(MNSResponse& _return, const std::string& appkey, const std::string& version, const std::string& env);
+ void send_getMNSCacheHttp(const std::string& appkey, const std::string& version, const std::string& env);
+ void recv_getMNSCacheHttp(MNSResponse& _return);
+ void getMNSCacheWithVersionCheck(MNSResponse& _return, const MnsRequest& req);
+ void send_getMNSCacheWithVersionCheck(const MnsRequest& req);
+ void recv_getMNSCacheWithVersionCheck(MNSResponse& _return);
+ void getMNSCacheByAppkeys(MNSBatchResponse& _return, const std::vector & appkeys, const std::string& protocol);
+ void send_getMNSCacheByAppkeys(const std::vector & appkeys, const std::string& protocol);
+ void recv_getMNSCacheByAppkeys(MNSBatchResponse& _return);
+ void getProvidersByIP(MNSResponse& _return, const std::string& ip);
+ void send_getProvidersByIP(const std::string& ip);
+ void recv_getProvidersByIP(MNSResponse& _return);
+ void getAppkeyListByIP(AppKeyListResponse& _return, const std::string& ip);
+ void send_getAppkeyListByIP(const std::string& ip);
+ void recv_getAppkeyListByIP(AppKeyListResponse& _return);
+ protected:
+ boost::shared_ptr< ::apache::thrift::protocol::TProtocol> piprot_;
+ boost::shared_ptr< ::apache::thrift::protocol::TProtocol> poprot_;
+ ::apache::thrift::protocol::TProtocol* iprot_;
+ ::apache::thrift::protocol::TProtocol* oprot_;
+};
+
+class MNSCacheServiceProcessor : public ::apache::thrift::TProcessor {
+ protected:
+ boost::shared_ptr iface_;
+ virtual bool process_fn(apache::thrift::protocol::TProtocol* iprot, apache::thrift::protocol::TProtocol* oprot, std::string& fname, int32_t seqid, void* callContext);
+ private:
+ std::map processMap_;
+ void process_getMNSCache(int32_t seqid, apache::thrift::protocol::TProtocol* iprot, apache::thrift::protocol::TProtocol* oprot, void* callContext);
+ void process_getMNSCacheHttp(int32_t seqid, apache::thrift::protocol::TProtocol* iprot, apache::thrift::protocol::TProtocol* oprot, void* callContext);
+ void process_getMNSCacheWithVersionCheck(int32_t seqid, apache::thrift::protocol::TProtocol* iprot, apache::thrift::protocol::TProtocol* oprot, void* callContext);
+ void process_getMNSCacheByAppkeys(int32_t seqid, apache::thrift::protocol::TProtocol* iprot, apache::thrift::protocol::TProtocol* oprot, void* callContext);
+ void process_getProvidersByIP(int32_t seqid, apache::thrift::protocol::TProtocol* iprot, apache::thrift::protocol::TProtocol* oprot, void* callContext);
+ void process_getAppkeyListByIP(int32_t seqid, apache::thrift::protocol::TProtocol* iprot, apache::thrift::protocol::TProtocol* oprot, void* callContext);
+ public:
+ MNSCacheServiceProcessor(boost::shared_ptr iface) :
+ iface_(iface) {
+ processMap_["getMNSCache"] = &MNSCacheServiceProcessor::process_getMNSCache;
+ processMap_["getMNSCacheHttp"] = &MNSCacheServiceProcessor::process_getMNSCacheHttp;
+ processMap_["getMNSCacheWithVersionCheck"] = &MNSCacheServiceProcessor::process_getMNSCacheWithVersionCheck;
+ processMap_["getMNSCacheByAppkeys"] = &MNSCacheServiceProcessor::process_getMNSCacheByAppkeys;
+ processMap_["getProvidersByIP"] = &MNSCacheServiceProcessor::process_getProvidersByIP;
+ processMap_["getAppkeyListByIP"] = &MNSCacheServiceProcessor::process_getAppkeyListByIP;
+ }
+
+ virtual bool process(boost::shared_ptr piprot, boost::shared_ptr poprot, void* callContext);
+ virtual ~MNSCacheServiceProcessor() {}
+};
+
+class MNSCacheServiceProcessorFactory : public ::apache::thrift::TProcessorFactory {
+ public:
+ MNSCacheServiceProcessorFactory(const ::boost::shared_ptr< MNSCacheServiceIfFactory >& handlerFactory) :
+ handlerFactory_(handlerFactory) {}
+
+ ::boost::shared_ptr< ::apache::thrift::TProcessor > getProcessor(const ::apache::thrift::TConnectionInfo& connInfo);
+
+ protected:
+ ::boost::shared_ptr< MNSCacheServiceIfFactory > handlerFactory_;
+};
+
+class MNSCacheServiceMultiface : virtual public MNSCacheServiceIf {
+ public:
+ MNSCacheServiceMultiface(std::vector >& ifaces) : ifaces_(ifaces) {
+ }
+ virtual ~MNSCacheServiceMultiface() {}
+ protected:
+ std::vector > ifaces_;
+ MNSCacheServiceMultiface() {}
+ void add(boost::shared_ptr iface) {
+ ifaces_.push_back(iface);
+ }
+ public:
+ void getMNSCache(MNSResponse& _return, const std::string& appkey, const std::string& version, const std::string& env) {
+ size_t sz = ifaces_.size();
+ for (size_t i = 0; i < sz; ++i) {
+ if (i == sz - 1) {
+ ifaces_[i]->getMNSCache(_return, appkey, version, env);
+ return;
+ } else {
+ ifaces_[i]->getMNSCache(_return, appkey, version, env);
+ }
+ }
+ }
+
+ void getMNSCacheHttp(MNSResponse& _return, const std::string& appkey, const std::string& version, const std::string& env) {
+ size_t sz = ifaces_.size();
+ for (size_t i = 0; i < sz; ++i) {
+ if (i == sz - 1) {
+ ifaces_[i]->getMNSCacheHttp(_return, appkey, version, env);
+ return;
+ } else {
+ ifaces_[i]->getMNSCacheHttp(_return, appkey, version, env);
+ }
+ }
+ }
+
+ void getMNSCacheWithVersionCheck(MNSResponse& _return, const MnsRequest& req) {
+ size_t sz = ifaces_.size();
+ for (size_t i = 0; i < sz; ++i) {
+ if (i == sz - 1) {
+ ifaces_[i]->getMNSCacheWithVersionCheck(_return, req);
+ return;
+ } else {
+ ifaces_[i]->getMNSCacheWithVersionCheck(_return, req);
+ }
+ }
+ }
+
+ void getMNSCacheByAppkeys(MNSBatchResponse& _return, const std::vector & appkeys, const std::string& protocol) {
+ size_t sz = ifaces_.size();
+ for (size_t i = 0; i < sz; ++i) {
+ if (i == sz - 1) {
+ ifaces_[i]->getMNSCacheByAppkeys(_return, appkeys, protocol);
+ return;
+ } else {
+ ifaces_[i]->getMNSCacheByAppkeys(_return, appkeys, protocol);
+ }
+ }
+ }
+
+ void getProvidersByIP(MNSResponse& _return, const std::string& ip) {
+ size_t sz = ifaces_.size();
+ for (size_t i = 0; i < sz; ++i) {
+ if (i == sz - 1) {
+ ifaces_[i]->getProvidersByIP(_return, ip);
+ return;
+ } else {
+ ifaces_[i]->getProvidersByIP(_return, ip);
+ }
+ }
+ }
+
+ void getAppkeyListByIP(AppKeyListResponse& _return, const std::string& ip) {
+ size_t sz = ifaces_.size();
+ for (size_t i = 0; i < sz; ++i) {
+ if (i == sz - 1) {
+ ifaces_[i]->getAppkeyListByIP(_return, ip);
+ return;
+ } else {
+ ifaces_[i]->getAppkeyListByIP(_return, ip);
+ }
+ }
+ }
+
+};
+
+} // namespace
+
+#endif
diff --git a/common/gen-cpp/ServiceAgent.cpp b/common/gen-cpp/ServiceAgent.cpp
new file mode 100644
index 0000000..4aee0f3
--- /dev/null
+++ b/common/gen-cpp/ServiceAgent.cpp
@@ -0,0 +1,1428 @@
+/**
+ * Autogenerated by Thrift Compiler (0.8.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ * @generated
+ */
+#include "ServiceAgent.h"
+
+namespace meituan_mns {
+
+uint32_t ServiceAgent_getServiceListByProtocol_args::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 1:
+ if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+ xfer += this->req.read(iprot);
+ this->__isset.req = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t ServiceAgent_getServiceListByProtocol_args::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("ServiceAgent_getServiceListByProtocol_args");
+ xfer += oprot->writeFieldBegin("req", ::apache::thrift::protocol::T_STRUCT, 1);
+ xfer += this->req.write(oprot);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+uint32_t ServiceAgent_getServiceListByProtocol_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("ServiceAgent_getServiceListByProtocol_pargs");
+ xfer += oprot->writeFieldBegin("req", ::apache::thrift::protocol::T_STRUCT, 1);
+ xfer += (*(this->req)).write(oprot);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+uint32_t ServiceAgent_getServiceListByProtocol_result::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 0:
+ if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+ xfer += this->success.read(iprot);
+ this->__isset.success = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t ServiceAgent_getServiceListByProtocol_result::write(::apache::thrift::protocol::TProtocol* oprot) const {
+
+ uint32_t xfer = 0;
+
+ xfer += oprot->writeStructBegin("ServiceAgent_getServiceListByProtocol_result");
+
+ if (this->__isset.success) {
+ xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_STRUCT, 0);
+ xfer += this->success.write(oprot);
+ xfer += oprot->writeFieldEnd();
+ }
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+uint32_t ServiceAgent_getServiceListByProtocol_presult::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 0:
+ if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+ xfer += (*(this->success)).read(iprot);
+ this->__isset.success = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t ServiceAgent_getOriginServiceList_args::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 1:
+ if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+ xfer += this->req.read(iprot);
+ this->__isset.req = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t ServiceAgent_getOriginServiceList_args::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("ServiceAgent_getOriginServiceList_args");
+ xfer += oprot->writeFieldBegin("req", ::apache::thrift::protocol::T_STRUCT, 1);
+ xfer += this->req.write(oprot);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+uint32_t ServiceAgent_getOriginServiceList_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("ServiceAgent_getOriginServiceList_pargs");
+ xfer += oprot->writeFieldBegin("req", ::apache::thrift::protocol::T_STRUCT, 1);
+ xfer += (*(this->req)).write(oprot);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+uint32_t ServiceAgent_getOriginServiceList_result::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 0:
+ if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+ xfer += this->success.read(iprot);
+ this->__isset.success = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t ServiceAgent_getOriginServiceList_result::write(::apache::thrift::protocol::TProtocol* oprot) const {
+
+ uint32_t xfer = 0;
+
+ xfer += oprot->writeStructBegin("ServiceAgent_getOriginServiceList_result");
+
+ if (this->__isset.success) {
+ xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_STRUCT, 0);
+ xfer += this->success.write(oprot);
+ xfer += oprot->writeFieldEnd();
+ }
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+uint32_t ServiceAgent_getOriginServiceList_presult::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 0:
+ if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+ xfer += (*(this->success)).read(iprot);
+ this->__isset.success = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t ServiceAgent_registService_args::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 1:
+ if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+ xfer += this->oService.read(iprot);
+ this->__isset.oService = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t ServiceAgent_registService_args::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("ServiceAgent_registService_args");
+ xfer += oprot->writeFieldBegin("oService", ::apache::thrift::protocol::T_STRUCT, 1);
+ xfer += this->oService.write(oprot);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+uint32_t ServiceAgent_registService_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("ServiceAgent_registService_pargs");
+ xfer += oprot->writeFieldBegin("oService", ::apache::thrift::protocol::T_STRUCT, 1);
+ xfer += (*(this->oService)).write(oprot);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+uint32_t ServiceAgent_registService_result::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 0:
+ if (ftype == ::apache::thrift::protocol::T_I32) {
+ xfer += iprot->readI32(this->success);
+ this->__isset.success = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t ServiceAgent_registService_result::write(::apache::thrift::protocol::TProtocol* oprot) const {
+
+ uint32_t xfer = 0;
+
+ xfer += oprot->writeStructBegin("ServiceAgent_registService_result");
+
+ if (this->__isset.success) {
+ xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_I32, 0);
+ xfer += oprot->writeI32(this->success);
+ xfer += oprot->writeFieldEnd();
+ }
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+uint32_t ServiceAgent_registService_presult::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 0:
+ if (ftype == ::apache::thrift::protocol::T_I32) {
+ xfer += iprot->readI32((*(this->success)));
+ this->__isset.success = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t ServiceAgent_registServicewithCmd_args::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 1:
+ if (ftype == ::apache::thrift::protocol::T_I32) {
+ xfer += iprot->readI32(this->uptCmd);
+ this->__isset.uptCmd = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 2:
+ if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+ xfer += this->oService.read(iprot);
+ this->__isset.oService = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t ServiceAgent_registServicewithCmd_args::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("ServiceAgent_registServicewithCmd_args");
+ xfer += oprot->writeFieldBegin("uptCmd", ::apache::thrift::protocol::T_I32, 1);
+ xfer += oprot->writeI32(this->uptCmd);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("oService", ::apache::thrift::protocol::T_STRUCT, 2);
+ xfer += this->oService.write(oprot);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+uint32_t ServiceAgent_registServicewithCmd_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("ServiceAgent_registServicewithCmd_pargs");
+ xfer += oprot->writeFieldBegin("uptCmd", ::apache::thrift::protocol::T_I32, 1);
+ xfer += oprot->writeI32((*(this->uptCmd)));
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("oService", ::apache::thrift::protocol::T_STRUCT, 2);
+ xfer += (*(this->oService)).write(oprot);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+uint32_t ServiceAgent_registServicewithCmd_result::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 0:
+ if (ftype == ::apache::thrift::protocol::T_I32) {
+ xfer += iprot->readI32(this->success);
+ this->__isset.success = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t ServiceAgent_registServicewithCmd_result::write(::apache::thrift::protocol::TProtocol* oprot) const {
+
+ uint32_t xfer = 0;
+
+ xfer += oprot->writeStructBegin("ServiceAgent_registServicewithCmd_result");
+
+ if (this->__isset.success) {
+ xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_I32, 0);
+ xfer += oprot->writeI32(this->success);
+ xfer += oprot->writeFieldEnd();
+ }
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+uint32_t ServiceAgent_registServicewithCmd_presult::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 0:
+ if (ftype == ::apache::thrift::protocol::T_I32) {
+ xfer += iprot->readI32((*(this->success)));
+ this->__isset.success = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t ServiceAgent_unRegistService_args::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 1:
+ if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+ xfer += this->oService.read(iprot);
+ this->__isset.oService = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t ServiceAgent_unRegistService_args::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("ServiceAgent_unRegistService_args");
+ xfer += oprot->writeFieldBegin("oService", ::apache::thrift::protocol::T_STRUCT, 1);
+ xfer += this->oService.write(oprot);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+uint32_t ServiceAgent_unRegistService_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("ServiceAgent_unRegistService_pargs");
+ xfer += oprot->writeFieldBegin("oService", ::apache::thrift::protocol::T_STRUCT, 1);
+ xfer += (*(this->oService)).write(oprot);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+uint32_t ServiceAgent_unRegistService_result::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 0:
+ if (ftype == ::apache::thrift::protocol::T_I32) {
+ xfer += iprot->readI32(this->success);
+ this->__isset.success = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t ServiceAgent_unRegistService_result::write(::apache::thrift::protocol::TProtocol* oprot) const {
+
+ uint32_t xfer = 0;
+
+ xfer += oprot->writeStructBegin("ServiceAgent_unRegistService_result");
+
+ if (this->__isset.success) {
+ xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_I32, 0);
+ xfer += oprot->writeI32(this->success);
+ xfer += oprot->writeFieldEnd();
+ }
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+uint32_t ServiceAgent_unRegistService_presult::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 0:
+ if (ftype == ::apache::thrift::protocol::T_I32) {
+ xfer += iprot->readI32((*(this->success)));
+ this->__isset.success = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+void ServiceAgentClient::getServiceListByProtocol(ProtocolResponse& _return, const ProtocolRequest& req)
+{
+ send_getServiceListByProtocol(req);
+ recv_getServiceListByProtocol(_return);
+}
+
+void ServiceAgentClient::send_getServiceListByProtocol(const ProtocolRequest& req)
+{
+ int32_t cseqid = 0;
+ oprot_->writeMessageBegin("getServiceListByProtocol", ::apache::thrift::protocol::T_CALL, cseqid);
+
+ ServiceAgent_getServiceListByProtocol_pargs args;
+ args.req = &req;
+ args.write(oprot_);
+
+ oprot_->writeMessageEnd();
+ oprot_->getTransport()->writeEnd();
+ oprot_->getTransport()->flush();
+}
+
+void ServiceAgentClient::recv_getServiceListByProtocol(ProtocolResponse& _return)
+{
+
+ int32_t rseqid = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TMessageType mtype;
+
+ iprot_->readMessageBegin(fname, mtype, rseqid);
+ if (mtype == ::apache::thrift::protocol::T_EXCEPTION) {
+ ::apache::thrift::TApplicationException x;
+ x.read(iprot_);
+ iprot_->readMessageEnd();
+ iprot_->getTransport()->readEnd();
+ throw x;
+ }
+ if (mtype != ::apache::thrift::protocol::T_REPLY) {
+ iprot_->skip(::apache::thrift::protocol::T_STRUCT);
+ iprot_->readMessageEnd();
+ iprot_->getTransport()->readEnd();
+ }
+ if (fname.compare("getServiceListByProtocol") != 0) {
+ iprot_->skip(::apache::thrift::protocol::T_STRUCT);
+ iprot_->readMessageEnd();
+ iprot_->getTransport()->readEnd();
+ }
+ ServiceAgent_getServiceListByProtocol_presult result;
+ result.success = &_return;
+ result.read(iprot_);
+ iprot_->readMessageEnd();
+ iprot_->getTransport()->readEnd();
+
+ if (result.__isset.success) {
+ // _return pointer has now been filled
+ return;
+ }
+ throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "getServiceListByProtocol failed: unknown result");
+}
+
+void ServiceAgentClient::getOriginServiceList(ProtocolResponse& _return, const ProtocolRequest& req)
+{
+ send_getOriginServiceList(req);
+ recv_getOriginServiceList(_return);
+}
+
+void ServiceAgentClient::send_getOriginServiceList(const ProtocolRequest& req)
+{
+ int32_t cseqid = 0;
+ oprot_->writeMessageBegin("getOriginServiceList", ::apache::thrift::protocol::T_CALL, cseqid);
+
+ ServiceAgent_getOriginServiceList_pargs args;
+ args.req = &req;
+ args.write(oprot_);
+
+ oprot_->writeMessageEnd();
+ oprot_->getTransport()->writeEnd();
+ oprot_->getTransport()->flush();
+}
+
+void ServiceAgentClient::recv_getOriginServiceList(ProtocolResponse& _return)
+{
+
+ int32_t rseqid = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TMessageType mtype;
+
+ iprot_->readMessageBegin(fname, mtype, rseqid);
+ if (mtype == ::apache::thrift::protocol::T_EXCEPTION) {
+ ::apache::thrift::TApplicationException x;
+ x.read(iprot_);
+ iprot_->readMessageEnd();
+ iprot_->getTransport()->readEnd();
+ throw x;
+ }
+ if (mtype != ::apache::thrift::protocol::T_REPLY) {
+ iprot_->skip(::apache::thrift::protocol::T_STRUCT);
+ iprot_->readMessageEnd();
+ iprot_->getTransport()->readEnd();
+ }
+ if (fname.compare("getOriginServiceList") != 0) {
+ iprot_->skip(::apache::thrift::protocol::T_STRUCT);
+ iprot_->readMessageEnd();
+ iprot_->getTransport()->readEnd();
+ }
+ ServiceAgent_getOriginServiceList_presult result;
+ result.success = &_return;
+ result.read(iprot_);
+ iprot_->readMessageEnd();
+ iprot_->getTransport()->readEnd();
+
+ if (result.__isset.success) {
+ // _return pointer has now been filled
+ return;
+ }
+ throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "getOriginServiceList failed: unknown result");
+}
+
+int32_t ServiceAgentClient::registService(const SGService& oService)
+{
+ send_registService(oService);
+ return recv_registService();
+}
+
+void ServiceAgentClient::send_registService(const SGService& oService)
+{
+ int32_t cseqid = 0;
+ oprot_->writeMessageBegin("registService", ::apache::thrift::protocol::T_CALL, cseqid);
+
+ ServiceAgent_registService_pargs args;
+ args.oService = &oService;
+ args.write(oprot_);
+
+ oprot_->writeMessageEnd();
+ oprot_->getTransport()->writeEnd();
+ oprot_->getTransport()->flush();
+}
+
+int32_t ServiceAgentClient::recv_registService()
+{
+
+ int32_t rseqid = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TMessageType mtype;
+
+ iprot_->readMessageBegin(fname, mtype, rseqid);
+ if (mtype == ::apache::thrift::protocol::T_EXCEPTION) {
+ ::apache::thrift::TApplicationException x;
+ x.read(iprot_);
+ iprot_->readMessageEnd();
+ iprot_->getTransport()->readEnd();
+ throw x;
+ }
+ if (mtype != ::apache::thrift::protocol::T_REPLY) {
+ iprot_->skip(::apache::thrift::protocol::T_STRUCT);
+ iprot_->readMessageEnd();
+ iprot_->getTransport()->readEnd();
+ }
+ if (fname.compare("registService") != 0) {
+ iprot_->skip(::apache::thrift::protocol::T_STRUCT);
+ iprot_->readMessageEnd();
+ iprot_->getTransport()->readEnd();
+ }
+ int32_t _return;
+ ServiceAgent_registService_presult result;
+ result.success = &_return;
+ result.read(iprot_);
+ iprot_->readMessageEnd();
+ iprot_->getTransport()->readEnd();
+
+ if (result.__isset.success) {
+ return _return;
+ }
+ throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "registService failed: unknown result");
+}
+
+int32_t ServiceAgentClient::registServicewithCmd(const int32_t uptCmd, const SGService& oService)
+{
+ send_registServicewithCmd(uptCmd, oService);
+ return recv_registServicewithCmd();
+}
+
+void ServiceAgentClient::send_registServicewithCmd(const int32_t uptCmd, const SGService& oService)
+{
+ int32_t cseqid = 0;
+ oprot_->writeMessageBegin("registServicewithCmd", ::apache::thrift::protocol::T_CALL, cseqid);
+
+ ServiceAgent_registServicewithCmd_pargs args;
+ args.uptCmd = &uptCmd;
+ args.oService = &oService;
+ args.write(oprot_);
+
+ oprot_->writeMessageEnd();
+ oprot_->getTransport()->writeEnd();
+ oprot_->getTransport()->flush();
+}
+
+int32_t ServiceAgentClient::recv_registServicewithCmd()
+{
+
+ int32_t rseqid = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TMessageType mtype;
+
+ iprot_->readMessageBegin(fname, mtype, rseqid);
+ if (mtype == ::apache::thrift::protocol::T_EXCEPTION) {
+ ::apache::thrift::TApplicationException x;
+ x.read(iprot_);
+ iprot_->readMessageEnd();
+ iprot_->getTransport()->readEnd();
+ throw x;
+ }
+ if (mtype != ::apache::thrift::protocol::T_REPLY) {
+ iprot_->skip(::apache::thrift::protocol::T_STRUCT);
+ iprot_->readMessageEnd();
+ iprot_->getTransport()->readEnd();
+ }
+ if (fname.compare("registServicewithCmd") != 0) {
+ iprot_->skip(::apache::thrift::protocol::T_STRUCT);
+ iprot_->readMessageEnd();
+ iprot_->getTransport()->readEnd();
+ }
+ int32_t _return;
+ ServiceAgent_registServicewithCmd_presult result;
+ result.success = &_return;
+ result.read(iprot_);
+ iprot_->readMessageEnd();
+ iprot_->getTransport()->readEnd();
+
+ if (result.__isset.success) {
+ return _return;
+ }
+ throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "registServicewithCmd failed: unknown result");
+}
+
+int32_t ServiceAgentClient::unRegistService(const SGService& oService)
+{
+ send_unRegistService(oService);
+ return recv_unRegistService();
+}
+
+void ServiceAgentClient::send_unRegistService(const SGService& oService)
+{
+ int32_t cseqid = 0;
+ oprot_->writeMessageBegin("unRegistService", ::apache::thrift::protocol::T_CALL, cseqid);
+
+ ServiceAgent_unRegistService_pargs args;
+ args.oService = &oService;
+ args.write(oprot_);
+
+ oprot_->writeMessageEnd();
+ oprot_->getTransport()->writeEnd();
+ oprot_->getTransport()->flush();
+}
+
+int32_t ServiceAgentClient::recv_unRegistService()
+{
+
+ int32_t rseqid = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TMessageType mtype;
+
+ iprot_->readMessageBegin(fname, mtype, rseqid);
+ if (mtype == ::apache::thrift::protocol::T_EXCEPTION) {
+ ::apache::thrift::TApplicationException x;
+ x.read(iprot_);
+ iprot_->readMessageEnd();
+ iprot_->getTransport()->readEnd();
+ throw x;
+ }
+ if (mtype != ::apache::thrift::protocol::T_REPLY) {
+ iprot_->skip(::apache::thrift::protocol::T_STRUCT);
+ iprot_->readMessageEnd();
+ iprot_->getTransport()->readEnd();
+ }
+ if (fname.compare("unRegistService") != 0) {
+ iprot_->skip(::apache::thrift::protocol::T_STRUCT);
+ iprot_->readMessageEnd();
+ iprot_->getTransport()->readEnd();
+ }
+ int32_t _return;
+ ServiceAgent_unRegistService_presult result;
+ result.success = &_return;
+ result.read(iprot_);
+ iprot_->readMessageEnd();
+ iprot_->getTransport()->readEnd();
+
+ if (result.__isset.success) {
+ return _return;
+ }
+ throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "unRegistService failed: unknown result");
+}
+
+bool ServiceAgentProcessor::process(boost::shared_ptr piprot, boost::shared_ptr poprot, void* callContext) {
+
+ ::apache::thrift::protocol::TProtocol* iprot = piprot.get();
+ ::apache::thrift::protocol::TProtocol* oprot = poprot.get();
+ std::string fname;
+ ::apache::thrift::protocol::TMessageType mtype;
+ int32_t seqid;
+
+ iprot->readMessageBegin(fname, mtype, seqid);
+
+ if (mtype != ::apache::thrift::protocol::T_CALL && mtype != ::apache::thrift::protocol::T_ONEWAY) {
+ iprot->skip(::apache::thrift::protocol::T_STRUCT);
+ iprot->readMessageEnd();
+ iprot->getTransport()->readEnd();
+ ::apache::thrift::TApplicationException x(::apache::thrift::TApplicationException::INVALID_MESSAGE_TYPE);
+ oprot->writeMessageBegin(fname, ::apache::thrift::protocol::T_EXCEPTION, seqid);
+ x.write(oprot);
+ oprot->writeMessageEnd();
+ oprot->getTransport()->writeEnd();
+ oprot->getTransport()->flush();
+ return true;
+ }
+
+ return process_fn(iprot, oprot, fname, seqid, callContext);
+}
+
+bool ServiceAgentProcessor::process_fn(apache::thrift::protocol::TProtocol* iprot, apache::thrift::protocol::TProtocol* oprot, std::string& fname, int32_t seqid, void* callContext) {
+ std::map::iterator pfn;
+ pfn = processMap_.find(fname);
+ if (pfn == processMap_.end()) {
+ iprot->skip(apache::thrift::protocol::T_STRUCT);
+ iprot->readMessageEnd();
+ iprot->getTransport()->readEnd();
+ ::apache::thrift::TApplicationException x(::apache::thrift::TApplicationException::UNKNOWN_METHOD, "Invalid method name: '"+fname+"'");
+ oprot->writeMessageBegin(fname, ::apache::thrift::protocol::T_EXCEPTION, seqid);
+ x.write(oprot);
+ oprot->writeMessageEnd();
+ oprot->getTransport()->writeEnd();
+ oprot->getTransport()->flush();
+ return true;
+ }
+ (this->*(pfn->second))(seqid, iprot, oprot, callContext);
+ return true;
+}
+
+void ServiceAgentProcessor::process_getServiceListByProtocol(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext)
+{
+ void* ctx = NULL;
+ if (this->eventHandler_.get() != NULL) {
+ ctx = this->eventHandler_->getContext("ServiceAgent.getServiceListByProtocol", callContext);
+ }
+ apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "ServiceAgent.getServiceListByProtocol");
+
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->preRead(ctx, "ServiceAgent.getServiceListByProtocol");
+ }
+
+ ServiceAgent_getServiceListByProtocol_args args;
+ args.read(iprot);
+ iprot->readMessageEnd();
+ uint32_t bytes = iprot->getTransport()->readEnd();
+
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->postRead(ctx, "ServiceAgent.getServiceListByProtocol", bytes);
+ }
+
+ ServiceAgent_getServiceListByProtocol_result result;
+ try {
+ iface_->getServiceListByProtocol(result.success, args.req);
+ result.__isset.success = true;
+ } catch (const std::exception& e) {
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->handlerError(ctx, "ServiceAgent.getServiceListByProtocol");
+ }
+
+ apache::thrift::TApplicationException x(e.what());
+ oprot->writeMessageBegin("getServiceListByProtocol", apache::thrift::protocol::T_EXCEPTION, seqid);
+ x.write(oprot);
+ oprot->writeMessageEnd();
+ oprot->getTransport()->writeEnd();
+ oprot->getTransport()->flush();
+ return;
+ }
+
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->preWrite(ctx, "ServiceAgent.getServiceListByProtocol");
+ }
+
+ oprot->writeMessageBegin("getServiceListByProtocol", apache::thrift::protocol::T_REPLY, seqid);
+ result.write(oprot);
+ oprot->writeMessageEnd();
+ bytes = oprot->getTransport()->writeEnd();
+ oprot->getTransport()->flush();
+
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->postWrite(ctx, "ServiceAgent.getServiceListByProtocol", bytes);
+ }
+}
+
+void ServiceAgentProcessor::process_getOriginServiceList(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext)
+{
+ void* ctx = NULL;
+ if (this->eventHandler_.get() != NULL) {
+ ctx = this->eventHandler_->getContext("ServiceAgent.getOriginServiceList", callContext);
+ }
+ apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "ServiceAgent.getOriginServiceList");
+
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->preRead(ctx, "ServiceAgent.getOriginServiceList");
+ }
+
+ ServiceAgent_getOriginServiceList_args args;
+ args.read(iprot);
+ iprot->readMessageEnd();
+ uint32_t bytes = iprot->getTransport()->readEnd();
+
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->postRead(ctx, "ServiceAgent.getOriginServiceList", bytes);
+ }
+
+ ServiceAgent_getOriginServiceList_result result;
+ try {
+ iface_->getOriginServiceList(result.success, args.req);
+ result.__isset.success = true;
+ } catch (const std::exception& e) {
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->handlerError(ctx, "ServiceAgent.getOriginServiceList");
+ }
+
+ apache::thrift::TApplicationException x(e.what());
+ oprot->writeMessageBegin("getOriginServiceList", apache::thrift::protocol::T_EXCEPTION, seqid);
+ x.write(oprot);
+ oprot->writeMessageEnd();
+ oprot->getTransport()->writeEnd();
+ oprot->getTransport()->flush();
+ return;
+ }
+
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->preWrite(ctx, "ServiceAgent.getOriginServiceList");
+ }
+
+ oprot->writeMessageBegin("getOriginServiceList", apache::thrift::protocol::T_REPLY, seqid);
+ result.write(oprot);
+ oprot->writeMessageEnd();
+ bytes = oprot->getTransport()->writeEnd();
+ oprot->getTransport()->flush();
+
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->postWrite(ctx, "ServiceAgent.getOriginServiceList", bytes);
+ }
+}
+
+void ServiceAgentProcessor::process_registService(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext)
+{
+ void* ctx = NULL;
+ if (this->eventHandler_.get() != NULL) {
+ ctx = this->eventHandler_->getContext("ServiceAgent.registService", callContext);
+ }
+ apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "ServiceAgent.registService");
+
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->preRead(ctx, "ServiceAgent.registService");
+ }
+
+ ServiceAgent_registService_args args;
+ args.read(iprot);
+ iprot->readMessageEnd();
+ uint32_t bytes = iprot->getTransport()->readEnd();
+
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->postRead(ctx, "ServiceAgent.registService", bytes);
+ }
+
+ ServiceAgent_registService_result result;
+ try {
+ result.success = iface_->registService(args.oService);
+ result.__isset.success = true;
+ } catch (const std::exception& e) {
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->handlerError(ctx, "ServiceAgent.registService");
+ }
+
+ apache::thrift::TApplicationException x(e.what());
+ oprot->writeMessageBegin("registService", apache::thrift::protocol::T_EXCEPTION, seqid);
+ x.write(oprot);
+ oprot->writeMessageEnd();
+ oprot->getTransport()->writeEnd();
+ oprot->getTransport()->flush();
+ return;
+ }
+
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->preWrite(ctx, "ServiceAgent.registService");
+ }
+
+ oprot->writeMessageBegin("registService", apache::thrift::protocol::T_REPLY, seqid);
+ result.write(oprot);
+ oprot->writeMessageEnd();
+ bytes = oprot->getTransport()->writeEnd();
+ oprot->getTransport()->flush();
+
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->postWrite(ctx, "ServiceAgent.registService", bytes);
+ }
+}
+
+void ServiceAgentProcessor::process_registServicewithCmd(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext)
+{
+ void* ctx = NULL;
+ if (this->eventHandler_.get() != NULL) {
+ ctx = this->eventHandler_->getContext("ServiceAgent.registServicewithCmd", callContext);
+ }
+ apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "ServiceAgent.registServicewithCmd");
+
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->preRead(ctx, "ServiceAgent.registServicewithCmd");
+ }
+
+ ServiceAgent_registServicewithCmd_args args;
+ args.read(iprot);
+ iprot->readMessageEnd();
+ uint32_t bytes = iprot->getTransport()->readEnd();
+
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->postRead(ctx, "ServiceAgent.registServicewithCmd", bytes);
+ }
+
+ ServiceAgent_registServicewithCmd_result result;
+ try {
+ result.success = iface_->registServicewithCmd(args.uptCmd, args.oService);
+ result.__isset.success = true;
+ } catch (const std::exception& e) {
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->handlerError(ctx, "ServiceAgent.registServicewithCmd");
+ }
+
+ apache::thrift::TApplicationException x(e.what());
+ oprot->writeMessageBegin("registServicewithCmd", apache::thrift::protocol::T_EXCEPTION, seqid);
+ x.write(oprot);
+ oprot->writeMessageEnd();
+ oprot->getTransport()->writeEnd();
+ oprot->getTransport()->flush();
+ return;
+ }
+
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->preWrite(ctx, "ServiceAgent.registServicewithCmd");
+ }
+
+ oprot->writeMessageBegin("registServicewithCmd", apache::thrift::protocol::T_REPLY, seqid);
+ result.write(oprot);
+ oprot->writeMessageEnd();
+ bytes = oprot->getTransport()->writeEnd();
+ oprot->getTransport()->flush();
+
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->postWrite(ctx, "ServiceAgent.registServicewithCmd", bytes);
+ }
+}
+
+void ServiceAgentProcessor::process_unRegistService(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext)
+{
+ void* ctx = NULL;
+ if (this->eventHandler_.get() != NULL) {
+ ctx = this->eventHandler_->getContext("ServiceAgent.unRegistService", callContext);
+ }
+ apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "ServiceAgent.unRegistService");
+
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->preRead(ctx, "ServiceAgent.unRegistService");
+ }
+
+ ServiceAgent_unRegistService_args args;
+ args.read(iprot);
+ iprot->readMessageEnd();
+ uint32_t bytes = iprot->getTransport()->readEnd();
+
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->postRead(ctx, "ServiceAgent.unRegistService", bytes);
+ }
+
+ ServiceAgent_unRegistService_result result;
+ try {
+ result.success = iface_->unRegistService(args.oService);
+ result.__isset.success = true;
+ } catch (const std::exception& e) {
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->handlerError(ctx, "ServiceAgent.unRegistService");
+ }
+
+ apache::thrift::TApplicationException x(e.what());
+ oprot->writeMessageBegin("unRegistService", apache::thrift::protocol::T_EXCEPTION, seqid);
+ x.write(oprot);
+ oprot->writeMessageEnd();
+ oprot->getTransport()->writeEnd();
+ oprot->getTransport()->flush();
+ return;
+ }
+
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->preWrite(ctx, "ServiceAgent.unRegistService");
+ }
+
+ oprot->writeMessageBegin("unRegistService", apache::thrift::protocol::T_REPLY, seqid);
+ result.write(oprot);
+ oprot->writeMessageEnd();
+ bytes = oprot->getTransport()->writeEnd();
+ oprot->getTransport()->flush();
+
+ if (this->eventHandler_.get() != NULL) {
+ this->eventHandler_->postWrite(ctx, "ServiceAgent.unRegistService", bytes);
+ }
+}
+
+::boost::shared_ptr< ::apache::thrift::TProcessor > ServiceAgentProcessorFactory::getProcessor(const ::apache::thrift::TConnectionInfo& connInfo) {
+ ::apache::thrift::ReleaseHandler< ServiceAgentIfFactory > cleanup(handlerFactory_);
+ ::boost::shared_ptr< ServiceAgentIf > handler(handlerFactory_->getHandler(connInfo), cleanup);
+ ::boost::shared_ptr< ::apache::thrift::TProcessor > processor(new ServiceAgentProcessor(handler));
+ return processor;
+}
+} // namespace
+
diff --git a/common/gen-cpp/ServiceAgent.h b/common/gen-cpp/ServiceAgent.h
new file mode 100644
index 0000000..b20dd69
--- /dev/null
+++ b/common/gen-cpp/ServiceAgent.h
@@ -0,0 +1,772 @@
+/**
+ * Autogenerated by Thrift Compiler (0.8.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ * @generated
+ */
+#ifndef ServiceAgent_H
+#define ServiceAgent_H
+
+#include
+#include "naming_service_types.h"
+
+namespace meituan_mns {
+
+class ServiceAgentIf {
+ public:
+ virtual ~ServiceAgentIf() {}
+ virtual void getServiceListByProtocol(ProtocolResponse& _return, const ProtocolRequest& req) = 0;
+ virtual void getOriginServiceList(ProtocolResponse& _return, const ProtocolRequest& req) = 0;
+ virtual int32_t registService(const SGService& oService) = 0;
+ virtual int32_t registServicewithCmd(const int32_t uptCmd, const SGService& oService) = 0;
+ virtual int32_t unRegistService(const SGService& oService) = 0;
+};
+
+class ServiceAgentIfFactory {
+ public:
+ typedef ServiceAgentIf Handler;
+
+ virtual ~ServiceAgentIfFactory() {}
+
+ virtual ServiceAgentIf* getHandler(const ::apache::thrift::TConnectionInfo& connInfo) = 0;
+ virtual void releaseHandler(ServiceAgentIf* /* handler */) = 0;
+};
+
+class ServiceAgentIfSingletonFactory : virtual public ServiceAgentIfFactory {
+ public:
+ ServiceAgentIfSingletonFactory(const boost::shared_ptr& iface) : iface_(iface) {}
+ virtual ~ServiceAgentIfSingletonFactory() {}
+
+ virtual ServiceAgentIf* getHandler(const ::apache::thrift::TConnectionInfo&) {
+ return iface_.get();
+ }
+ virtual void releaseHandler(ServiceAgentIf* /* handler */) {}
+
+ protected:
+ boost::shared_ptr iface_;
+};
+
+class ServiceAgentNull : virtual public ServiceAgentIf {
+ public:
+ virtual ~ServiceAgentNull() {}
+ void getServiceListByProtocol(ProtocolResponse& /* _return */, const ProtocolRequest& /* req */) {
+ return;
+ }
+ void getOriginServiceList(ProtocolResponse& /* _return */, const ProtocolRequest& /* req */) {
+ return;
+ }
+ int32_t registService(const SGService& /* oService */) {
+ int32_t _return = 0;
+ return _return;
+ }
+ int32_t registServicewithCmd(const int32_t /* uptCmd */, const SGService& /* oService */) {
+ int32_t _return = 0;
+ return _return;
+ }
+ int32_t unRegistService(const SGService& /* oService */) {
+ int32_t _return = 0;
+ return _return;
+ }
+};
+
+typedef struct _ServiceAgent_getServiceListByProtocol_args__isset {
+ _ServiceAgent_getServiceListByProtocol_args__isset() : req(false) {}
+ bool req;
+} _ServiceAgent_getServiceListByProtocol_args__isset;
+
+class ServiceAgent_getServiceListByProtocol_args {
+ public:
+
+ ServiceAgent_getServiceListByProtocol_args() {
+ }
+
+ virtual ~ServiceAgent_getServiceListByProtocol_args() throw() {}
+
+ ProtocolRequest req;
+
+ _ServiceAgent_getServiceListByProtocol_args__isset __isset;
+
+ void __set_req(const ProtocolRequest& val) {
+ req = val;
+ }
+
+ bool operator == (const ServiceAgent_getServiceListByProtocol_args & rhs) const
+ {
+ if (!(req == rhs.req))
+ return false;
+ return true;
+ }
+ bool operator != (const ServiceAgent_getServiceListByProtocol_args &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const ServiceAgent_getServiceListByProtocol_args & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+
+class ServiceAgent_getServiceListByProtocol_pargs {
+ public:
+
+
+ virtual ~ServiceAgent_getServiceListByProtocol_pargs() throw() {}
+
+ const ProtocolRequest* req;
+
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _ServiceAgent_getServiceListByProtocol_result__isset {
+ _ServiceAgent_getServiceListByProtocol_result__isset() : success(false) {}
+ bool success;
+} _ServiceAgent_getServiceListByProtocol_result__isset;
+
+class ServiceAgent_getServiceListByProtocol_result {
+ public:
+
+ ServiceAgent_getServiceListByProtocol_result() {
+ }
+
+ virtual ~ServiceAgent_getServiceListByProtocol_result() throw() {}
+
+ ProtocolResponse success;
+
+ _ServiceAgent_getServiceListByProtocol_result__isset __isset;
+
+ void __set_success(const ProtocolResponse& val) {
+ success = val;
+ }
+
+ bool operator == (const ServiceAgent_getServiceListByProtocol_result & rhs) const
+ {
+ if (!(success == rhs.success))
+ return false;
+ return true;
+ }
+ bool operator != (const ServiceAgent_getServiceListByProtocol_result &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const ServiceAgent_getServiceListByProtocol_result & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _ServiceAgent_getServiceListByProtocol_presult__isset {
+ _ServiceAgent_getServiceListByProtocol_presult__isset() : success(false) {}
+ bool success;
+} _ServiceAgent_getServiceListByProtocol_presult__isset;
+
+class ServiceAgent_getServiceListByProtocol_presult {
+ public:
+
+
+ virtual ~ServiceAgent_getServiceListByProtocol_presult() throw() {}
+
+ ProtocolResponse* success;
+
+ _ServiceAgent_getServiceListByProtocol_presult__isset __isset;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+
+};
+
+typedef struct _ServiceAgent_getOriginServiceList_args__isset {
+ _ServiceAgent_getOriginServiceList_args__isset() : req(false) {}
+ bool req;
+} _ServiceAgent_getOriginServiceList_args__isset;
+
+class ServiceAgent_getOriginServiceList_args {
+ public:
+
+ ServiceAgent_getOriginServiceList_args() {
+ }
+
+ virtual ~ServiceAgent_getOriginServiceList_args() throw() {}
+
+ ProtocolRequest req;
+
+ _ServiceAgent_getOriginServiceList_args__isset __isset;
+
+ void __set_req(const ProtocolRequest& val) {
+ req = val;
+ }
+
+ bool operator == (const ServiceAgent_getOriginServiceList_args & rhs) const
+ {
+ if (!(req == rhs.req))
+ return false;
+ return true;
+ }
+ bool operator != (const ServiceAgent_getOriginServiceList_args &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const ServiceAgent_getOriginServiceList_args & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+
+class ServiceAgent_getOriginServiceList_pargs {
+ public:
+
+
+ virtual ~ServiceAgent_getOriginServiceList_pargs() throw() {}
+
+ const ProtocolRequest* req;
+
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _ServiceAgent_getOriginServiceList_result__isset {
+ _ServiceAgent_getOriginServiceList_result__isset() : success(false) {}
+ bool success;
+} _ServiceAgent_getOriginServiceList_result__isset;
+
+class ServiceAgent_getOriginServiceList_result {
+ public:
+
+ ServiceAgent_getOriginServiceList_result() {
+ }
+
+ virtual ~ServiceAgent_getOriginServiceList_result() throw() {}
+
+ ProtocolResponse success;
+
+ _ServiceAgent_getOriginServiceList_result__isset __isset;
+
+ void __set_success(const ProtocolResponse& val) {
+ success = val;
+ }
+
+ bool operator == (const ServiceAgent_getOriginServiceList_result & rhs) const
+ {
+ if (!(success == rhs.success))
+ return false;
+ return true;
+ }
+ bool operator != (const ServiceAgent_getOriginServiceList_result &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const ServiceAgent_getOriginServiceList_result & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _ServiceAgent_getOriginServiceList_presult__isset {
+ _ServiceAgent_getOriginServiceList_presult__isset() : success(false) {}
+ bool success;
+} _ServiceAgent_getOriginServiceList_presult__isset;
+
+class ServiceAgent_getOriginServiceList_presult {
+ public:
+
+
+ virtual ~ServiceAgent_getOriginServiceList_presult() throw() {}
+
+ ProtocolResponse* success;
+
+ _ServiceAgent_getOriginServiceList_presult__isset __isset;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+
+};
+
+typedef struct _ServiceAgent_registService_args__isset {
+ _ServiceAgent_registService_args__isset() : oService(false) {}
+ bool oService;
+} _ServiceAgent_registService_args__isset;
+
+class ServiceAgent_registService_args {
+ public:
+
+ ServiceAgent_registService_args() {
+ }
+
+ virtual ~ServiceAgent_registService_args() throw() {}
+
+ SGService oService;
+
+ _ServiceAgent_registService_args__isset __isset;
+
+ void __set_oService(const SGService& val) {
+ oService = val;
+ }
+
+ bool operator == (const ServiceAgent_registService_args & rhs) const
+ {
+ if (!(oService == rhs.oService))
+ return false;
+ return true;
+ }
+ bool operator != (const ServiceAgent_registService_args &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const ServiceAgent_registService_args & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+
+class ServiceAgent_registService_pargs {
+ public:
+
+
+ virtual ~ServiceAgent_registService_pargs() throw() {}
+
+ const SGService* oService;
+
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _ServiceAgent_registService_result__isset {
+ _ServiceAgent_registService_result__isset() : success(false) {}
+ bool success;
+} _ServiceAgent_registService_result__isset;
+
+class ServiceAgent_registService_result {
+ public:
+
+ ServiceAgent_registService_result() : success(0) {
+ }
+
+ virtual ~ServiceAgent_registService_result() throw() {}
+
+ int32_t success;
+
+ _ServiceAgent_registService_result__isset __isset;
+
+ void __set_success(const int32_t val) {
+ success = val;
+ }
+
+ bool operator == (const ServiceAgent_registService_result & rhs) const
+ {
+ if (!(success == rhs.success))
+ return false;
+ return true;
+ }
+ bool operator != (const ServiceAgent_registService_result &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const ServiceAgent_registService_result & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _ServiceAgent_registService_presult__isset {
+ _ServiceAgent_registService_presult__isset() : success(false) {}
+ bool success;
+} _ServiceAgent_registService_presult__isset;
+
+class ServiceAgent_registService_presult {
+ public:
+
+
+ virtual ~ServiceAgent_registService_presult() throw() {}
+
+ int32_t* success;
+
+ _ServiceAgent_registService_presult__isset __isset;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+
+};
+
+typedef struct _ServiceAgent_registServicewithCmd_args__isset {
+ _ServiceAgent_registServicewithCmd_args__isset() : uptCmd(false), oService(false) {}
+ bool uptCmd;
+ bool oService;
+} _ServiceAgent_registServicewithCmd_args__isset;
+
+class ServiceAgent_registServicewithCmd_args {
+ public:
+
+ ServiceAgent_registServicewithCmd_args() : uptCmd(0) {
+ }
+
+ virtual ~ServiceAgent_registServicewithCmd_args() throw() {}
+
+ int32_t uptCmd;
+ SGService oService;
+
+ _ServiceAgent_registServicewithCmd_args__isset __isset;
+
+ void __set_uptCmd(const int32_t val) {
+ uptCmd = val;
+ }
+
+ void __set_oService(const SGService& val) {
+ oService = val;
+ }
+
+ bool operator == (const ServiceAgent_registServicewithCmd_args & rhs) const
+ {
+ if (!(uptCmd == rhs.uptCmd))
+ return false;
+ if (!(oService == rhs.oService))
+ return false;
+ return true;
+ }
+ bool operator != (const ServiceAgent_registServicewithCmd_args &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const ServiceAgent_registServicewithCmd_args & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+
+class ServiceAgent_registServicewithCmd_pargs {
+ public:
+
+
+ virtual ~ServiceAgent_registServicewithCmd_pargs() throw() {}
+
+ const int32_t* uptCmd;
+ const SGService* oService;
+
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _ServiceAgent_registServicewithCmd_result__isset {
+ _ServiceAgent_registServicewithCmd_result__isset() : success(false) {}
+ bool success;
+} _ServiceAgent_registServicewithCmd_result__isset;
+
+class ServiceAgent_registServicewithCmd_result {
+ public:
+
+ ServiceAgent_registServicewithCmd_result() : success(0) {
+ }
+
+ virtual ~ServiceAgent_registServicewithCmd_result() throw() {}
+
+ int32_t success;
+
+ _ServiceAgent_registServicewithCmd_result__isset __isset;
+
+ void __set_success(const int32_t val) {
+ success = val;
+ }
+
+ bool operator == (const ServiceAgent_registServicewithCmd_result & rhs) const
+ {
+ if (!(success == rhs.success))
+ return false;
+ return true;
+ }
+ bool operator != (const ServiceAgent_registServicewithCmd_result &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const ServiceAgent_registServicewithCmd_result & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _ServiceAgent_registServicewithCmd_presult__isset {
+ _ServiceAgent_registServicewithCmd_presult__isset() : success(false) {}
+ bool success;
+} _ServiceAgent_registServicewithCmd_presult__isset;
+
+class ServiceAgent_registServicewithCmd_presult {
+ public:
+
+
+ virtual ~ServiceAgent_registServicewithCmd_presult() throw() {}
+
+ int32_t* success;
+
+ _ServiceAgent_registServicewithCmd_presult__isset __isset;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+
+};
+
+typedef struct _ServiceAgent_unRegistService_args__isset {
+ _ServiceAgent_unRegistService_args__isset() : oService(false) {}
+ bool oService;
+} _ServiceAgent_unRegistService_args__isset;
+
+class ServiceAgent_unRegistService_args {
+ public:
+
+ ServiceAgent_unRegistService_args() {
+ }
+
+ virtual ~ServiceAgent_unRegistService_args() throw() {}
+
+ SGService oService;
+
+ _ServiceAgent_unRegistService_args__isset __isset;
+
+ void __set_oService(const SGService& val) {
+ oService = val;
+ }
+
+ bool operator == (const ServiceAgent_unRegistService_args & rhs) const
+ {
+ if (!(oService == rhs.oService))
+ return false;
+ return true;
+ }
+ bool operator != (const ServiceAgent_unRegistService_args &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const ServiceAgent_unRegistService_args & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+
+class ServiceAgent_unRegistService_pargs {
+ public:
+
+
+ virtual ~ServiceAgent_unRegistService_pargs() throw() {}
+
+ const SGService* oService;
+
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _ServiceAgent_unRegistService_result__isset {
+ _ServiceAgent_unRegistService_result__isset() : success(false) {}
+ bool success;
+} _ServiceAgent_unRegistService_result__isset;
+
+class ServiceAgent_unRegistService_result {
+ public:
+
+ ServiceAgent_unRegistService_result() : success(0) {
+ }
+
+ virtual ~ServiceAgent_unRegistService_result() throw() {}
+
+ int32_t success;
+
+ _ServiceAgent_unRegistService_result__isset __isset;
+
+ void __set_success(const int32_t val) {
+ success = val;
+ }
+
+ bool operator == (const ServiceAgent_unRegistService_result & rhs) const
+ {
+ if (!(success == rhs.success))
+ return false;
+ return true;
+ }
+ bool operator != (const ServiceAgent_unRegistService_result &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const ServiceAgent_unRegistService_result & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _ServiceAgent_unRegistService_presult__isset {
+ _ServiceAgent_unRegistService_presult__isset() : success(false) {}
+ bool success;
+} _ServiceAgent_unRegistService_presult__isset;
+
+class ServiceAgent_unRegistService_presult {
+ public:
+
+
+ virtual ~ServiceAgent_unRegistService_presult() throw() {}
+
+ int32_t* success;
+
+ _ServiceAgent_unRegistService_presult__isset __isset;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+
+};
+
+class ServiceAgentClient : virtual public ServiceAgentIf {
+ public:
+ ServiceAgentClient(boost::shared_ptr< ::apache::thrift::protocol::TProtocol> prot) :
+ piprot_(prot),
+ poprot_(prot) {
+ iprot_ = prot.get();
+ oprot_ = prot.get();
+ }
+ ServiceAgentClient(boost::shared_ptr< ::apache::thrift::protocol::TProtocol> iprot, boost::shared_ptr< ::apache::thrift::protocol::TProtocol> oprot) :
+ piprot_(iprot),
+ poprot_(oprot) {
+ iprot_ = iprot.get();
+ oprot_ = oprot.get();
+ }
+ boost::shared_ptr< ::apache::thrift::protocol::TProtocol> getInputProtocol() {
+ return piprot_;
+ }
+ boost::shared_ptr< ::apache::thrift::protocol::TProtocol> getOutputProtocol() {
+ return poprot_;
+ }
+ void getServiceListByProtocol(ProtocolResponse& _return, const ProtocolRequest& req);
+ void send_getServiceListByProtocol(const ProtocolRequest& req);
+ void recv_getServiceListByProtocol(ProtocolResponse& _return);
+ void getOriginServiceList(ProtocolResponse& _return, const ProtocolRequest& req);
+ void send_getOriginServiceList(const ProtocolRequest& req);
+ void recv_getOriginServiceList(ProtocolResponse& _return);
+ int32_t registService(const SGService& oService);
+ void send_registService(const SGService& oService);
+ int32_t recv_registService();
+ int32_t registServicewithCmd(const int32_t uptCmd, const SGService& oService);
+ void send_registServicewithCmd(const int32_t uptCmd, const SGService& oService);
+ int32_t recv_registServicewithCmd();
+ int32_t unRegistService(const SGService& oService);
+ void send_unRegistService(const SGService& oService);
+ int32_t recv_unRegistService();
+ protected:
+ boost::shared_ptr< ::apache::thrift::protocol::TProtocol> piprot_;
+ boost::shared_ptr< ::apache::thrift::protocol::TProtocol> poprot_;
+ ::apache::thrift::protocol::TProtocol* iprot_;
+ ::apache::thrift::protocol::TProtocol* oprot_;
+};
+
+class ServiceAgentProcessor : public ::apache::thrift::TProcessor {
+ protected:
+ boost::shared_ptr iface_;
+ virtual bool process_fn(apache::thrift::protocol::TProtocol* iprot, apache::thrift::protocol::TProtocol* oprot, std::string& fname, int32_t seqid, void* callContext);
+ private:
+ std::map processMap_;
+ void process_getServiceListByProtocol(int32_t seqid, apache::thrift::protocol::TProtocol* iprot, apache::thrift::protocol::TProtocol* oprot, void* callContext);
+ void process_getOriginServiceList(int32_t seqid, apache::thrift::protocol::TProtocol* iprot, apache::thrift::protocol::TProtocol* oprot, void* callContext);
+ void process_registService(int32_t seqid, apache::thrift::protocol::TProtocol* iprot, apache::thrift::protocol::TProtocol* oprot, void* callContext);
+ void process_registServicewithCmd(int32_t seqid, apache::thrift::protocol::TProtocol* iprot, apache::thrift::protocol::TProtocol* oprot, void* callContext);
+ void process_unRegistService(int32_t seqid, apache::thrift::protocol::TProtocol* iprot, apache::thrift::protocol::TProtocol* oprot, void* callContext);
+ public:
+ ServiceAgentProcessor(boost::shared_ptr iface) :
+ iface_(iface) {
+ processMap_["getServiceListByProtocol"] = &ServiceAgentProcessor::process_getServiceListByProtocol;
+ processMap_["getOriginServiceList"] = &ServiceAgentProcessor::process_getOriginServiceList;
+ processMap_["registService"] = &ServiceAgentProcessor::process_registService;
+ processMap_["registServicewithCmd"] = &ServiceAgentProcessor::process_registServicewithCmd;
+ processMap_["unRegistService"] = &ServiceAgentProcessor::process_unRegistService;
+ }
+
+ virtual bool process(boost::shared_ptr piprot, boost::shared_ptr poprot, void* callContext);
+ virtual ~ServiceAgentProcessor() {}
+};
+
+class ServiceAgentProcessorFactory : public ::apache::thrift::TProcessorFactory {
+ public:
+ ServiceAgentProcessorFactory(const ::boost::shared_ptr< ServiceAgentIfFactory >& handlerFactory) :
+ handlerFactory_(handlerFactory) {}
+
+ ::boost::shared_ptr< ::apache::thrift::TProcessor > getProcessor(const ::apache::thrift::TConnectionInfo& connInfo);
+
+ protected:
+ ::boost::shared_ptr< ServiceAgentIfFactory > handlerFactory_;
+};
+
+class ServiceAgentMultiface : virtual public ServiceAgentIf {
+ public:
+ ServiceAgentMultiface(std::vector >& ifaces) : ifaces_(ifaces) {
+ }
+ virtual ~ServiceAgentMultiface() {}
+ protected:
+ std::vector > ifaces_;
+ ServiceAgentMultiface() {}
+ void add(boost::shared_ptr iface) {
+ ifaces_.push_back(iface);
+ }
+ public:
+ void getServiceListByProtocol(ProtocolResponse& _return, const ProtocolRequest& req) {
+ size_t sz = ifaces_.size();
+ for (size_t i = 0; i < sz; ++i) {
+ if (i == sz - 1) {
+ ifaces_[i]->getServiceListByProtocol(_return, req);
+ return;
+ } else {
+ ifaces_[i]->getServiceListByProtocol(_return, req);
+ }
+ }
+ }
+
+ void getOriginServiceList(ProtocolResponse& _return, const ProtocolRequest& req) {
+ size_t sz = ifaces_.size();
+ for (size_t i = 0; i < sz; ++i) {
+ if (i == sz - 1) {
+ ifaces_[i]->getOriginServiceList(_return, req);
+ return;
+ } else {
+ ifaces_[i]->getOriginServiceList(_return, req);
+ }
+ }
+ }
+
+ int32_t registService(const SGService& oService) {
+ size_t sz = ifaces_.size();
+ for (size_t i = 0; i < sz; ++i) {
+ if (i == sz - 1) {
+ return ifaces_[i]->registService(oService);
+ } else {
+ ifaces_[i]->registService(oService);
+ }
+ }
+ }
+
+ int32_t registServicewithCmd(const int32_t uptCmd, const SGService& oService) {
+ size_t sz = ifaces_.size();
+ for (size_t i = 0; i < sz; ++i) {
+ if (i == sz - 1) {
+ return ifaces_[i]->registServicewithCmd(uptCmd, oService);
+ } else {
+ ifaces_[i]->registServicewithCmd(uptCmd, oService);
+ }
+ }
+ }
+
+ int32_t unRegistService(const SGService& oService) {
+ size_t sz = ifaces_.size();
+ for (size_t i = 0; i < sz; ++i) {
+ if (i == sz - 1) {
+ return ifaces_[i]->unRegistService(oService);
+ } else {
+ ifaces_[i]->unRegistService(oService);
+ }
+ }
+ }
+
+};
+
+} // namespace
+
+#endif
diff --git a/common/gen-cpp/ServiceAgent_server.skeleton.cpp b/common/gen-cpp/ServiceAgent_server.skeleton.cpp
new file mode 100644
index 0000000..311d1e7
--- /dev/null
+++ b/common/gen-cpp/ServiceAgent_server.skeleton.cpp
@@ -0,0 +1,64 @@
+// This autogenerated skeleton file illustrates how to build a server.
+// You should copy it to another filename to avoid overwriting it.
+
+#include "ServiceAgent.h"
+#include
+#include
+#include
+#include
+
+using namespace ::apache::thrift;
+using namespace ::apache::thrift::protocol;
+using namespace ::apache::thrift::transport;
+using namespace ::apache::thrift::server;
+
+using boost::shared_ptr;
+
+using namespace ::meituan_mns;
+
+class ServiceAgentHandler : virtual public ServiceAgentIf {
+ public:
+ ServiceAgentHandler() {
+ // Your initialization goes here
+ }
+
+ void getServiceListByProtocol(ProtocolResponse& _return, const ProtocolRequest& req) {
+ // Your implementation goes here
+ printf("getServiceListByProtocol\n");
+ }
+
+ void getOriginServiceList(ProtocolResponse& _return, const ProtocolRequest& req) {
+ // Your implementation goes here
+ printf("getOriginServiceList\n");
+ }
+
+ int32_t registService(const SGService& oService) {
+ // Your implementation goes here
+ printf("registService\n");
+ }
+
+ int32_t registServicewithCmd(const int32_t uptCmd, const SGService& oService) {
+ // Your implementation goes here
+ printf("registServicewithCmd\n");
+ }
+
+ int32_t unRegistService(const SGService& oService) {
+ // Your implementation goes here
+ printf("unRegistService\n");
+ }
+
+};
+
+int main(int argc, char **argv) {
+ int port = 9090;
+ shared_ptr handler(new ServiceAgentHandler());
+ shared_ptr processor(new ServiceAgentProcessor(handler));
+ shared_ptr serverTransport(new TServerSocket(port));
+ shared_ptr transportFactory(new TBufferedTransportFactory());
+ shared_ptr protocolFactory(new TBinaryProtocolFactory());
+
+ TSimpleServer server(processor, serverTransport, transportFactory, protocolFactory);
+ server.serve();
+ return 0;
+}
+
diff --git a/common/gen-cpp/ThriftSpans_constants.cpp b/common/gen-cpp/ThriftSpans_constants.cpp
new file mode 100644
index 0000000..7c9f006
--- /dev/null
+++ b/common/gen-cpp/ThriftSpans_constants.cpp
@@ -0,0 +1,17 @@
+/**
+ * Autogenerated by Thrift Compiler (0.8.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ * @generated
+ */
+#include "ThriftSpans_constants.h"
+
+
+
+const ThriftSpansConstants g_ThriftSpans_constants;
+
+ThriftSpansConstants::ThriftSpansConstants() {
+}
+
+
+
diff --git a/common/gen-cpp/ThriftSpans_constants.h b/common/gen-cpp/ThriftSpans_constants.h
new file mode 100644
index 0000000..d5d80b9
--- /dev/null
+++ b/common/gen-cpp/ThriftSpans_constants.h
@@ -0,0 +1,24 @@
+/**
+ * Autogenerated by Thrift Compiler (0.8.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ * @generated
+ */
+#ifndef ThriftSpans_CONSTANTS_H
+#define ThriftSpans_CONSTANTS_H
+
+#include "ThriftSpans_types.h"
+
+
+
+class ThriftSpansConstants {
+ public:
+ ThriftSpansConstants();
+
+};
+
+extern const ThriftSpansConstants g_ThriftSpans_constants;
+
+
+
+#endif
diff --git a/common/gen-cpp/ThriftSpans_types.cpp b/common/gen-cpp/ThriftSpans_types.cpp
new file mode 100644
index 0000000..eebe512
--- /dev/null
+++ b/common/gen-cpp/ThriftSpans_types.cpp
@@ -0,0 +1,669 @@
+/**
+ * Autogenerated by Thrift Compiler (0.8.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ * @generated
+ */
+#include "ThriftSpans_types.h"
+
+
+
+int _kStatusCodeValues[] = {
+ StatusCode::SUCCESS,
+ StatusCode::EXCEPTION,
+ StatusCode::TIMEOUT,
+ StatusCode::DROP
+};
+const char* _kStatusCodeNames[] = {
+ "SUCCESS",
+ "EXCEPTION",
+ "TIMEOUT",
+ "DROP"
+};
+const std::map _StatusCode_VALUES_TO_NAMES(::apache::thrift::TEnumIterator(4, _kStatusCodeValues, _kStatusCodeNames), ::apache::thrift::TEnumIterator(-1, NULL, NULL));
+
+const char* Endpoint::ascii_fingerprint = "C7D2D58463AC91C552EE8B325EA2ACCC";
+const uint8_t Endpoint::binary_fingerprint[16] = {0xC7,0xD2,0xD5,0x84,0x63,0xAC,0x91,0xC5,0x52,0xEE,0x8B,0x32,0x5E,0xA2,0xAC,0xCC};
+
+uint32_t Endpoint::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+ bool isset_ip = false;
+ bool isset_port = false;
+ bool isset_appKey = false;
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 1:
+ if (ftype == ::apache::thrift::protocol::T_I32) {
+ xfer += iprot->readI32(this->ip);
+ isset_ip = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 2:
+ if (ftype == ::apache::thrift::protocol::T_I16) {
+ xfer += iprot->readI16(this->port);
+ isset_port = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 3:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->appKey);
+ isset_appKey = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ if (!isset_ip)
+ throw TProtocolException(TProtocolException::INVALID_DATA);
+ if (!isset_port)
+ throw TProtocolException(TProtocolException::INVALID_DATA);
+ if (!isset_appKey)
+ throw TProtocolException(TProtocolException::INVALID_DATA);
+ return xfer;
+}
+
+uint32_t Endpoint::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("Endpoint");
+ xfer += oprot->writeFieldBegin("ip", ::apache::thrift::protocol::T_I32, 1);
+ xfer += oprot->writeI32(this->ip);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("port", ::apache::thrift::protocol::T_I16, 2);
+ xfer += oprot->writeI16(this->port);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("appKey", ::apache::thrift::protocol::T_STRING, 3);
+ xfer += oprot->writeString(this->appKey);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+const char* Annotation::ascii_fingerprint = "CE5BE9A8A7BD398538F703F899B08A94";
+const uint8_t Annotation::binary_fingerprint[16] = {0xCE,0x5B,0xE9,0xA8,0xA7,0xBD,0x39,0x85,0x38,0xF7,0x03,0xF8,0x99,0xB0,0x8A,0x94};
+
+uint32_t Annotation::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+ bool isset_value = false;
+ bool isset_timestamp = false;
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 1:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->value);
+ isset_value = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 2:
+ if (ftype == ::apache::thrift::protocol::T_I64) {
+ xfer += iprot->readI64(this->timestamp);
+ isset_timestamp = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 3:
+ if (ftype == ::apache::thrift::protocol::T_I32) {
+ xfer += iprot->readI32(this->duration);
+ this->__isset.duration = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ if (!isset_value)
+ throw TProtocolException(TProtocolException::INVALID_DATA);
+ if (!isset_timestamp)
+ throw TProtocolException(TProtocolException::INVALID_DATA);
+ return xfer;
+}
+
+uint32_t Annotation::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("Annotation");
+ xfer += oprot->writeFieldBegin("value", ::apache::thrift::protocol::T_STRING, 1);
+ xfer += oprot->writeString(this->value);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("timestamp", ::apache::thrift::protocol::T_I64, 2);
+ xfer += oprot->writeI64(this->timestamp);
+ xfer += oprot->writeFieldEnd();
+ if (this->__isset.duration) {
+ xfer += oprot->writeFieldBegin("duration", ::apache::thrift::protocol::T_I32, 3);
+ xfer += oprot->writeI32(this->duration);
+ xfer += oprot->writeFieldEnd();
+ }
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+const char* KVAnnotation::ascii_fingerprint = "07A9615F837F7D0A952B595DD3020972";
+const uint8_t KVAnnotation::binary_fingerprint[16] = {0x07,0xA9,0x61,0x5F,0x83,0x7F,0x7D,0x0A,0x95,0x2B,0x59,0x5D,0xD3,0x02,0x09,0x72};
+
+uint32_t KVAnnotation::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+ bool isset_key = false;
+ bool isset_value = false;
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 1:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->key);
+ isset_key = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 2:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->value);
+ isset_value = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ if (!isset_key)
+ throw TProtocolException(TProtocolException::INVALID_DATA);
+ if (!isset_value)
+ throw TProtocolException(TProtocolException::INVALID_DATA);
+ return xfer;
+}
+
+uint32_t KVAnnotation::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("KVAnnotation");
+ xfer += oprot->writeFieldBegin("key", ::apache::thrift::protocol::T_STRING, 1);
+ xfer += oprot->writeString(this->key);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("value", ::apache::thrift::protocol::T_STRING, 2);
+ xfer += oprot->writeString(this->value);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+const char* ThriftSpan::ascii_fingerprint = "B08D60902E6EF2A6DF2C5746A48261F4";
+const uint8_t ThriftSpan::binary_fingerprint[16] = {0xB0,0x8D,0x60,0x90,0x2E,0x6E,0xF2,0xA6,0xDF,0x2C,0x57,0x46,0xA4,0x82,0x61,0xF4};
+
+uint32_t ThriftSpan::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+ bool isset_traceId = false;
+ bool isset_spanId = false;
+ bool isset_spanName = false;
+ bool isset_local = false;
+ bool isset_remote = false;
+ bool isset_start = false;
+ bool isset_duration = false;
+ bool isset_clientSide = false;
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 1:
+ if (ftype == ::apache::thrift::protocol::T_I64) {
+ xfer += iprot->readI64(this->traceId);
+ isset_traceId = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 2:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->spanId);
+ isset_spanId = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 3:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->spanName);
+ isset_spanName = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 4:
+ if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+ xfer += this->local.read(iprot);
+ isset_local = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 5:
+ if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+ xfer += this->remote.read(iprot);
+ isset_remote = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 6:
+ if (ftype == ::apache::thrift::protocol::T_I64) {
+ xfer += iprot->readI64(this->start);
+ isset_start = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 7:
+ if (ftype == ::apache::thrift::protocol::T_I32) {
+ xfer += iprot->readI32(this->duration);
+ isset_duration = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 8:
+ if (ftype == ::apache::thrift::protocol::T_BOOL) {
+ xfer += iprot->readBool(this->clientSide);
+ isset_clientSide = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 9:
+ if (ftype == ::apache::thrift::protocol::T_LIST) {
+ {
+ this->annotations.clear();
+ uint32_t _size0;
+ ::apache::thrift::protocol::TType _etype3;
+ iprot->readListBegin(_etype3, _size0);
+ this->annotations.resize(_size0);
+ uint32_t _i4;
+ for (_i4 = 0; _i4 < _size0; ++_i4)
+ {
+ xfer += this->annotations[_i4].read(iprot);
+ }
+ iprot->readListEnd();
+ }
+ this->__isset.annotations = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 10:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->type);
+ this->__isset.type = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 11:
+ if (ftype == ::apache::thrift::protocol::T_I32) {
+ xfer += iprot->readI32(this->packageSize);
+ this->__isset.packageSize = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 12:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->infraName);
+ this->__isset.infraName = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 13:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->infraVersion);
+ this->__isset.infraVersion = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 14:
+ if (ftype == ::apache::thrift::protocol::T_LIST) {
+ {
+ this->kvAnnotations.clear();
+ uint32_t _size5;
+ ::apache::thrift::protocol::TType _etype8;
+ iprot->readListBegin(_etype8, _size5);
+ this->kvAnnotations.resize(_size5);
+ uint32_t _i9;
+ for (_i9 = 0; _i9 < _size5; ++_i9)
+ {
+ xfer += this->kvAnnotations[_i9].read(iprot);
+ }
+ iprot->readListEnd();
+ }
+ this->__isset.kvAnnotations = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 15:
+ if (ftype == ::apache::thrift::protocol::T_I32) {
+ int32_t ecast10;
+ xfer += iprot->readI32(ecast10);
+ this->status = (StatusCode::type)ecast10;
+ this->__isset.status = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 16:
+ if (ftype == ::apache::thrift::protocol::T_I32) {
+ xfer += iprot->readI32(this->mask);
+ this->__isset.mask = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ if (!isset_traceId)
+ throw TProtocolException(TProtocolException::INVALID_DATA);
+ if (!isset_spanId)
+ throw TProtocolException(TProtocolException::INVALID_DATA);
+ if (!isset_spanName)
+ throw TProtocolException(TProtocolException::INVALID_DATA);
+ if (!isset_local)
+ throw TProtocolException(TProtocolException::INVALID_DATA);
+ if (!isset_remote)
+ throw TProtocolException(TProtocolException::INVALID_DATA);
+ if (!isset_start)
+ throw TProtocolException(TProtocolException::INVALID_DATA);
+ if (!isset_duration)
+ throw TProtocolException(TProtocolException::INVALID_DATA);
+ if (!isset_clientSide)
+ throw TProtocolException(TProtocolException::INVALID_DATA);
+ return xfer;
+}
+
+uint32_t ThriftSpan::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("ThriftSpan");
+ xfer += oprot->writeFieldBegin("traceId", ::apache::thrift::protocol::T_I64, 1);
+ xfer += oprot->writeI64(this->traceId);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("spanId", ::apache::thrift::protocol::T_STRING, 2);
+ xfer += oprot->writeString(this->spanId);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("spanName", ::apache::thrift::protocol::T_STRING, 3);
+ xfer += oprot->writeString(this->spanName);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("local", ::apache::thrift::protocol::T_STRUCT, 4);
+ xfer += this->local.write(oprot);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("remote", ::apache::thrift::protocol::T_STRUCT, 5);
+ xfer += this->remote.write(oprot);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("start", ::apache::thrift::protocol::T_I64, 6);
+ xfer += oprot->writeI64(this->start);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("duration", ::apache::thrift::protocol::T_I32, 7);
+ xfer += oprot->writeI32(this->duration);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("clientSide", ::apache::thrift::protocol::T_BOOL, 8);
+ xfer += oprot->writeBool(this->clientSide);
+ xfer += oprot->writeFieldEnd();
+ if (this->__isset.annotations) {
+ xfer += oprot->writeFieldBegin("annotations", ::apache::thrift::protocol::T_LIST, 9);
+ {
+ xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast(this->annotations.size()));
+ std::vector ::const_iterator _iter11;
+ for (_iter11 = this->annotations.begin(); _iter11 != this->annotations.end(); ++_iter11)
+ {
+ xfer += (*_iter11).write(oprot);
+ }
+ xfer += oprot->writeListEnd();
+ }
+ xfer += oprot->writeFieldEnd();
+ }
+ if (this->__isset.type) {
+ xfer += oprot->writeFieldBegin("type", ::apache::thrift::protocol::T_STRING, 10);
+ xfer += oprot->writeString(this->type);
+ xfer += oprot->writeFieldEnd();
+ }
+ if (this->__isset.packageSize) {
+ xfer += oprot->writeFieldBegin("packageSize", ::apache::thrift::protocol::T_I32, 11);
+ xfer += oprot->writeI32(this->packageSize);
+ xfer += oprot->writeFieldEnd();
+ }
+ if (this->__isset.infraName) {
+ xfer += oprot->writeFieldBegin("infraName", ::apache::thrift::protocol::T_STRING, 12);
+ xfer += oprot->writeString(this->infraName);
+ xfer += oprot->writeFieldEnd();
+ }
+ if (this->__isset.infraVersion) {
+ xfer += oprot->writeFieldBegin("infraVersion", ::apache::thrift::protocol::T_STRING, 13);
+ xfer += oprot->writeString(this->infraVersion);
+ xfer += oprot->writeFieldEnd();
+ }
+ if (this->__isset.kvAnnotations) {
+ xfer += oprot->writeFieldBegin("kvAnnotations", ::apache::thrift::protocol::T_LIST, 14);
+ {
+ xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast(this->kvAnnotations.size()));
+ std::vector ::const_iterator _iter12;
+ for (_iter12 = this->kvAnnotations.begin(); _iter12 != this->kvAnnotations.end(); ++_iter12)
+ {
+ xfer += (*_iter12).write(oprot);
+ }
+ xfer += oprot->writeListEnd();
+ }
+ xfer += oprot->writeFieldEnd();
+ }
+ if (this->__isset.status) {
+ xfer += oprot->writeFieldBegin("status", ::apache::thrift::protocol::T_I32, 15);
+ xfer += oprot->writeI32((int32_t)this->status);
+ xfer += oprot->writeFieldEnd();
+ }
+ if (this->__isset.mask) {
+ xfer += oprot->writeFieldBegin("mask", ::apache::thrift::protocol::T_I32, 16);
+ xfer += oprot->writeI32(this->mask);
+ xfer += oprot->writeFieldEnd();
+ }
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+const char* ThriftSpanList::ascii_fingerprint = "01BB7DF5DC125F694C08EE3ED02BB420";
+const uint8_t ThriftSpanList::binary_fingerprint[16] = {0x01,0xBB,0x7D,0xF5,0xDC,0x12,0x5F,0x69,0x4C,0x08,0xEE,0x3E,0xD0,0x2B,0xB4,0x20};
+
+uint32_t ThriftSpanList::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+ bool isset_spans = false;
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 1:
+ if (ftype == ::apache::thrift::protocol::T_LIST) {
+ {
+ this->spans.clear();
+ uint32_t _size13;
+ ::apache::thrift::protocol::TType _etype16;
+ iprot->readListBegin(_etype16, _size13);
+ this->spans.resize(_size13);
+ uint32_t _i17;
+ for (_i17 = 0; _i17 < _size13; ++_i17)
+ {
+ xfer += this->spans[_i17].read(iprot);
+ }
+ iprot->readListEnd();
+ }
+ isset_spans = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 2:
+ if (ftype == ::apache::thrift::protocol::T_I32) {
+ xfer += iprot->readI32(this->var1);
+ this->__isset.var1 = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 3:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->var2);
+ this->__isset.var2 = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ if (!isset_spans)
+ throw TProtocolException(TProtocolException::INVALID_DATA);
+ return xfer;
+}
+
+uint32_t ThriftSpanList::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("ThriftSpanList");
+ xfer += oprot->writeFieldBegin("spans", ::apache::thrift::protocol::T_LIST, 1);
+ {
+ xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast(this->spans.size()));
+ std::vector ::const_iterator _iter18;
+ for (_iter18 = this->spans.begin(); _iter18 != this->spans.end(); ++_iter18)
+ {
+ xfer += (*_iter18).write(oprot);
+ }
+ xfer += oprot->writeListEnd();
+ }
+ xfer += oprot->writeFieldEnd();
+ if (this->__isset.var1) {
+ xfer += oprot->writeFieldBegin("var1", ::apache::thrift::protocol::T_I32, 2);
+ xfer += oprot->writeI32(this->var1);
+ xfer += oprot->writeFieldEnd();
+ }
+ if (this->__isset.var2) {
+ xfer += oprot->writeFieldBegin("var2", ::apache::thrift::protocol::T_STRING, 3);
+ xfer += oprot->writeString(this->var2);
+ xfer += oprot->writeFieldEnd();
+ }
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+
diff --git a/common/gen-cpp/ThriftSpans_types.h b/common/gen-cpp/ThriftSpans_types.h
new file mode 100644
index 0000000..74b7ead
--- /dev/null
+++ b/common/gen-cpp/ThriftSpans_types.h
@@ -0,0 +1,420 @@
+/**
+ * Autogenerated by Thrift Compiler (0.8.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ * @generated
+ */
+#ifndef ThriftSpans_TYPES_H
+#define ThriftSpans_TYPES_H
+
+#include
+#include
+#include
+#include
+
+
+
+
+
+struct StatusCode {
+ enum type {
+ SUCCESS = 0,
+ EXCEPTION = 1,
+ TIMEOUT = 2,
+ DROP = 3
+ };
+};
+
+extern const std::map _StatusCode_VALUES_TO_NAMES;
+
+
+class Endpoint {
+ public:
+
+ static const char* ascii_fingerprint; // = "C7D2D58463AC91C552EE8B325EA2ACCC";
+ static const uint8_t binary_fingerprint[16]; // = {0xC7,0xD2,0xD5,0x84,0x63,0xAC,0x91,0xC5,0x52,0xEE,0x8B,0x32,0x5E,0xA2,0xAC,0xCC};
+
+ Endpoint() : ip(0), port(0), appKey("") {
+ }
+
+ virtual ~Endpoint() throw() {}
+
+ int32_t ip;
+ int16_t port;
+ std::string appKey;
+
+ void __set_ip(const int32_t val) {
+ ip = val;
+ }
+
+ void __set_port(const int16_t val) {
+ port = val;
+ }
+
+ void __set_appKey(const std::string& val) {
+ appKey = val;
+ }
+
+ bool operator == (const Endpoint & rhs) const
+ {
+ if (!(ip == rhs.ip))
+ return false;
+ if (!(port == rhs.port))
+ return false;
+ if (!(appKey == rhs.appKey))
+ return false;
+ return true;
+ }
+ bool operator != (const Endpoint &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const Endpoint & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _Annotation__isset {
+ _Annotation__isset() : duration(false) {}
+ bool duration;
+} _Annotation__isset;
+
+class Annotation {
+ public:
+
+ static const char* ascii_fingerprint; // = "CE5BE9A8A7BD398538F703F899B08A94";
+ static const uint8_t binary_fingerprint[16]; // = {0xCE,0x5B,0xE9,0xA8,0xA7,0xBD,0x39,0x85,0x38,0xF7,0x03,0xF8,0x99,0xB0,0x8A,0x94};
+
+ Annotation() : value(""), timestamp(0), duration(0) {
+ }
+
+ virtual ~Annotation() throw() {}
+
+ std::string value;
+ int64_t timestamp;
+ int32_t duration;
+
+ _Annotation__isset __isset;
+
+ void __set_value(const std::string& val) {
+ value = val;
+ }
+
+ void __set_timestamp(const int64_t val) {
+ timestamp = val;
+ }
+
+ void __set_duration(const int32_t val) {
+ duration = val;
+ __isset.duration = true;
+ }
+
+ bool operator == (const Annotation & rhs) const
+ {
+ if (!(value == rhs.value))
+ return false;
+ if (!(timestamp == rhs.timestamp))
+ return false;
+ if (__isset.duration != rhs.__isset.duration)
+ return false;
+ else if (__isset.duration && !(duration == rhs.duration))
+ return false;
+ return true;
+ }
+ bool operator != (const Annotation &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const Annotation & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+
+class KVAnnotation {
+ public:
+
+ static const char* ascii_fingerprint; // = "07A9615F837F7D0A952B595DD3020972";
+ static const uint8_t binary_fingerprint[16]; // = {0x07,0xA9,0x61,0x5F,0x83,0x7F,0x7D,0x0A,0x95,0x2B,0x59,0x5D,0xD3,0x02,0x09,0x72};
+
+ KVAnnotation() : key(""), value("") {
+ }
+
+ virtual ~KVAnnotation() throw() {}
+
+ std::string key;
+ std::string value;
+
+ void __set_key(const std::string& val) {
+ key = val;
+ }
+
+ void __set_value(const std::string& val) {
+ value = val;
+ }
+
+ bool operator == (const KVAnnotation & rhs) const
+ {
+ if (!(key == rhs.key))
+ return false;
+ if (!(value == rhs.value))
+ return false;
+ return true;
+ }
+ bool operator != (const KVAnnotation &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const KVAnnotation & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _ThriftSpan__isset {
+ _ThriftSpan__isset() : annotations(false), type(false), packageSize(false), infraName(false), infraVersion(false), kvAnnotations(false), status(false), mask(false) {}
+ bool annotations;
+ bool type;
+ bool packageSize;
+ bool infraName;
+ bool infraVersion;
+ bool kvAnnotations;
+ bool status;
+ bool mask;
+} _ThriftSpan__isset;
+
+class ThriftSpan {
+ public:
+
+ static const char* ascii_fingerprint; // = "B08D60902E6EF2A6DF2C5746A48261F4";
+ static const uint8_t binary_fingerprint[16]; // = {0xB0,0x8D,0x60,0x90,0x2E,0x6E,0xF2,0xA6,0xDF,0x2C,0x57,0x46,0xA4,0x82,0x61,0xF4};
+
+ ThriftSpan() : traceId(0), spanId(""), spanName(""), start(0), duration(0), clientSide(0), type(""), packageSize(0), infraName(""), infraVersion(""), status((StatusCode::type)0), mask(0) {
+ }
+
+ virtual ~ThriftSpan() throw() {}
+
+ int64_t traceId;
+ std::string spanId;
+ std::string spanName;
+ Endpoint local;
+ Endpoint remote;
+ int64_t start;
+ int32_t duration;
+ bool clientSide;
+ std::vector annotations;
+ std::string type;
+ int32_t packageSize;
+ std::string infraName;
+ std::string infraVersion;
+ std::vector kvAnnotations;
+ StatusCode::type status;
+ int32_t mask;
+
+ _ThriftSpan__isset __isset;
+
+ void __set_traceId(const int64_t val) {
+ traceId = val;
+ }
+
+ void __set_spanId(const std::string& val) {
+ spanId = val;
+ }
+
+ void __set_spanName(const std::string& val) {
+ spanName = val;
+ }
+
+ void __set_local(const Endpoint& val) {
+ local = val;
+ }
+
+ void __set_remote(const Endpoint& val) {
+ remote = val;
+ }
+
+ void __set_start(const int64_t val) {
+ start = val;
+ }
+
+ void __set_duration(const int32_t val) {
+ duration = val;
+ }
+
+ void __set_clientSide(const bool val) {
+ clientSide = val;
+ }
+
+ void __set_annotations(const std::vector & val) {
+ annotations = val;
+ __isset.annotations = true;
+ }
+
+ void __set_type(const std::string& val) {
+ type = val;
+ __isset.type = true;
+ }
+
+ void __set_packageSize(const int32_t val) {
+ packageSize = val;
+ __isset.packageSize = true;
+ }
+
+ void __set_infraName(const std::string& val) {
+ infraName = val;
+ __isset.infraName = true;
+ }
+
+ void __set_infraVersion(const std::string& val) {
+ infraVersion = val;
+ __isset.infraVersion = true;
+ }
+
+ void __set_kvAnnotations(const std::vector & val) {
+ kvAnnotations = val;
+ __isset.kvAnnotations = true;
+ }
+
+ void __set_status(const StatusCode::type val) {
+ status = val;
+ __isset.status = true;
+ }
+
+ void __set_mask(const int32_t val) {
+ mask = val;
+ __isset.mask = true;
+ }
+
+ bool operator == (const ThriftSpan & rhs) const
+ {
+ if (!(traceId == rhs.traceId))
+ return false;
+ if (!(spanId == rhs.spanId))
+ return false;
+ if (!(spanName == rhs.spanName))
+ return false;
+ if (!(local == rhs.local))
+ return false;
+ if (!(remote == rhs.remote))
+ return false;
+ if (!(start == rhs.start))
+ return false;
+ if (!(duration == rhs.duration))
+ return false;
+ if (!(clientSide == rhs.clientSide))
+ return false;
+ if (__isset.annotations != rhs.__isset.annotations)
+ return false;
+ else if (__isset.annotations && !(annotations == rhs.annotations))
+ return false;
+ if (__isset.type != rhs.__isset.type)
+ return false;
+ else if (__isset.type && !(type == rhs.type))
+ return false;
+ if (__isset.packageSize != rhs.__isset.packageSize)
+ return false;
+ else if (__isset.packageSize && !(packageSize == rhs.packageSize))
+ return false;
+ if (__isset.infraName != rhs.__isset.infraName)
+ return false;
+ else if (__isset.infraName && !(infraName == rhs.infraName))
+ return false;
+ if (__isset.infraVersion != rhs.__isset.infraVersion)
+ return false;
+ else if (__isset.infraVersion && !(infraVersion == rhs.infraVersion))
+ return false;
+ if (__isset.kvAnnotations != rhs.__isset.kvAnnotations)
+ return false;
+ else if (__isset.kvAnnotations && !(kvAnnotations == rhs.kvAnnotations))
+ return false;
+ if (__isset.status != rhs.__isset.status)
+ return false;
+ else if (__isset.status && !(status == rhs.status))
+ return false;
+ if (__isset.mask != rhs.__isset.mask)
+ return false;
+ else if (__isset.mask && !(mask == rhs.mask))
+ return false;
+ return true;
+ }
+ bool operator != (const ThriftSpan &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const ThriftSpan & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _ThriftSpanList__isset {
+ _ThriftSpanList__isset() : var1(false), var2(false) {}
+ bool var1;
+ bool var2;
+} _ThriftSpanList__isset;
+
+class ThriftSpanList {
+ public:
+
+ static const char* ascii_fingerprint; // = "01BB7DF5DC125F694C08EE3ED02BB420";
+ static const uint8_t binary_fingerprint[16]; // = {0x01,0xBB,0x7D,0xF5,0xDC,0x12,0x5F,0x69,0x4C,0x08,0xEE,0x3E,0xD0,0x2B,0xB4,0x20};
+
+ ThriftSpanList() : var1(0), var2("") {
+ }
+
+ virtual ~ThriftSpanList() throw() {}
+
+ std::vector spans;
+ int32_t var1;
+ std::string var2;
+
+ _ThriftSpanList__isset __isset;
+
+ void __set_spans(const std::vector & val) {
+ spans = val;
+ }
+
+ void __set_var1(const int32_t val) {
+ var1 = val;
+ __isset.var1 = true;
+ }
+
+ void __set_var2(const std::string& val) {
+ var2 = val;
+ __isset.var2 = true;
+ }
+
+ bool operator == (const ThriftSpanList & rhs) const
+ {
+ if (!(spans == rhs.spans))
+ return false;
+ if (__isset.var1 != rhs.__isset.var1)
+ return false;
+ else if (__isset.var1 && !(var1 == rhs.var1))
+ return false;
+ if (__isset.var2 != rhs.__isset.var2)
+ return false;
+ else if (__isset.var2 && !(var2 == rhs.var2))
+ return false;
+ return true;
+ }
+ bool operator != (const ThriftSpanList &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const ThriftSpanList & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+
+
+#endif
diff --git a/common/gen-cpp/mnsc_data_constants.cpp b/common/gen-cpp/mnsc_data_constants.cpp
new file mode 100644
index 0000000..41cc863
--- /dev/null
+++ b/common/gen-cpp/mnsc_data_constants.cpp
@@ -0,0 +1,35 @@
+/**
+ * Autogenerated by Thrift Compiler (0.8.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ * @generated
+ */
+#include "mnsc_data_constants.h"
+
+namespace meituan_mns {
+
+const mnsc_dataConstants g_mnsc_data_constants;
+
+mnsc_dataConstants::mnsc_dataConstants() {
+ PROD = "prod";
+
+ STAGE = "stage";
+
+ TEST = "test";
+
+ SUCCESS = 200;
+
+ MNSCache_UPDATE = 500;
+
+ TIMEOUT_ERROR = 400;
+
+ ILLEGAL_ARGUMENT = 400;
+
+ NOT_FOUND = 404;
+
+ NOT_MODIFIED = 304;
+
+}
+
+} // namespace
+
diff --git a/common/gen-cpp/mnsc_data_constants.h b/common/gen-cpp/mnsc_data_constants.h
new file mode 100644
index 0000000..77fc7ab
--- /dev/null
+++ b/common/gen-cpp/mnsc_data_constants.h
@@ -0,0 +1,33 @@
+/**
+ * Autogenerated by Thrift Compiler (0.8.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ * @generated
+ */
+#ifndef mnsc_data_CONSTANTS_H
+#define mnsc_data_CONSTANTS_H
+
+#include "mnsc_data_types.h"
+
+namespace meituan_mns {
+
+class mnsc_dataConstants {
+ public:
+ mnsc_dataConstants();
+
+ std::string PROD;
+ std::string STAGE;
+ std::string TEST;
+ int32_t SUCCESS;
+ int32_t MNSCache_UPDATE;
+ int32_t TIMEOUT_ERROR;
+ int32_t ILLEGAL_ARGUMENT;
+ int32_t NOT_FOUND;
+ int32_t NOT_MODIFIED;
+};
+
+extern const mnsc_dataConstants g_mnsc_data_constants;
+
+} // namespace
+
+#endif
diff --git a/common/gen-cpp/mnsc_data_types.cpp b/common/gen-cpp/mnsc_data_types.cpp
new file mode 100644
index 0000000..d82ac98
--- /dev/null
+++ b/common/gen-cpp/mnsc_data_types.cpp
@@ -0,0 +1,430 @@
+/**
+ * Autogenerated by Thrift Compiler (0.8.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ * @generated
+ */
+#include "mnsc_data_types.h"
+
+namespace meituan_mns {
+
+int _kProtocolsValues[] = {
+ Protocols::THRIFT,
+ Protocols::HTTP
+};
+const char* _kProtocolsNames[] = {
+ "THRIFT",
+ "HTTP"
+};
+const std::map _Protocols_VALUES_TO_NAMES(::apache::thrift::TEnumIterator(2, _kProtocolsValues, _kProtocolsNames), ::apache::thrift::TEnumIterator(-1, NULL, NULL));
+
+const char* MNSResponse::ascii_fingerprint = "262B7A6EE88301D8EA2B9CBECB4AF401";
+const uint8_t MNSResponse::binary_fingerprint[16] = {0x26,0x2B,0x7A,0x6E,0xE8,0x83,0x01,0xD8,0xEA,0x2B,0x9C,0xBE,0xCB,0x4A,0xF4,0x01};
+
+uint32_t MNSResponse::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+ bool isset_code = false;
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 1:
+ if (ftype == ::apache::thrift::protocol::T_I32) {
+ xfer += iprot->readI32(this->code);
+ isset_code = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 2:
+ if (ftype == ::apache::thrift::protocol::T_LIST) {
+ {
+ this->defaultMNSCache.clear();
+ uint32_t _size0;
+ ::apache::thrift::protocol::TType _etype3;
+ iprot->readListBegin(_etype3, _size0);
+ this->defaultMNSCache.resize(_size0);
+ uint32_t _i4;
+ for (_i4 = 0; _i4 < _size0; ++_i4)
+ {
+ xfer += this->defaultMNSCache[_i4].read(iprot);
+ }
+ iprot->readListEnd();
+ }
+ this->__isset.defaultMNSCache = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 3:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->version);
+ this->__isset.version = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ if (!isset_code)
+ throw TProtocolException(TProtocolException::INVALID_DATA);
+ return xfer;
+}
+
+uint32_t MNSResponse::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("MNSResponse");
+ xfer += oprot->writeFieldBegin("code", ::apache::thrift::protocol::T_I32, 1);
+ xfer += oprot->writeI32(this->code);
+ xfer += oprot->writeFieldEnd();
+ if (this->__isset.defaultMNSCache) {
+ xfer += oprot->writeFieldBegin("defaultMNSCache", ::apache::thrift::protocol::T_LIST, 2);
+ {
+ xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast(this->defaultMNSCache.size()));
+ std::vector ::const_iterator _iter5;
+ for (_iter5 = this->defaultMNSCache.begin(); _iter5 != this->defaultMNSCache.end(); ++_iter5)
+ {
+ xfer += (*_iter5).write(oprot);
+ }
+ xfer += oprot->writeListEnd();
+ }
+ xfer += oprot->writeFieldEnd();
+ }
+ if (this->__isset.version) {
+ xfer += oprot->writeFieldBegin("version", ::apache::thrift::protocol::T_STRING, 3);
+ xfer += oprot->writeString(this->version);
+ xfer += oprot->writeFieldEnd();
+ }
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+const char* MNSBatchResponse::ascii_fingerprint = "C0A3C40A83F3EC7069EF8B80B7669355";
+const uint8_t MNSBatchResponse::binary_fingerprint[16] = {0xC0,0xA3,0xC4,0x0A,0x83,0xF3,0xEC,0x70,0x69,0xEF,0x8B,0x80,0xB7,0x66,0x93,0x55};
+
+uint32_t MNSBatchResponse::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+ bool isset_code = false;
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 1:
+ if (ftype == ::apache::thrift::protocol::T_I32) {
+ xfer += iprot->readI32(this->code);
+ isset_code = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 2:
+ if (ftype == ::apache::thrift::protocol::T_MAP) {
+ {
+ this->cache.clear();
+ uint32_t _size6;
+ ::apache::thrift::protocol::TType _ktype7;
+ ::apache::thrift::protocol::TType _vtype8;
+ iprot->readMapBegin(_ktype7, _vtype8, _size6);
+ uint32_t _i10;
+ for (_i10 = 0; _i10 < _size6; ++_i10)
+ {
+ std::string _key11;
+ xfer += iprot->readString(_key11);
+ std::map > & _val12 = this->cache[_key11];
+ {
+ _val12.clear();
+ uint32_t _size13;
+ ::apache::thrift::protocol::TType _ktype14;
+ ::apache::thrift::protocol::TType _vtype15;
+ iprot->readMapBegin(_ktype14, _vtype15, _size13);
+ uint32_t _i17;
+ for (_i17 = 0; _i17 < _size13; ++_i17)
+ {
+ std::string _key18;
+ xfer += iprot->readString(_key18);
+ std::vector & _val19 = _val12[_key18];
+ {
+ _val19.clear();
+ uint32_t _size20;
+ ::apache::thrift::protocol::TType _etype23;
+ iprot->readListBegin(_etype23, _size20);
+ _val19.resize(_size20);
+ uint32_t _i24;
+ for (_i24 = 0; _i24 < _size20; ++_i24)
+ {
+ xfer += _val19[_i24].read(iprot);
+ }
+ iprot->readListEnd();
+ }
+ }
+ iprot->readMapEnd();
+ }
+ }
+ iprot->readMapEnd();
+ }
+ this->__isset.cache = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ if (!isset_code)
+ throw TProtocolException(TProtocolException::INVALID_DATA);
+ return xfer;
+}
+
+uint32_t MNSBatchResponse::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("MNSBatchResponse");
+ xfer += oprot->writeFieldBegin("code", ::apache::thrift::protocol::T_I32, 1);
+ xfer += oprot->writeI32(this->code);
+ xfer += oprot->writeFieldEnd();
+ if (this->__isset.cache) {
+ xfer += oprot->writeFieldBegin("cache", ::apache::thrift::protocol::T_MAP, 2);
+ {
+ xfer += oprot->writeMapBegin(::apache::thrift::protocol::T_STRING, ::apache::thrift::protocol::T_MAP, static_cast(this->cache.size()));
+ std::map > > ::const_iterator _iter25;
+ for (_iter25 = this->cache.begin(); _iter25 != this->cache.end(); ++_iter25)
+ {
+ xfer += oprot->writeString(_iter25->first);
+ {
+ xfer += oprot->writeMapBegin(::apache::thrift::protocol::T_STRING, ::apache::thrift::protocol::T_LIST, static_cast(_iter25->second.size()));
+ std::map > ::const_iterator _iter26;
+ for (_iter26 = _iter25->second.begin(); _iter26 != _iter25->second.end(); ++_iter26)
+ {
+ xfer += oprot->writeString(_iter26->first);
+ {
+ xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast(_iter26->second.size()));
+ std::vector ::const_iterator _iter27;
+ for (_iter27 = _iter26->second.begin(); _iter27 != _iter26->second.end(); ++_iter27)
+ {
+ xfer += (*_iter27).write(oprot);
+ }
+ xfer += oprot->writeListEnd();
+ }
+ }
+ xfer += oprot->writeMapEnd();
+ }
+ }
+ xfer += oprot->writeMapEnd();
+ }
+ xfer += oprot->writeFieldEnd();
+ }
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+const char* AppKeyListResponse::ascii_fingerprint = "93CC3D1E71866966C22792AABF4C3815";
+const uint8_t AppKeyListResponse::binary_fingerprint[16] = {0x93,0xCC,0x3D,0x1E,0x71,0x86,0x69,0x66,0xC2,0x27,0x92,0xAA,0xBF,0x4C,0x38,0x15};
+
+uint32_t AppKeyListResponse::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+ bool isset_code = false;
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 1:
+ if (ftype == ::apache::thrift::protocol::T_I32) {
+ xfer += iprot->readI32(this->code);
+ isset_code = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 2:
+ if (ftype == ::apache::thrift::protocol::T_LIST) {
+ {
+ this->appKeyList.clear();
+ uint32_t _size28;
+ ::apache::thrift::protocol::TType _etype31;
+ iprot->readListBegin(_etype31, _size28);
+ this->appKeyList.resize(_size28);
+ uint32_t _i32;
+ for (_i32 = 0; _i32 < _size28; ++_i32)
+ {
+ xfer += iprot->readString(this->appKeyList[_i32]);
+ }
+ iprot->readListEnd();
+ }
+ this->__isset.appKeyList = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ if (!isset_code)
+ throw TProtocolException(TProtocolException::INVALID_DATA);
+ return xfer;
+}
+
+uint32_t AppKeyListResponse::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("AppKeyListResponse");
+ xfer += oprot->writeFieldBegin("code", ::apache::thrift::protocol::T_I32, 1);
+ xfer += oprot->writeI32(this->code);
+ xfer += oprot->writeFieldEnd();
+ if (this->__isset.appKeyList) {
+ xfer += oprot->writeFieldBegin("appKeyList", ::apache::thrift::protocol::T_LIST, 2);
+ {
+ xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast(this->appKeyList.size()));
+ std::vector ::const_iterator _iter33;
+ for (_iter33 = this->appKeyList.begin(); _iter33 != this->appKeyList.end(); ++_iter33)
+ {
+ xfer += oprot->writeString((*_iter33));
+ }
+ xfer += oprot->writeListEnd();
+ }
+ xfer += oprot->writeFieldEnd();
+ }
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+const char* MnsRequest::ascii_fingerprint = "38C252E94E93B69D04EB3A6EE2F9EDFB";
+const uint8_t MnsRequest::binary_fingerprint[16] = {0x38,0xC2,0x52,0xE9,0x4E,0x93,0xB6,0x9D,0x04,0xEB,0x3A,0x6E,0xE2,0xF9,0xED,0xFB};
+
+uint32_t MnsRequest::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 1:
+ if (ftype == ::apache::thrift::protocol::T_I32) {
+ int32_t ecast34;
+ xfer += iprot->readI32(ecast34);
+ this->protoctol = (Protocols::type)ecast34;
+ this->__isset.protoctol = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 2:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->appkey);
+ this->__isset.appkey = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 3:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->env);
+ this->__isset.env = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t MnsRequest::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("MnsRequest");
+ xfer += oprot->writeFieldBegin("protoctol", ::apache::thrift::protocol::T_I32, 1);
+ xfer += oprot->writeI32((int32_t)this->protoctol);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("appkey", ::apache::thrift::protocol::T_STRING, 2);
+ xfer += oprot->writeString(this->appkey);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("env", ::apache::thrift::protocol::T_STRING, 3);
+ xfer += oprot->writeString(this->env);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+} // namespace
diff --git a/common/gen-cpp/mnsc_data_types.h b/common/gen-cpp/mnsc_data_types.h
new file mode 100644
index 0000000..5835c20
--- /dev/null
+++ b/common/gen-cpp/mnsc_data_types.h
@@ -0,0 +1,254 @@
+/**
+ * Autogenerated by Thrift Compiler (0.8.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ * @generated
+ */
+#ifndef mnsc_data_TYPES_H
+#define mnsc_data_TYPES_H
+
+#include
+#include
+#include
+#include
+
+#include "naming_common_types.h"
+
+
+namespace meituan_mns {
+
+struct Protocols {
+ enum type {
+ THRIFT = 0,
+ HTTP = 1
+ };
+};
+
+extern const std::map _Protocols_VALUES_TO_NAMES;
+
+typedef class ::meituan_mns::SGService SGService;
+
+typedef struct _MNSResponse__isset {
+ _MNSResponse__isset() : defaultMNSCache(false), version(false) {}
+ bool defaultMNSCache;
+ bool version;
+} _MNSResponse__isset;
+
+class MNSResponse {
+ public:
+
+ static const char* ascii_fingerprint; // = "262B7A6EE88301D8EA2B9CBECB4AF401";
+ static const uint8_t binary_fingerprint[16]; // = {0x26,0x2B,0x7A,0x6E,0xE8,0x83,0x01,0xD8,0xEA,0x2B,0x9C,0xBE,0xCB,0x4A,0xF4,0x01};
+
+ MNSResponse() : code(200), version("") {
+ }
+
+ virtual ~MNSResponse() throw() {}
+
+ int32_t code;
+ std::vector defaultMNSCache;
+ std::string version;
+
+ _MNSResponse__isset __isset;
+
+ void __set_code(const int32_t val) {
+ code = val;
+ }
+
+ void __set_defaultMNSCache(const std::vector & val) {
+ defaultMNSCache = val;
+ __isset.defaultMNSCache = true;
+ }
+
+ void __set_version(const std::string& val) {
+ version = val;
+ __isset.version = true;
+ }
+
+ bool operator == (const MNSResponse & rhs) const
+ {
+ if (!(code == rhs.code))
+ return false;
+ if (__isset.defaultMNSCache != rhs.__isset.defaultMNSCache)
+ return false;
+ else if (__isset.defaultMNSCache && !(defaultMNSCache == rhs.defaultMNSCache))
+ return false;
+ if (__isset.version != rhs.__isset.version)
+ return false;
+ else if (__isset.version && !(version == rhs.version))
+ return false;
+ return true;
+ }
+ bool operator != (const MNSResponse &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const MNSResponse & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _MNSBatchResponse__isset {
+ _MNSBatchResponse__isset() : cache(false) {}
+ bool cache;
+} _MNSBatchResponse__isset;
+
+class MNSBatchResponse {
+ public:
+
+ static const char* ascii_fingerprint; // = "C0A3C40A83F3EC7069EF8B80B7669355";
+ static const uint8_t binary_fingerprint[16]; // = {0xC0,0xA3,0xC4,0x0A,0x83,0xF3,0xEC,0x70,0x69,0xEF,0x8B,0x80,0xB7,0x66,0x93,0x55};
+
+ MNSBatchResponse() : code(200) {
+ }
+
+ virtual ~MNSBatchResponse() throw() {}
+
+ int32_t code;
+ std::map > > cache;
+
+ _MNSBatchResponse__isset __isset;
+
+ void __set_code(const int32_t val) {
+ code = val;
+ }
+
+ void __set_cache(const std::map > > & val) {
+ cache = val;
+ __isset.cache = true;
+ }
+
+ bool operator == (const MNSBatchResponse & rhs) const
+ {
+ if (!(code == rhs.code))
+ return false;
+ if (__isset.cache != rhs.__isset.cache)
+ return false;
+ else if (__isset.cache && !(cache == rhs.cache))
+ return false;
+ return true;
+ }
+ bool operator != (const MNSBatchResponse &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const MNSBatchResponse & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _AppKeyListResponse__isset {
+ _AppKeyListResponse__isset() : appKeyList(false) {}
+ bool appKeyList;
+} _AppKeyListResponse__isset;
+
+class AppKeyListResponse {
+ public:
+
+ static const char* ascii_fingerprint; // = "93CC3D1E71866966C22792AABF4C3815";
+ static const uint8_t binary_fingerprint[16]; // = {0x93,0xCC,0x3D,0x1E,0x71,0x86,0x69,0x66,0xC2,0x27,0x92,0xAA,0xBF,0x4C,0x38,0x15};
+
+ AppKeyListResponse() : code(200) {
+ }
+
+ virtual ~AppKeyListResponse() throw() {}
+
+ int32_t code;
+ std::vector appKeyList;
+
+ _AppKeyListResponse__isset __isset;
+
+ void __set_code(const int32_t val) {
+ code = val;
+ }
+
+ void __set_appKeyList(const std::vector & val) {
+ appKeyList = val;
+ __isset.appKeyList = true;
+ }
+
+ bool operator == (const AppKeyListResponse & rhs) const
+ {
+ if (!(code == rhs.code))
+ return false;
+ if (__isset.appKeyList != rhs.__isset.appKeyList)
+ return false;
+ else if (__isset.appKeyList && !(appKeyList == rhs.appKeyList))
+ return false;
+ return true;
+ }
+ bool operator != (const AppKeyListResponse &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const AppKeyListResponse & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _MnsRequest__isset {
+ _MnsRequest__isset() : protoctol(false), appkey(false), env(false) {}
+ bool protoctol;
+ bool appkey;
+ bool env;
+} _MnsRequest__isset;
+
+class MnsRequest {
+ public:
+
+ static const char* ascii_fingerprint; // = "38C252E94E93B69D04EB3A6EE2F9EDFB";
+ static const uint8_t binary_fingerprint[16]; // = {0x38,0xC2,0x52,0xE9,0x4E,0x93,0xB6,0x9D,0x04,0xEB,0x3A,0x6E,0xE2,0xF9,0xED,0xFB};
+
+ MnsRequest() : protoctol((Protocols::type)0), appkey(""), env("") {
+ }
+
+ virtual ~MnsRequest() throw() {}
+
+ Protocols::type protoctol;
+ std::string appkey;
+ std::string env;
+
+ _MnsRequest__isset __isset;
+
+ void __set_protoctol(const Protocols::type val) {
+ protoctol = val;
+ }
+
+ void __set_appkey(const std::string& val) {
+ appkey = val;
+ }
+
+ void __set_env(const std::string& val) {
+ env = val;
+ }
+
+ bool operator == (const MnsRequest & rhs) const
+ {
+ if (!(protoctol == rhs.protoctol))
+ return false;
+ if (!(appkey == rhs.appkey))
+ return false;
+ if (!(env == rhs.env))
+ return false;
+ return true;
+ }
+ bool operator != (const MnsRequest &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const MnsRequest & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+} // namespace
+
+#endif
diff --git a/common/gen-cpp/mnsc_service_constants.cpp b/common/gen-cpp/mnsc_service_constants.cpp
new file mode 100644
index 0000000..5db972d
--- /dev/null
+++ b/common/gen-cpp/mnsc_service_constants.cpp
@@ -0,0 +1,17 @@
+/**
+ * Autogenerated by Thrift Compiler (0.8.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ * @generated
+ */
+#include "mnsc_service_constants.h"
+
+namespace meituan_mns {
+
+const mnsc_serviceConstants g_mnsc_service_constants;
+
+mnsc_serviceConstants::mnsc_serviceConstants() {
+}
+
+} // namespace
+
diff --git a/common/gen-cpp/mnsc_service_constants.h b/common/gen-cpp/mnsc_service_constants.h
new file mode 100644
index 0000000..7c99008
--- /dev/null
+++ b/common/gen-cpp/mnsc_service_constants.h
@@ -0,0 +1,24 @@
+/**
+ * Autogenerated by Thrift Compiler (0.8.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ * @generated
+ */
+#ifndef mnsc_service_CONSTANTS_H
+#define mnsc_service_CONSTANTS_H
+
+#include "mnsc_service_types.h"
+
+namespace meituan_mns {
+
+class mnsc_serviceConstants {
+ public:
+ mnsc_serviceConstants();
+
+};
+
+extern const mnsc_serviceConstants g_mnsc_service_constants;
+
+} // namespace
+
+#endif
diff --git a/common/gen-cpp/mnsc_service_types.cpp b/common/gen-cpp/mnsc_service_types.cpp
new file mode 100644
index 0000000..bd77e33
--- /dev/null
+++ b/common/gen-cpp/mnsc_service_types.cpp
@@ -0,0 +1,11 @@
+/**
+ * Autogenerated by Thrift Compiler (0.8.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ * @generated
+ */
+#include "mnsc_service_types.h"
+
+namespace meituan_mns {
+
+} // namespace
diff --git a/common/gen-cpp/mnsc_service_types.h b/common/gen-cpp/mnsc_service_types.h
new file mode 100644
index 0000000..6a0bbd0
--- /dev/null
+++ b/common/gen-cpp/mnsc_service_types.h
@@ -0,0 +1,32 @@
+/**
+ * Autogenerated by Thrift Compiler (0.8.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ * @generated
+ */
+#ifndef mnsc_service_TYPES_H
+#define mnsc_service_TYPES_H
+
+#include
+#include
+#include
+#include
+
+#include "mnsc_data_types.h"
+
+
+namespace meituan_mns {
+
+typedef class ::meituan_mns::MNSResponse MNSResponse;
+
+typedef class ::meituan_mns::MNSBatchResponse MNSBatchResponse;
+
+typedef class ::meituan_mns::AppKeyListResponse AppKeyListResponse;
+
+typedef class ::meituan_mns::MnsRequest MnsRequest;
+
+typedef ::meituan_mns::SGService SGService;
+
+} // namespace
+
+#endif
diff --git a/common/gen-cpp/naming_common_constants.cpp b/common/gen-cpp/naming_common_constants.cpp
new file mode 100644
index 0000000..e35a4b4
--- /dev/null
+++ b/common/gen-cpp/naming_common_constants.cpp
@@ -0,0 +1,17 @@
+/**
+ * Autogenerated by Thrift Compiler (0.8.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ * @generated
+ */
+#include "naming_common_constants.h"
+
+namespace meituan_mns {
+
+const naming_commonConstants g_naming_common_constants;
+
+naming_commonConstants::naming_commonConstants() {
+}
+
+} // namespace
+
diff --git a/common/gen-cpp/naming_common_constants.h b/common/gen-cpp/naming_common_constants.h
new file mode 100644
index 0000000..abc434b
--- /dev/null
+++ b/common/gen-cpp/naming_common_constants.h
@@ -0,0 +1,24 @@
+/**
+ * Autogenerated by Thrift Compiler (0.8.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ * @generated
+ */
+#ifndef naming_common_CONSTANTS_H
+#define naming_common_CONSTANTS_H
+
+#include "naming_common_types.h"
+
+namespace meituan_mns {
+
+class naming_commonConstants {
+ public:
+ naming_commonConstants();
+
+};
+
+extern const naming_commonConstants g_naming_common_constants;
+
+} // namespace
+
+#endif
diff --git a/common/gen-cpp/naming_common_types.cpp b/common/gen-cpp/naming_common_types.cpp
new file mode 100644
index 0000000..439598e
--- /dev/null
+++ b/common/gen-cpp/naming_common_types.cpp
@@ -0,0 +1,1106 @@
+/**
+ * Autogenerated by Thrift Compiler (0.8.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ * @generated
+ */
+#include "naming_common_types.h"
+
+namespace meituan_mns {
+
+int _kUptCmdValues[] = {
+ UptCmd::RESET,
+ UptCmd::ADD,
+ UptCmd::DELETE
+};
+const char* _kUptCmdNames[] = {
+ "RESET",
+ "ADD",
+ "DELETE"
+};
+const std::map _UptCmd_VALUES_TO_NAMES(::apache::thrift::TEnumIterator(3, _kUptCmdValues, _kUptCmdNames), ::apache::thrift::TEnumIterator(-1, NULL, NULL));
+
+int _kfb_statusValues[] = {
+ fb_status::DEAD,
+ fb_status::STARTING,
+ fb_status::ALIVE,
+ fb_status::STOPPING,
+ fb_status::STOPPED,
+ fb_status::WARNING
+};
+const char* _kfb_statusNames[] = {
+ "DEAD",
+ "STARTING",
+ "ALIVE",
+ "STOPPING",
+ "STOPPED",
+ "WARNING"
+};
+const std::map _fb_status_VALUES_TO_NAMES(::apache::thrift::TEnumIterator(6, _kfb_statusValues, _kfb_statusNames), ::apache::thrift::TEnumIterator(-1, NULL, NULL));
+
+int _kHeartbeatSupportTypeValues[] = {
+ HeartbeatSupportType::NoSupport,
+ HeartbeatSupportType::P2POnly,
+ HeartbeatSupportType::ScannerOnly,
+ HeartbeatSupportType::BothSupport
+};
+const char* _kHeartbeatSupportTypeNames[] = {
+ "NoSupport",
+ "P2POnly",
+ "ScannerOnly",
+ "BothSupport"
+};
+const std::map _HeartbeatSupportType_VALUES_TO_NAMES(::apache::thrift::TEnumIterator(4, _kHeartbeatSupportTypeValues, _kHeartbeatSupportTypeNames), ::apache::thrift::TEnumIterator(-1, NULL, NULL));
+
+const char* ServiceDetail::ascii_fingerprint = "5892306F7B861249AE8E27C8ED619593";
+const uint8_t ServiceDetail::binary_fingerprint[16] = {0x58,0x92,0x30,0x6F,0x7B,0x86,0x12,0x49,0xAE,0x8E,0x27,0xC8,0xED,0x61,0x95,0x93};
+
+uint32_t ServiceDetail::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 1:
+ if (ftype == ::apache::thrift::protocol::T_BOOL) {
+ xfer += iprot->readBool(this->unifiedProto);
+ this->__isset.unifiedProto = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t ServiceDetail::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("ServiceDetail");
+ xfer += oprot->writeFieldBegin("unifiedProto", ::apache::thrift::protocol::T_BOOL, 1);
+ xfer += oprot->writeBool(this->unifiedProto);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+const char* SGService::ascii_fingerprint = "BE473A6FD5DE924200DDD8D539C779C1";
+const uint8_t SGService::binary_fingerprint[16] = {0xBE,0x47,0x3A,0x6F,0xD5,0xDE,0x92,0x42,0x00,0xDD,0xD8,0xD5,0x39,0xC7,0x79,0xC1};
+
+uint32_t SGService::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 1:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->appkey);
+ this->__isset.appkey = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 2:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->version);
+ this->__isset.version = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 3:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->ip);
+ this->__isset.ip = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 4:
+ if (ftype == ::apache::thrift::protocol::T_I32) {
+ xfer += iprot->readI32(this->port);
+ this->__isset.port = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 5:
+ if (ftype == ::apache::thrift::protocol::T_I32) {
+ xfer += iprot->readI32(this->weight);
+ this->__isset.weight = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 6:
+ if (ftype == ::apache::thrift::protocol::T_I32) {
+ xfer += iprot->readI32(this->status);
+ this->__isset.status = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 7:
+ if (ftype == ::apache::thrift::protocol::T_I32) {
+ xfer += iprot->readI32(this->role);
+ this->__isset.role = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 8:
+ if (ftype == ::apache::thrift::protocol::T_I32) {
+ xfer += iprot->readI32(this->envir);
+ this->__isset.envir = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 9:
+ if (ftype == ::apache::thrift::protocol::T_I32) {
+ xfer += iprot->readI32(this->lastUpdateTime);
+ this->__isset.lastUpdateTime = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 10:
+ if (ftype == ::apache::thrift::protocol::T_DOUBLE) {
+ xfer += iprot->readDouble(this->fweight);
+ this->__isset.fweight = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 11:
+ if (ftype == ::apache::thrift::protocol::T_I32) {
+ xfer += iprot->readI32(this->serverType);
+ this->__isset.serverType = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 12:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->protocol);
+ this->__isset.protocol = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 13:
+ if (ftype == ::apache::thrift::protocol::T_MAP) {
+ {
+ this->serviceInfo.clear();
+ uint32_t _size0;
+ ::apache::thrift::protocol::TType _ktype1;
+ ::apache::thrift::protocol::TType _vtype2;
+ iprot->readMapBegin(_ktype1, _vtype2, _size0);
+ uint32_t _i4;
+ for (_i4 = 0; _i4 < _size0; ++_i4)
+ {
+ std::string _key5;
+ xfer += iprot->readString(_key5);
+ ServiceDetail& _val6 = this->serviceInfo[_key5];
+ xfer += _val6.read(iprot);
+ }
+ iprot->readMapEnd();
+ }
+ this->__isset.serviceInfo = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 14:
+ if (ftype == ::apache::thrift::protocol::T_BYTE) {
+ xfer += iprot->readByte(this->heartbeatSupport);
+ this->__isset.heartbeatSupport = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 15:
+ if (ftype == ::apache::thrift::protocol::T_I32) {
+ xfer += iprot->readI32(this->warmup);
+ this->__isset.warmup = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t SGService::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("SGService");
+ xfer += oprot->writeFieldBegin("appkey", ::apache::thrift::protocol::T_STRING, 1);
+ xfer += oprot->writeString(this->appkey);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("version", ::apache::thrift::protocol::T_STRING, 2);
+ xfer += oprot->writeString(this->version);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("ip", ::apache::thrift::protocol::T_STRING, 3);
+ xfer += oprot->writeString(this->ip);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("port", ::apache::thrift::protocol::T_I32, 4);
+ xfer += oprot->writeI32(this->port);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("weight", ::apache::thrift::protocol::T_I32, 5);
+ xfer += oprot->writeI32(this->weight);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("status", ::apache::thrift::protocol::T_I32, 6);
+ xfer += oprot->writeI32(this->status);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("role", ::apache::thrift::protocol::T_I32, 7);
+ xfer += oprot->writeI32(this->role);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("envir", ::apache::thrift::protocol::T_I32, 8);
+ xfer += oprot->writeI32(this->envir);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("lastUpdateTime", ::apache::thrift::protocol::T_I32, 9);
+ xfer += oprot->writeI32(this->lastUpdateTime);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("fweight", ::apache::thrift::protocol::T_DOUBLE, 10);
+ xfer += oprot->writeDouble(this->fweight);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("serverType", ::apache::thrift::protocol::T_I32, 11);
+ xfer += oprot->writeI32(this->serverType);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("protocol", ::apache::thrift::protocol::T_STRING, 12);
+ xfer += oprot->writeString(this->protocol);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("serviceInfo", ::apache::thrift::protocol::T_MAP, 13);
+ {
+ xfer += oprot->writeMapBegin(::apache::thrift::protocol::T_STRING, ::apache::thrift::protocol::T_STRUCT, static_cast(this->serviceInfo.size()));
+ std::map ::const_iterator _iter7;
+ for (_iter7 = this->serviceInfo.begin(); _iter7 != this->serviceInfo.end(); ++_iter7)
+ {
+ xfer += oprot->writeString(_iter7->first);
+ xfer += _iter7->second.write(oprot);
+ }
+ xfer += oprot->writeMapEnd();
+ }
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("heartbeatSupport", ::apache::thrift::protocol::T_BYTE, 14);
+ xfer += oprot->writeByte(this->heartbeatSupport);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("warmup", ::apache::thrift::protocol::T_I32, 15);
+ xfer += oprot->writeI32(this->warmup);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+const char* ServiceNode::ascii_fingerprint = "E6EB76A1BCBAF7124A43817D5BC322F7";
+const uint8_t ServiceNode::binary_fingerprint[16] = {0xE6,0xEB,0x76,0xA1,0xBC,0xBA,0xF7,0x12,0x4A,0x43,0x81,0x7D,0x5B,0xC3,0x22,0xF7};
+
+uint32_t ServiceNode::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 1:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->serviceName);
+ this->__isset.serviceName = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 2:
+ if (ftype == ::apache::thrift::protocol::T_SET) {
+ {
+ this->appkeys.clear();
+ uint32_t _size8;
+ ::apache::thrift::protocol::TType _etype11;
+ iprot->readSetBegin(_etype11, _size8);
+ uint32_t _i12;
+ for (_i12 = 0; _i12 < _size8; ++_i12)
+ {
+ std::string _elem13;
+ xfer += iprot->readString(_elem13);
+ this->appkeys.insert(_elem13);
+ }
+ iprot->readSetEnd();
+ }
+ this->__isset.appkeys = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 3:
+ if (ftype == ::apache::thrift::protocol::T_I32) {
+ xfer += iprot->readI32(this->lastUpdateTime);
+ this->__isset.lastUpdateTime = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t ServiceNode::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("ServiceNode");
+ xfer += oprot->writeFieldBegin("serviceName", ::apache::thrift::protocol::T_STRING, 1);
+ xfer += oprot->writeString(this->serviceName);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("appkeys", ::apache::thrift::protocol::T_SET, 2);
+ {
+ xfer += oprot->writeSetBegin(::apache::thrift::protocol::T_STRING, static_cast(this->appkeys.size()));
+ std::set ::const_iterator _iter14;
+ for (_iter14 = this->appkeys.begin(); _iter14 != this->appkeys.end(); ++_iter14)
+ {
+ xfer += oprot->writeString((*_iter14));
+ }
+ xfer += oprot->writeSetEnd();
+ }
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("lastUpdateTime", ::apache::thrift::protocol::T_I32, 3);
+ xfer += oprot->writeI32(this->lastUpdateTime);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+const char* Consumer::ascii_fingerprint = "AA819045335EAFAB5C2FE456B4B9CC1C";
+const uint8_t Consumer::binary_fingerprint[16] = {0xAA,0x81,0x90,0x45,0x33,0x5E,0xAF,0xAB,0x5C,0x2F,0xE4,0x56,0xB4,0xB9,0xCC,0x1C};
+
+uint32_t Consumer::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 1:
+ if (ftype == ::apache::thrift::protocol::T_LIST) {
+ {
+ this->ips.clear();
+ uint32_t _size15;
+ ::apache::thrift::protocol::TType _etype18;
+ iprot->readListBegin(_etype18, _size15);
+ this->ips.resize(_size15);
+ uint32_t _i19;
+ for (_i19 = 0; _i19 < _size15; ++_i19)
+ {
+ xfer += iprot->readString(this->ips[_i19]);
+ }
+ iprot->readListEnd();
+ }
+ this->__isset.ips = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 2:
+ if (ftype == ::apache::thrift::protocol::T_LIST) {
+ {
+ this->appkeys.clear();
+ uint32_t _size20;
+ ::apache::thrift::protocol::TType _etype23;
+ iprot->readListBegin(_etype23, _size20);
+ this->appkeys.resize(_size20);
+ uint32_t _i24;
+ for (_i24 = 0; _i24 < _size20; ++_i24)
+ {
+ xfer += iprot->readString(this->appkeys[_i24]);
+ }
+ iprot->readListEnd();
+ }
+ this->__isset.appkeys = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t Consumer::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("Consumer");
+ xfer += oprot->writeFieldBegin("ips", ::apache::thrift::protocol::T_LIST, 1);
+ {
+ xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast(this->ips.size()));
+ std::vector ::const_iterator _iter25;
+ for (_iter25 = this->ips.begin(); _iter25 != this->ips.end(); ++_iter25)
+ {
+ xfer += oprot->writeString((*_iter25));
+ }
+ xfer += oprot->writeListEnd();
+ }
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("appkeys", ::apache::thrift::protocol::T_LIST, 2);
+ {
+ xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast(this->appkeys.size()));
+ std::vector ::const_iterator _iter26;
+ for (_iter26 = this->appkeys.begin(); _iter26 != this->appkeys.end(); ++_iter26)
+ {
+ xfer += oprot->writeString((*_iter26));
+ }
+ xfer += oprot->writeListEnd();
+ }
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+const char* CRouteData::ascii_fingerprint = "BA097AEDC13A13D0EF25D33F4578FC59";
+const uint8_t CRouteData::binary_fingerprint[16] = {0xBA,0x09,0x7A,0xED,0xC1,0x3A,0x13,0xD0,0xEF,0x25,0xD3,0x3F,0x45,0x78,0xFC,0x59};
+
+uint32_t CRouteData::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 1:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->id);
+ this->__isset.id = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 2:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->name);
+ this->__isset.name = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 3:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->appkey);
+ this->__isset.appkey = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 4:
+ if (ftype == ::apache::thrift::protocol::T_I32) {
+ xfer += iprot->readI32(this->env);
+ this->__isset.env = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 5:
+ if (ftype == ::apache::thrift::protocol::T_I32) {
+ xfer += iprot->readI32(this->category);
+ this->__isset.category = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 6:
+ if (ftype == ::apache::thrift::protocol::T_I32) {
+ xfer += iprot->readI32(this->priority);
+ this->__isset.priority = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 7:
+ if (ftype == ::apache::thrift::protocol::T_I32) {
+ xfer += iprot->readI32(this->status);
+ this->__isset.status = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 8:
+ if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+ xfer += this->consumer.read(iprot);
+ this->__isset.consumer = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 9:
+ if (ftype == ::apache::thrift::protocol::T_LIST) {
+ {
+ this->provider.clear();
+ uint32_t _size27;
+ ::apache::thrift::protocol::TType _etype30;
+ iprot->readListBegin(_etype30, _size27);
+ this->provider.resize(_size27);
+ uint32_t _i31;
+ for (_i31 = 0; _i31 < _size27; ++_i31)
+ {
+ xfer += iprot->readString(this->provider[_i31]);
+ }
+ iprot->readListEnd();
+ }
+ this->__isset.provider = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 10:
+ if (ftype == ::apache::thrift::protocol::T_I32) {
+ xfer += iprot->readI32(this->updateTime);
+ this->__isset.updateTime = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 11:
+ if (ftype == ::apache::thrift::protocol::T_I32) {
+ xfer += iprot->readI32(this->createTime);
+ this->__isset.createTime = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 12:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->reserved);
+ this->__isset.reserved = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t CRouteData::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("CRouteData");
+ xfer += oprot->writeFieldBegin("id", ::apache::thrift::protocol::T_STRING, 1);
+ xfer += oprot->writeString(this->id);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("name", ::apache::thrift::protocol::T_STRING, 2);
+ xfer += oprot->writeString(this->name);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("appkey", ::apache::thrift::protocol::T_STRING, 3);
+ xfer += oprot->writeString(this->appkey);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("env", ::apache::thrift::protocol::T_I32, 4);
+ xfer += oprot->writeI32(this->env);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("category", ::apache::thrift::protocol::T_I32, 5);
+ xfer += oprot->writeI32(this->category);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("priority", ::apache::thrift::protocol::T_I32, 6);
+ xfer += oprot->writeI32(this->priority);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("status", ::apache::thrift::protocol::T_I32, 7);
+ xfer += oprot->writeI32(this->status);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("consumer", ::apache::thrift::protocol::T_STRUCT, 8);
+ xfer += this->consumer.write(oprot);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("provider", ::apache::thrift::protocol::T_LIST, 9);
+ {
+ xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast(this->provider.size()));
+ std::vector ::const_iterator _iter32;
+ for (_iter32 = this->provider.begin(); _iter32 != this->provider.end(); ++_iter32)
+ {
+ xfer += oprot->writeString((*_iter32));
+ }
+ xfer += oprot->writeListEnd();
+ }
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("updateTime", ::apache::thrift::protocol::T_I32, 10);
+ xfer += oprot->writeI32(this->updateTime);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("createTime", ::apache::thrift::protocol::T_I32, 11);
+ xfer += oprot->writeI32(this->createTime);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("reserved", ::apache::thrift::protocol::T_STRING, 12);
+ xfer += oprot->writeString(this->reserved);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+const char* CProviderNode::ascii_fingerprint = "9118FDD77343DD231D97C424A53D2DCF";
+const uint8_t CProviderNode::binary_fingerprint[16] = {0x91,0x18,0xFD,0xD7,0x73,0x43,0xDD,0x23,0x1D,0x97,0xC4,0x24,0xA5,0x3D,0x2D,0xCF};
+
+uint32_t CProviderNode::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 1:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->appkey);
+ this->__isset.appkey = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 2:
+ if (ftype == ::apache::thrift::protocol::T_I64) {
+ xfer += iprot->readI64(this->lastModifiedTime);
+ this->__isset.lastModifiedTime = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 3:
+ if (ftype == ::apache::thrift::protocol::T_I64) {
+ xfer += iprot->readI64(this->mtime);
+ this->__isset.mtime = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 4:
+ if (ftype == ::apache::thrift::protocol::T_I64) {
+ xfer += iprot->readI64(this->cversion);
+ this->__isset.cversion = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 5:
+ if (ftype == ::apache::thrift::protocol::T_I64) {
+ xfer += iprot->readI64(this->version);
+ this->__isset.version = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t CProviderNode::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("CProviderNode");
+ xfer += oprot->writeFieldBegin("appkey", ::apache::thrift::protocol::T_STRING, 1);
+ xfer += oprot->writeString(this->appkey);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("lastModifiedTime", ::apache::thrift::protocol::T_I64, 2);
+ xfer += oprot->writeI64(this->lastModifiedTime);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("mtime", ::apache::thrift::protocol::T_I64, 3);
+ xfer += oprot->writeI64(this->mtime);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("cversion", ::apache::thrift::protocol::T_I64, 4);
+ xfer += oprot->writeI64(this->cversion);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("version", ::apache::thrift::protocol::T_I64, 5);
+ xfer += oprot->writeI64(this->version);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+const char* CRouteNode::ascii_fingerprint = "9118FDD77343DD231D97C424A53D2DCF";
+const uint8_t CRouteNode::binary_fingerprint[16] = {0x91,0x18,0xFD,0xD7,0x73,0x43,0xDD,0x23,0x1D,0x97,0xC4,0x24,0xA5,0x3D,0x2D,0xCF};
+
+uint32_t CRouteNode::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 1:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->appkey);
+ this->__isset.appkey = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 2:
+ if (ftype == ::apache::thrift::protocol::T_I64) {
+ xfer += iprot->readI64(this->lastModifiedTime);
+ this->__isset.lastModifiedTime = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 3:
+ if (ftype == ::apache::thrift::protocol::T_I64) {
+ xfer += iprot->readI64(this->mtime);
+ this->__isset.mtime = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 4:
+ if (ftype == ::apache::thrift::protocol::T_I64) {
+ xfer += iprot->readI64(this->cversion);
+ this->__isset.cversion = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 5:
+ if (ftype == ::apache::thrift::protocol::T_I64) {
+ xfer += iprot->readI64(this->version);
+ this->__isset.version = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t CRouteNode::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("CRouteNode");
+ xfer += oprot->writeFieldBegin("appkey", ::apache::thrift::protocol::T_STRING, 1);
+ xfer += oprot->writeString(this->appkey);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("lastModifiedTime", ::apache::thrift::protocol::T_I64, 2);
+ xfer += oprot->writeI64(this->lastModifiedTime);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("mtime", ::apache::thrift::protocol::T_I64, 3);
+ xfer += oprot->writeI64(this->mtime);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("cversion", ::apache::thrift::protocol::T_I64, 4);
+ xfer += oprot->writeI64(this->cversion);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("version", ::apache::thrift::protocol::T_I64, 5);
+ xfer += oprot->writeI64(this->version);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+const char* ProtocolRequest::ascii_fingerprint = "C93D890311F28844166CF6E571EB3AC2";
+const uint8_t ProtocolRequest::binary_fingerprint[16] = {0xC9,0x3D,0x89,0x03,0x11,0xF2,0x88,0x44,0x16,0x6C,0xF6,0xE5,0x71,0xEB,0x3A,0xC2};
+
+uint32_t ProtocolRequest::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 1:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->localAppkey);
+ this->__isset.localAppkey = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 2:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->remoteAppkey);
+ this->__isset.remoteAppkey = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 3:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->protocol);
+ this->__isset.protocol = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 4:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->serviceName);
+ this->__isset.serviceName = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t ProtocolRequest::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("ProtocolRequest");
+ xfer += oprot->writeFieldBegin("localAppkey", ::apache::thrift::protocol::T_STRING, 1);
+ xfer += oprot->writeString(this->localAppkey);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("remoteAppkey", ::apache::thrift::protocol::T_STRING, 2);
+ xfer += oprot->writeString(this->remoteAppkey);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("protocol", ::apache::thrift::protocol::T_STRING, 3);
+ xfer += oprot->writeString(this->protocol);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("serviceName", ::apache::thrift::protocol::T_STRING, 4);
+ xfer += oprot->writeString(this->serviceName);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+const char* ProtocolResponse::ascii_fingerprint = "F56E7FEC73C75A28B4691E35627DB92D";
+const uint8_t ProtocolResponse::binary_fingerprint[16] = {0xF5,0x6E,0x7F,0xEC,0x73,0xC7,0x5A,0x28,0xB4,0x69,0x1E,0x35,0x62,0x7D,0xB9,0x2D};
+
+uint32_t ProtocolResponse::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 1:
+ if (ftype == ::apache::thrift::protocol::T_I32) {
+ xfer += iprot->readI32(this->errcode);
+ this->__isset.errcode = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 2:
+ if (ftype == ::apache::thrift::protocol::T_LIST) {
+ {
+ this->servicelist.clear();
+ uint32_t _size33;
+ ::apache::thrift::protocol::TType _etype36;
+ iprot->readListBegin(_etype36, _size33);
+ this->servicelist.resize(_size33);
+ uint32_t _i37;
+ for (_i37 = 0; _i37 < _size33; ++_i37)
+ {
+ xfer += this->servicelist[_i37].read(iprot);
+ }
+ iprot->readListEnd();
+ }
+ this->__isset.servicelist = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t ProtocolResponse::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("ProtocolResponse");
+ xfer += oprot->writeFieldBegin("errcode", ::apache::thrift::protocol::T_I32, 1);
+ xfer += oprot->writeI32(this->errcode);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("servicelist", ::apache::thrift::protocol::T_LIST, 2);
+ {
+ xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast(this->servicelist.size()));
+ std::vector ::const_iterator _iter38;
+ for (_iter38 = this->servicelist.begin(); _iter38 != this->servicelist.end(); ++_iter38)
+ {
+ xfer += (*_iter38).write(oprot);
+ }
+ xfer += oprot->writeListEnd();
+ }
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+} // namespace
diff --git a/common/gen-cpp/naming_common_types.h b/common/gen-cpp/naming_common_types.h
new file mode 100644
index 0000000..b15324b
--- /dev/null
+++ b/common/gen-cpp/naming_common_types.h
@@ -0,0 +1,744 @@
+/**
+ * Autogenerated by Thrift Compiler (0.8.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ * @generated
+ */
+#ifndef naming_common_TYPES_H
+#define naming_common_TYPES_H
+
+#include
+#include
+#include
+#include
+
+
+
+namespace meituan_mns {
+
+struct UptCmd {
+ enum type {
+ RESET = 0,
+ ADD = 1,
+ DELETE = 2
+ };
+};
+
+extern const std::map _UptCmd_VALUES_TO_NAMES;
+
+struct fb_status {
+ enum type {
+ DEAD = 0,
+ STARTING = 1,
+ ALIVE = 2,
+ STOPPING = 3,
+ STOPPED = 4,
+ WARNING = 5
+ };
+};
+
+extern const std::map _fb_status_VALUES_TO_NAMES;
+
+struct HeartbeatSupportType {
+ enum type {
+ NoSupport = 0,
+ P2POnly = 1,
+ ScannerOnly = 2,
+ BothSupport = 3
+ };
+};
+
+extern const std::map _HeartbeatSupportType_VALUES_TO_NAMES;
+
+typedef struct _ServiceDetail__isset {
+ _ServiceDetail__isset() : unifiedProto(false) {}
+ bool unifiedProto;
+} _ServiceDetail__isset;
+
+class ServiceDetail {
+ public:
+
+ static const char* ascii_fingerprint; // = "5892306F7B861249AE8E27C8ED619593";
+ static const uint8_t binary_fingerprint[16]; // = {0x58,0x92,0x30,0x6F,0x7B,0x86,0x12,0x49,0xAE,0x8E,0x27,0xC8,0xED,0x61,0x95,0x93};
+
+ ServiceDetail() : unifiedProto(0) {
+ }
+
+ virtual ~ServiceDetail() throw() {}
+
+ bool unifiedProto;
+
+ _ServiceDetail__isset __isset;
+
+ void __set_unifiedProto(const bool val) {
+ unifiedProto = val;
+ }
+
+ bool operator == (const ServiceDetail & rhs) const
+ {
+ if (!(unifiedProto == rhs.unifiedProto))
+ return false;
+ return true;
+ }
+ bool operator != (const ServiceDetail &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const ServiceDetail & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _SGService__isset {
+ _SGService__isset() : appkey(false), version(false), ip(false), port(false), weight(false), status(false), role(false), envir(false), lastUpdateTime(false), fweight(false), serverType(false), protocol(false), serviceInfo(false), heartbeatSupport(false), warmup(false) {}
+ bool appkey;
+ bool version;
+ bool ip;
+ bool port;
+ bool weight;
+ bool status;
+ bool role;
+ bool envir;
+ bool lastUpdateTime;
+ bool fweight;
+ bool serverType;
+ bool protocol;
+ bool serviceInfo;
+ bool heartbeatSupport;
+ bool warmup;
+} _SGService__isset;
+
+class SGService {
+ public:
+
+ static const char* ascii_fingerprint; // = "BE473A6FD5DE924200DDD8D539C779C1";
+ static const uint8_t binary_fingerprint[16]; // = {0xBE,0x47,0x3A,0x6F,0xD5,0xDE,0x92,0x42,0x00,0xDD,0xD8,0xD5,0x39,0xC7,0x79,0xC1};
+
+ SGService() : appkey(""), version(""), ip(""), port(0), weight(0), status(0), role(0), envir(0), lastUpdateTime(0), fweight(0), serverType(0), protocol(""), heartbeatSupport(0), warmup(0) {
+ }
+
+ virtual ~SGService() throw() {}
+
+ std::string appkey;
+ std::string version;
+ std::string ip;
+ int32_t port;
+ int32_t weight;
+ int32_t status;
+ int32_t role;
+ int32_t envir;
+ int32_t lastUpdateTime;
+ double fweight;
+ int32_t serverType;
+ std::string protocol;
+ std::map serviceInfo;
+ int8_t heartbeatSupport;
+ int32_t warmup;
+
+ _SGService__isset __isset;
+
+ void __set_appkey(const std::string& val) {
+ appkey = val;
+ }
+
+ void __set_version(const std::string& val) {
+ version = val;
+ }
+
+ void __set_ip(const std::string& val) {
+ ip = val;
+ }
+
+ void __set_port(const int32_t val) {
+ port = val;
+ }
+
+ void __set_weight(const int32_t val) {
+ weight = val;
+ }
+
+ void __set_status(const int32_t val) {
+ status = val;
+ }
+
+ void __set_role(const int32_t val) {
+ role = val;
+ }
+
+ void __set_envir(const int32_t val) {
+ envir = val;
+ }
+
+ void __set_lastUpdateTime(const int32_t val) {
+ lastUpdateTime = val;
+ }
+
+ void __set_fweight(const double val) {
+ fweight = val;
+ }
+
+ void __set_serverType(const int32_t val) {
+ serverType = val;
+ }
+
+ void __set_protocol(const std::string& val) {
+ protocol = val;
+ }
+
+ void __set_serviceInfo(const std::map & val) {
+ serviceInfo = val;
+ }
+
+ void __set_heartbeatSupport(const int8_t val) {
+ heartbeatSupport = val;
+ }
+
+ void __set_warmup(const int32_t val) {
+ warmup = val;
+ }
+
+ bool operator == (const SGService & rhs) const
+ {
+ if (!(appkey == rhs.appkey))
+ return false;
+ if (!(version == rhs.version))
+ return false;
+ if (!(ip == rhs.ip))
+ return false;
+ if (!(port == rhs.port))
+ return false;
+ if (!(weight == rhs.weight))
+ return false;
+ if (!(status == rhs.status))
+ return false;
+ if (!(role == rhs.role))
+ return false;
+ if (!(envir == rhs.envir))
+ return false;
+ if (!(lastUpdateTime == rhs.lastUpdateTime))
+ return false;
+ if (!(fweight == rhs.fweight))
+ return false;
+ if (!(serverType == rhs.serverType))
+ return false;
+ if (!(protocol == rhs.protocol))
+ return false;
+ if (!(serviceInfo == rhs.serviceInfo))
+ return false;
+ if (!(heartbeatSupport == rhs.heartbeatSupport))
+ return false;
+ if (!(warmup == rhs.warmup))
+ return false;
+ return true;
+ }
+ bool operator != (const SGService &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const SGService & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _ServiceNode__isset {
+ _ServiceNode__isset() : serviceName(false), appkeys(false), lastUpdateTime(false) {}
+ bool serviceName;
+ bool appkeys;
+ bool lastUpdateTime;
+} _ServiceNode__isset;
+
+class ServiceNode {
+ public:
+
+ static const char* ascii_fingerprint; // = "E6EB76A1BCBAF7124A43817D5BC322F7";
+ static const uint8_t binary_fingerprint[16]; // = {0xE6,0xEB,0x76,0xA1,0xBC,0xBA,0xF7,0x12,0x4A,0x43,0x81,0x7D,0x5B,0xC3,0x22,0xF7};
+
+ ServiceNode() : serviceName(""), lastUpdateTime(0) {
+ }
+
+ virtual ~ServiceNode() throw() {}
+
+ std::string serviceName;
+ std::set appkeys;
+ int32_t lastUpdateTime;
+
+ _ServiceNode__isset __isset;
+
+ void __set_serviceName(const std::string& val) {
+ serviceName = val;
+ }
+
+ void __set_appkeys(const std::set & val) {
+ appkeys = val;
+ }
+
+ void __set_lastUpdateTime(const int32_t val) {
+ lastUpdateTime = val;
+ }
+
+ bool operator == (const ServiceNode & rhs) const
+ {
+ if (!(serviceName == rhs.serviceName))
+ return false;
+ if (!(appkeys == rhs.appkeys))
+ return false;
+ if (!(lastUpdateTime == rhs.lastUpdateTime))
+ return false;
+ return true;
+ }
+ bool operator != (const ServiceNode &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const ServiceNode & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _Consumer__isset {
+ _Consumer__isset() : ips(false), appkeys(false) {}
+ bool ips;
+ bool appkeys;
+} _Consumer__isset;
+
+class Consumer {
+ public:
+
+ static const char* ascii_fingerprint; // = "AA819045335EAFAB5C2FE456B4B9CC1C";
+ static const uint8_t binary_fingerprint[16]; // = {0xAA,0x81,0x90,0x45,0x33,0x5E,0xAF,0xAB,0x5C,0x2F,0xE4,0x56,0xB4,0xB9,0xCC,0x1C};
+
+ Consumer() {
+ }
+
+ virtual ~Consumer() throw() {}
+
+ std::vector ips;
+ std::vector appkeys;
+
+ _Consumer__isset __isset;
+
+ void __set_ips(const std::vector & val) {
+ ips = val;
+ }
+
+ void __set_appkeys(const std::vector & val) {
+ appkeys = val;
+ }
+
+ bool operator == (const Consumer & rhs) const
+ {
+ if (!(ips == rhs.ips))
+ return false;
+ if (!(appkeys == rhs.appkeys))
+ return false;
+ return true;
+ }
+ bool operator != (const Consumer &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const Consumer & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _CRouteData__isset {
+ _CRouteData__isset() : id(false), name(false), appkey(false), env(false), category(false), priority(false), status(false), consumer(false), provider(false), updateTime(false), createTime(false), reserved(false) {}
+ bool id;
+ bool name;
+ bool appkey;
+ bool env;
+ bool category;
+ bool priority;
+ bool status;
+ bool consumer;
+ bool provider;
+ bool updateTime;
+ bool createTime;
+ bool reserved;
+} _CRouteData__isset;
+
+class CRouteData {
+ public:
+
+ static const char* ascii_fingerprint; // = "BA097AEDC13A13D0EF25D33F4578FC59";
+ static const uint8_t binary_fingerprint[16]; // = {0xBA,0x09,0x7A,0xED,0xC1,0x3A,0x13,0xD0,0xEF,0x25,0xD3,0x3F,0x45,0x78,0xFC,0x59};
+
+ CRouteData() : id(""), name(""), appkey(""), env(0), category(0), priority(0), status(0), updateTime(0), createTime(0), reserved("") {
+ }
+
+ virtual ~CRouteData() throw() {}
+
+ std::string id;
+ std::string name;
+ std::string appkey;
+ int32_t env;
+ int32_t category;
+ int32_t priority;
+ int32_t status;
+ Consumer consumer;
+ std::vector provider;
+ int32_t updateTime;
+ int32_t createTime;
+ std::string reserved;
+
+ _CRouteData__isset __isset;
+
+ void __set_id(const std::string& val) {
+ id = val;
+ }
+
+ void __set_name(const std::string& val) {
+ name = val;
+ }
+
+ void __set_appkey(const std::string& val) {
+ appkey = val;
+ }
+
+ void __set_env(const int32_t val) {
+ env = val;
+ }
+
+ void __set_category(const int32_t val) {
+ category = val;
+ }
+
+ void __set_priority(const int32_t val) {
+ priority = val;
+ }
+
+ void __set_status(const int32_t val) {
+ status = val;
+ }
+
+ void __set_consumer(const Consumer& val) {
+ consumer = val;
+ }
+
+ void __set_provider(const std::vector & val) {
+ provider = val;
+ }
+
+ void __set_updateTime(const int32_t val) {
+ updateTime = val;
+ }
+
+ void __set_createTime(const int32_t val) {
+ createTime = val;
+ }
+
+ void __set_reserved(const std::string& val) {
+ reserved = val;
+ }
+
+ bool operator == (const CRouteData & rhs) const
+ {
+ if (!(id == rhs.id))
+ return false;
+ if (!(name == rhs.name))
+ return false;
+ if (!(appkey == rhs.appkey))
+ return false;
+ if (!(env == rhs.env))
+ return false;
+ if (!(category == rhs.category))
+ return false;
+ if (!(priority == rhs.priority))
+ return false;
+ if (!(status == rhs.status))
+ return false;
+ if (!(consumer == rhs.consumer))
+ return false;
+ if (!(provider == rhs.provider))
+ return false;
+ if (!(updateTime == rhs.updateTime))
+ return false;
+ if (!(createTime == rhs.createTime))
+ return false;
+ if (!(reserved == rhs.reserved))
+ return false;
+ return true;
+ }
+ bool operator != (const CRouteData &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const CRouteData & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _CProviderNode__isset {
+ _CProviderNode__isset() : appkey(false), lastModifiedTime(false), mtime(false), cversion(false), version(false) {}
+ bool appkey;
+ bool lastModifiedTime;
+ bool mtime;
+ bool cversion;
+ bool version;
+} _CProviderNode__isset;
+
+class CProviderNode {
+ public:
+
+ static const char* ascii_fingerprint; // = "9118FDD77343DD231D97C424A53D2DCF";
+ static const uint8_t binary_fingerprint[16]; // = {0x91,0x18,0xFD,0xD7,0x73,0x43,0xDD,0x23,0x1D,0x97,0xC4,0x24,0xA5,0x3D,0x2D,0xCF};
+
+ CProviderNode() : appkey(""), lastModifiedTime(0), mtime(0), cversion(0), version(0) {
+ }
+
+ virtual ~CProviderNode() throw() {}
+
+ std::string appkey;
+ int64_t lastModifiedTime;
+ int64_t mtime;
+ int64_t cversion;
+ int64_t version;
+
+ _CProviderNode__isset __isset;
+
+ void __set_appkey(const std::string& val) {
+ appkey = val;
+ }
+
+ void __set_lastModifiedTime(const int64_t val) {
+ lastModifiedTime = val;
+ }
+
+ void __set_mtime(const int64_t val) {
+ mtime = val;
+ }
+
+ void __set_cversion(const int64_t val) {
+ cversion = val;
+ }
+
+ void __set_version(const int64_t val) {
+ version = val;
+ }
+
+ bool operator == (const CProviderNode & rhs) const
+ {
+ if (!(appkey == rhs.appkey))
+ return false;
+ if (!(lastModifiedTime == rhs.lastModifiedTime))
+ return false;
+ if (!(mtime == rhs.mtime))
+ return false;
+ if (!(cversion == rhs.cversion))
+ return false;
+ if (!(version == rhs.version))
+ return false;
+ return true;
+ }
+ bool operator != (const CProviderNode &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const CProviderNode & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _CRouteNode__isset {
+ _CRouteNode__isset() : appkey(false), lastModifiedTime(false), mtime(false), cversion(false), version(false) {}
+ bool appkey;
+ bool lastModifiedTime;
+ bool mtime;
+ bool cversion;
+ bool version;
+} _CRouteNode__isset;
+
+class CRouteNode {
+ public:
+
+ static const char* ascii_fingerprint; // = "9118FDD77343DD231D97C424A53D2DCF";
+ static const uint8_t binary_fingerprint[16]; // = {0x91,0x18,0xFD,0xD7,0x73,0x43,0xDD,0x23,0x1D,0x97,0xC4,0x24,0xA5,0x3D,0x2D,0xCF};
+
+ CRouteNode() : appkey(""), lastModifiedTime(0), mtime(0), cversion(0), version(0) {
+ }
+
+ virtual ~CRouteNode() throw() {}
+
+ std::string appkey;
+ int64_t lastModifiedTime;
+ int64_t mtime;
+ int64_t cversion;
+ int64_t version;
+
+ _CRouteNode__isset __isset;
+
+ void __set_appkey(const std::string& val) {
+ appkey = val;
+ }
+
+ void __set_lastModifiedTime(const int64_t val) {
+ lastModifiedTime = val;
+ }
+
+ void __set_mtime(const int64_t val) {
+ mtime = val;
+ }
+
+ void __set_cversion(const int64_t val) {
+ cversion = val;
+ }
+
+ void __set_version(const int64_t val) {
+ version = val;
+ }
+
+ bool operator == (const CRouteNode & rhs) const
+ {
+ if (!(appkey == rhs.appkey))
+ return false;
+ if (!(lastModifiedTime == rhs.lastModifiedTime))
+ return false;
+ if (!(mtime == rhs.mtime))
+ return false;
+ if (!(cversion == rhs.cversion))
+ return false;
+ if (!(version == rhs.version))
+ return false;
+ return true;
+ }
+ bool operator != (const CRouteNode &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const CRouteNode & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _ProtocolRequest__isset {
+ _ProtocolRequest__isset() : localAppkey(false), remoteAppkey(false), protocol(false), serviceName(false) {}
+ bool localAppkey;
+ bool remoteAppkey;
+ bool protocol;
+ bool serviceName;
+} _ProtocolRequest__isset;
+
+class ProtocolRequest {
+ public:
+
+ static const char* ascii_fingerprint; // = "C93D890311F28844166CF6E571EB3AC2";
+ static const uint8_t binary_fingerprint[16]; // = {0xC9,0x3D,0x89,0x03,0x11,0xF2,0x88,0x44,0x16,0x6C,0xF6,0xE5,0x71,0xEB,0x3A,0xC2};
+
+ ProtocolRequest() : localAppkey(""), remoteAppkey(""), protocol(""), serviceName("") {
+ }
+
+ virtual ~ProtocolRequest() throw() {}
+
+ std::string localAppkey;
+ std::string remoteAppkey;
+ std::string protocol;
+ std::string serviceName;
+
+ _ProtocolRequest__isset __isset;
+
+ void __set_localAppkey(const std::string& val) {
+ localAppkey = val;
+ }
+
+ void __set_remoteAppkey(const std::string& val) {
+ remoteAppkey = val;
+ }
+
+ void __set_protocol(const std::string& val) {
+ protocol = val;
+ }
+
+ void __set_serviceName(const std::string& val) {
+ serviceName = val;
+ }
+
+ bool operator == (const ProtocolRequest & rhs) const
+ {
+ if (!(localAppkey == rhs.localAppkey))
+ return false;
+ if (!(remoteAppkey == rhs.remoteAppkey))
+ return false;
+ if (!(protocol == rhs.protocol))
+ return false;
+ if (!(serviceName == rhs.serviceName))
+ return false;
+ return true;
+ }
+ bool operator != (const ProtocolRequest &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const ProtocolRequest & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _ProtocolResponse__isset {
+ _ProtocolResponse__isset() : errcode(false), servicelist(false) {}
+ bool errcode;
+ bool servicelist;
+} _ProtocolResponse__isset;
+
+class ProtocolResponse {
+ public:
+
+ static const char* ascii_fingerprint; // = "F56E7FEC73C75A28B4691E35627DB92D";
+ static const uint8_t binary_fingerprint[16]; // = {0xF5,0x6E,0x7F,0xEC,0x73,0xC7,0x5A,0x28,0xB4,0x69,0x1E,0x35,0x62,0x7D,0xB9,0x2D};
+
+ ProtocolResponse() : errcode(0) {
+ }
+
+ virtual ~ProtocolResponse() throw() {}
+
+ int32_t errcode;
+ std::vector servicelist;
+
+ _ProtocolResponse__isset __isset;
+
+ void __set_errcode(const int32_t val) {
+ errcode = val;
+ }
+
+ void __set_servicelist(const std::vector & val) {
+ servicelist = val;
+ }
+
+ bool operator == (const ProtocolResponse & rhs) const
+ {
+ if (!(errcode == rhs.errcode))
+ return false;
+ if (!(servicelist == rhs.servicelist))
+ return false;
+ return true;
+ }
+ bool operator != (const ProtocolResponse &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const ProtocolResponse & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+} // namespace
+
+#endif
diff --git a/common/gen-cpp/naming_data_constants.cpp b/common/gen-cpp/naming_data_constants.cpp
new file mode 100644
index 0000000..a9a573b
--- /dev/null
+++ b/common/gen-cpp/naming_data_constants.cpp
@@ -0,0 +1,17 @@
+/**
+ * Autogenerated by Thrift Compiler (0.8.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ * @generated
+ */
+#include "naming_data_constants.h"
+
+namespace meituan_mns {
+
+const naming_dataConstants g_naming_data_constants;
+
+naming_dataConstants::naming_dataConstants() {
+}
+
+} // namespace
+
diff --git a/common/gen-cpp/naming_data_constants.h b/common/gen-cpp/naming_data_constants.h
new file mode 100644
index 0000000..7ef8442
--- /dev/null
+++ b/common/gen-cpp/naming_data_constants.h
@@ -0,0 +1,24 @@
+/**
+ * Autogenerated by Thrift Compiler (0.8.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ * @generated
+ */
+#ifndef naming_data_CONSTANTS_H
+#define naming_data_CONSTANTS_H
+
+#include "naming_data_types.h"
+
+namespace meituan_mns {
+
+class naming_dataConstants {
+ public:
+ naming_dataConstants();
+
+};
+
+extern const naming_dataConstants g_naming_data_constants;
+
+} // namespace
+
+#endif
diff --git a/common/gen-cpp/naming_data_types.cpp b/common/gen-cpp/naming_data_types.cpp
new file mode 100644
index 0000000..de69dea
--- /dev/null
+++ b/common/gen-cpp/naming_data_types.cpp
@@ -0,0 +1,726 @@
+/**
+ * Autogenerated by Thrift Compiler (0.8.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ * @generated
+ */
+#include "naming_data_types.h"
+
+namespace meituan_mns {
+
+int _kRegistCmdValues[] = {
+ RegistCmd::REGIST,
+ RegistCmd::UNREGIST
+};
+const char* _kRegistCmdNames[] = {
+ "REGIST",
+ "UNREGIST"
+};
+const std::map _RegistCmd_VALUES_TO_NAMES(::apache::thrift::TEnumIterator(2, _kRegistCmdValues, _kRegistCmdNames), ::apache::thrift::TEnumIterator(-1, NULL, NULL));
+
+const char* getservice_req_param_t::ascii_fingerprint = "C93D890311F28844166CF6E571EB3AC2";
+const uint8_t getservice_req_param_t::binary_fingerprint[16] = {0xC9,0x3D,0x89,0x03,0x11,0xF2,0x88,0x44,0x16,0x6C,0xF6,0xE5,0x71,0xEB,0x3A,0xC2};
+
+uint32_t getservice_req_param_t::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 1:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->localAppkey);
+ this->__isset.localAppkey = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 2:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->remoteAppkey);
+ this->__isset.remoteAppkey = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 3:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->version);
+ this->__isset.version = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 4:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->protocol);
+ this->__isset.protocol = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t getservice_req_param_t::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("getservice_req_param_t");
+ xfer += oprot->writeFieldBegin("localAppkey", ::apache::thrift::protocol::T_STRING, 1);
+ xfer += oprot->writeString(this->localAppkey);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("remoteAppkey", ::apache::thrift::protocol::T_STRING, 2);
+ xfer += oprot->writeString(this->remoteAppkey);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("version", ::apache::thrift::protocol::T_STRING, 3);
+ xfer += oprot->writeString(this->version);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("protocol", ::apache::thrift::protocol::T_STRING, 4);
+ xfer += oprot->writeString(this->protocol);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+const char* getservice_res_param_t::ascii_fingerprint = "BEE4DB4CE7FE0806BC8C2B45BA6E4742";
+const uint8_t getservice_res_param_t::binary_fingerprint[16] = {0xBE,0xE4,0xDB,0x4C,0xE7,0xFE,0x08,0x06,0xBC,0x8C,0x2B,0x45,0xBA,0x6E,0x47,0x42};
+
+uint32_t getservice_res_param_t::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 1:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->localAppkey);
+ this->__isset.localAppkey = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 2:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->remoteAppkey);
+ this->__isset.remoteAppkey = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 3:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->version);
+ this->__isset.version = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 4:
+ if (ftype == ::apache::thrift::protocol::T_LIST) {
+ {
+ this->serviceList.clear();
+ uint32_t _size0;
+ ::apache::thrift::protocol::TType _etype3;
+ iprot->readListBegin(_etype3, _size0);
+ this->serviceList.resize(_size0);
+ uint32_t _i4;
+ for (_i4 = 0; _i4 < _size0; ++_i4)
+ {
+ xfer += this->serviceList[_i4].read(iprot);
+ }
+ iprot->readListEnd();
+ }
+ this->__isset.serviceList = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 5:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->protocol);
+ this->__isset.protocol = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t getservice_res_param_t::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("getservice_res_param_t");
+ xfer += oprot->writeFieldBegin("localAppkey", ::apache::thrift::protocol::T_STRING, 1);
+ xfer += oprot->writeString(this->localAppkey);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("remoteAppkey", ::apache::thrift::protocol::T_STRING, 2);
+ xfer += oprot->writeString(this->remoteAppkey);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("version", ::apache::thrift::protocol::T_STRING, 3);
+ xfer += oprot->writeString(this->version);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("serviceList", ::apache::thrift::protocol::T_LIST, 4);
+ {
+ xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast(this->serviceList.size()));
+ std::vector ::const_iterator _iter5;
+ for (_iter5 = this->serviceList.begin(); _iter5 != this->serviceList.end(); ++_iter5)
+ {
+ xfer += (*_iter5).write(oprot);
+ }
+ xfer += oprot->writeListEnd();
+ }
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("protocol", ::apache::thrift::protocol::T_STRING, 5);
+ xfer += oprot->writeString(this->protocol);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+const char* getservicename_req_param_t::ascii_fingerprint = "C93D890311F28844166CF6E571EB3AC2";
+const uint8_t getservicename_req_param_t::binary_fingerprint[16] = {0xC9,0x3D,0x89,0x03,0x11,0xF2,0x88,0x44,0x16,0x6C,0xF6,0xE5,0x71,0xEB,0x3A,0xC2};
+
+uint32_t getservicename_req_param_t::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 1:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->localAppkey);
+ this->__isset.localAppkey = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 2:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->servicename);
+ this->__isset.servicename = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 3:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->version);
+ this->__isset.version = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 4:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->protocol);
+ this->__isset.protocol = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t getservicename_req_param_t::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("getservicename_req_param_t");
+ xfer += oprot->writeFieldBegin("localAppkey", ::apache::thrift::protocol::T_STRING, 1);
+ xfer += oprot->writeString(this->localAppkey);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("servicename", ::apache::thrift::protocol::T_STRING, 2);
+ xfer += oprot->writeString(this->servicename);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("version", ::apache::thrift::protocol::T_STRING, 3);
+ xfer += oprot->writeString(this->version);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("protocol", ::apache::thrift::protocol::T_STRING, 4);
+ xfer += oprot->writeString(this->protocol);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+const char* getservicename_res_param_t::ascii_fingerprint = "029F9D059094419E5A20EF21917997A5";
+const uint8_t getservicename_res_param_t::binary_fingerprint[16] = {0x02,0x9F,0x9D,0x05,0x90,0x94,0x41,0x9E,0x5A,0x20,0xEF,0x21,0x91,0x79,0x97,0xA5};
+
+uint32_t getservicename_res_param_t::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 1:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->localAppkey);
+ this->__isset.localAppkey = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 2:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->servicename);
+ this->__isset.servicename = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 3:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->version);
+ this->__isset.version = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 4:
+ if (ftype == ::apache::thrift::protocol::T_SET) {
+ {
+ this->appkeys.clear();
+ uint32_t _size6;
+ ::apache::thrift::protocol::TType _etype9;
+ iprot->readSetBegin(_etype9, _size6);
+ uint32_t _i10;
+ for (_i10 = 0; _i10 < _size6; ++_i10)
+ {
+ std::string _elem11;
+ xfer += iprot->readString(_elem11);
+ this->appkeys.insert(_elem11);
+ }
+ iprot->readSetEnd();
+ }
+ this->__isset.appkeys = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 5:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->protocol);
+ this->__isset.protocol = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t getservicename_res_param_t::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("getservicename_res_param_t");
+ xfer += oprot->writeFieldBegin("localAppkey", ::apache::thrift::protocol::T_STRING, 1);
+ xfer += oprot->writeString(this->localAppkey);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("servicename", ::apache::thrift::protocol::T_STRING, 2);
+ xfer += oprot->writeString(this->servicename);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("version", ::apache::thrift::protocol::T_STRING, 3);
+ xfer += oprot->writeString(this->version);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("appkeys", ::apache::thrift::protocol::T_SET, 4);
+ {
+ xfer += oprot->writeSetBegin(::apache::thrift::protocol::T_STRING, static_cast(this->appkeys.size()));
+ std::set ::const_iterator _iter12;
+ for (_iter12 = this->appkeys.begin(); _iter12 != this->appkeys.end(); ++_iter12)
+ {
+ xfer += oprot->writeString((*_iter12));
+ }
+ xfer += oprot->writeSetEnd();
+ }
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("protocol", ::apache::thrift::protocol::T_STRING, 5);
+ xfer += oprot->writeString(this->protocol);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+const char* getroute_req_param_t::ascii_fingerprint = "C93D890311F28844166CF6E571EB3AC2";
+const uint8_t getroute_req_param_t::binary_fingerprint[16] = {0xC9,0x3D,0x89,0x03,0x11,0xF2,0x88,0x44,0x16,0x6C,0xF6,0xE5,0x71,0xEB,0x3A,0xC2};
+
+uint32_t getroute_req_param_t::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 1:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->localAppkey);
+ this->__isset.localAppkey = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 2:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->remoteAppkey);
+ this->__isset.remoteAppkey = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 3:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->version);
+ this->__isset.version = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 4:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->protocol);
+ this->__isset.protocol = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t getroute_req_param_t::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("getroute_req_param_t");
+ xfer += oprot->writeFieldBegin("localAppkey", ::apache::thrift::protocol::T_STRING, 1);
+ xfer += oprot->writeString(this->localAppkey);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("remoteAppkey", ::apache::thrift::protocol::T_STRING, 2);
+ xfer += oprot->writeString(this->remoteAppkey);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("version", ::apache::thrift::protocol::T_STRING, 3);
+ xfer += oprot->writeString(this->version);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("protocol", ::apache::thrift::protocol::T_STRING, 4);
+ xfer += oprot->writeString(this->protocol);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+const char* getroute_res_param_t::ascii_fingerprint = "61123EDDD00927E85F89381EEBDBC37F";
+const uint8_t getroute_res_param_t::binary_fingerprint[16] = {0x61,0x12,0x3E,0xDD,0xD0,0x09,0x27,0xE8,0x5F,0x89,0x38,0x1E,0xEB,0xDB,0xC3,0x7F};
+
+uint32_t getroute_res_param_t::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 1:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->localAppkey);
+ this->__isset.localAppkey = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 2:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->remoteAppkey);
+ this->__isset.remoteAppkey = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 3:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->version);
+ this->__isset.version = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 4:
+ if (ftype == ::apache::thrift::protocol::T_LIST) {
+ {
+ this->routeList.clear();
+ uint32_t _size13;
+ ::apache::thrift::protocol::TType _etype16;
+ iprot->readListBegin(_etype16, _size13);
+ this->routeList.resize(_size13);
+ uint32_t _i17;
+ for (_i17 = 0; _i17 < _size13; ++_i17)
+ {
+ xfer += this->routeList[_i17].read(iprot);
+ }
+ iprot->readListEnd();
+ }
+ this->__isset.routeList = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 5:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->protocol);
+ this->__isset.protocol = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t getroute_res_param_t::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("getroute_res_param_t");
+ xfer += oprot->writeFieldBegin("localAppkey", ::apache::thrift::protocol::T_STRING, 1);
+ xfer += oprot->writeString(this->localAppkey);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("remoteAppkey", ::apache::thrift::protocol::T_STRING, 2);
+ xfer += oprot->writeString(this->remoteAppkey);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("version", ::apache::thrift::protocol::T_STRING, 3);
+ xfer += oprot->writeString(this->version);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("routeList", ::apache::thrift::protocol::T_LIST, 4);
+ {
+ xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast(this->routeList.size()));
+ std::vector ::const_iterator _iter18;
+ for (_iter18 = this->routeList.begin(); _iter18 != this->routeList.end(); ++_iter18)
+ {
+ xfer += (*_iter18).write(oprot);
+ }
+ xfer += oprot->writeListEnd();
+ }
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("protocol", ::apache::thrift::protocol::T_STRING, 5);
+ xfer += oprot->writeString(this->protocol);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+const char* regist_req_param_t::ascii_fingerprint = "0E9168D7B65EE33C82EF267B678FCB69";
+const uint8_t regist_req_param_t::binary_fingerprint[16] = {0x0E,0x91,0x68,0xD7,0xB6,0x5E,0xE3,0x3C,0x82,0xEF,0x26,0x7B,0x67,0x8F,0xCB,0x69};
+
+uint32_t regist_req_param_t::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 1:
+ if (ftype == ::apache::thrift::protocol::T_I32) {
+ xfer += iprot->readI32(this->retry_times);
+ this->__isset.retry_times = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 2:
+ if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+ xfer += this->sgservice.read(iprot);
+ this->__isset.sgservice = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 3:
+ if (ftype == ::apache::thrift::protocol::T_I32) {
+ xfer += iprot->readI32(this->uptCmd);
+ this->__isset.uptCmd = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 4:
+ if (ftype == ::apache::thrift::protocol::T_I32) {
+ int32_t ecast19;
+ xfer += iprot->readI32(ecast19);
+ this->regCmd = (RegistCmd::type)ecast19;
+ this->__isset.regCmd = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t regist_req_param_t::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("regist_req_param_t");
+ xfer += oprot->writeFieldBegin("retry_times", ::apache::thrift::protocol::T_I32, 1);
+ xfer += oprot->writeI32(this->retry_times);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("sgservice", ::apache::thrift::protocol::T_STRUCT, 2);
+ xfer += this->sgservice.write(oprot);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("uptCmd", ::apache::thrift::protocol::T_I32, 3);
+ xfer += oprot->writeI32(this->uptCmd);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("regCmd", ::apache::thrift::protocol::T_I32, 4);
+ xfer += oprot->writeI32((int32_t)this->regCmd);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+} // namespace
diff --git a/common/gen-cpp/naming_data_types.h b/common/gen-cpp/naming_data_types.h
new file mode 100644
index 0000000..9272deb
--- /dev/null
+++ b/common/gen-cpp/naming_data_types.h
@@ -0,0 +1,514 @@
+/**
+ * Autogenerated by Thrift Compiler (0.8.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ * @generated
+ */
+#ifndef naming_data_TYPES_H
+#define naming_data_TYPES_H
+
+#include
+#include
+#include
+#include
+
+#include "naming_common_types.h"
+
+
+namespace meituan_mns {
+
+struct RegistCmd {
+ enum type {
+ REGIST = 0,
+ UNREGIST = 1
+ };
+};
+
+extern const std::map _RegistCmd_VALUES_TO_NAMES;
+
+typedef class ::meituan_mns::SGService SGService;
+
+typedef class ::meituan_mns::CRouteData CRouteData;
+
+typedef struct _getservice_req_param_t__isset {
+ _getservice_req_param_t__isset() : localAppkey(false), remoteAppkey(false), version(false), protocol(false) {}
+ bool localAppkey;
+ bool remoteAppkey;
+ bool version;
+ bool protocol;
+} _getservice_req_param_t__isset;
+
+class getservice_req_param_t {
+ public:
+
+ static const char* ascii_fingerprint; // = "C93D890311F28844166CF6E571EB3AC2";
+ static const uint8_t binary_fingerprint[16]; // = {0xC9,0x3D,0x89,0x03,0x11,0xF2,0x88,0x44,0x16,0x6C,0xF6,0xE5,0x71,0xEB,0x3A,0xC2};
+
+ getservice_req_param_t() : localAppkey(""), remoteAppkey(""), version(""), protocol("") {
+ }
+
+ virtual ~getservice_req_param_t() throw() {}
+
+ std::string localAppkey;
+ std::string remoteAppkey;
+ std::string version;
+ std::string protocol;
+
+ _getservice_req_param_t__isset __isset;
+
+ void __set_localAppkey(const std::string& val) {
+ localAppkey = val;
+ }
+
+ void __set_remoteAppkey(const std::string& val) {
+ remoteAppkey = val;
+ }
+
+ void __set_version(const std::string& val) {
+ version = val;
+ }
+
+ void __set_protocol(const std::string& val) {
+ protocol = val;
+ }
+
+ bool operator == (const getservice_req_param_t & rhs) const
+ {
+ if (!(localAppkey == rhs.localAppkey))
+ return false;
+ if (!(remoteAppkey == rhs.remoteAppkey))
+ return false;
+ if (!(version == rhs.version))
+ return false;
+ if (!(protocol == rhs.protocol))
+ return false;
+ return true;
+ }
+ bool operator != (const getservice_req_param_t &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const getservice_req_param_t & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _getservice_res_param_t__isset {
+ _getservice_res_param_t__isset() : localAppkey(false), remoteAppkey(false), version(false), serviceList(false), protocol(false) {}
+ bool localAppkey;
+ bool remoteAppkey;
+ bool version;
+ bool serviceList;
+ bool protocol;
+} _getservice_res_param_t__isset;
+
+class getservice_res_param_t {
+ public:
+
+ static const char* ascii_fingerprint; // = "BEE4DB4CE7FE0806BC8C2B45BA6E4742";
+ static const uint8_t binary_fingerprint[16]; // = {0xBE,0xE4,0xDB,0x4C,0xE7,0xFE,0x08,0x06,0xBC,0x8C,0x2B,0x45,0xBA,0x6E,0x47,0x42};
+
+ getservice_res_param_t() : localAppkey(""), remoteAppkey(""), version(""), protocol("") {
+ }
+
+ virtual ~getservice_res_param_t() throw() {}
+
+ std::string localAppkey;
+ std::string remoteAppkey;
+ std::string version;
+ std::vector serviceList;
+ std::string protocol;
+
+ _getservice_res_param_t__isset __isset;
+
+ void __set_localAppkey(const std::string& val) {
+ localAppkey = val;
+ }
+
+ void __set_remoteAppkey(const std::string& val) {
+ remoteAppkey = val;
+ }
+
+ void __set_version(const std::string& val) {
+ version = val;
+ }
+
+ void __set_serviceList(const std::vector & val) {
+ serviceList = val;
+ }
+
+ void __set_protocol(const std::string& val) {
+ protocol = val;
+ }
+
+ bool operator == (const getservice_res_param_t & rhs) const
+ {
+ if (!(localAppkey == rhs.localAppkey))
+ return false;
+ if (!(remoteAppkey == rhs.remoteAppkey))
+ return false;
+ if (!(version == rhs.version))
+ return false;
+ if (!(serviceList == rhs.serviceList))
+ return false;
+ if (!(protocol == rhs.protocol))
+ return false;
+ return true;
+ }
+ bool operator != (const getservice_res_param_t &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const getservice_res_param_t & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _getservicename_req_param_t__isset {
+ _getservicename_req_param_t__isset() : localAppkey(false), servicename(false), version(false), protocol(false) {}
+ bool localAppkey;
+ bool servicename;
+ bool version;
+ bool protocol;
+} _getservicename_req_param_t__isset;
+
+class getservicename_req_param_t {
+ public:
+
+ static const char* ascii_fingerprint; // = "C93D890311F28844166CF6E571EB3AC2";
+ static const uint8_t binary_fingerprint[16]; // = {0xC9,0x3D,0x89,0x03,0x11,0xF2,0x88,0x44,0x16,0x6C,0xF6,0xE5,0x71,0xEB,0x3A,0xC2};
+
+ getservicename_req_param_t() : localAppkey(""), servicename(""), version(""), protocol("") {
+ }
+
+ virtual ~getservicename_req_param_t() throw() {}
+
+ std::string localAppkey;
+ std::string servicename;
+ std::string version;
+ std::string protocol;
+
+ _getservicename_req_param_t__isset __isset;
+
+ void __set_localAppkey(const std::string& val) {
+ localAppkey = val;
+ }
+
+ void __set_servicename(const std::string& val) {
+ servicename = val;
+ }
+
+ void __set_version(const std::string& val) {
+ version = val;
+ }
+
+ void __set_protocol(const std::string& val) {
+ protocol = val;
+ }
+
+ bool operator == (const getservicename_req_param_t & rhs) const
+ {
+ if (!(localAppkey == rhs.localAppkey))
+ return false;
+ if (!(servicename == rhs.servicename))
+ return false;
+ if (!(version == rhs.version))
+ return false;
+ if (!(protocol == rhs.protocol))
+ return false;
+ return true;
+ }
+ bool operator != (const getservicename_req_param_t &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const getservicename_req_param_t & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _getservicename_res_param_t__isset {
+ _getservicename_res_param_t__isset() : localAppkey(false), servicename(false), version(false), appkeys(false), protocol(false) {}
+ bool localAppkey;
+ bool servicename;
+ bool version;
+ bool appkeys;
+ bool protocol;
+} _getservicename_res_param_t__isset;
+
+class getservicename_res_param_t {
+ public:
+
+ static const char* ascii_fingerprint; // = "029F9D059094419E5A20EF21917997A5";
+ static const uint8_t binary_fingerprint[16]; // = {0x02,0x9F,0x9D,0x05,0x90,0x94,0x41,0x9E,0x5A,0x20,0xEF,0x21,0x91,0x79,0x97,0xA5};
+
+ getservicename_res_param_t() : localAppkey(""), servicename(""), version(""), protocol("") {
+ }
+
+ virtual ~getservicename_res_param_t() throw() {}
+
+ std::string localAppkey;
+ std::string servicename;
+ std::string version;
+ std::set appkeys;
+ std::string protocol;
+
+ _getservicename_res_param_t__isset __isset;
+
+ void __set_localAppkey(const std::string& val) {
+ localAppkey = val;
+ }
+
+ void __set_servicename(const std::string& val) {
+ servicename = val;
+ }
+
+ void __set_version(const std::string& val) {
+ version = val;
+ }
+
+ void __set_appkeys(const std::set & val) {
+ appkeys = val;
+ }
+
+ void __set_protocol(const std::string& val) {
+ protocol = val;
+ }
+
+ bool operator == (const getservicename_res_param_t & rhs) const
+ {
+ if (!(localAppkey == rhs.localAppkey))
+ return false;
+ if (!(servicename == rhs.servicename))
+ return false;
+ if (!(version == rhs.version))
+ return false;
+ if (!(appkeys == rhs.appkeys))
+ return false;
+ if (!(protocol == rhs.protocol))
+ return false;
+ return true;
+ }
+ bool operator != (const getservicename_res_param_t &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const getservicename_res_param_t & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _getroute_req_param_t__isset {
+ _getroute_req_param_t__isset() : localAppkey(false), remoteAppkey(false), version(false), protocol(false) {}
+ bool localAppkey;
+ bool remoteAppkey;
+ bool version;
+ bool protocol;
+} _getroute_req_param_t__isset;
+
+class getroute_req_param_t {
+ public:
+
+ static const char* ascii_fingerprint; // = "C93D890311F28844166CF6E571EB3AC2";
+ static const uint8_t binary_fingerprint[16]; // = {0xC9,0x3D,0x89,0x03,0x11,0xF2,0x88,0x44,0x16,0x6C,0xF6,0xE5,0x71,0xEB,0x3A,0xC2};
+
+ getroute_req_param_t() : localAppkey(""), remoteAppkey(""), version(""), protocol("") {
+ }
+
+ virtual ~getroute_req_param_t() throw() {}
+
+ std::string localAppkey;
+ std::string remoteAppkey;
+ std::string version;
+ std::string protocol;
+
+ _getroute_req_param_t__isset __isset;
+
+ void __set_localAppkey(const std::string& val) {
+ localAppkey = val;
+ }
+
+ void __set_remoteAppkey(const std::string& val) {
+ remoteAppkey = val;
+ }
+
+ void __set_version(const std::string& val) {
+ version = val;
+ }
+
+ void __set_protocol(const std::string& val) {
+ protocol = val;
+ }
+
+ bool operator == (const getroute_req_param_t & rhs) const
+ {
+ if (!(localAppkey == rhs.localAppkey))
+ return false;
+ if (!(remoteAppkey == rhs.remoteAppkey))
+ return false;
+ if (!(version == rhs.version))
+ return false;
+ if (!(protocol == rhs.protocol))
+ return false;
+ return true;
+ }
+ bool operator != (const getroute_req_param_t &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const getroute_req_param_t & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _getroute_res_param_t__isset {
+ _getroute_res_param_t__isset() : localAppkey(false), remoteAppkey(false), version(false), routeList(false), protocol(false) {}
+ bool localAppkey;
+ bool remoteAppkey;
+ bool version;
+ bool routeList;
+ bool protocol;
+} _getroute_res_param_t__isset;
+
+class getroute_res_param_t {
+ public:
+
+ static const char* ascii_fingerprint; // = "61123EDDD00927E85F89381EEBDBC37F";
+ static const uint8_t binary_fingerprint[16]; // = {0x61,0x12,0x3E,0xDD,0xD0,0x09,0x27,0xE8,0x5F,0x89,0x38,0x1E,0xEB,0xDB,0xC3,0x7F};
+
+ getroute_res_param_t() : localAppkey(""), remoteAppkey(""), version(""), protocol("") {
+ }
+
+ virtual ~getroute_res_param_t() throw() {}
+
+ std::string localAppkey;
+ std::string remoteAppkey;
+ std::string version;
+ std::vector routeList;
+ std::string protocol;
+
+ _getroute_res_param_t__isset __isset;
+
+ void __set_localAppkey(const std::string& val) {
+ localAppkey = val;
+ }
+
+ void __set_remoteAppkey(const std::string& val) {
+ remoteAppkey = val;
+ }
+
+ void __set_version(const std::string& val) {
+ version = val;
+ }
+
+ void __set_routeList(const std::vector & val) {
+ routeList = val;
+ }
+
+ void __set_protocol(const std::string& val) {
+ protocol = val;
+ }
+
+ bool operator == (const getroute_res_param_t & rhs) const
+ {
+ if (!(localAppkey == rhs.localAppkey))
+ return false;
+ if (!(remoteAppkey == rhs.remoteAppkey))
+ return false;
+ if (!(version == rhs.version))
+ return false;
+ if (!(routeList == rhs.routeList))
+ return false;
+ if (!(protocol == rhs.protocol))
+ return false;
+ return true;
+ }
+ bool operator != (const getroute_res_param_t &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const getroute_res_param_t & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _regist_req_param_t__isset {
+ _regist_req_param_t__isset() : retry_times(false), sgservice(false), uptCmd(false), regCmd(false) {}
+ bool retry_times;
+ bool sgservice;
+ bool uptCmd;
+ bool regCmd;
+} _regist_req_param_t__isset;
+
+class regist_req_param_t {
+ public:
+
+ static const char* ascii_fingerprint; // = "0E9168D7B65EE33C82EF267B678FCB69";
+ static const uint8_t binary_fingerprint[16]; // = {0x0E,0x91,0x68,0xD7,0xB6,0x5E,0xE3,0x3C,0x82,0xEF,0x26,0x7B,0x67,0x8F,0xCB,0x69};
+
+ regist_req_param_t() : retry_times(0), uptCmd(0), regCmd((RegistCmd::type)0) {
+ }
+
+ virtual ~regist_req_param_t() throw() {}
+
+ int32_t retry_times;
+ SGService sgservice;
+ int32_t uptCmd;
+ RegistCmd::type regCmd;
+
+ _regist_req_param_t__isset __isset;
+
+ void __set_retry_times(const int32_t val) {
+ retry_times = val;
+ }
+
+ void __set_sgservice(const SGService& val) {
+ sgservice = val;
+ }
+
+ void __set_uptCmd(const int32_t val) {
+ uptCmd = val;
+ }
+
+ void __set_regCmd(const RegistCmd::type val) {
+ regCmd = val;
+ }
+
+ bool operator == (const regist_req_param_t & rhs) const
+ {
+ if (!(retry_times == rhs.retry_times))
+ return false;
+ if (!(sgservice == rhs.sgservice))
+ return false;
+ if (!(uptCmd == rhs.uptCmd))
+ return false;
+ if (!(regCmd == rhs.regCmd))
+ return false;
+ return true;
+ }
+ bool operator != (const regist_req_param_t &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const regist_req_param_t & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+} // namespace
+
+#endif
diff --git a/common/gen-cpp/naming_service_constants.cpp b/common/gen-cpp/naming_service_constants.cpp
new file mode 100644
index 0000000..77a730a
--- /dev/null
+++ b/common/gen-cpp/naming_service_constants.cpp
@@ -0,0 +1,17 @@
+/**
+ * Autogenerated by Thrift Compiler (0.8.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ * @generated
+ */
+#include "naming_service_constants.h"
+
+namespace meituan_mns {
+
+const naming_serviceConstants g_naming_service_constants;
+
+naming_serviceConstants::naming_serviceConstants() {
+}
+
+} // namespace
+
diff --git a/common/gen-cpp/naming_service_constants.h b/common/gen-cpp/naming_service_constants.h
new file mode 100644
index 0000000..54a6a0c
--- /dev/null
+++ b/common/gen-cpp/naming_service_constants.h
@@ -0,0 +1,24 @@
+/**
+ * Autogenerated by Thrift Compiler (0.8.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ * @generated
+ */
+#ifndef naming_service_CONSTANTS_H
+#define naming_service_CONSTANTS_H
+
+#include "naming_service_types.h"
+
+namespace meituan_mns {
+
+class naming_serviceConstants {
+ public:
+ naming_serviceConstants();
+
+};
+
+extern const naming_serviceConstants g_naming_service_constants;
+
+} // namespace
+
+#endif
diff --git a/common/gen-cpp/naming_service_types.cpp b/common/gen-cpp/naming_service_types.cpp
new file mode 100644
index 0000000..5fd5241
--- /dev/null
+++ b/common/gen-cpp/naming_service_types.cpp
@@ -0,0 +1,11 @@
+/**
+ * Autogenerated by Thrift Compiler (0.8.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ * @generated
+ */
+#include "naming_service_types.h"
+
+namespace meituan_mns {
+
+} // namespace
diff --git a/common/gen-cpp/naming_service_types.h b/common/gen-cpp/naming_service_types.h
new file mode 100644
index 0000000..62b923e
--- /dev/null
+++ b/common/gen-cpp/naming_service_types.h
@@ -0,0 +1,28 @@
+/**
+ * Autogenerated by Thrift Compiler (0.8.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ * @generated
+ */
+#ifndef naming_service_TYPES_H
+#define naming_service_TYPES_H
+
+#include
+#include
+#include
+#include
+
+#include "naming_common_types.h"
+
+
+namespace meituan_mns {
+
+typedef class ::meituan_mns::SGService SGService;
+
+typedef class ::meituan_mns::ProtocolRequest ProtocolRequest;
+
+typedef class ::meituan_mns::ProtocolResponse ProtocolResponse;
+
+} // namespace
+
+#endif
diff --git a/common/gen-cpp/unified_protocol_constants.cpp b/common/gen-cpp/unified_protocol_constants.cpp
new file mode 100644
index 0000000..bc989c3
--- /dev/null
+++ b/common/gen-cpp/unified_protocol_constants.cpp
@@ -0,0 +1,17 @@
+/**
+ * Autogenerated by Thrift Compiler (0.8.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ * @generated
+ */
+#include "unified_protocol_constants.h"
+
+namespace meituan_mns {
+
+const unified_protocolConstants g_unified_protocol_constants;
+
+unified_protocolConstants::unified_protocolConstants() {
+}
+
+} // namespace
+
diff --git a/common/gen-cpp/unified_protocol_constants.h b/common/gen-cpp/unified_protocol_constants.h
new file mode 100644
index 0000000..760de8a
--- /dev/null
+++ b/common/gen-cpp/unified_protocol_constants.h
@@ -0,0 +1,24 @@
+/**
+ * Autogenerated by Thrift Compiler (0.8.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ * @generated
+ */
+#ifndef unified_protocol_CONSTANTS_H
+#define unified_protocol_CONSTANTS_H
+
+#include "unified_protocol_types.h"
+
+namespace meituan_mns {
+
+class unified_protocolConstants {
+ public:
+ unified_protocolConstants();
+
+};
+
+extern const unified_protocolConstants g_unified_protocol_constants;
+
+} // namespace
+
+#endif
diff --git a/common/gen-cpp/unified_protocol_types.cpp b/common/gen-cpp/unified_protocol_types.cpp
new file mode 100644
index 0000000..9e5bb3e
--- /dev/null
+++ b/common/gen-cpp/unified_protocol_types.cpp
@@ -0,0 +1,825 @@
+/**
+ * Autogenerated by Thrift Compiler (0.8.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ * @generated
+ */
+#include "unified_protocol_types.h"
+
+namespace meituan_mns {
+
+int _kMessageTypeValues[] = {
+ MessageType::Normal,
+ MessageType::NormalHeartbeat,
+ MessageType::ScannerHeartbeat
+};
+const char* _kMessageTypeNames[] = {
+ "Normal",
+ "NormalHeartbeat",
+ "ScannerHeartbeat"
+};
+const std::map _MessageType_VALUES_TO_NAMES(::apache::thrift::TEnumIterator(3, _kMessageTypeValues, _kMessageTypeNames), ::apache::thrift::TEnumIterator(-1, NULL, NULL));
+
+int _kCompressTypeValues[] = {
+ CompressType::None,
+ CompressType::Snappy,
+ CompressType::Gzip
+};
+const char* _kCompressTypeNames[] = {
+ "None",
+ "Snappy",
+ "Gzip"
+};
+const std::map _CompressType_VALUES_TO_NAMES(::apache::thrift::TEnumIterator(3, _kCompressTypeValues, _kCompressTypeNames), ::apache::thrift::TEnumIterator(-1, NULL, NULL));
+
+int _kCallTypeValues[] = {
+ CallType::Reply,
+ CallType::NoReply
+};
+const char* _kCallTypeNames[] = {
+ "Reply",
+ "NoReply"
+};
+const std::map _CallType_VALUES_TO_NAMES(::apache::thrift::TEnumIterator(2, _kCallTypeValues, _kCallTypeNames), ::apache::thrift::TEnumIterator(-1, NULL, NULL));
+
+int _kStatusCodesValues[] = {
+ StatusCodes::Success,
+ StatusCodes::ApplicationException,
+ StatusCodes::RuntimeException,
+ StatusCodes::RpcException,
+ StatusCodes::TransportException,
+ StatusCodes::ProtocolException,
+ StatusCodes::DegradeException,
+ StatusCodes::SecurityException,
+ StatusCodes::ServiceException,
+ StatusCodes::RemoteException
+};
+const char* _kStatusCodesNames[] = {
+ "Success",
+ "ApplicationException",
+ "RuntimeException",
+ "RpcException",
+ "TransportException",
+ "ProtocolException",
+ "DegradeException",
+ "SecurityException",
+ "ServiceException",
+ "RemoteException"
+};
+const std::map _StatusCodes_VALUES_TO_NAMES(::apache::thrift::TEnumIterator(10, _kStatusCodesValues, _kStatusCodesNames), ::apache::thrift::TEnumIterator(-1, NULL, NULL));
+
+const char* RequestInfo::ascii_fingerprint = "59AD75927B39FBAC91B35C663FDB29CD";
+const uint8_t RequestInfo::binary_fingerprint[16] = {0x59,0xAD,0x75,0x92,0x7B,0x39,0xFB,0xAC,0x91,0xB3,0x5C,0x66,0x3F,0xDB,0x29,0xCD};
+
+uint32_t RequestInfo::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+ bool isset_serviceName = false;
+ bool isset_sequenceId = false;
+ bool isset_callType = false;
+ bool isset_timeout = false;
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 1:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->serviceName);
+ isset_serviceName = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 2:
+ if (ftype == ::apache::thrift::protocol::T_I64) {
+ xfer += iprot->readI64(this->sequenceId);
+ isset_sequenceId = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 3:
+ if (ftype == ::apache::thrift::protocol::T_BYTE) {
+ xfer += iprot->readByte(this->callType);
+ isset_callType = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 4:
+ if (ftype == ::apache::thrift::protocol::T_I32) {
+ xfer += iprot->readI32(this->timeout);
+ isset_timeout = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ if (!isset_serviceName)
+ throw TProtocolException(TProtocolException::INVALID_DATA);
+ if (!isset_sequenceId)
+ throw TProtocolException(TProtocolException::INVALID_DATA);
+ if (!isset_callType)
+ throw TProtocolException(TProtocolException::INVALID_DATA);
+ if (!isset_timeout)
+ throw TProtocolException(TProtocolException::INVALID_DATA);
+ return xfer;
+}
+
+uint32_t RequestInfo::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("RequestInfo");
+ xfer += oprot->writeFieldBegin("serviceName", ::apache::thrift::protocol::T_STRING, 1);
+ xfer += oprot->writeString(this->serviceName);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("sequenceId", ::apache::thrift::protocol::T_I64, 2);
+ xfer += oprot->writeI64(this->sequenceId);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("callType", ::apache::thrift::protocol::T_BYTE, 3);
+ xfer += oprot->writeByte(this->callType);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("timeout", ::apache::thrift::protocol::T_I32, 4);
+ xfer += oprot->writeI32(this->timeout);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+const char* ResponseInfo::ascii_fingerprint = "C6D3CA4A6A1EB8E865A6A00B60176AA8";
+const uint8_t ResponseInfo::binary_fingerprint[16] = {0xC6,0xD3,0xCA,0x4A,0x6A,0x1E,0xB8,0xE8,0x65,0xA6,0xA0,0x0B,0x60,0x17,0x6A,0xA8};
+
+uint32_t ResponseInfo::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+ bool isset_sequenceId = false;
+ bool isset_status = false;
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 1:
+ if (ftype == ::apache::thrift::protocol::T_I64) {
+ xfer += iprot->readI64(this->sequenceId);
+ isset_sequenceId = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 2:
+ if (ftype == ::apache::thrift::protocol::T_BYTE) {
+ xfer += iprot->readByte(this->status);
+ isset_status = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 3:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->message);
+ this->__isset.message = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ if (!isset_sequenceId)
+ throw TProtocolException(TProtocolException::INVALID_DATA);
+ if (!isset_status)
+ throw TProtocolException(TProtocolException::INVALID_DATA);
+ return xfer;
+}
+
+uint32_t ResponseInfo::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("ResponseInfo");
+ xfer += oprot->writeFieldBegin("sequenceId", ::apache::thrift::protocol::T_I64, 1);
+ xfer += oprot->writeI64(this->sequenceId);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldBegin("status", ::apache::thrift::protocol::T_BYTE, 2);
+ xfer += oprot->writeByte(this->status);
+ xfer += oprot->writeFieldEnd();
+ if (this->__isset.message) {
+ xfer += oprot->writeFieldBegin("message", ::apache::thrift::protocol::T_STRING, 3);
+ xfer += oprot->writeString(this->message);
+ xfer += oprot->writeFieldEnd();
+ }
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+const char* TraceInfo::ascii_fingerprint = "ABB2B5AA298E9052ED1A5DE871EF9527";
+const uint8_t TraceInfo::binary_fingerprint[16] = {0xAB,0xB2,0xB5,0xAA,0x29,0x8E,0x90,0x52,0xED,0x1A,0x5D,0xE8,0x71,0xEF,0x95,0x27};
+
+uint32_t TraceInfo::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+ bool isset_clientAppkey = false;
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 1:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->clientAppkey);
+ isset_clientAppkey = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 2:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->traceId);
+ this->__isset.traceId = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 3:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->spanId);
+ this->__isset.spanId = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 4:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->rootMessageId);
+ this->__isset.rootMessageId = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 5:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->currentMessageId);
+ this->__isset.currentMessageId = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 6:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->serverMessageId);
+ this->__isset.serverMessageId = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 7:
+ if (ftype == ::apache::thrift::protocol::T_BOOL) {
+ xfer += iprot->readBool(this->debug);
+ this->__isset.debug = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 8:
+ if (ftype == ::apache::thrift::protocol::T_BOOL) {
+ xfer += iprot->readBool(this->sample);
+ this->__isset.sample = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 9:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->clientIp);
+ this->__isset.clientIp = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ if (!isset_clientAppkey)
+ throw TProtocolException(TProtocolException::INVALID_DATA);
+ return xfer;
+}
+
+uint32_t TraceInfo::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("TraceInfo");
+ xfer += oprot->writeFieldBegin("clientAppkey", ::apache::thrift::protocol::T_STRING, 1);
+ xfer += oprot->writeString(this->clientAppkey);
+ xfer += oprot->writeFieldEnd();
+ if (this->__isset.traceId) {
+ xfer += oprot->writeFieldBegin("traceId", ::apache::thrift::protocol::T_STRING, 2);
+ xfer += oprot->writeString(this->traceId);
+ xfer += oprot->writeFieldEnd();
+ }
+ if (this->__isset.spanId) {
+ xfer += oprot->writeFieldBegin("spanId", ::apache::thrift::protocol::T_STRING, 3);
+ xfer += oprot->writeString(this->spanId);
+ xfer += oprot->writeFieldEnd();
+ }
+ if (this->__isset.rootMessageId) {
+ xfer += oprot->writeFieldBegin("rootMessageId", ::apache::thrift::protocol::T_STRING, 4);
+ xfer += oprot->writeString(this->rootMessageId);
+ xfer += oprot->writeFieldEnd();
+ }
+ if (this->__isset.currentMessageId) {
+ xfer += oprot->writeFieldBegin("currentMessageId", ::apache::thrift::protocol::T_STRING, 5);
+ xfer += oprot->writeString(this->currentMessageId);
+ xfer += oprot->writeFieldEnd();
+ }
+ if (this->__isset.serverMessageId) {
+ xfer += oprot->writeFieldBegin("serverMessageId", ::apache::thrift::protocol::T_STRING, 6);
+ xfer += oprot->writeString(this->serverMessageId);
+ xfer += oprot->writeFieldEnd();
+ }
+ if (this->__isset.debug) {
+ xfer += oprot->writeFieldBegin("debug", ::apache::thrift::protocol::T_BOOL, 7);
+ xfer += oprot->writeBool(this->debug);
+ xfer += oprot->writeFieldEnd();
+ }
+ if (this->__isset.sample) {
+ xfer += oprot->writeFieldBegin("sample", ::apache::thrift::protocol::T_BOOL, 8);
+ xfer += oprot->writeBool(this->sample);
+ xfer += oprot->writeFieldEnd();
+ }
+ if (this->__isset.clientIp) {
+ xfer += oprot->writeFieldBegin("clientIp", ::apache::thrift::protocol::T_STRING, 9);
+ xfer += oprot->writeString(this->clientIp);
+ xfer += oprot->writeFieldEnd();
+ }
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+const char* LoadInfo::ascii_fingerprint = "F424555CA1CEF935A4729C49DC664047";
+const uint8_t LoadInfo::binary_fingerprint[16] = {0xF4,0x24,0x55,0x5C,0xA1,0xCE,0xF9,0x35,0xA4,0x72,0x9C,0x49,0xDC,0x66,0x40,0x47};
+
+uint32_t LoadInfo::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 1:
+ if (ftype == ::apache::thrift::protocol::T_DOUBLE) {
+ xfer += iprot->readDouble(this->averageLoad);
+ this->__isset.averageLoad = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 2:
+ if (ftype == ::apache::thrift::protocol::T_I32) {
+ xfer += iprot->readI32(this->oldGC);
+ this->__isset.oldGC = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 3:
+ if (ftype == ::apache::thrift::protocol::T_I32) {
+ xfer += iprot->readI32(this->threadNum);
+ this->__isset.threadNum = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 4:
+ if (ftype == ::apache::thrift::protocol::T_I32) {
+ xfer += iprot->readI32(this->queueSize);
+ this->__isset.queueSize = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 5:
+ if (ftype == ::apache::thrift::protocol::T_MAP) {
+ {
+ this->methodQpsMap.clear();
+ uint32_t _size0;
+ ::apache::thrift::protocol::TType _ktype1;
+ ::apache::thrift::protocol::TType _vtype2;
+ iprot->readMapBegin(_ktype1, _vtype2, _size0);
+ uint32_t _i4;
+ for (_i4 = 0; _i4 < _size0; ++_i4)
+ {
+ std::string _key5;
+ xfer += iprot->readString(_key5);
+ double& _val6 = this->methodQpsMap[_key5];
+ xfer += iprot->readDouble(_val6);
+ }
+ iprot->readMapEnd();
+ }
+ this->__isset.methodQpsMap = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t LoadInfo::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("LoadInfo");
+ if (this->__isset.averageLoad) {
+ xfer += oprot->writeFieldBegin("averageLoad", ::apache::thrift::protocol::T_DOUBLE, 1);
+ xfer += oprot->writeDouble(this->averageLoad);
+ xfer += oprot->writeFieldEnd();
+ }
+ if (this->__isset.oldGC) {
+ xfer += oprot->writeFieldBegin("oldGC", ::apache::thrift::protocol::T_I32, 2);
+ xfer += oprot->writeI32(this->oldGC);
+ xfer += oprot->writeFieldEnd();
+ }
+ if (this->__isset.threadNum) {
+ xfer += oprot->writeFieldBegin("threadNum", ::apache::thrift::protocol::T_I32, 3);
+ xfer += oprot->writeI32(this->threadNum);
+ xfer += oprot->writeFieldEnd();
+ }
+ if (this->__isset.queueSize) {
+ xfer += oprot->writeFieldBegin("queueSize", ::apache::thrift::protocol::T_I32, 4);
+ xfer += oprot->writeI32(this->queueSize);
+ xfer += oprot->writeFieldEnd();
+ }
+ if (this->__isset.methodQpsMap) {
+ xfer += oprot->writeFieldBegin("methodQpsMap", ::apache::thrift::protocol::T_MAP, 5);
+ {
+ xfer += oprot->writeMapBegin(::apache::thrift::protocol::T_STRING, ::apache::thrift::protocol::T_DOUBLE, static_cast(this->methodQpsMap.size()));
+ std::map ::const_iterator _iter7;
+ for (_iter7 = this->methodQpsMap.begin(); _iter7 != this->methodQpsMap.end(); ++_iter7)
+ {
+ xfer += oprot->writeString(_iter7->first);
+ xfer += oprot->writeDouble(_iter7->second);
+ }
+ xfer += oprot->writeMapEnd();
+ }
+ xfer += oprot->writeFieldEnd();
+ }
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+const char* HeartbeatInfo::ascii_fingerprint = "EF43E82D9230E1225E24787F74163831";
+const uint8_t HeartbeatInfo::binary_fingerprint[16] = {0xEF,0x43,0xE8,0x2D,0x92,0x30,0xE1,0x22,0x5E,0x24,0x78,0x7F,0x74,0x16,0x38,0x31};
+
+uint32_t HeartbeatInfo::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+ bool isset_status = false;
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 1:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->appkey);
+ this->__isset.appkey = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 2:
+ if (ftype == ::apache::thrift::protocol::T_I64) {
+ xfer += iprot->readI64(this->sendTime);
+ this->__isset.sendTime = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 3:
+ if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+ xfer += this->loadInfo.read(iprot);
+ this->__isset.loadInfo = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 4:
+ if (ftype == ::apache::thrift::protocol::T_I32) {
+ xfer += iprot->readI32(this->status);
+ isset_status = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ if (!isset_status)
+ throw TProtocolException(TProtocolException::INVALID_DATA);
+ return xfer;
+}
+
+uint32_t HeartbeatInfo::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("HeartbeatInfo");
+ if (this->__isset.appkey) {
+ xfer += oprot->writeFieldBegin("appkey", ::apache::thrift::protocol::T_STRING, 1);
+ xfer += oprot->writeString(this->appkey);
+ xfer += oprot->writeFieldEnd();
+ }
+ if (this->__isset.sendTime) {
+ xfer += oprot->writeFieldBegin("sendTime", ::apache::thrift::protocol::T_I64, 2);
+ xfer += oprot->writeI64(this->sendTime);
+ xfer += oprot->writeFieldEnd();
+ }
+ if (this->__isset.loadInfo) {
+ xfer += oprot->writeFieldBegin("loadInfo", ::apache::thrift::protocol::T_STRUCT, 3);
+ xfer += this->loadInfo.write(oprot);
+ xfer += oprot->writeFieldEnd();
+ }
+ xfer += oprot->writeFieldBegin("status", ::apache::thrift::protocol::T_I32, 4);
+ xfer += oprot->writeI32(this->status);
+ xfer += oprot->writeFieldEnd();
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+const char* Header::ascii_fingerprint = "449EC0AD8F982561B4D899B14FB0084B";
+const uint8_t Header::binary_fingerprint[16] = {0x44,0x9E,0xC0,0xAD,0x8F,0x98,0x25,0x61,0xB4,0xD8,0x99,0xB1,0x4F,0xB0,0x08,0x4B};
+
+uint32_t Header::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 1:
+ if (ftype == ::apache::thrift::protocol::T_BYTE) {
+ xfer += iprot->readByte(this->messageType);
+ this->__isset.messageType = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 2:
+ if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+ xfer += this->requestInfo.read(iprot);
+ this->__isset.requestInfo = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 3:
+ if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+ xfer += this->responseInfo.read(iprot);
+ this->__isset.responseInfo = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 4:
+ if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+ xfer += this->traceInfo.read(iprot);
+ this->__isset.traceInfo = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 5:
+ if (ftype == ::apache::thrift::protocol::T_MAP) {
+ {
+ this->globalContext.clear();
+ uint32_t _size8;
+ ::apache::thrift::protocol::TType _ktype9;
+ ::apache::thrift::protocol::TType _vtype10;
+ iprot->readMapBegin(_ktype9, _vtype10, _size8);
+ uint32_t _i12;
+ for (_i12 = 0; _i12 < _size8; ++_i12)
+ {
+ std::string _key13;
+ xfer += iprot->readString(_key13);
+ std::string& _val14 = this->globalContext[_key13];
+ xfer += iprot->readString(_val14);
+ }
+ iprot->readMapEnd();
+ }
+ this->__isset.globalContext = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 6:
+ if (ftype == ::apache::thrift::protocol::T_MAP) {
+ {
+ this->localContext.clear();
+ uint32_t _size15;
+ ::apache::thrift::protocol::TType _ktype16;
+ ::apache::thrift::protocol::TType _vtype17;
+ iprot->readMapBegin(_ktype16, _vtype17, _size15);
+ uint32_t _i19;
+ for (_i19 = 0; _i19 < _size15; ++_i19)
+ {
+ std::string _key20;
+ xfer += iprot->readString(_key20);
+ std::string& _val21 = this->localContext[_key20];
+ xfer += iprot->readString(_val21);
+ }
+ iprot->readMapEnd();
+ }
+ this->__isset.localContext = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ case 7:
+ if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+ xfer += this->heartbeatInfo.read(iprot);
+ this->__isset.heartbeatInfo = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t Header::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ xfer += oprot->writeStructBegin("Header");
+ if (this->__isset.messageType) {
+ xfer += oprot->writeFieldBegin("messageType", ::apache::thrift::protocol::T_BYTE, 1);
+ xfer += oprot->writeByte(this->messageType);
+ xfer += oprot->writeFieldEnd();
+ }
+ if (this->__isset.requestInfo) {
+ xfer += oprot->writeFieldBegin("requestInfo", ::apache::thrift::protocol::T_STRUCT, 2);
+ xfer += this->requestInfo.write(oprot);
+ xfer += oprot->writeFieldEnd();
+ }
+ if (this->__isset.responseInfo) {
+ xfer += oprot->writeFieldBegin("responseInfo", ::apache::thrift::protocol::T_STRUCT, 3);
+ xfer += this->responseInfo.write(oprot);
+ xfer += oprot->writeFieldEnd();
+ }
+ if (this->__isset.traceInfo) {
+ xfer += oprot->writeFieldBegin("traceInfo", ::apache::thrift::protocol::T_STRUCT, 4);
+ xfer += this->traceInfo.write(oprot);
+ xfer += oprot->writeFieldEnd();
+ }
+ if (this->__isset.globalContext) {
+ xfer += oprot->writeFieldBegin("globalContext", ::apache::thrift::protocol::T_MAP, 5);
+ {
+ xfer += oprot->writeMapBegin(::apache::thrift::protocol::T_STRING, ::apache::thrift::protocol::T_STRING, static_cast(this->globalContext.size()));
+ std::map ::const_iterator _iter22;
+ for (_iter22 = this->globalContext.begin(); _iter22 != this->globalContext.end(); ++_iter22)
+ {
+ xfer += oprot->writeString(_iter22->first);
+ xfer += oprot->writeString(_iter22->second);
+ }
+ xfer += oprot->writeMapEnd();
+ }
+ xfer += oprot->writeFieldEnd();
+ }
+ if (this->__isset.localContext) {
+ xfer += oprot->writeFieldBegin("localContext", ::apache::thrift::protocol::T_MAP, 6);
+ {
+ xfer += oprot->writeMapBegin(::apache::thrift::protocol::T_STRING, ::apache::thrift::protocol::T_STRING, static_cast(this->localContext.size()));
+ std::map ::const_iterator _iter23;
+ for (_iter23 = this->localContext.begin(); _iter23 != this->localContext.end(); ++_iter23)
+ {
+ xfer += oprot->writeString(_iter23->first);
+ xfer += oprot->writeString(_iter23->second);
+ }
+ xfer += oprot->writeMapEnd();
+ }
+ xfer += oprot->writeFieldEnd();
+ }
+ if (this->__isset.heartbeatInfo) {
+ xfer += oprot->writeFieldBegin("heartbeatInfo", ::apache::thrift::protocol::T_STRUCT, 7);
+ xfer += this->heartbeatInfo.write(oprot);
+ xfer += oprot->writeFieldEnd();
+ }
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+} // namespace
diff --git a/common/gen-cpp/unified_protocol_types.h b/common/gen-cpp/unified_protocol_types.h
new file mode 100644
index 0000000..df6a0cf
--- /dev/null
+++ b/common/gen-cpp/unified_protocol_types.h
@@ -0,0 +1,582 @@
+/**
+ * Autogenerated by Thrift Compiler (0.8.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ * @generated
+ */
+#ifndef unified_protocol_TYPES_H
+#define unified_protocol_TYPES_H
+
+#include
+#include
+#include
+#include
+
+
+
+namespace meituan_mns {
+
+struct MessageType {
+ enum type {
+ Normal = 0,
+ NormalHeartbeat = 1,
+ ScannerHeartbeat = 2
+ };
+};
+
+extern const std::map _MessageType_VALUES_TO_NAMES;
+
+struct CompressType {
+ enum type {
+ None = 0,
+ Snappy = 1,
+ Gzip = 2
+ };
+};
+
+extern const std::map _CompressType_VALUES_TO_NAMES;
+
+struct CallType {
+ enum type {
+ Reply = 0,
+ NoReply = 1
+ };
+};
+
+extern const std::map _CallType_VALUES_TO_NAMES;
+
+struct StatusCodes {
+ enum type {
+ Success = 0,
+ ApplicationException = 1,
+ RuntimeException = 2,
+ RpcException = 3,
+ TransportException = 4,
+ ProtocolException = 5,
+ DegradeException = 6,
+ SecurityException = 7,
+ ServiceException = 8,
+ RemoteException = 9
+ };
+};
+
+extern const std::map _StatusCodes_VALUES_TO_NAMES;
+
+typedef std::map Context;
+
+
+class RequestInfo {
+ public:
+
+ static const char* ascii_fingerprint; // = "59AD75927B39FBAC91B35C663FDB29CD";
+ static const uint8_t binary_fingerprint[16]; // = {0x59,0xAD,0x75,0x92,0x7B,0x39,0xFB,0xAC,0x91,0xB3,0x5C,0x66,0x3F,0xDB,0x29,0xCD};
+
+ RequestInfo() : serviceName(""), sequenceId(0), callType(0), timeout(0) {
+ }
+
+ virtual ~RequestInfo() throw() {}
+
+ std::string serviceName;
+ int64_t sequenceId;
+ int8_t callType;
+ int32_t timeout;
+
+ void __set_serviceName(const std::string& val) {
+ serviceName = val;
+ }
+
+ void __set_sequenceId(const int64_t val) {
+ sequenceId = val;
+ }
+
+ void __set_callType(const int8_t val) {
+ callType = val;
+ }
+
+ void __set_timeout(const int32_t val) {
+ timeout = val;
+ }
+
+ bool operator == (const RequestInfo & rhs) const
+ {
+ if (!(serviceName == rhs.serviceName))
+ return false;
+ if (!(sequenceId == rhs.sequenceId))
+ return false;
+ if (!(callType == rhs.callType))
+ return false;
+ if (!(timeout == rhs.timeout))
+ return false;
+ return true;
+ }
+ bool operator != (const RequestInfo &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const RequestInfo & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _ResponseInfo__isset {
+ _ResponseInfo__isset() : message(false) {}
+ bool message;
+} _ResponseInfo__isset;
+
+class ResponseInfo {
+ public:
+
+ static const char* ascii_fingerprint; // = "C6D3CA4A6A1EB8E865A6A00B60176AA8";
+ static const uint8_t binary_fingerprint[16]; // = {0xC6,0xD3,0xCA,0x4A,0x6A,0x1E,0xB8,0xE8,0x65,0xA6,0xA0,0x0B,0x60,0x17,0x6A,0xA8};
+
+ ResponseInfo() : sequenceId(0), status(0), message("") {
+ }
+
+ virtual ~ResponseInfo() throw() {}
+
+ int64_t sequenceId;
+ int8_t status;
+ std::string message;
+
+ _ResponseInfo__isset __isset;
+
+ void __set_sequenceId(const int64_t val) {
+ sequenceId = val;
+ }
+
+ void __set_status(const int8_t val) {
+ status = val;
+ }
+
+ void __set_message(const std::string& val) {
+ message = val;
+ __isset.message = true;
+ }
+
+ bool operator == (const ResponseInfo & rhs) const
+ {
+ if (!(sequenceId == rhs.sequenceId))
+ return false;
+ if (!(status == rhs.status))
+ return false;
+ if (__isset.message != rhs.__isset.message)
+ return false;
+ else if (__isset.message && !(message == rhs.message))
+ return false;
+ return true;
+ }
+ bool operator != (const ResponseInfo &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const ResponseInfo & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _TraceInfo__isset {
+ _TraceInfo__isset() : traceId(false), spanId(false), rootMessageId(false), currentMessageId(false), serverMessageId(false), debug(false), sample(false), clientIp(false) {}
+ bool traceId;
+ bool spanId;
+ bool rootMessageId;
+ bool currentMessageId;
+ bool serverMessageId;
+ bool debug;
+ bool sample;
+ bool clientIp;
+} _TraceInfo__isset;
+
+class TraceInfo {
+ public:
+
+ static const char* ascii_fingerprint; // = "ABB2B5AA298E9052ED1A5DE871EF9527";
+ static const uint8_t binary_fingerprint[16]; // = {0xAB,0xB2,0xB5,0xAA,0x29,0x8E,0x90,0x52,0xED,0x1A,0x5D,0xE8,0x71,0xEF,0x95,0x27};
+
+ TraceInfo() : clientAppkey(""), traceId(""), spanId(""), rootMessageId(""), currentMessageId(""), serverMessageId(""), debug(0), sample(0), clientIp("") {
+ }
+
+ virtual ~TraceInfo() throw() {}
+
+ std::string clientAppkey;
+ std::string traceId;
+ std::string spanId;
+ std::string rootMessageId;
+ std::string currentMessageId;
+ std::string serverMessageId;
+ bool debug;
+ bool sample;
+ std::string clientIp;
+
+ _TraceInfo__isset __isset;
+
+ void __set_clientAppkey(const std::string& val) {
+ clientAppkey = val;
+ }
+
+ void __set_traceId(const std::string& val) {
+ traceId = val;
+ __isset.traceId = true;
+ }
+
+ void __set_spanId(const std::string& val) {
+ spanId = val;
+ __isset.spanId = true;
+ }
+
+ void __set_rootMessageId(const std::string& val) {
+ rootMessageId = val;
+ __isset.rootMessageId = true;
+ }
+
+ void __set_currentMessageId(const std::string& val) {
+ currentMessageId = val;
+ __isset.currentMessageId = true;
+ }
+
+ void __set_serverMessageId(const std::string& val) {
+ serverMessageId = val;
+ __isset.serverMessageId = true;
+ }
+
+ void __set_debug(const bool val) {
+ debug = val;
+ __isset.debug = true;
+ }
+
+ void __set_sample(const bool val) {
+ sample = val;
+ __isset.sample = true;
+ }
+
+ void __set_clientIp(const std::string& val) {
+ clientIp = val;
+ __isset.clientIp = true;
+ }
+
+ bool operator == (const TraceInfo & rhs) const
+ {
+ if (!(clientAppkey == rhs.clientAppkey))
+ return false;
+ if (__isset.traceId != rhs.__isset.traceId)
+ return false;
+ else if (__isset.traceId && !(traceId == rhs.traceId))
+ return false;
+ if (__isset.spanId != rhs.__isset.spanId)
+ return false;
+ else if (__isset.spanId && !(spanId == rhs.spanId))
+ return false;
+ if (__isset.rootMessageId != rhs.__isset.rootMessageId)
+ return false;
+ else if (__isset.rootMessageId && !(rootMessageId == rhs.rootMessageId))
+ return false;
+ if (__isset.currentMessageId != rhs.__isset.currentMessageId)
+ return false;
+ else if (__isset.currentMessageId && !(currentMessageId == rhs.currentMessageId))
+ return false;
+ if (__isset.serverMessageId != rhs.__isset.serverMessageId)
+ return false;
+ else if (__isset.serverMessageId && !(serverMessageId == rhs.serverMessageId))
+ return false;
+ if (__isset.debug != rhs.__isset.debug)
+ return false;
+ else if (__isset.debug && !(debug == rhs.debug))
+ return false;
+ if (__isset.sample != rhs.__isset.sample)
+ return false;
+ else if (__isset.sample && !(sample == rhs.sample))
+ return false;
+ if (__isset.clientIp != rhs.__isset.clientIp)
+ return false;
+ else if (__isset.clientIp && !(clientIp == rhs.clientIp))
+ return false;
+ return true;
+ }
+ bool operator != (const TraceInfo &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const TraceInfo & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _LoadInfo__isset {
+ _LoadInfo__isset() : averageLoad(false), oldGC(false), threadNum(false), queueSize(false), methodQpsMap(false) {}
+ bool averageLoad;
+ bool oldGC;
+ bool threadNum;
+ bool queueSize;
+ bool methodQpsMap;
+} _LoadInfo__isset;
+
+class LoadInfo {
+ public:
+
+ static const char* ascii_fingerprint; // = "F424555CA1CEF935A4729C49DC664047";
+ static const uint8_t binary_fingerprint[16]; // = {0xF4,0x24,0x55,0x5C,0xA1,0xCE,0xF9,0x35,0xA4,0x72,0x9C,0x49,0xDC,0x66,0x40,0x47};
+
+ LoadInfo() : averageLoad(0), oldGC(0), threadNum(0), queueSize(0) {
+ }
+
+ virtual ~LoadInfo() throw() {}
+
+ double averageLoad;
+ int32_t oldGC;
+ int32_t threadNum;
+ int32_t queueSize;
+ std::map methodQpsMap;
+
+ _LoadInfo__isset __isset;
+
+ void __set_averageLoad(const double val) {
+ averageLoad = val;
+ __isset.averageLoad = true;
+ }
+
+ void __set_oldGC(const int32_t val) {
+ oldGC = val;
+ __isset.oldGC = true;
+ }
+
+ void __set_threadNum(const int32_t val) {
+ threadNum = val;
+ __isset.threadNum = true;
+ }
+
+ void __set_queueSize(const int32_t val) {
+ queueSize = val;
+ __isset.queueSize = true;
+ }
+
+ void __set_methodQpsMap(const std::map & val) {
+ methodQpsMap = val;
+ __isset.methodQpsMap = true;
+ }
+
+ bool operator == (const LoadInfo & rhs) const
+ {
+ if (__isset.averageLoad != rhs.__isset.averageLoad)
+ return false;
+ else if (__isset.averageLoad && !(averageLoad == rhs.averageLoad))
+ return false;
+ if (__isset.oldGC != rhs.__isset.oldGC)
+ return false;
+ else if (__isset.oldGC && !(oldGC == rhs.oldGC))
+ return false;
+ if (__isset.threadNum != rhs.__isset.threadNum)
+ return false;
+ else if (__isset.threadNum && !(threadNum == rhs.threadNum))
+ return false;
+ if (__isset.queueSize != rhs.__isset.queueSize)
+ return false;
+ else if (__isset.queueSize && !(queueSize == rhs.queueSize))
+ return false;
+ if (__isset.methodQpsMap != rhs.__isset.methodQpsMap)
+ return false;
+ else if (__isset.methodQpsMap && !(methodQpsMap == rhs.methodQpsMap))
+ return false;
+ return true;
+ }
+ bool operator != (const LoadInfo &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const LoadInfo & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _HeartbeatInfo__isset {
+ _HeartbeatInfo__isset() : appkey(false), sendTime(false), loadInfo(false) {}
+ bool appkey;
+ bool sendTime;
+ bool loadInfo;
+} _HeartbeatInfo__isset;
+
+class HeartbeatInfo {
+ public:
+
+ static const char* ascii_fingerprint; // = "EF43E82D9230E1225E24787F74163831";
+ static const uint8_t binary_fingerprint[16]; // = {0xEF,0x43,0xE8,0x2D,0x92,0x30,0xE1,0x22,0x5E,0x24,0x78,0x7F,0x74,0x16,0x38,0x31};
+
+ HeartbeatInfo() : appkey(""), sendTime(0), status(0) {
+ }
+
+ virtual ~HeartbeatInfo() throw() {}
+
+ std::string appkey;
+ int64_t sendTime;
+ LoadInfo loadInfo;
+ int32_t status;
+
+ _HeartbeatInfo__isset __isset;
+
+ void __set_appkey(const std::string& val) {
+ appkey = val;
+ __isset.appkey = true;
+ }
+
+ void __set_sendTime(const int64_t val) {
+ sendTime = val;
+ __isset.sendTime = true;
+ }
+
+ void __set_loadInfo(const LoadInfo& val) {
+ loadInfo = val;
+ __isset.loadInfo = true;
+ }
+
+ void __set_status(const int32_t val) {
+ status = val;
+ }
+
+ bool operator == (const HeartbeatInfo & rhs) const
+ {
+ if (__isset.appkey != rhs.__isset.appkey)
+ return false;
+ else if (__isset.appkey && !(appkey == rhs.appkey))
+ return false;
+ if (__isset.sendTime != rhs.__isset.sendTime)
+ return false;
+ else if (__isset.sendTime && !(sendTime == rhs.sendTime))
+ return false;
+ if (__isset.loadInfo != rhs.__isset.loadInfo)
+ return false;
+ else if (__isset.loadInfo && !(loadInfo == rhs.loadInfo))
+ return false;
+ if (!(status == rhs.status))
+ return false;
+ return true;
+ }
+ bool operator != (const HeartbeatInfo &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const HeartbeatInfo & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+typedef struct _Header__isset {
+ _Header__isset() : messageType(false), requestInfo(false), responseInfo(false), traceInfo(false), globalContext(false), localContext(false), heartbeatInfo(false) {}
+ bool messageType;
+ bool requestInfo;
+ bool responseInfo;
+ bool traceInfo;
+ bool globalContext;
+ bool localContext;
+ bool heartbeatInfo;
+} _Header__isset;
+
+class Header {
+ public:
+
+ static const char* ascii_fingerprint; // = "449EC0AD8F982561B4D899B14FB0084B";
+ static const uint8_t binary_fingerprint[16]; // = {0x44,0x9E,0xC0,0xAD,0x8F,0x98,0x25,0x61,0xB4,0xD8,0x99,0xB1,0x4F,0xB0,0x08,0x4B};
+
+ Header() : messageType(0) {
+ }
+
+ virtual ~Header() throw() {}
+
+ int8_t messageType;
+ RequestInfo requestInfo;
+ ResponseInfo responseInfo;
+ TraceInfo traceInfo;
+ Context globalContext;
+ Context localContext;
+ HeartbeatInfo heartbeatInfo;
+
+ _Header__isset __isset;
+
+ void __set_messageType(const int8_t val) {
+ messageType = val;
+ __isset.messageType = true;
+ }
+
+ void __set_requestInfo(const RequestInfo& val) {
+ requestInfo = val;
+ __isset.requestInfo = true;
+ }
+
+ void __set_responseInfo(const ResponseInfo& val) {
+ responseInfo = val;
+ __isset.responseInfo = true;
+ }
+
+ void __set_traceInfo(const TraceInfo& val) {
+ traceInfo = val;
+ __isset.traceInfo = true;
+ }
+
+ void __set_globalContext(const Context& val) {
+ globalContext = val;
+ __isset.globalContext = true;
+ }
+
+ void __set_localContext(const Context& val) {
+ localContext = val;
+ __isset.localContext = true;
+ }
+
+ void __set_heartbeatInfo(const HeartbeatInfo& val) {
+ heartbeatInfo = val;
+ __isset.heartbeatInfo = true;
+ }
+
+ bool operator == (const Header & rhs) const
+ {
+ if (__isset.messageType != rhs.__isset.messageType)
+ return false;
+ else if (__isset.messageType && !(messageType == rhs.messageType))
+ return false;
+ if (__isset.requestInfo != rhs.__isset.requestInfo)
+ return false;
+ else if (__isset.requestInfo && !(requestInfo == rhs.requestInfo))
+ return false;
+ if (__isset.responseInfo != rhs.__isset.responseInfo)
+ return false;
+ else if (__isset.responseInfo && !(responseInfo == rhs.responseInfo))
+ return false;
+ if (__isset.traceInfo != rhs.__isset.traceInfo)
+ return false;
+ else if (__isset.traceInfo && !(traceInfo == rhs.traceInfo))
+ return false;
+ if (__isset.globalContext != rhs.__isset.globalContext)
+ return false;
+ else if (__isset.globalContext && !(globalContext == rhs.globalContext))
+ return false;
+ if (__isset.localContext != rhs.__isset.localContext)
+ return false;
+ else if (__isset.localContext && !(localContext == rhs.localContext))
+ return false;
+ if (__isset.heartbeatInfo != rhs.__isset.heartbeatInfo)
+ return false;
+ else if (__isset.heartbeatInfo && !(heartbeatInfo == rhs.heartbeatInfo))
+ return false;
+ return true;
+ }
+ bool operator != (const Header &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const Header & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+} // namespace
+
+#endif
diff --git a/common/idl-mns/idl-common/Compile.md b/common/idl-mns/idl-common/Compile.md
new file mode 100644
index 0000000..35f5ffa
--- /dev/null
+++ b/common/idl-mns/idl-common/Compile.md
@@ -0,0 +1,26 @@
+
+# idl-common 源码编译说明
+
+## 1.下载工程
+```
+ git clone https://github.com/Meituan-Dianping/octo-ns.git
+```
+
+## 2.构建Jar包
+环境要求:
+
+- Java version >= 1.8
+- Maven version >= 3.2
+
+切换到idl-common目录
+
+```
+cd common/idl-mns/idl-common
+```
+
+本地install,执行后在本地仓库~/.m2/repository/com/meituan/octo/idl-common/(假如你的仓库位置是~/.m2/repository)下可以找到idl-common的jar
+
+```
+# common/idl-mns/idl-common 目录下
+mvn clean install -Dmaven.test.skip=true
+```
diff --git a/common/idl-mns/idl-common/pom.xml b/common/idl-mns/idl-common/pom.xml
new file mode 100644
index 0000000..b391482
--- /dev/null
+++ b/common/idl-mns/idl-common/pom.xml
@@ -0,0 +1,55 @@
+
+
+ 4.0.0
+ com.meituan.octo
+ idl-common
+ 1.0.0
+ jar
+
+
+ org.apache.thrift
+ libthrift
+
+ 0.9.3
+
+
+
+
+
+ org.apache.thrift.tools
+ maven-thrift-plugin
+ 0.1.11
+
+
+ /usr/local/bin/thrift
+
+
+
+ thrift-sources
+ generate-sources
+
+ compile
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-source-plugin
+ 3.0.1
+
+
+ attach-sources
+ package
+
+ jar-no-fork
+ test-jar-no-fork
+
+
+
+
+
+
+
diff --git a/common/idl-mns/idl-common/src/main/thrift/idc.thrift b/common/idl-mns/idl-common/src/main/thrift/idc.thrift
new file mode 100644
index 0000000..841eb77
--- /dev/null
+++ b/common/idl-mns/idl-common/src/main/thrift/idc.thrift
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2018 Meituan Dianping. All rights reserved.
+ *
+ * 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.
+ */
+
+namespace java com.octo.idc.model
+
+struct Idc {
+ 1:string region;
+ 2:string idc;
+ 3:optional string center;
+}
diff --git a/common/idl-mns/idl-common/src/main/thrift/naming_common.thrift b/common/idl-mns/idl-common/src/main/thrift/naming_common.thrift
new file mode 100644
index 0000000..ef67a02
--- /dev/null
+++ b/common/idl-mns/idl-common/src/main/thrift/naming_common.thrift
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2018 Meituan Dianping. All rights reserved.
+ *
+ * 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.
+ */
+
+namespace java com.octo.naming.common.thrift.model
+namespace cpp meituan_mns
+enum UptCmd {
+ RESET = 0,
+ ADD = 1,
+ DELETE = 2,
+}
+/**
+ * Common status reporting mechanism across all services
+ */
+enum fb_status {
+ DEAD = 0,//宕机,故障
+ STARTING = 1,//启动中
+ ALIVE = 2,//正常
+ STOPPING = 3,//正在下线
+ STOPPED = 4,//禁用
+ WARNING = 5,//警告
+}
+enum HeartbeatSupportType {
+ NoSupport = 0,
+ P2POnly = 1,
+ ScannerOnly = 2,
+ BothSupport = 3,
+}
+struct ServiceDetail {
+ 1:bool unifiedProto; //默认为false,true代表支持统一协议
+}
+
+struct SGService
+{
+ 1:string appkey;
+ 2:string version;
+ 3:string ip;
+ 4:i32 port;
+ 5:i32 weight;
+ 6:i32 status; //正常状态,重启状态,下线状态,故障状态,具体值参考fb_status
+ 7:i32 role; //backup角色,当其他服务无法服务的时候,启用backup状态;0(主)1(备)
+ 8:i32 envir; //运行环境,prod(线上环境3),stag(线上测试环境2),test(测试环境1)
+ 9:i32 lastUpdateTime; //最后修改时间
+ 10:double fweight; //浮点型权重
+ 11:i32 serverType; //用于区分http(1)和thrift(0)
+ 12:string protocol; //支持扩展协议
+ 13:map serviceInfo; //serviceName 到 servcieDetail的映射
+ 14:byte heartbeatSupport; //0:不支持心跳, 1:仅支持端对端心跳 2:仅支持scanner心跳 3:两种心跳都支持
+ 15:i32 warmup; //节点预热时间,单位秒
+}
+/*
+ * 服务节点, 主要储存服务->appkey映射
+ */
+struct ServiceNode
+{
+ 1:string serviceName;
+ 2:set appkeys; //serviceName对应的appkey
+ 3:i32 lastUpdateTime; //最后修改时间
+}
+/*
+ * 服务分组,consumer定义
+ */
+struct Consumer
+{
+ 1:list ips;
+ 2:list appkeys;
+}
+
+/*
+ * 服务分组定义
+ */
+struct CRouteData
+{
+ 1:string id;
+ 2:string name;
+ 3:string appkey;
+ 4:i32 env;
+ 5:i32 category;
+ 6:i32 priority;
+ 7:i32 status; //服务分组,0:禁用,1:启用
+ 8:Consumer consumer;
+ 9:list provider;
+ 10:i32 updateTime; //最后修改时间
+ 11:i32 createTime; //最后修改时间
+ 12:string reserved; //扩展 k1:v1|k2:v2...
+}
+/*
+ * 路由分组中provider节点信息
+ */
+struct CProviderNode
+{
+ 1:string appkey;
+ 2:i64 lastModifiedTime;
+ 3:i64 mtime;
+ 4:i64 cversion;
+ 5:i64 version;
+}
+/*
+ * 路由分组中route根节点结构
+ */
+struct CRouteNode
+{
+ 1:string appkey;
+ 2:i64 lastModifiedTime;
+ 3:i64 mtime;
+ 4:i64 cversion;
+ 5:i64 version;
+}
+struct ProtocolRequest {
+ 1:string localAppkey;
+ 2:string remoteAppkey;
+ 3:string protocol;
+ 4:string serviceName;
+}
+struct ProtocolResponse {
+ 1:i32 errcode;
+ 2:list servicelist;
+}
diff --git a/common/idl-mns/idl-common/src/main/thrift/naming_data.thrift b/common/idl-mns/idl-common/src/main/thrift/naming_data.thrift
new file mode 100644
index 0000000..05ed505
--- /dev/null
+++ b/common/idl-mns/idl-common/src/main/thrift/naming_data.thrift
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2018 Meituan Dianping. All rights reserved.
+ *
+ * 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.
+ */
+
+namespace java com.octo.data.thrift.model
+namespace cpp meituan_mns
+
+include "naming_common.thrift"
+typedef naming_common.SGService SGService
+typedef naming_common.CRouteData CRouteData
+enum RegistCmd {
+ REGIST = 0,
+ UNREGIST = 1
+}
+struct getservice_req_param_t
+{
+ 1:string localAppkey;
+ 2:string remoteAppkey;
+ 3:string version;
+ 4:string protocol;
+}
+struct getservice_res_param_t
+{
+ 1:string localAppkey;
+ 2:string remoteAppkey;
+ 3:string version;
+ 4:list serviceList;
+ 5:string protocol;
+}
+struct getservicename_req_param_t
+{
+ 1:string localAppkey;
+ 2:string servicename;
+ 3:string version;
+ 4:string protocol;
+}
+struct getservicename_res_param_t
+{
+ 1:string localAppkey;
+ 2:string servicename;
+ 3:string version;
+ 4:set appkeys;
+ 5:string protocol;
+}
+struct getroute_req_param_t
+{
+ 1:string localAppkey;
+ 2:string remoteAppkey;
+ 3:string version;
+ 4:string protocol;
+}
+struct getroute_res_param_t
+{
+ 1:string localAppkey;
+ 2:string remoteAppkey;
+ 3:string version;
+ 4:list routeList;
+ 5:string protocol;
+}
+struct regist_req_param_t
+{
+ 1:i32 retry_times = 0;
+ 2:SGService sgservice;
+ 3:i32 uptCmd;
+ 4:RegistCmd regCmd;
+}
diff --git a/common/idl-mns/idl-common/src/main/thrift/naming_service.thrift b/common/idl-mns/idl-common/src/main/thrift/naming_service.thrift
new file mode 100644
index 0000000..ccd4689
--- /dev/null
+++ b/common/idl-mns/idl-common/src/main/thrift/naming_service.thrift
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2018 Meituan Dianping. All rights reserved.
+ *
+ * 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.
+ */
+
+namespace java com.octo.naming.service.thrift.model
+namespace cpp meituan_mns
+
+include "naming_common.thrift"
+typedef naming_common.SGService SGService
+typedef naming_common.ProtocolRequest ProtocolRequest
+typedef naming_common.ProtocolResponse ProtocolResponse
+/**
+ * Common status reporting mechanism across all services
+ */
+service ServiceAgent
+{
+ /*
+ * 新增协议获取服务列表的接口
+ */
+ ProtocolResponse getServiceListByProtocol(1:ProtocolRequest req);
+ // 获取zk全部节点的接口
+ ProtocolResponse getOriginServiceList(1:ProtocolRequest req);
+ /*
+ *服务注册
+ */
+ i32 registService(1:SGService oService);
+
+ /*
+ * 注册服务
+ * uptCmd:0,重置(代表后面的serviceName list就是该应用支持的全量接口);
+ * 1,增加(代表后面的serviceName list是该应用新增的接口);
+ * 2,减少(代表后面的serviceName list是该应用删除的接口)。
+ */
+ i32 registServicewithCmd(1:i32 uptCmd, 2:SGService oService);
+ /*
+ *服务注销
+ */
+ i32 unRegistService(1:SGService oService);
+}
diff --git a/common/idl-mns/idl-common/src/main/thrift/unified_protocol.thrift b/common/idl-mns/idl-common/src/main/thrift/unified_protocol.thrift
new file mode 100644
index 0000000..b75db8f
--- /dev/null
+++ b/common/idl-mns/idl-common/src/main/thrift/unified_protocol.thrift
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2018 Meituan Dianping. All rights reserved.
+ *
+ * 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.
+ */
+
+namespace java com.octo.unified.protocol
+namespace cpp meituan_mns
+
+enum MessageType { // 消息类型
+ Normal = 0, // 正常消息
+ NormalHeartbeat = 1, // 端对端心跳消息
+ ScannerHeartbeat = 2 //scanner心跳消息
+}
+
+enum CompressType { // 压缩类型
+ None = 0, // 不压缩
+ Snappy = 1, // Snappy
+ Gzip = 2 // Gzip
+}
+
+struct RequestInfo { // 请求信息
+ 1: required string serviceName; // 服务名
+ 2: required i64 sequenceId; // 消息序列号
+ 3: required byte callType; // 调用类型
+ 4: required i32 timeout; // 请求超时时间
+}
+
+enum CallType { // 调用类型
+ Reply = 0, // 需要响应
+ NoReply = 1, // 不需要响应
+}
+
+struct ResponseInfo { // 响应信息
+ 1: required i64 sequenceId; // 消息序列号
+ 2: required byte status; // 消息返回状态
+ 3: optional string message; //异常消息
+}
+
+enum StatusCodes{
+ Success = 0, // 成功
+ ApplicationException = 1, // 业务异常,业务接口方法定义抛出的异常
+ RuntimeException = 2, // 运行时异常,一般由业务抛出
+ RpcException = 3, // 框架异常,包含没有被下列异常覆盖到的框架异常
+ TransportException = 4, // 传输异常
+ ProtocolException = 5, // 协议异常
+ DegradeException = 6, // 降级异常
+ SecurityException = 7, // 安全异常
+ ServiceException = 8, // 服务异常,如服务端找不到对应的服务或方法
+ RemoteException = 9, // 远程异常
+}
+
+
+
+struct TraceInfo { // Mtrace 跟踪信息,原 MTthrift 中的 RequestHeader
+ 1: required string clientAppkey; // 客户端应用名
+ 2: optional string traceId; // Mtrace 的 traceId
+ 3: optional string spanId; // Mtrace 的 spanId
+ 4: optional string rootMessageId; // Cat 的 rootMessageId
+ 5: optional string currentMessageId; // Cat 的 currentMessageId
+ 6: optional string serverMessageId; // Cat 的 serverMessageId
+ 7: optional bool debug; // 是否强制采样
+ 8: optional bool sample; // 是否采样
+ 9: optional string clientIp; // 客户端IP
+}
+
+
+struct LoadInfo{
+ 1: optional double averageLoad;
+ 2: optional i32 oldGC;
+ 3: optional i32 threadNum; //默认线程池
+ 4: optional i32 queueSize; //主IO线程队列长度
+ 5: optional map methodQpsMap; //key为ServiceName.methodName,value为1分钟内的对应的qps值(key为all,value则为所有方法的qps)
+}
+
+struct HeartbeatInfo {
+ 1: optional string appkey; // 解决重复注册,修改错误appkey状态的问题
+ 2: optional i64 sendTime; // 发送心跳时间,微秒,方便业务剔除历史心跳
+ 3: optional LoadInfo loadInfo; // 负载信息
+ 4: required i32 status; // 0:DEAD(未启动), 2:ALIVE(正常),4:STOPPED(禁用)
+}
+
+typedef map Context // 消息上下文,用于传递自定义数据
+
+struct Header { // 消息头
+ 1: optional byte messageType = MessageType.Normal; // 消息类型
+ 2: optional RequestInfo requestInfo; // 请求信息
+ 3: optional ResponseInfo responseInfo; // 响应信息
+ 4: optional TraceInfo traceInfo; // 跟踪信息
+ 5: optional Context globalContext; // 全链路消息上下文,总大小不超过 512 Bytes
+ 6: optional Context localContext; // 单次消息上下文,总大小不超过 2K Bytes
+ 7: optional HeartbeatInfo heartbeatInfo; // 心跳信息
+}
diff --git a/common/idl-mns/idl-mnsc/Compile.md b/common/idl-mns/idl-mnsc/Compile.md
new file mode 100644
index 0000000..7de0605
--- /dev/null
+++ b/common/idl-mns/idl-mnsc/Compile.md
@@ -0,0 +1,28 @@
+
+# idl-mnsc 源码编译说明
+
+## 1.下载工程
+```
+ git clone https://github.com/Meituan-Dianping/octo-ns.git
+```
+
+## 2.构建Jar包
+环境要求:
+
+- Java version >= 1.8
+- Maven version >= 3.2
+
+切换到idl-mnsc目录
+
+```
+cd common/idl-mns/idl-mnsc
+```
+
+本地install,执行后在本地仓库~/.m2/repository/com/meituan/octo/idl-mnsc/(假如你的仓库位置是~/.m2/repository)下可以找到idl-mnsc的jar
+
+```
+# common/idl-mns/idl-mnsc 目录下
+mvn clean install -Dmaven.test.skip=true
+```
+
+```
diff --git a/common/idl-mns/idl-mnsc/pom.xml b/common/idl-mns/idl-mnsc/pom.xml
new file mode 100644
index 0000000..43c9514
--- /dev/null
+++ b/common/idl-mns/idl-mnsc/pom.xml
@@ -0,0 +1,60 @@
+
+
+ 4.0.0
+ com.meituan.octo
+ idl-mnsc
+ 1.0.0
+ jar
+
+
+ com.meituan.octo
+ idl-common
+ 1.0.0
+
+
+ org.apache.thrift
+
+ libthrift
+ 0.9.3
+
+
+
+
+
+ org.apache.thrift.tools
+ maven-thrift-plugin
+ 0.1.11
+
+
+ /usr/local/bin/thrift
+
+
+
+ thrift-sources
+ generate-sources
+
+ compile
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-source-plugin
+ 3.0.1
+
+
+ attach-sources
+ package
+
+ jar-no-fork
+ test-jar-no-fork
+
+
+
+
+
+
+
diff --git a/common/idl-mns/idl-mnsc/src/main/thrift/mnsc_data.thrift b/common/idl-mns/idl-mnsc/src/main/thrift/mnsc_data.thrift
new file mode 100644
index 0000000..3cd463b
--- /dev/null
+++ b/common/idl-mns/idl-mnsc/src/main/thrift/mnsc_data.thrift
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2018 Meituan Dianping. All rights reserved.
+ *
+ * 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.
+ */
+
+namespace java com.octo.mnsc.idl.thrift.model
+namespace cpp meituan_mns
+include "../../../../idl-common/src/main/thrift/naming_common.thrift"
+typedef naming_common.SGService SGService
+struct MNSResponse {
+ /*
+ * 状态码,200: 正常返回200;如果version不同,MNSCache正在更新时,先直接返回500; 400: 访问MNS请求超时
+ */
+ 1 : required i32 code = 200;
+ /*
+ * 节点列表,code = 200时,必须返回的字段
+ */
+ 2 : optional list defaultMNSCache;
+ /*
+ * 版本信息
+ */
+ 3 : optional string version; //正常返回时,附带上version信息
+}
+// for scanner
+struct MNSBatchResponse {
+ /*
+ * 状态码,200: 正常返回200;如果version不同,MNSCache正在更新时,先直接返回500; 400: 访问MNS请求超时
+ */
+ 1 : required i32 code = 200;
+ /*
+ * appkey->(env->detail)
+ */
+ 2 : optional map>> cache;
+}
+struct AppKeyListResponse {
+ /*
+ * 状态码,200: 正常返回;400: 访问MNS请求超时;
+ */
+ 1 : required i32 code = 200;
+ /*
+ * 服务appkey列表
+ */
+ 2 : optional list appKeyList;
+}
+enum Protocols{
+ THRIFT,
+ HTTP
+}
+struct MnsRequest{
+ 1: Protocols protoctol;
+ 2: string appkey;
+ 3: string env;
+}
+//环境的名字
+const string PROD = "prod";
+const string STAGE = "stage";
+const string TEST = "test";
+/**
+* 异常错误定义
+**/
+/**
+* 正常服务
+**/
+const i32 SUCCESS = 200;
+/**
+* 如果version不同,MNSCache正在更新时,先直接返回500
+**/
+const i32 MNSCache_UPDATE = 500;
+/**
+* 超时异常
+**/
+const i32 TIMEOUT_ERROR = 400;
+//参数错误
+const i32 ILLEGAL_ARGUMENT = 400;
+//请求的缓存不存在
+const i32 NOT_FOUND = 404
+//缓存没有变化
+const i32 NOT_MODIFIED = 304
diff --git a/common/idl-mns/idl-mnsc/src/main/thrift/mnsc_service.thrift b/common/idl-mns/idl-mnsc/src/main/thrift/mnsc_service.thrift
new file mode 100644
index 0000000..c5bff72
--- /dev/null
+++ b/common/idl-mns/idl-mnsc/src/main/thrift/mnsc_service.thrift
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2018 Meituan Dianping. All rights reserved.
+ *
+ * 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.
+ */
+
+namespace java com.octo.mnsc.idl.thrift.service
+namespace cpp meituan_mns
+include "mnsc_data.thrift"
+typedef mnsc_data.MNSResponse MNSResponse
+typedef mnsc_data.MNSBatchResponse MNSBatchResponse
+typedef mnsc_data.AppKeyListResponse AppKeyListResponse
+typedef mnsc_data.MnsRequest MnsRequest
+typedef mnsc_data.SGService SGService
+service MNSCacheService {
+ /**
+ * @param appkey 服务标识
+ * @param version 版本
+ * @param env 环境
+ * @return 服务的节点列表
+ * @name 获取服务的节点列表
+ */
+ MNSResponse getMNSCache(1:string appkey, 2:string version, 3:string env);
+ /**
+ * @param appkey 服务标识
+ * @param version 版本
+ * @param env 环境
+ * @return 服务的HLB节点列表
+ * @name 获取服务的HLB节点列表
+ */
+ MNSResponse getMNSCacheHttp(1:string appkey, 2:string version, 3:string env);
+ /**
+ * @param req 请求结构体
+ * @name 获取服务的节点列表; 获取时, 会将缓存中的version与zk上的version进行比较,如果不相等,则重新更新缓存后,再返回数据。
+ */
+ MNSResponse getMNSCacheWithVersionCheck(1:MnsRequest req);
+ /**
+ * @param appkeys 请求的appkey列表
+ * @param protocol
+ */
+ MNSBatchResponse getMNSCacheByAppkeys(1:list appkeys, 2:string protocol);
+ /**
+ * 根据IP返回与该IP相关的服务节点
+ * @param ip IP 地址
+ */
+ MNSResponse getProvidersByIP(1:string ip);
+ /**
+ *
+ * @param ip
+ * @return appkey列表
+ */
+ AppKeyListResponse getAppkeyListByIP(1:string ip);
+}
diff --git a/conf/build_common_cfg.sh b/conf/build_common_cfg.sh
new file mode 100755
index 0000000..0e0c084
--- /dev/null
+++ b/conf/build_common_cfg.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+ mkdir -p /data/webapps
+ mkdir -p /octo/ns/
+ cp -rf octo.cfg /data/webapps
+ cp -rf idc.xml /octo/ns/
+ echo "you have create the octo.cfg dir(/data/webapps) and idc.xml dir(/octo/ns/sg_agent)"
diff --git a/conf/idc.xml b/conf/idc.xml
new file mode 100644
index 0000000..ca99fcd
--- /dev/null
+++ b/conf/idc.xml
@@ -0,0 +1,97 @@
+
+
+
+ beijing
+
+ DX
+ BJ1
+ -
+
10.32.0.0
+ 255.255.0.0
+
+ -
+
10.33.0.0
+ 255.255.0.0
+
+
+
+ YF
+ BJ2
+ -
+
10.4.0.0
+ 255.255.0.0
+
+ -
+
10.5.0.0
+ 255.255.0.0
+
+
+
+ RZ
+ NOCENTER
+ -
+
10.16.0.0
+ 255.255.0.0
+
+ -
+
10.17.0.0
+ 255.255.0.0
+
+
+
+ GH
+ BJ1
+ -
+
10.20.0.0
+ 255.255.0.0
+
+ -
+
10.21.0.0
+ 255.255.0.0
+
+
+
+ TXBJ
+ BJ1
+ -
+
10.61.0.0
+ 255.255.0.0
+
+
+
+
+ shanghai
+
+ DP
+ SH
+ -
+
10.100.0.0
+ 255.255.0.0
+
+
+
+ GQ
+ SH
+ -
+
10.3.0.0
+ 255.255.0.0
+
+ -
+
10.67.0.0
+ 255.255.0.0
+
+
+
+ NH
+ SH
+ -
+
10.1.0.0
+ 255.255.0.0
+
+ -
+
10.101.0.0
+ 255.255.0.0
+
+
+
+
diff --git a/conf/octo.cfg b/conf/octo.cfg
new file mode 100644
index 0000000..66987f4
--- /dev/null
+++ b/conf/octo.cfg
@@ -0,0 +1,7 @@
+env=test
+mns_url=http://10.24.33.222:8911
+idc_path=/octo/ns/idc.xml
+port=5266
+sg_sentinel_appkey=com.octo.example.sg_sentinel
+sgagent_appkey=com.octo.example.sgagent
+mnszk_url=127.0.0.1:2181
diff --git a/docs/image/ns.svg b/docs/image/ns.svg
new file mode 100644
index 0000000..ab93faa
--- /dev/null
+++ b/docs/image/ns.svg
@@ -0,0 +1 @@
+naming service cache(nsc)
\ No newline at end of file
diff --git a/docs/image/ns_components.svg b/docs/image/ns_components.svg
new file mode 100644
index 0000000..ea9fd29
--- /dev/null
+++ b/docs/image/ns_components.svg
@@ -0,0 +1 @@
+service provider instance
service consumer instance
\ No newline at end of file
diff --git a/docs/image/ns_trait.svg b/docs/image/ns_trait.svg
new file mode 100644
index 0000000..6c086b8
--- /dev/null
+++ b/docs/image/ns_trait.svg
@@ -0,0 +1,2 @@
+
+[Not supported by viewer] [Not supported by viewer] [Not supported by viewer] <font style="font-size: 20px">服务治理代理sgagent</font> [Not supported by viewer] [Not supported by viewer] [Not supported by viewer] [Not supported by viewer] [Not supported by viewer] [Not supported by viewer] [Not supported by viewer] service provider service provider service provider [Not supported by viewer] [Not supported by viewer] [Not supported by viewer] service consumer service consumer service consumer [Not supported by viewer]
\ No newline at end of file
diff --git a/docs/image/registry_sucess.png b/docs/image/registry_sucess.png
new file mode 100644
index 0000000..4eddac5
Binary files /dev/null and b/docs/image/registry_sucess.png differ
diff --git a/docs/image/scanner_traits.png b/docs/image/scanner_traits.png
new file mode 100644
index 0000000..ef81f50
Binary files /dev/null and b/docs/image/scanner_traits.png differ
diff --git a/docs/ns-quick-start.md b/docs/ns-quick-start.md
new file mode 100644
index 0000000..aaba191
--- /dev/null
+++ b/docs/ns-quick-start.md
@@ -0,0 +1,195 @@
+## Naming Service(NS)
+
+ 快速进行Java环境配置、依赖管理以及ZooKeeper、项目下载和配置、NSC、NSInvoker、SGAgent四部分部署即可进行服务注册、服务发现功能,下面给出安装部署说明.
+
+
+| 步骤| 描述 | 备注 |
+| ------ | ------ | ------ |
+| 1.Java环境配置 | 服务依赖的Java环境 | |
+| 2.依赖管理 | 第三方库| |
+| 3.ZooKeeper部署 | 存储注册数据| |
+| 4.项目下载 | 从git下载项目工程| |
+| 5.配置更新 | 更新配置依赖项| |
+| 6.NSC部署 | NS缓存服务部署| |
+| 7.SGAgent部署 | 服务治理代理安装部署 | |
+
+### Java环境配置
+
+64bit OS: Linux/Unix/Mac, Linux/Unix/Mac recommended.
+
+64bit JDK 1.8+: [downloads](https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html), [JAVA_HOME settings](https://docs.oracle.com/cd/E19182-01/820-7851/inst_cli_jdk_javahome_t/)
+
+Maven 3.2.x+: [downloads](https://maven.apache.org/download.cgi), [settings](https://maven.apache.org/settings.html).
+
+### 依赖管理
+
+| 库依赖 | 版本 | 备注 |
+| ------ | ------ | ------ |
+| muduo | v1.1.0 | 有http服务补丁,见 patch/0001-add-patch-for-http.patch |
+| zookeeper | v3.4.6 | |
+| thrift | v0.9.3 |依赖的java组件请配置对应程序执行路径,缺省路径/usr/local/bin|
+
+
+
+### ZooKeeper部署
+---
+
+> [见ZooKeeper安装及部署](https://zookeeper.apache.org/doc/r3.1.2/zookeeperStarted.html)
+> [ZooKeeper数据初始化](https://github.com/Meituan-Dianping/octo-ns/tree/master/docs/zookeeper_data_build.md)
+> 记录部署的ZooKeeper单机IP或集群IP列表及端口
+
+### 项目下载
+---
+~~~
+git clone https://github.com/Meituan-Dianping/octo-ns.git
+~~~
+
+### 配置更新
+---
+~~~
+cd octo-ns/conf
+更新octo.cfg中mnszk_url=IP:PORT //已部署的ZooKeeper机器地址
+更新octo.cfg中mns_url=http://IP:PORT //已部署的NSC服务机器地址,若有多台可配置成为域名)
+sh build_common_cfg.sh //见conf目录下的README.md介绍
+~~~
+
+
+### NSC部署
+---
+依赖构建
+[idl-common依赖构建](../common/idl-mns/idl-common/Compile.md)
+[idl-mnsc依赖构建](../common/idl-mns/idl-mnsc/Compile.md)
+[mns-invoker依赖构建](../sdk/mns-invoker/docs/Compile.md)
+[Dorado依赖构建](https://github.com/Meituan-Dianping/octo-rpc/blob/master/dorado/dorado-doc/manual-developer/Compile.md)
+
+
+部署运行
+
+~~~
+cd nsc
+sh run.sh
+lsof -i:[port] //查看服务端口是否已启用
+~~~
+
+
+### SGAgent部署
+---
+#### 支持环境
+ * CentOS(支持CentOS 6系统)
+
+#### 依赖初始化
+~~~
+cd octo-ns/sg_agent
+sh build.sh init
+已自带常用第三方依赖库 //见thrid_party README.md详细介绍
+~~~
+#### 配置初始化
+
+>日志级别配置见[Log4cplus使用指南](https://github.com/log4cplus/log4cplus)
+cd sg_agent
+修改sg\_agent\_mutable.xml的MnsHost对应地域ZooKeeper地址信息(区分测试和生产环境)
+
+#### 编译
+~~~
+cd octo-ns/sg_agent
+sh build.sh with_bin //可执行文件生成
+~~~
+#### 运行
+~~~
+cd octo-ns/sg_agent/tool
+sh build_resource.sh //见配置资源文件介绍
+sh run_server.sh
+lsof -i:[port] //查看服务端口是否已启用
+~~~
+查看log日志是否有sg_agent自注册日志,如下:
+
+~~~
+[2018-12-18 22:43:13:671.423]
+[../util/json_data_tools.cc:177]
+INFO - out: {
+ "appkey": "com.octo.mns.sg_agent",
+ "version": "sg_agent-open",
+ "ip": "10.4.231.87",
+ "port": 7776,
+ "weight": 10,
+ "status": 2,
+ "role": 0,
+ "env": 1,
+ "lastUpdateTime": 1545144193,
+ "fweight": 10,
+ "serverType": 0,
+ "warmup": 0,
+ "heartbeatSupport": 0,
+ "protocol": "thrift",
+ "serviceInfo": {
+}
+}
+[2018-12-18 22:43:13:671.443] [registry_service.cc:482] INFO - to regist when node exists, uptCmd : 1, appkey : com.octo.mns.sg_agent, env : 1, local env : 1, status : 2; fweight : 10; serverType : 0; protocol: thrift, ip : 10.4.231.87
+[2018-12-18 22:43:13:674.349] [zk_client.cc:310] INFO - zoo_set ret = 0, path = /octo/nameservice/test/com.sankuai.inf.newct/provider/10.4.231.87:7776
+[2018-12-18 22:43:13:677.031] [zk_client.cc:310] INFO - zoo_set ret = 0, path = /octo/nameservice/test/com.sankuai.inf.newct/provider
+[2018-12-18 22:43:13:677.106] [registry_service.cc:105] INFO - success registry, appkey:com.octo.mns.sg_agent; ip = 10.4.231.87
+~~~
+
+
+
+##### 使用C++ NSSdk发起服务注册/服务发现示例
+---
+见C++ [NSSdk示例说明](../sdk/mns-sdk/ReadMe.md)
+
+##### 使用Java NSInvoker发起服务注册/服务发现示例
+添加依赖
+
+~~~
+pom.xml添加mns-invoker的maven坐标,如下:
+
+ com.meituan.octo
+ mns-invoker
+ 1.0.0
+
+pom.xml添加依赖,如下:
+
+ com.meituan.octo
+ mns-invoker
+ 1.0.0
+
+~~~
+
+> 构建thrift协议示例,观察SGAgent日志.
+
+
+~~~
+String appkey ="com.meituan.octo.dorado.server";
+String protocol = "thrift";
+int port = 5198;
+String version = "original";
+String ip = "127.0.0.1";
+int serverType = 0;//thrift是0,http是1
+
+SGService service = new SGService();
+ service.setAppkey(appkey);
+ service.setPort(port);
+ service.setVersion(version);
+ service.setIp(ip);
+ service.setLastUpdateTime((int) (System.currentTimeMillis() / 1000));
+ service.setServerType(serverType);
+ service.setWeight(10);
+ service.setFweight(10.0);
+ service.setProtocol(protocol);
+
+MnsInvoker.registServiceWithCmd(1,service);//增量模式注册
+~~~
+
+##### 使用NSInvoker发起服务发现流程
+下面是发现上述服务的例子
+
+~~~
+String consumerAppkey = "com.meituan.octo.dorado.client";
+String remoteAppkey = "com.meituan.octo.dorado.server";
+
+ProtocolRequest thriftReq = new ProtocolRequest()
+ .setLocalAppkey(consumerAppkey)
+ .setRemoteAppkey(remoteAppkey)
+ .setProtocol("thrift");
+
+List thriftList = MnsInvoker.getServiceList(thriftReq);
+~~~
diff --git a/docs/zookeeper_data_build.md b/docs/zookeeper_data_build.md
new file mode 100644
index 0000000..d6998b0
--- /dev/null
+++ b/docs/zookeeper_data_build.md
@@ -0,0 +1,46 @@
+## zookeeper数据初始化
+
+ 由于NSC服务启用依赖zookeeper数据的path路径,快速构建可使用zookeeper自带的zkCli.sh脚本进入zookeeper操作控制台操作,也可使用第三方脚本自行创建如python,其自带了zkclient包,便于操作.
+ 以下给出第一种简单操作方式.
+
+### 使用zkClie.sh创建数据
+---
+切换至zookeeper安装的bin文件目录
+
+~~~
+cd [dirName] //dirName为zookeeper的bin目录
+~~~
+
+创建节点信息test、stage、prod环境path
+
+~~~
+cd [dirName] //dirName为zookeeper的bin目录
+./zkCli.sh -timeout 1000 -r -server 127.0.0.1:2181
+create /octo "top octo path" //永久节点方式
+create /octo/nameservice "nameservice dir"
+create /octo/nameservice/test "test dir"
+create /octo/nameservice/stage "stage dir"
+create /octo/nameservice/prod "prod dir"
+~~~
+
+创建servicename环境test、stage、prod路径
+
+~~~
+cd [dirName] //dirName为zookeeper的bin目录
+./zkCli.sh -timeout 1000 -r -server 127.0.0.1:2181
+create /octo "top octo path" //永久节点方式
+create /octo/service "nameservice dir"
+create /octo/service/test "test dir"
+create /octo/service/stage "stage dir"
+create /octo/service/prod "prod dir"
+~~~
+
+### 数据导入
+将项目中自带的快照数据导入到安装的zookeeper数据路径
+
+~~~
+scp octo-ns/conf/snapshot [dirName]
+cd [zkBinDir]
+./zkServer.sh restart
+
+~~~
diff --git a/nsc/README.md b/nsc/README.md
new file mode 100644
index 0000000..f7570e9
--- /dev/null
+++ b/nsc/README.md
@@ -0,0 +1,56 @@
+# nsc 介绍
+
+## 背景描述
+nsc 是 octo 服务治理体系内的缓存服务数据子系统.
+
+开发语言: Java
+
+运行环境要求: JDK 1.8及以上、maven3、zookeeper
+
+组件依赖: [Dorado](https://github.com/Meituan-Dianping/octo-rpc/tree/master/dorado)
+
+主要功能点:
+
+1. 缓存服务注册信息,为octo组件提供批量获取服务列表功能
+2. 提供sgagent哨兵列表,本地sg不可用时,业务服务fallback到哨兵服务,保证octo健壮性
+
+
+## 实现细节
+### 数据同步机制
+被动notify + push的机制保障数据实效性;周期性的pull同步模式,确保数据完整性。
+
+### 异步模式
+采用异步模式处理watcher触发后的逻辑,避免同步模式下大量watcher阻塞执行,排队耗费大量等待时间。
+
+### 过滤zk事件
+网络抖动时,产生的网络事件会导致zk-client进行watcher实例重复注册;频繁网络抖动可能导致进程OOM。
+
+### 队列分离
+分队列处理不同优先级任务,保证核心任务快速响应
+
+## 快速上手
+### 依赖构建
+[idl-common依赖构建](https://github.com/Meituan-Dianping/octo-ns/tree/master/common/idl-mns/idl-common/Compile.md)
+[idl-mnsc依赖构建](https://github.com/Meituan-Dianping/octo-ns/tree/master/common/idl-mns/idl-mnsc/Compile.md)
+[mns-invoker依赖构建](https://github.com/Meituan-Dianping/octo-ns/tree/master/mns-invoker/docs/Compile.md)
+[Dorado依赖构建](https://github.com/Meituan-Dianping/octo-rpc/blob/master/dorado/dorado-doc/manual-developer/Compile.md)
+
+
+
+
+### 打包运行nsc
+
+
+```bash
+git clone git@github.com:Meituan-Dianping/octo-ns.git
+
+cd octo-ns/mns-cache
+
+sh ./run.sh
+
+#需要在启动提前在octo.cfg参数中指定zookeeper地址
+#日志会输出到当前路径下"/opt/logs/com.meituan.octo.mnsc/mnsc-server.log"文件
+
+```
+
+
diff --git a/nsc/pom.xml b/nsc/pom.xml
new file mode 100644
index 0000000..171a8b0
--- /dev/null
+++ b/nsc/pom.xml
@@ -0,0 +1,285 @@
+
+
+ 4.0.0
+ com.meituan.octo
+ mnsc
+ 1.0.0
+ jar
+ mnsc
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 1.5.18.RELEASE
+
+
+
+ 2.9.5
+ 2.7
+ 3.1.0
+ 2.10.7
+ 2.1.0
+ 0.11.2
+ 2.4.0-M1
+ 0.3.16
+ 2.2.4
+ 2.6
+
+
+
+ org.springframework.boot
+ spring-boot-starter
+
+
+ logback-classic
+ ch.qos.logback
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ org.springframework.boot
+ spring-boot-starter-jetty
+
+
+ org.eclipse.jetty.websocket
+ websocket-server
+
+
+ org.eclipse.jetty.websocket
+ javax-websocket-server-impl
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ com.fasterxml.jackson.core
+ jackson-core
+ ${jackson.version}
+
+
+ com.fasterxml.jackson.core
+ jackson-annotations
+ ${jackson.version}
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ ${jackson.version}
+
+
+ com.meituan.octo
+ idl-common
+ 1.0.0
+
+
+ libthrift
+ org.apache.thrift
+
+
+
+
+ com.meituan.octo
+ idl-mnsc
+ 1.0.0
+
+
+ com.meituan.octo
+ mns-invoker
+ 1.0.0
+
+
+ com.fasterxml.jackson.module
+ jackson-module-scala_2.10
+ 2.9.2
+
+
+
+ org.apache.curator
+ curator-framework
+ 4.0.1
+
+
+ org.apache.curator
+ curator-recipes
+ 4.0.1
+
+
+ org.apache.zookeeper
+ zookeeper
+ 3.4.8
+
+
+ slf4j-log4j12
+ org.slf4j
+
+
+ log4j
+ log4j
+
+
+
+
+ joda-time
+ joda-time
+ 2.8.2
+
+
+ com.meituan.octo
+ dorado
+ 1.0.0
+
+
+ junit
+ junit
+ 4.12
+ test
+
+
+ org.codehaus.jackson
+ jackson-mapper-asl
+ 1.8.0
+
+
+ net.liftweb
+ lift-json_2.10
+ 2.5
+
+
+ org.scala-lang
+ scala-compiler
+ ${scala.version}
+
+
+ org.scala-lang
+ scala-library
+ ${scala.version}
+
+
+ org.scalaj
+ scalaj-http_2.10
+ ${scalaj-http.version}
+
+
+ com.typesafe.slick
+ slick_2.10
+ ${slick.version}
+
+
+ com.typesafe.slick
+ slick-codegen_2.10
+ ${slick.version}
+
+
+ com.typesafe.play
+ play-json_2.10
+ ${play-json.version}
+
+
+ net.databinder.dispatch
+ dispatch-core_2.10
+ ${dispatch.version}
+
+
+ org.scalatest
+ scalatest_2.10
+ ${scalatest.version}
+
+
+ org.apache.logging.log4j
+ log4j-slf4j-impl
+ ${log4j.version}
+ true
+
+
+ org.apache.logging.log4j
+ log4j-core
+ ${log4j.version}
+ true
+
+
+ commons-lang
+ commons-lang
+ ${commons-lang.version}
+
+
+
+
+
+ net.alchim31.maven
+ scala-maven-plugin
+ ${scala.maven.version}
+
+
+ scala-compile-first
+ process-resources
+
+ add-source
+ compile
+
+
+
+ scala-test-compile
+ process-test-resources
+
+ testCompile
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+ false
+
+ **/*Test.java
+
+
+
+
+
+
+
+ test
+
+ true
+
+
+
+
+ src/main/profiles/test
+
+
+ src/main/resources
+
+
+
+
+
+ online
+
+
+
+ src/main/profiles/online
+
+
+ src/main/resources
+
+
+
+
+
+
diff --git a/nsc/run.sh b/nsc/run.sh
new file mode 100644
index 0000000..8b663ed
--- /dev/null
+++ b/nsc/run.sh
@@ -0,0 +1,13 @@
+#!/usr/bin/env bash
+JVM_ARGS="-server -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8 -Djava.io.tmpdir=/tmp -Djava.net.preferIPv6Addresses=false"
+JVM_GC="-XX:+DisableExplicitGC -XX:+PrintGCDetails -XX:+PrintHeapAtGC -XX:+PrintTenuringDistribution -XX:+UseConcMarkSweepGC -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps"
+JVM_GC=$JVM_GC" -XX:CMSFullGCsBeforeCompaction=0 -XX:+UseCMSCompactAtFullCollection -XX:CMSInitiatingOccupancyFraction=80"
+JVM_HEAP="-XX:SurvivorRatio=8 -XX:PermSize=256m -XX:MaxPermSize=256m -XX:+HeapDumpOnOutOfMemoryError -XX:ReservedCodeCacheSize=128m -XX:InitialCodeCacheSize=128m"
+JVM_SIZE="-Xmx4g -Xms4g -Xmn2g"
+
+EXEC_JAVA="java $JVM_ARGS $JVM_SIZE $JVM_HEAP $JVM_GC"
+EXEC_JAVA=$EXEC_JAVA" $JAVA_ARGS"
+
+mvn clean -U package -Dmaven.test.skip=true
+cd target
+$EXEC_JAVA -jar mnsc-1.0.0.jar
\ No newline at end of file
diff --git a/nsc/src/main/java/com/meituan/octo/mnsc/MnscServerApplication.java b/nsc/src/main/java/com/meituan/octo/mnsc/MnscServerApplication.java
new file mode 100644
index 0000000..0594f89
--- /dev/null
+++ b/nsc/src/main/java/com/meituan/octo/mnsc/MnscServerApplication.java
@@ -0,0 +1,13 @@
+package com.meituan.octo.mnsc;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.ImportResource;
+
+@SpringBootApplication
+@ImportResource(locations = {"classpath:applicationContext.xml", "classpath:webmvc-config.xml"})
+public class MnscServerApplication {
+ public static void main(String[] args) {
+ SpringApplication.run(MnscServerApplication.class, args);
+ }
+}
diff --git a/nsc/src/main/java/com/meituan/octo/mnsc/thrift/service/impl/MNSCacheServiceImpl.java b/nsc/src/main/java/com/meituan/octo/mnsc/thrift/service/impl/MNSCacheServiceImpl.java
new file mode 100644
index 0000000..a013788
--- /dev/null
+++ b/nsc/src/main/java/com/meituan/octo/mnsc/thrift/service/impl/MNSCacheServiceImpl.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2011-2018, Meituan Dianping. All Rights Reserved.
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+package com.meituan.octo.mnsc.thrift.service.impl;
+
+import com.octo.mnsc.idl.thrift.model.*;
+import com.octo.mnsc.idl.thrift.service.MNSCacheService;
+import com.meituan.octo.mnsc.model.Env;
+import com.meituan.octo.mnsc.service.mnscService;
+import org.apache.commons.lang.StringUtils;
+import org.apache.thrift.TException;
+import org.springframework.util.Assert;
+
+import java.util.List;
+
+public class MNSCacheServiceImpl implements MNSCacheService.Iface {
+ @Override
+ public MNSResponse getMNSCache(String appkey, String version, String env) throws TException {
+ if (!Env.isValid(env) || org.apache.commons.lang3.StringUtils.isEmpty(appkey)) {
+ MNSResponse ret = new MNSResponse();
+ ret.setCode(mnsc_dataConstants.ILLEGAL_ARGUMENT);
+ return ret;
+ }
+ return mnscService.getMnsc(appkey, version, env);
+ }
+
+ @Override
+ public MNSResponse getMNSCacheHttp(String appkey, String version, String env) throws TException {
+ if (!Env.isValid(env) || org.apache.commons.lang3.StringUtils.isEmpty(appkey)) {
+ MNSResponse ret = new MNSResponse();
+ ret.setCode(mnsc_dataConstants.ILLEGAL_ARGUMENT);
+ return ret;
+ }
+ return mnscService.getMNSCache4HLB(appkey, version, env);
+ }
+
+ @Override
+ public MNSBatchResponse getMNSCacheByAppkeys(List appkeys, String protocol) throws TException {
+ if (null == appkeys || StringUtils.isEmpty(protocol)) {
+ return new MNSBatchResponse().setCode(mnsc_dataConstants.ILLEGAL_ARGUMENT);
+ }
+ return mnscService.getMNSCacheByAppkeys(appkeys, protocol);
+ }
+
+ @Override
+ public MNSResponse getProvidersByIP(String ip) throws TException {
+ Assert.hasText(ip, "ip不能为空");
+ return mnscService.getProvidersByIP(ip);
+ }
+
+ @Override
+ public MNSResponse getMNSCacheWithVersionCheck(MnsRequest mnsRequest) throws TException {
+ if (null == mnsRequest || StringUtils.isEmpty(mnsRequest.getAppkey()) || !Env.isValid(mnsRequest.getEnv())) {
+ MNSResponse invalidResponse = new MNSResponse();
+ invalidResponse.setCode(mnsc_dataConstants.ILLEGAL_ARGUMENT);
+ return invalidResponse;
+ }
+ return mnscService.getMnsc(mnsRequest);
+ }
+
+ @Override
+ public AppKeyListResponse getAppkeyListByIP(String ip) throws TException {
+ AppKeyListResponse ret = new AppKeyListResponse();
+ if (StringUtils.isEmpty(ip)) {
+ ret.setCode(400);
+ } else {
+ List appkeys = mnscService.getAppkeyListByIP(ip.trim());
+ ret.setCode(200).setAppKeyList(appkeys);
+ }
+ return ret;
+ }
+}
diff --git a/nsc/src/main/java/com/meituan/octo/mnsc/web/api/ApiController.java b/nsc/src/main/java/com/meituan/octo/mnsc/web/api/ApiController.java
new file mode 100644
index 0000000..884b98e
--- /dev/null
+++ b/nsc/src/main/java/com/meituan/octo/mnsc/web/api/ApiController.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2011-2018, Meituan Dianping. All Rights Reserved.
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+package com.meituan.octo.mnsc.web.api;
+
+import com.meituan.octo.mns.util.ProcessInfoUtil;
+import com.meituan.octo.mnsc.model.Env;
+import com.meituan.octo.mnsc.service.apiService;
+import com.meituan.octo.mnsc.service.mnscService;
+import com.meituan.octo.mnsc.utils.api;
+import com.meituan.octo.mnsc.utils.ipCommon;
+import com.meituan.octo.mnsc.utils.mnscCommon;
+import com.octo.mnsc.idl.thrift.model.AppKeyListResponse;
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Controller;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.springframework.web.bind.annotation.*;
+
+@Controller
+@RequestMapping("/api")
+public class ApiController {
+ private static final Logger LOG = LoggerFactory.getLogger(ApiController.class);
+ private static final String SENTINEL = ProcessInfoUtil.getSgsentinelAppkey();
+
+ @RequestMapping(value = "/monitor/alive")
+ @ResponseBody
+ public Map monitorAlive() {
+ Map result = new HashMap(1);
+ result.put("status", "ok");
+ return result;
+ }
+
+ @RequestMapping(value = "/servicelist", method = RequestMethod.GET, produces = "application/json")
+ @ResponseBody
+ public String getServiceList(@RequestParam("appkey") String appkey,
+ @RequestParam("env") String env,
+ @RequestParam("ip") String ip) {
+ //all parameters are required.
+ try {
+ if (!SENTINEL.equals(appkey)) {
+ return api.errorJson(400, "appkey currently only supports com.sankuai.inf.sgsentinel");
+
+ }
+
+ if (StringUtils.isEmpty(ip) || !(ipCommon.checkIP(ip.trim()))) {
+ return api.errorJson(400, "ip invalid");
+ }
+ if (!Env.isValid(env.trim())) {
+ return api.errorJson(400, "env invalid");
+ }
+
+ return apiService.getServiceList(appkey, env.trim(), ip.trim());
+ } catch (Exception e) {
+ LOG.error("/api/servicelist error ", e);
+ return api.errorJson(500, "server error");
+ }
+ }
+
+ @RequestMapping(value = "/{ip}/appkeylist", method = RequestMethod.GET, produces = "application/json")
+ @ResponseBody
+ public String getAppkeyList(@PathVariable("ip") String ip) {
+ AppKeyListResponse ret = new AppKeyListResponse();
+ if (StringUtils.isEmpty(ip)) {
+ ret.setCode(400);
+ } else {
+ List appkeys = mnscService.getAppkeyListByIP(ip.trim());
+ ret.setCode(200).setAppKeyList(appkeys);
+ }
+ return api.dataJson(ret.getCode(), ret.getAppKeyList());
+ }
+
+
+ @RequestMapping(value = "/allappkeys", method = RequestMethod.GET, produces = "application/json")
+ @ResponseBody
+ public String getAppkeys() {
+ return api.dataJson200(mnscCommon.allAppkeysList());
+ }
+}
\ No newline at end of file
diff --git a/nsc/src/main/java/com/meituan/octo/mnsc/web/api/ProvidersController.java b/nsc/src/main/java/com/meituan/octo/mnsc/web/api/ProvidersController.java
new file mode 100644
index 0000000..f065361
--- /dev/null
+++ b/nsc/src/main/java/com/meituan/octo/mnsc/web/api/ProvidersController.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2011-2018, Meituan Dianping. All Rights Reserved.
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+package com.meituan.octo.mnsc.web.api;
+
+import com.meituan.octo.mnsc.dataCache.appProviderDataCache;
+import com.meituan.octo.mnsc.dataCache.appProviderHttpDataCache;
+import com.meituan.octo.mnsc.model.Env;
+import com.meituan.octo.mnsc.service.apiProviders;
+import com.meituan.octo.mnsc.utils.api;
+import com.octo.naming.common.thrift.model.SGService;
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+
+@Controller
+@RequestMapping("/api/providers")
+public class ProvidersController {
+ private static final Logger LOG = LoggerFactory.getLogger(ProvidersController.class);
+ private static final String HTTP = "http";
+ private static final String THRIFT = "thrift";
+
+ @RequestMapping(value = "", method = RequestMethod.GET, produces = "application/json")
+ @ResponseBody
+ public String getProviders(@RequestParam("appkey") String appkey,
+ @RequestParam("env") int env,
+ @RequestParam("protocol") String protocol) {
+ try {
+ if (StringUtils.isEmpty(appkey)) {
+ return api.errorJson(400, "appkey is not allowed to empty");
+ }
+
+ if (!Env.isValid(env)) {
+ return api.errorJson(400, "env invalid");
+ }
+
+ if (StringUtils.isEmpty(protocol)) {
+ return api.errorJson(400, "protocol is not allowed to empty");
+ }
+
+ if (THRIFT.equalsIgnoreCase(protocol)) {
+ return api.dataJson(appProviderDataCache.getProviderCache(appkey, Env.apply(env).toString(),false));
+ } else if (HTTP.equalsIgnoreCase(protocol)) {
+ return api.dataJson(appProviderHttpDataCache.getProviderHttpCache(appkey, Env.apply(env).toString(),false));
+ } else {
+ return apiProviders.getProviders(appkey.trim(), env, protocol);
+ }
+ } catch (Exception e) {
+ LOG.error("/api/providers error ", e);
+ return api.errorJson(500, "server error");
+ }
+ }
+
+ @RequestMapping(value = "", method = RequestMethod.POST, produces = "application/json")
+ @ResponseBody
+ public String postProviders(@RequestBody List providers) {
+ return api.jsonStr(apiProviders.postProviders(providers));
+ }
+
+ @RequestMapping(value = "", method = RequestMethod.DELETE, produces = "application/json")
+ @ResponseBody
+ public String deleteProviders(@RequestBody List providers) {
+ return api.jsonStr(apiProviders.deleteProviders(providers));
+ }
+
+ @RequestMapping(value = "/delete", method = RequestMethod.POST, produces = "application/json")
+ @ResponseBody
+ public String deletePostProviders(@RequestBody List providers) {
+ // client may be able to delete the nodes because the jdk bug, so add a new API. more detail see: http://bugs.java.com/view_bug.do?bug_id=8148558
+ return api.jsonStr(apiProviders.deleteProviders(providers));
+ }
+}
diff --git a/nsc/src/main/profiles/online/log4j2.xml b/nsc/src/main/profiles/online/log4j2.xml
new file mode 100644
index 0000000..893540c
--- /dev/null
+++ b/nsc/src/main/profiles/online/log4j2.xml
@@ -0,0 +1,24 @@
+
+
+
+ com.meituan.octo.mnsc
+ mnsc-server
+
+
+
+
+ %d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/nsc/src/main/profiles/test/log4j2.xml b/nsc/src/main/profiles/test/log4j2.xml
new file mode 100644
index 0000000..4e4c30a
--- /dev/null
+++ b/nsc/src/main/profiles/test/log4j2.xml
@@ -0,0 +1,28 @@
+
+
+
+ com.meituan.octo.mnsc
+ mnsc-server
+
+
+
+
+
+
+
+ %d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/nsc/src/main/resources/application.yaml b/nsc/src/main/resources/application.yaml
new file mode 100644
index 0000000..16e6559
--- /dev/null
+++ b/nsc/src/main/resources/application.yaml
@@ -0,0 +1,2 @@
+server:
+ port: 8911
\ No newline at end of file
diff --git a/nsc/src/main/resources/applicationContext.xml b/nsc/src/main/resources/applicationContext.xml
new file mode 100644
index 0000000..22d5410
--- /dev/null
+++ b/nsc/src/main/resources/applicationContext.xml
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/nsc/src/main/resources/webmvc-config.xml b/nsc/src/main/resources/webmvc-config.xml
new file mode 100644
index 0000000..cc918f8
--- /dev/null
+++ b/nsc/src/main/resources/webmvc-config.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/nsc/src/main/scala/com/meituan/octo/mnsc/bootstrap/bootstrap.scala b/nsc/src/main/scala/com/meituan/octo/mnsc/bootstrap/bootstrap.scala
new file mode 100644
index 0000000..227e8d1
--- /dev/null
+++ b/nsc/src/main/scala/com/meituan/octo/mnsc/bootstrap/bootstrap.scala
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2011-2018, Meituan Dianping. All Rights Reserved.
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+package com.meituan.octo.mnsc.bootstrap
+
+import com.meituan.octo.mnsc.dataCache.{appProviderDataCache, appProviderHttpDataCache}
+import com.meituan.octo.mnsc.model.Path
+import com.meituan.octo.mnsc.zkWatcher.appProviderWatcher
+import org.joda.time.DateTime
+
+class bootstrap {
+ def init() = {
+ val start = new DateTime().getMillis
+ println(s"start to init.")
+ appProviderDataCache.renewAllProviderForce(Path.provider.toString, true)
+ appProviderHttpDataCache.renewAllProviderForce(Path.providerHttp.toString, true)
+
+ appProviderWatcher.initWatcher()
+
+ appProviderHttpDataCache.doRenew()
+ appProviderDataCache.doRenew()
+ val end = new DateTime().getMillis
+ println(s"finish to init --> cost ${end - start}")
+ }
+}
diff --git a/nsc/src/main/scala/com/meituan/octo/mnsc/dataCache/appProviderDataCache.scala b/nsc/src/main/scala/com/meituan/octo/mnsc/dataCache/appProviderDataCache.scala
new file mode 100644
index 0000000..6ef73b4
--- /dev/null
+++ b/nsc/src/main/scala/com/meituan/octo/mnsc/dataCache/appProviderDataCache.scala
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2011-2018, Meituan Dianping. All Rights Reserved.
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+package com.meituan.octo.mnsc.dataCache
+
+import java.util.concurrent.{ConcurrentHashMap, Executors, TimeUnit}
+
+import com.meituan.octo.mnsc.model.{Env, Path, ServerType}
+import com.meituan.octo.mnsc.remote.zk
+import com.meituan.octo.mnsc.utils.mnscCommon
+import com.meituan.octo.mnsc.model.service.CacheValue
+import org.slf4j.LoggerFactory
+
+import scala.collection.JavaConverters._
+import scala.collection.concurrent.Map
+
+/**
+ * ZK provider节点下数据缓存
+ */
+object appProviderDataCache extends providerBaseCache {
+ private val LOG = LoggerFactory.getLogger(appProviderDataCache.getClass)
+
+ //服务的provider缓存,key为"appkey|env"
+ private val providerCache = new ConcurrentHashMap[String, CacheValue]() asScala
+
+ private val ipInfoCache = new ConcurrentHashMap[String, scala.collection.Set[String]]() asScala
+
+ private var pullCount4Provider = 0
+
+ private val scheduler = Executors.newScheduledThreadPool(2)
+
+ //获取provider cache
+ def getProviderCache(appkey: String, env: String, isSearchZK: Boolean) = {
+ val cache = getCache(appkey)
+ val providers = cache.get(getCacheKey(appkey, env))
+ if (providers.isEmpty && isSearchZK) {
+ LOG.debug(s"providerCache don't exist $appkey|$env")
+ val (version, _) = zk.getNodeVersion(s"${mnscCommon.rootPre}/$env/$appkey/${Path.provider.toString}")
+ updateProviderCache(version, appkey, env, Path.provider.toString)
+ cache.get(getCacheKey(appkey, env))
+
+ } else {
+ providers
+ }
+ }
+
+ override protected def getCache(appkey: String) = {
+ providerCache
+ }
+
+ override protected def getCache(): Map[String, CacheValue] = providerCache
+
+ override protected def getIpInfoCache(): Map[String, scala.collection.Set[String]] = ipInfoCache
+
+ //周期进行强同步和弱同步
+ def doRenew() = {
+ val now = System.currentTimeMillis() / mnscCommon.initDelay4Provider
+ val init = 60 - (now % 60)
+ LOG.info(s"init doRenew on $now with delay $init")
+ //provider定时同步任务
+ scheduler.scheduleAtFixedRate(new Runnable {
+ def run(): Unit = {
+ try {
+ if (0 == pullCount4Provider) {
+ LOG.info("renewAllProviderForce start. count = {}", pullCount4Provider + 1)
+ val startProvider = System.currentTimeMillis()
+ renewAllProviderForce(Path.provider.toString, true)
+ val endProvider = System.currentTimeMillis()
+ LOG.info("renewAllProviderForce cost {}", endProvider - startProvider)
+ //逐出被删除的appKey
+ deleteNonexistentAppKey()
+ } else {
+ LOG.info(s"renewAllProvider start. count = {}", pullCount4Provider + 1)
+ val startProvider = System.currentTimeMillis()
+ renewAllProvider(providerCache, Path.provider.toString)
+ val endProvider = System.currentTimeMillis()
+ LOG.info(s"renewAllProvider cost {}", endProvider - startProvider)
+ }
+ pullCount4Provider = (pullCount4Provider + 1) % mnscCommon.forceBorder4Provider
+ } catch {
+ case e: Exception => LOG.error(s"renew localCache fail.", e)
+ }
+ }
+ }, init, mnscCommon.renewInterval4Provider * 6, TimeUnit.SECONDS)
+
+ scheduler.scheduleWithFixedDelay(new Runnable {
+ def run(): Unit = {
+ try {
+ LOG.info(s"renew ip to appkeys map start.")
+ val startProvider = System.currentTimeMillis()
+
+ ipInfoCache.foreach {
+ item =>
+ val removeAppkey = scala.collection.mutable.ArrayBuffer[String]()
+ item._2.foreach {
+ app =>
+ val isExists = Env.values.exists{
+ env =>
+ val key = s"$app|$env"
+ providerCache.keySet.contains(key) && providerCache(key).SGServices.exists(_.ip == item._1)
+ }
+ if (!isExists) {
+ removeAppkey += app
+ }
+ }
+ val newCache = item._2 -- removeAppkey
+ ipInfoCache.update(item._1, newCache)
+ }
+ val endProvider = System.currentTimeMillis()
+ LOG.info(s"renew ip to appkeys map start cost ${endProvider - startProvider}")
+ } catch {
+ case e: Exception => LOG.error(s"renew ip to appkeys map start fail.", e)
+ }
+ }
+ }, init, 10, TimeUnit.MINUTES)
+ }
+
+
+ def getProvidersByIP(ip: String) = {
+ val list = providerCache.flatMap(_._2.SGServices.filter(_.ip.equals(ip)))
+ list.foreach(_.setServerType(ServerType.thrift.id))
+ list.toList
+ }
+}
\ No newline at end of file
diff --git a/nsc/src/main/scala/com/meituan/octo/mnsc/dataCache/appProviderHttpDataCache.scala b/nsc/src/main/scala/com/meituan/octo/mnsc/dataCache/appProviderHttpDataCache.scala
new file mode 100644
index 0000000..4347cf8
--- /dev/null
+++ b/nsc/src/main/scala/com/meituan/octo/mnsc/dataCache/appProviderHttpDataCache.scala
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 2011-2018, Meituan Dianping. All Rights Reserved.
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+package com.meituan.octo.mnsc.dataCache
+
+import java.util.concurrent.{ConcurrentHashMap, Executors, TimeUnit}
+
+import com.meituan.octo.mnsc.model.{Env, Path, ServerType}
+import com.meituan.octo.mnsc.model.service.CacheValue
+import com.meituan.octo.mnsc.remote.zk
+import com.meituan.octo.mnsc.utils.mnscCommon
+import org.joda.time.DateTime
+import org.slf4j.{Logger, LoggerFactory}
+
+import scala.collection.JavaConverters._
+import scala.collection.concurrent.Map
+
+object appProviderHttpDataCache extends providerBaseCache {
+ private val LOG: Logger = LoggerFactory.getLogger(appProviderHttpDataCache.getClass)
+ private val pre = mnscCommon.rootPre
+
+ //服务的provider-http缓存,key为"appkey|env"
+ private val providerHttpCache = new ConcurrentHashMap[String, CacheValue]() asScala
+
+ private val ipInfoCache = new ConcurrentHashMap[String, scala.collection.Set[String]]() asScala
+
+ private var pullCount4ProviderHttp = 0
+
+ private val scheduler = Executors.newScheduledThreadPool(1)
+
+ //周期进行强同步和弱同步
+ def doRenew() = {
+ val now = System.currentTimeMillis() / mnscCommon.initDelay4HttpProperties
+ val init = 60 - (now % 60)
+ LOG.info(s"init doRenew on $now with delay $init")
+
+ //provider-http定时同步任务
+ scheduler.scheduleAtFixedRate(new Runnable {
+ def run(): Unit = {
+ try {
+ if (0 == pullCount4ProviderHttp) {
+ //For provider-http
+ LOG.info("renewAllProviderHTTPForce start")
+ val startProviderHTTP = new DateTime().getMillis
+ renewAllProviderForce(Path.providerHttp.toString, true)
+ val endProviderHTTP = new DateTime().getMillis
+ LOG.info(s"renewAllProviderHTTPForce cost ${endProviderHTTP - startProviderHTTP}")
+ //逐出被删除的appKey
+ deleteNonexistentAppKey()
+ } else {
+ LOG.info("renewAllProviderHTTP start")
+ val startProviderHTTP = new DateTime().getMillis
+ renewAllProvider(providerHttpCache, Path.providerHttp.toString)
+ val endProviderHTTP = new DateTime().getMillis
+ LOG.info(s"renewAllProviderHTTP cost ${endProviderHTTP - startProviderHTTP}")
+ }
+ pullCount4ProviderHttp = (pullCount4ProviderHttp + 1) % mnscCommon.forceBorder4ProviderHttp
+ } catch {
+ case e: Exception => LOG.error(s"renew localCache fail.", e)
+ }
+ }
+ }, init, mnscCommon.renewInterval4ProviderHttp * 6, TimeUnit.SECONDS)
+
+ scheduler.scheduleWithFixedDelay(new Runnable {
+ def run(): Unit = {
+ try {
+ LOG.info(s"renewHTTP ip to appkeys map start.")
+ val startProvider = System.currentTimeMillis()
+
+ ipInfoCache.foreach {
+ item =>
+ val removeAppkey = scala.collection.mutable.ArrayBuffer[String]()
+ item._2.foreach {
+ app =>
+ val isExists = Env.values.exists{
+ env =>
+ val key = s"$app|$env"
+ providerHttpCache.keySet.contains(key) && providerHttpCache(key).SGServices.exists(_.ip == item._1)
+ }
+ if (!isExists) {
+ removeAppkey += app
+ }
+ }
+ val newCache = item._2 -- removeAppkey
+ ipInfoCache.update(item._1, newCache)
+ }
+ val endProvider = System.currentTimeMillis()
+ LOG.info(s"renewHTTP ip to appkeys map start cost ${endProvider - startProvider}")
+ } catch {
+ case e: Exception => LOG.error(s"renewHTTP ip to appkeys map start fail.", e)
+ }
+ }
+ }, init+1, 10, TimeUnit.MINUTES)
+ }
+
+ //获取provider-http cache
+ def getProviderHttpCache(appkey: String, env: String, isSearchZK: Boolean) = {
+ val providers = providerHttpCache.get(getCacheKey(appkey, env))
+ if (providers.isEmpty && isSearchZK) {
+ LOG.debug(s"providerHttpCache don't exist $appkey|$env")
+ val (version, _) = zk.getNodeVersion(s"${mnscCommon.rootPre}/$env/$appkey/${Path.providerHttp.toString}")
+ updateProviderCache(version, appkey, env, Path.providerHttp.toString)
+ providerHttpCache.get(s"$appkey|$env")
+ } else {
+ providers
+ }
+ }
+
+ def getProvidersByIP(ip: String) = {
+ val list = providerHttpCache.flatMap(_._2.SGServices.filter(_.ip.equals(ip)))
+ list.foreach(_.setServerType(ServerType.http.id))
+ list.toList
+ }
+
+ override protected def getCache(appkey: String): Map[String, CacheValue] = providerHttpCache
+
+ override protected def getCache() = providerHttpCache
+
+ override protected def getIpInfoCache(): Map[String, scala.collection.Set[String]] = ipInfoCache
+}
+
+
diff --git a/nsc/src/main/scala/com/meituan/octo/mnsc/dataCache/appProvidersCommCache.scala b/nsc/src/main/scala/com/meituan/octo/mnsc/dataCache/appProvidersCommCache.scala
new file mode 100644
index 0000000..c4632ae
--- /dev/null
+++ b/nsc/src/main/scala/com/meituan/octo/mnsc/dataCache/appProvidersCommCache.scala
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2011-2018, Meituan Dianping. All Rights Reserved.
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+package com.meituan.octo.mnsc.dataCache
+
+import java.util.concurrent.ConcurrentHashMap
+
+import com.meituan.octo.mnsc.model.Env
+import com.meituan.octo.mnsc.remote.zk
+import com.meituan.octo.mnsc.utils.zkCommon
+import com.meituan.octo.mnsc.model.service.{CacheData, ProviderNode}
+import org.slf4j.{Logger, LoggerFactory}
+import play.api.libs.json.Json
+
+import scala.collection.JavaConverters._
+
+/**
+ * ZK provider节点下数据缓存
+ */
+object appProvidersCommCache {
+ private val LOG: Logger = LoggerFactory.getLogger(appProvidersCommCache.getClass)
+
+ //服务的provider缓存,key为"appkey|env"
+ private val providerCache = new ConcurrentHashMap[String, CacheData]() asScala
+
+ //获取provider cache
+ def getProviderCache(appkey: String, env: Int, protocol: String): CacheData = {
+ val strEnv = Env(env).toString
+ val providers = providerCache.get(s"$appkey|$strEnv|$protocol")
+ providers match {
+ case Some(value) => {
+ val curTime = System.currentTimeMillis() / 1000
+ if (10 > curTime - providers.get.lastGetTime) {
+ providers.get
+ } else {
+ LOG.info(s"providerCache $appkey|$strEnv|$protocol is expired")
+ getProviderPar(appkey, strEnv, protocol)
+ }
+ }
+ case None =>
+ LOG.info(s"providerCache don't exist $appkey|$strEnv|$protocol")
+ getProviderPar(appkey, strEnv, protocol)
+ }
+ }
+
+ def getProviderPar(appkey: String, env: String, protocol: String) = {
+ val path = zkCommon.getProtocolPath(appkey, env, protocol)
+ val (version, _) = zk.getNodeVersion(path)
+ val nodeList = zk.children(path)
+ val versionNew = zk.getNodeVersion(path)
+ if (version != versionNew) {
+ LOG.warn(s"version changed during zk.children($path) from $version to $versionNew")
+ }
+ val result = scala.collection.mutable.ArrayBuffer[ProviderNode]()
+ nodeList.foreach(
+ node => {
+ val nodePath = s"$path/$node"
+ try {
+ val data = zk.getData(nodePath)
+ Json.parse(data).validate[ProviderNode].asOpt match {
+ case Some(x) =>
+ result.synchronized {
+ result += x
+ }
+ case _ => //do nothing
+ }
+ } catch {
+ case e: Exception => LOG.error(s"get path $nodePath or Json.validate error ${e.getMessage}", e)
+ }
+ }
+ )
+ val cacheData = CacheData(version, result.toList)
+ providerCache.update(s"$appkey|$env|$protocol", cacheData)
+ cacheData
+ }
+
+}
\ No newline at end of file
diff --git a/nsc/src/main/scala/com/meituan/octo/mnsc/dataCache/providerBaseCache.scala b/nsc/src/main/scala/com/meituan/octo/mnsc/dataCache/providerBaseCache.scala
new file mode 100644
index 0000000..0a53f7a
--- /dev/null
+++ b/nsc/src/main/scala/com/meituan/octo/mnsc/dataCache/providerBaseCache.scala
@@ -0,0 +1,197 @@
+/*
+ * Copyright (c) 2011-2018, Meituan Dianping. All Rights Reserved.
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+package com.meituan.octo.mnsc.dataCache
+
+import com.meituan.octo.mnsc.model
+import com.meituan.octo.mnsc.model.Env
+import com.meituan.octo.mnsc.remote.zk
+import com.meituan.octo.mnsc.utils.mnscCommon
+import com.meituan.octo.mnsc.model.service.{CacheValue, ProviderNode}
+import com.octo.naming.common.thrift.model.SGService
+import org.apache.commons.lang.StringUtils
+import org.joda.time.DateTime
+import org.slf4j.LoggerFactory
+import play.api.libs.json.Json
+
+import scala.collection.JavaConverters._
+
+
+abstract class providerBaseCache {
+ private val LOG = LoggerFactory.getLogger(this.getClass)
+
+ def updateProviderCache(providerVersion: String, appkey: String, env: String, providerPath: String, isPar: Boolean = false) = {
+ val path = s"${mnscCommon.rootPre}/$env/$appkey/$providerPath"
+ if (StringUtils.isNotEmpty(providerVersion)) {
+ try {
+ val nodeList = zk.client().getChildren.forPath(path).asScala
+ val result = scala.collection.mutable.ArrayBuffer[SGService]()
+ val parList = if (isPar) {
+ nodeList.par
+ } else {
+ nodeList
+ }
+
+ val ipToAppkey = getIpInfoCache()
+ parList.foreach(
+ node => {
+ val nodePath = s"$path/$node"
+ val data = zk.client.getData.forPath(nodePath)
+ val dataUTF8 = if (null == data) "" else new String(data, "utf-8")
+ if (dataUTF8.nonEmpty) {
+ Json.parse(dataUTF8).validate[ProviderNode].asOpt match {
+ case Some(x) =>
+ val service = model.service.ProviderNode2SGService(x)
+ result.synchronized {
+ result += service
+ }
+
+ if (service.ip.nonEmpty) {
+ val v = if (ipToAppkey.keySet.contains(service.ip)) {
+ ipToAppkey(service.ip) + service.appkey
+ } else {
+ scala.collection.Set[String](service.appkey)
+ }
+
+ ipToAppkey.update(service.ip, v)
+ }
+ case _ => //do nothing
+ }
+ }
+ }
+ )
+ val currentCache = getCache(appkey)
+ val cacheValue = CacheValue(providerVersion, result.toList)
+ currentCache.update(getCacheKey(appkey, env), cacheValue)
+ cacheValue
+ } catch {
+ case e: Exception =>
+ LOG.error(s"fail to update cache, appkey=$appkey env=$env", e)
+ null
+ }
+ } else {
+ null
+ }
+ }
+
+ protected def getCache(appkey: String): scala.collection.concurrent.Map[String, CacheValue]
+
+ protected def getCache(): scala.collection.concurrent.Map[String, CacheValue]
+
+ protected def getIpInfoCache(): scala.collection.concurrent.Map[String, scala.collection.Set[String]]
+
+ protected def getCacheKey(appkey: String, env: String) = s"$appkey|$env"
+
+ //若在providerCache中发现不存在的appkey,删除之
+ def deleteNonexistentAppKey() = {
+ val cache = getCache()
+ val newAppkeys = mnscCommon.allApp()
+ val cacheAppkeys = getAppkeysByCacheKeySet(cache.keySet)
+ LOG.info(s"[deleteNonexistentAppKey] providerCache=${cache.keySet.size} cacheAppkeys=${cacheAppkeys.size} newAppkeys=${newAppkeys.size}")
+
+ cacheAppkeys.toList.filter(!newAppkeys.contains(_)).foreach {
+ appkey =>
+ Env.values.foreach {
+ env =>
+ cache.remove(s"$appkey|$env")
+ LOG.info(s"[deleteNonexistentAppKey] providerCache delete $appkey|$env")
+ }
+ }
+ }
+
+ //定时任务强同步pull provider
+ def renewAllProviderForce(providerPathStr: String, isPar: Boolean) = {
+ val apps = mnscCommon.allAppkeys(isPar)
+ val start = new DateTime().getMillis
+ Env.values.foreach {
+ env =>
+ apps.foreach {
+ appkey =>
+ val path = s"${mnscCommon.rootPre}/$env/$appkey/$providerPathStr"
+ val (version, _) = zk.getNodeVersion(path)
+ if (null == version) {
+ LOG.error(s"renewAllProviderForce failed, $path don't exist")
+ } else {
+ updateProviderCache(version, appkey, env.toString, providerPathStr)
+ }
+ }
+ }
+ val end = new DateTime().getMillis
+ LOG.info(s"renewProviderForce--> path=${providerPathStr} apps.length=${apps.length} cost ${end - start}")
+
+ }
+
+ private def getAppkeysByCacheKeySet(appkeySets: scala.collection.Set[String]) = appkeySets.map(x => x.stripSuffix("|prod").stripSuffix("|stage").stripSuffix("|test"))
+
+ //定时任务弱同步pull provider
+ protected def renewAllProvider(cache: scala.collection.concurrent.Map[String, CacheValue], providerPathStr: String) = {
+ val apps = mnscCommon.allApp().par
+ apps.foreach {
+ appkey =>
+ Env.values.foreach {
+ env =>
+ val providers = cache.get(getCacheKey(appkey, env.toString))
+ providers match {
+ case Some(value) =>
+ val path = s"${mnscCommon.rootPre}/$env/$appkey/$providerPathStr"
+ val (version, _) = zk.getNodeVersion(path)
+ if (null == version) {
+ LOG.warn(s"renewAllProvider failed, $path don't exist")
+ } else {
+ if (version != value.version) {
+ updateProviderCache(version, appkey, env.toString, providerPathStr)
+ }
+ }
+ case None =>
+ LOG.debug(s"reload providerCache is empty: $appkey|$env")
+ }
+ }
+ }
+ }
+
+
+ //watcher触发执行动作
+ def mnscWatcherAction(appkey: String, env: String, providerPathStr: String) = {
+ val providers = getCache(appkey).get(getCacheKey(appkey, env))
+ val path = s"${mnscCommon.rootPre}/$env/$appkey/$providerPathStr"
+ val (version, _) = zk.getNodeVersion(path)
+ providers match {
+ case Some(value) =>
+ if (version != value.version) {
+ updateProviderCache(version, appkey, env, providerPathStr)
+ }
+ case None =>
+ updateProviderCache(version, appkey, env, providerPathStr)
+ }
+ }
+
+ def getAppkeyListByIP(ip: String) = {
+ val cache = getCache()
+ val keySet = cache.filter(_._2.SGServices.foldLeft(false) { (result, item) =>
+ result || StringUtils.equals(ip, item.ip)
+ }).keySet
+ getAppkeysByCacheKeySet(keySet)
+ }
+
+ def getAppkeysByIP(ip: String) = {
+ getIpInfoCache().getOrElse(ip, Nil)
+ }
+}
diff --git a/nsc/src/main/scala/com/meituan/octo/mnsc/model/Env.scala b/nsc/src/main/scala/com/meituan/octo/mnsc/model/Env.scala
new file mode 100644
index 0000000..e0de759
--- /dev/null
+++ b/nsc/src/main/scala/com/meituan/octo/mnsc/model/Env.scala
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2011-2018, Meituan Dianping. All Rights Reserved.
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+package com.meituan.octo.mnsc.model
+
+import com.meituan.octo.mns.util.ProcessInfoUtil
+import org.apache.commons.lang.StringUtils
+
+object Env extends Enumeration {
+ type Env = Value
+ val test = Value(1)
+ val stage = Value(2)
+ val prod = Value(3)
+
+ def isValid(env: String) = {
+ if (StringUtils.isEmpty(env)) {
+ false
+ } else {
+ if (ProcessInfoUtil.isLocalHostOnline) {
+ onlineEnv.contains(env)
+ } else {
+ offlineEnv.contains(env)
+ }
+ }
+ }
+
+ def strConvertEnum(env:String)={
+ val envEnum= if (ProcessInfoUtil.isLocalHostOnline){
+ onlineEnv.get(env)
+ }else{
+ offlineEnv.get(env)
+ }
+ envEnum.get
+ }
+
+ private val offlineEnv = Map(
+ "ppe" -> stage,
+ "dev" -> prod,
+ "test" -> test,
+ "prod" -> prod,
+ "stage" -> stage,
+ "beta" -> stage,
+ "1" -> test,
+ "2" -> stage,
+ "3" -> prod
+ )
+ private val onlineEnv = Map(
+ "prod" -> prod,
+ "staging" -> stage,
+ "stage" -> stage,
+ "test" -> test,
+ "1" -> test,
+ "2" -> stage,
+ "3" -> prod
+ )
+
+ def isValid(env: Int) = values.map(_.id).contains(env)
+}
diff --git a/nsc/src/main/scala/com/meituan/octo/mnsc/model/Path.scala b/nsc/src/main/scala/com/meituan/octo/mnsc/model/Path.scala
new file mode 100644
index 0000000..53fa4c4
--- /dev/null
+++ b/nsc/src/main/scala/com/meituan/octo/mnsc/model/Path.scala
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2011-2018, Meituan Dianping. All Rights Reserved.
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+package com.meituan.octo.mnsc.model
+
+object Path extends Enumeration {
+ type Path = Value
+ val provider = Value("provider")
+ val providerHttp = Value("provider-http")
+}
diff --git a/nsc/src/main/scala/com/meituan/octo/mnsc/model/ServerType.scala b/nsc/src/main/scala/com/meituan/octo/mnsc/model/ServerType.scala
new file mode 100644
index 0000000..b8c2c71
--- /dev/null
+++ b/nsc/src/main/scala/com/meituan/octo/mnsc/model/ServerType.scala
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2011-2018, Meituan Dianping. All Rights Reserved.
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+package com.meituan.octo.mnsc.model
+
+object ServerType extends Enumeration {
+ type ServerType= Value
+ val thrift = Value(0,"provider")
+ val http = Value(1,"provider-http")
+}
diff --git a/nsc/src/main/scala/com/meituan/octo/mnsc/model/service.scala b/nsc/src/main/scala/com/meituan/octo/mnsc/model/service.scala
new file mode 100644
index 0000000..4f2e8ea
--- /dev/null
+++ b/nsc/src/main/scala/com/meituan/octo/mnsc/model/service.scala
@@ -0,0 +1,163 @@
+/*
+ * Copyright (c) 2011-2018, Meituan Dianping. All Rights Reserved.
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+package com.meituan.octo.mnsc.model
+
+import com.octo.naming.common.thrift.model.SGService
+import org.apache.commons.lang3.StringUtils
+import play.api.libs.json.Json.JsValueWrapper
+import play.api.libs.json._
+import scala.collection.JavaConverters._
+
+
+object service {
+
+ case class ServiceDetail(unifiedProto: Int)
+
+ // enabled 0 启用 1 停用 trace 0 关闭 1 开启
+ case class ProviderNode(appkey: String, version: String, ip: String, port: Int,
+ weight: Int, fweight: Option[Double], status: Int, role: Int, env: Int,
+ lastUpdateTime: Long, serverType: Option[Int] = Some(0), protocol: Option[String] = Some(""),
+ serviceInfo: Option[Map[String, ServiceDetail]], heartbeatSupport: Option[Int] = Some(0)) {
+ override def toString = try {
+ val envir = Env(env)
+ s"""{"appkey":"${appkey}","version":"${version}","ip":"${ip},"port":${port},"weight":${weight},"fweight":$fweight,"status:":${status},"role":$role,"envir":"${envir}","lastUpdateTime":${lastUpdateTime},"serverType":$serverType,"protocol":"${protocol},"serviceInfo":"${serviceInfo}","heartbeatSupport":"${heartbeatSupport}"}"""
+ } catch {
+ case e: Exception => ""
+ }
+ }
+
+ case class AppkeyTs(appkey: String, lastUpdateTime: Long)
+
+ implicit val ApppkeyTsReads = Json.reads[AppkeyTs]
+ implicit val ApppkeyTsWrites = Json.writes[AppkeyTs]
+
+ implicit val serviceDetailRepads = Json.reads[ServiceDetail]
+ implicit val serviceDetailWrites = Json.writes[ServiceDetail]
+
+
+ implicit val mapRepads: Reads[Map[String, ServiceDetail]] = new Reads[Map[String, ServiceDetail]] {
+ override def reads(json: JsValue): JsResult[Map[String, ServiceDetail]] = JsSuccess {
+ json.as[JsObject].value.map {
+ case (k, v) => (k, ServiceDetail(
+ (v \ "unifiedProto").as[Int]
+ ))
+ }.toMap
+ }
+ }
+ implicit val mapWrites: Writes[Map[String, ServiceDetail]] = new Writes[Map[String, ServiceDetail]] {
+ def writes(map: Map[String, ServiceDetail]): JsValue =
+ Json.obj(map.map { case (s, o) =>
+ val ret: (String, JsValueWrapper) = s -> Json.toJson(o)
+ ret
+ }.toSeq: _*)
+ }
+
+
+ case class ProviderDel(appkey: String, protocol: String, ip: String, prot: Int, env: Int)
+
+ case class Provider(appkey: String, lastUpdateTime: Long)
+
+ implicit val providerNodeReads = Json.reads[ProviderNode]
+ implicit val providerNodeWrites = Json.writes[ProviderNode]
+
+ implicit val providerReads = Json.reads[Provider]
+ implicit val providerWrites = Json.writes[Provider]
+
+ implicit val providerDelReads = Json.reads[ProviderDel]
+ implicit val providerDelWrites = Json.writes[ProviderDel]
+
+
+ case class NodeState(mtime: Long, cversion: Long, version: Long)
+
+ implicit val nodeStateR = Json.reads[NodeState]
+ implicit val nodeStateW = Json.writes[NodeState]
+
+ case class CacheValue(version: String, SGServices: List[SGService])
+
+ case class CacheData(version: String, Providers: List[ProviderNode], lastGetTime: Long = System.currentTimeMillis() / 1000)
+
+ // version mtime|cversion|version
+
+ def ProviderNode2SGService(node: ProviderNode) = {
+
+ val service = new SGService()
+ service.setAppkey(node.appkey)
+ .setVersion(node.version)
+ .setIp(node.ip)
+ .setPort(node.port)
+ .setWeight(node.weight)
+ .setStatus(node.status)
+ .setRole(node.role)
+ .setEnvir(node.env)
+ .setLastUpdateTime(node.lastUpdateTime.toInt)
+ .setFweight(node.fweight.getOrElse(0))
+ .setServerType(node.serverType.getOrElse(0))
+ .setProtocol(node.protocol.getOrElse(""))
+ .setHeartbeatSupport(node.heartbeatSupport.getOrElse(0).toByte)
+ .setServiceInfo(ProviderInfo2Info(node).asJava)
+ }
+
+
+ def SGService2ProviderNode(service: SGService) = {
+ val serviceInfo = if (null == service.serviceInfo) {
+ Some(Map[String, ServiceDetail]())
+ } else {
+ Some(SGServiceInfo2Info(service))
+ }
+ val protocolTemp = if (StringUtils.isEmpty(service.protocol)) None else Some(service.protocol)
+
+ ProviderNode(service.appkey,
+ service.version,
+ service.ip,
+ service.port,
+ service.weight,
+ Some(service.fweight),
+ service.status,
+ service.role,
+ service.envir,
+ service.lastUpdateTime,
+ Some(service.serverType),
+ protocolTemp,
+ serviceInfo = serviceInfo,
+ heartbeatSupport = Some(service.heartbeatSupport & 0xff)
+ )
+ }
+
+ private def ProviderInfo2Info(node: ProviderNode) = {
+ val info = node.serviceInfo.getOrElse(Map[String, ServiceDetail]())
+ info.map {
+ item =>
+ val value = new com.octo.naming.common.thrift.model.ServiceDetail()
+ value.setUnifiedProto(1 == item._2.unifiedProto)
+ (item._1 -> value)
+ }
+ }
+
+ private def SGServiceInfo2Info(service: SGService) = {
+ val serviceInfo = service.serviceInfo.asScala
+ val info = scala.collection.mutable.Map[String, ServiceDetail]()
+ serviceInfo.foreach { e =>
+ info.put(e._1, ServiceDetail(if (e._2.isUnifiedProto) 1 else 0))
+ }
+ info.toMap
+ }
+}
diff --git a/nsc/src/main/scala/com/meituan/octo/mnsc/remote/zk.scala b/nsc/src/main/scala/com/meituan/octo/mnsc/remote/zk.scala
new file mode 100644
index 0000000..9248862
--- /dev/null
+++ b/nsc/src/main/scala/com/meituan/octo/mnsc/remote/zk.scala
@@ -0,0 +1,213 @@
+/*
+ * Copyright (c) 2011-2018, Meituan Dianping. All Rights Reserved.
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+package com.meituan.octo.mnsc.remote
+
+import java.util
+
+import com.meituan.octo.mns.util.ProcessInfoUtil
+import com.meituan.octo.mnsc.utils.mnscCommon
+import org.apache.curator.framework.CuratorFrameworkFactory
+import org.apache.curator.framework.api.CuratorWatcher
+import org.apache.curator.retry.RetryUntilElapsed
+import org.apache.zookeeper.data._
+import org.slf4j.{Logger, LoggerFactory}
+
+import scala.collection.JavaConverters._
+import scala.util.control.Breaks
+
+
+object zk {
+ private val LOG: Logger = LoggerFactory.getLogger(zk.getClass)
+ private val singleHostCount = mnscCommon.singleHostCount4ZK
+ private var INDEX = 0
+ private val zkList = (1 to singleHostCount).flatMap(x => getZk).toList
+ private val zkWatcher = getWatcherZk
+ private val zkCount = zkList.length
+ private val zkClientLock = new Object()
+
+ private def getZk = {
+ getURLCn2.map {
+ host =>
+ val superClient = CuratorFrameworkFactory.builder.connectString(host).retryPolicy(new RetryUntilElapsed(3000, 2000)).build()
+ LOG.info("start zk client with " + host)
+ superClient.start()
+ superClient
+ }
+ }
+
+ private def getWatcherZk = {
+ val superClient = CuratorFrameworkFactory.builder.connectString(url).retryPolicy(new RetryUntilElapsed(3000, 2000)).build()
+ superClient.start()
+ superClient
+ }
+
+ private def getURLCn2 = {
+ val urlsArr = url.split(",")
+ val ret = new util.ArrayList[String]
+ var x = 0
+ while (x < urlsArr.length) {
+ var y = x + 1
+ while (y < urlsArr.length) {
+ ret.add(s"${urlsArr(x)},${urlsArr(y)}")
+ y += 1
+ }
+ x += 1
+ }
+ if (ret.isEmpty) {
+ ret.add(url)
+ }
+ ret.asScala
+ }
+
+ def client() = {
+ val loop = new Breaks
+ var curIndex = getZkIndex()
+ var ret = zkList(curIndex)
+ loop.breakable {
+ for (i <- 1 to zkCount) {
+ ret = zkList(curIndex)
+ if (!ret.getZookeeperClient.isConnected) {
+ curIndex = getNextIndex(curIndex)
+ } else {
+ loop.break()
+ }
+ }
+ }
+ ret
+ }
+
+ private def getNextIndex(curIndex: Int) = (curIndex + 1) % zkCount
+
+ private def getZkIndex() = zkClientLock.synchronized {
+ INDEX = getNextIndex(INDEX)
+ INDEX
+ }
+
+ private def url: String = {
+ val uri = ProcessInfoUtil.getMnsZKUrl
+ if (uri.isEmpty) {
+ LOG.error("Please set zk url in octo.cfg")
+ mnscCommon.zookeeperHost
+ } else uri
+ }
+
+ def getData(path: String): java.lang.String = {
+ try {
+ val data = client.getData.forPath(path)
+ if (data == null) "" else new String(data, "utf-8")
+ } catch {
+ case e: Exception => {
+ LOG.error(s"function zk.getData exception.", e)
+ ""
+ }
+ }
+ }
+
+ def children(path: String) = {
+ try {
+ client.getChildren.forPath(path).asScala
+ } catch {
+ case e: Exception => {
+ LOG.error("function zk.children exception.", e)
+ List[String]()
+ }
+ }
+ }
+
+ def exist(path: String): Boolean = {
+ try {
+ client.checkExists().forPath(path) != null
+ } catch {
+ case e: Exception => {
+ LOG.error("function zk.exist exception.", e)
+ false
+ }
+ }
+ }
+
+ private def addWatcher(path: String, watcher: CuratorWatcher, isData: Boolean) = {
+ try {
+ if (isData) {
+ zkWatcher.getData.usingWatcher(watcher).inBackground().forPath(path)
+ } else {
+ zkWatcher.getChildren.usingWatcher(watcher).inBackground().forPath(path)
+ }
+ true
+ } catch {
+ case e: Exception =>
+ LOG.error("fail to add watcher.", e)
+ false
+ }
+ }
+
+ def addDataWatcher(path: String, watcher: CuratorWatcher) = {
+ addWatcher(path, watcher, true)
+ }
+
+ def addChildrenWatcher(path: String, watcher: CuratorWatcher) = {
+ addWatcher(path, watcher, false)
+ }
+
+ def getNodeState(path: String) = {
+ try {
+ client.checkExists().forPath(path)
+ } catch {
+ case e: Exception => {
+ LOG.error(s"function zk.getNodeState exception.", e)
+ null
+ }
+ }
+ }
+
+ def getNodeVersion(path: String) = {
+ val nodeState = getNodeState(path)
+ if (null != nodeState) {
+ (s"${nodeState.getMtime}|${nodeState.getCversion}|${nodeState.getVersion}", nodeState.getMtime)
+ } else {
+
+ (null, -101l)
+ }
+ }
+
+ def getNodeVersion(nodeState: Stat) = {
+ if (null != nodeState) {
+ s"${nodeState.getMtime}|${nodeState.getCversion}|${nodeState.getVersion}"
+ } else {
+ null
+ }
+ }
+
+ def versionCompare(inputVersion: String, cacheVersion: String, defaultValue: Boolean, f: (Long, Long) => Boolean) = {
+ if (null == inputVersion || null == cacheVersion) {
+ defaultValue
+ } else {
+ val inputVersionArray = inputVersion.split("\\|")
+ val cacheVersionArray = cacheVersion.split("\\|")
+ if (inputVersionArray.length == 3 && cacheVersionArray.length == 3) {
+ f(inputVersionArray(2).toLong, cacheVersionArray(2).toLong)
+ } else {
+ defaultValue
+ }
+ }
+
+ }
+}
diff --git a/nsc/src/main/scala/com/meituan/octo/mnsc/service/apiProviders.scala b/nsc/src/main/scala/com/meituan/octo/mnsc/service/apiProviders.scala
new file mode 100644
index 0000000..7b19523
--- /dev/null
+++ b/nsc/src/main/scala/com/meituan/octo/mnsc/service/apiProviders.scala
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2011-2018, Meituan Dianping. All Rights Reserved.
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+package com.meituan.octo.mnsc.service
+
+import scala.collection.JavaConverters._
+import com.meituan.octo.mnsc.dataCache.appProvidersCommCache
+import com.meituan.octo.mnsc.model.{Env, service}
+import com.meituan.octo.mnsc.model.service.{Provider, ProviderNode}
+import com.meituan.octo.mnsc.remote.zk
+import com.meituan.octo.mnsc.utils.{api, zkCommon}
+import com.octo.naming.common.thrift.model.SGService
+import org.slf4j.{Logger, LoggerFactory}
+import play.api.libs.json.Json
+
+object apiProviders {
+ private val LOG: Logger = LoggerFactory.getLogger(apiProviders.getClass)
+
+
+ def getProviders(appkey: String, env: Int, protocol: String) = {
+ val services = appProvidersCommCache.getProviderCache(appkey, env, protocol)
+ if (services.Providers.isEmpty) api.errorJson(404, s"can't find appkey:$appkey env:$env protocol:$protocol") else api.dataJson(200, Map {
+ "serviceList" -> services.Providers
+ })
+ }
+
+ def postProviders(providers: java.util.List[SGService]) = {
+ providers.asScala.map {
+ svr =>
+ if (null == svr.getVersion) {
+ // version cannot be null
+ svr.setVersion("")
+ }
+ val item = service.SGService2ProviderNode(svr)
+ val protocol = getProtocol(item)
+ val providerPath = zkCommon.getProtocolPath(item.appkey, Env(item.env).toString, protocol)
+ val nodePath = s"${providerPath}/${item.ip}:${item.port}"
+ val nodeData = Json.prettyPrint(Json.toJson(item))
+ val provider = Provider(item.appkey, item.lastUpdateTime)
+ val providerData = Json.prettyPrint(Json.toJson(provider))
+ if (!zk.exist(providerPath)) {
+ val msg = Map("appkey" -> item.appkey, "ip" -> item.ip, "port" -> item.port)
+ Map("ret" -> 404, "msg" -> msg)
+ }
+ else if (zk.exist(nodePath)) {
+ zk.client.inTransaction().setData().forPath(nodePath, nodeData.getBytes("utf-8")).and().setData().forPath(providerPath, providerData.getBytes("utf-8")).and().commit()
+ Map("ret" -> 200, "msg" -> "success")
+ }
+ else {
+ zk.client.inTransaction().create().forPath(nodePath, nodeData.getBytes("utf-8")).and().setData().forPath(providerPath, providerData.getBytes("utf-8")).and().commit()
+ Map("ret" -> 200, "msg" -> "success")
+ }
+ }
+ }
+
+
+ def deleteProviders(providers: java.util.List[SGService]) = {
+ providers.asScala.map {
+ svr =>
+ val item = service.SGService2ProviderNode(svr)
+ val protocol = getProtocol(item)
+ val providerPath = zkCommon.getProtocolPath(item.appkey, Env(item.env).toString, protocol)
+ val nodePath = s"${providerPath}/${item.ip}:${item.port}"
+ val provider = Provider(item.appkey, item.lastUpdateTime)
+ val providerData = Json.prettyPrint(Json.toJson(provider))
+ if (!zk.exist(providerPath) || !zk.exist(nodePath)) {
+ val msg = Map("appkey" -> item.appkey, "ip" -> item.ip, "port" -> item.port)
+ Map("ret" -> 404, "msg" -> msg)
+ }
+ else {
+ zk.client.inTransaction().delete().forPath(nodePath).and().setData().forPath(providerPath, providerData.getBytes("utf-8")).and().commit()
+ Map("ret" -> 200, "msg" -> "success")
+ }
+ }
+ }
+
+ def getProtocol(item: ProviderNode) = {
+ item.protocol.getOrElse(if (Some(1) == item.serverType) "http" else "thrift")
+ }
+
+}
diff --git a/nsc/src/main/scala/com/meituan/octo/mnsc/service/apiService.scala b/nsc/src/main/scala/com/meituan/octo/mnsc/service/apiService.scala
new file mode 100644
index 0000000..0161b23
--- /dev/null
+++ b/nsc/src/main/scala/com/meituan/octo/mnsc/service/apiService.scala
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2011-2018, Meituan Dianping. All Rights Reserved.
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+package com.meituan.octo.mnsc.service
+
+import java.text.SimpleDateFormat
+import java.util.Date
+
+import com.meituan.octo.mns.util.IpUtil
+import com.meituan.octo.mnsc.dataCache.appProviderDataCache
+import com.meituan.octo.mnsc.model.service
+import com.meituan.octo.mnsc.model.service.CacheValue
+import com.meituan.octo.mnsc.utils.api
+import com.octo.naming.common.thrift.model.{SGService, fb_status}
+import com.octo.idc.model.Idc
+import org.slf4j.{Logger, LoggerFactory}
+
+import scala.collection.JavaConverters._
+object apiService {
+ private val LOG: Logger = LoggerFactory.getLogger(apiService.getClass)
+ private def getTimeMillis(time: String) = {
+ val ret = try {
+ val dateFormat = new SimpleDateFormat("yy-MM-dd HH:mm:ss");
+ val dayFormat = new SimpleDateFormat("yy-MM-dd");
+ val curDate = dateFormat.parse(dayFormat.format(new Date()) + " " + time);
+ curDate.getTime()
+ } catch {
+ case e: Exception =>
+ //ignore
+ 0l
+ }
+ ret
+ }
+ private def getSamePrefixIP(list: List[SGService], ipIdc: String) = {
+ val defaultIdc = new Idc()
+ defaultIdc.setIdc("")
+ if (ipIdc.nonEmpty) {
+ list.filter(x => (IpUtil.getIdcInfoFromLocal(List(x.ip).asJava)).asScala.getOrElse(x.ip, defaultIdc).getIdc == ipIdc)
+ } else {
+ List()
+ }
+ }
+ private def isListAlive(list: List[SGService]) = {
+ list.foldLeft(false) {
+ (ret, item) =>
+ ret || (item.status == fb_status.ALIVE.getValue)
+ }
+ }
+ private def handleServiceList(list: List[SGService], ip: String) = {
+ val defaultIdc = new Idc()
+ defaultIdc.setIdc("")
+ val localIdc = IpUtil.getIdcInfoFromLocal(List(ip).asJava).asScala.getOrElse(ip, defaultIdc)
+ val regionList = list.filter(x => (IpUtil.getIdcInfoFromLocal(List(x.ip).asJava)).asScala.getOrElse(x.ip, defaultIdc).getRegion == localIdc.getRegion)
+ val sameIDCList = getSamePrefixIP(regionList, localIdc.getIdc)
+ if (isListAlive(sameIDCList)) {
+ sameIDCList
+ } else if (isListAlive(regionList)) {
+ regionList
+ } else {
+ list
+ }
+ }
+ def getServiceList(appkey: String, env: String, ip: String) = {
+ val services = appProviderDataCache.getProviderCache(appkey, env, false).getOrElse(CacheValue("", List()))
+ val list = handleServiceList(services.SGServices, ip)
+ val retList = if (list.isEmpty) {
+ List()
+ } else {
+ list.map {
+ item =>
+ service.SGService2ProviderNode(item)
+ }
+ }
+ val retCode = if (retList.isEmpty) 404 else 200
+ api.dataJson(retCode, Map("serviceList" -> retList))
+ }
+}
\ No newline at end of file
diff --git a/nsc/src/main/scala/com/meituan/octo/mnsc/service/mnscService.scala b/nsc/src/main/scala/com/meituan/octo/mnsc/service/mnscService.scala
new file mode 100644
index 0000000..83ef55b
--- /dev/null
+++ b/nsc/src/main/scala/com/meituan/octo/mnsc/service/mnscService.scala
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 2011-2018, Meituan Dianping. All Rights Reserved.
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+package com.meituan.octo.mnsc.service
+
+import java.util.concurrent.ConcurrentHashMap
+
+import com.meituan.octo.mnsc.dataCache.{appProviderDataCache, appProviderHttpDataCache}
+import com.meituan.octo.mnsc.model.{Env, Path, service}
+import com.meituan.octo.mnsc.remote.zk
+import com.meituan.octo.mnsc.utils.mnscCommon
+import com.meituan.octo.mnsc.model.service.CacheValue
+import com.octo.mnsc.idl.thrift.model._
+import com.octo.naming.common.thrift.model.SGService
+import org.slf4j.{Logger, LoggerFactory}
+
+import scala.collection.JavaConverters._
+
+object mnscService {
+ private val LOG: Logger = LoggerFactory.getLogger(mnscService.getClass)
+
+ def getMnsc(req: MnsRequest) = {
+ req.getProtoctol match {
+ case Protocols.THRIFT =>
+ getCache(req, Path.provider.toString, appProviderDataCache.getProviderCache, appProviderDataCache.updateProviderCache)
+ case Protocols.HTTP =>
+ getCache(req, Path.providerHttp.toString, appProviderHttpDataCache.getProviderHttpCache, appProviderHttpDataCache.updateProviderCache)
+ case _ =>
+ val result = new MNSResponse
+ result.setCode(mnsc_dataConstants.ILLEGAL_ARGUMENT)
+ result
+ }
+ }
+
+ private def getCache(req: MnsRequest, providerPath: String, fCache: (String, String, Boolean) => Option[service.CacheValue], fpar: (String, String, String, String, Boolean) => service.CacheValue) = {
+ val result = new MNSResponse
+ val cacheProviders = fCache(req.appkey, req.env, false)
+ val path = s"${mnscCommon.rootPre}/${req.getEnv}/${req.getAppkey}/$providerPath"
+ val (zkVersion, _) = zk.getNodeVersion(path)
+ cacheProviders match {
+ case Some(item) =>
+ result.setCode(mnsc_dataConstants.SUCCESS)
+ if (zk.versionCompare(item.version, zkVersion, true, (arg1: Long, arg2: Long) => arg1 == arg2)) {
+ result.setDefaultMNSCache(item.SGServices.asJava)
+ .setVersion(item.version)
+ } else {
+ val (version,_) = zk.getNodeVersion(path)
+ val providersUpdate = fpar(version, req.getAppkey, req.getEnv, providerPath, false)
+ if (null == providersUpdate) {
+ result.setDefaultMNSCache(item.SGServices.asJava)
+ .setVersion(item.version)
+ } else {
+ result.setDefaultMNSCache(providersUpdate.SGServices.asJava)
+ .setVersion(providersUpdate.version)
+ }
+ }
+ case None =>
+ result.setCode(mnsc_dataConstants.NOT_FOUND)
+ }
+ result
+ }
+
+ def getMnsc(appkey: String, version: String, env: String) = {
+ val providers = appProviderDataCache.getProviderCache(appkey, env, false)
+ getThriftOrHLBCache(providers, appkey, version, env)
+ }
+
+
+ def getMNSCache4HLB(appkey: String, version: String, env: String) = {
+ val providers = appProviderHttpDataCache.getProviderHttpCache(appkey, env, false)
+ getThriftOrHLBCache(providers, appkey, version, env)
+ }
+
+ private def getThriftOrHLBCache(providers: Option[service.CacheValue], appkey: String, version: String, env: String) = {
+ val res = new MNSResponse
+ providers match {
+ case Some(value) =>
+ // if input version is smaller than or equal to cache version,
+ if (zk.versionCompare(version, value.version, true, (arg1: Long, arg2: Long) => arg1 <= arg2)) {
+ res.setCode(mnsc_dataConstants.SUCCESS)
+ .setDefaultMNSCache(value.SGServices.asJava)
+ .setVersion(value.version)
+ } else {
+ res.setCode(mnsc_dataConstants.NOT_MODIFIED)
+ }
+ case None =>
+ LOG.debug(s"localCache don't exist $appkey|$env")
+ res.setCode(mnsc_dataConstants.NOT_FOUND)
+
+ }
+ res
+ }
+
+ def getMNSCacheByAppkeys(appkeys: java.util.List[String], protocol: String) = {
+ val ret = new MNSBatchResponse()
+ ret.cache = new ConcurrentHashMap[String, java.util.Map[String, java.util.List[SGService]]]()
+ appkeys.asScala.foreach {
+ appkey =>
+ Env.values.foreach {
+ env =>
+ val service = if ("thrift".equalsIgnoreCase(protocol)) {
+ appProviderDataCache.getProviderCache(appkey, env.toString, false)
+ } else if ("http".equalsIgnoreCase(protocol)) {
+ appProviderHttpDataCache.getProviderHttpCache(appkey, env.toString, false)
+ } else {
+ None
+ }
+ val serviceItem = service.getOrElse(new CacheValue(s"$appkey|$env", List())).SGServices.asJava
+ // ret.cache.synchronized {
+ if (null == ret.cache.get(appkey)) {
+ ret.cache.put(appkey, new ConcurrentHashMap[String, java.util.List[SGService]]())
+ }
+ // }
+ ret.cache.get(appkey).put(env.toString, serviceItem)
+ }
+ }
+ ret
+ }
+
+ def getProvidersByIP(ip: String) = {
+ LOG.debug(s"[getProviderByIP] Input--> ip=$ip")
+ val ret = new MNSResponse()
+ try {
+ val thriftProviders = appProviderDataCache.getProvidersByIP(ip)
+ val httpProviders = appProviderHttpDataCache.getProvidersByIP(ip)
+ val list = thriftProviders ::: httpProviders
+ ret.setCode(200)
+ ret.setDefaultMNSCache(list.asJava)
+ } catch {
+ case e: Exception =>
+ ret.setCode(500)
+ }
+ ret
+ }
+
+ def getAppkeyListByIP(ip: String) = {
+ val appkeys = appProviderDataCache.getAppkeysByIP(ip) ++ appProviderHttpDataCache.getAppkeysByIP(ip)
+ appkeys.toList.asJava
+ }
+
+}
diff --git a/nsc/src/main/scala/com/meituan/octo/mnsc/utils/api.scala b/nsc/src/main/scala/com/meituan/octo/mnsc/utils/api.scala
new file mode 100644
index 0000000..0d30510
--- /dev/null
+++ b/nsc/src/main/scala/com/meituan/octo/mnsc/utils/api.scala
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2011-2018, Meituan Dianping. All Rights Reserved.
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+package com.meituan.octo.mnsc.utils
+
+import javax.crypto.Mac
+import javax.crypto.spec.SecretKeySpec
+
+import com.fasterxml.jackson.databind.ObjectMapper
+import com.fasterxml.jackson.module.scala.DefaultScalaModule
+import com.fasterxml.jackson.module.scala.experimental.ScalaObjectMapper
+import org.apache.commons.codec.binary.Base64
+
+object api {
+ /** ObjectMapper is thread safe */
+ private val mapper = new ObjectMapper() with ScalaObjectMapper
+ mapper.registerModule(DefaultScalaModule)
+ def errorJsonArgInvalid(msg: AnyRef):String ={
+ errorJson(400,msg)
+ }
+
+ def dataJson200(data: AnyRef):String={
+ dataJson(200,data)
+ }
+
+ def dataJson(errorCode:Int,data: AnyRef):String={
+ val map = Map("ret" -> errorCode, "data" -> data)
+ jsonStr(map)
+ }
+
+ def dataJson(errorCode:Int, errorMsg:String, data: AnyRef):String={
+ val map = Map("ret" -> errorCode, "msg" -> errorMsg, "data" -> data)
+ jsonStr(map)
+ }
+
+ def errorJson(errorCode: Int, msg: AnyRef): String = {
+ val map = Map("ret" -> errorCode, "msg" -> msg)
+ jsonStr(map)
+ }
+
+ def dataJson(data: AnyRef): String = {
+ val map = Map("data" -> data, "isSuccess" -> true)
+ jsonStr(map)
+ }
+
+ def jsonStr(data: AnyRef): String = {
+ new String(jsonBytes(data), "utf-8")
+ }
+
+ def jsonBytes(data: AnyRef): Array[Byte] = {
+ mapper.writeValueAsBytes(data)
+ }
+
+ def toObject[T](bytes: Array[Byte], valueType: Class[T]) = {
+ mapper.readValue(bytes, valueType)
+ }
+
+ def toObject[T](str: String, valueType: Class[T]) = {
+ mapper.readValue(str, valueType)
+ }
+
+ def authorization(uri: String, method: String, date: String, clientId: String, secret: String): String = {
+ val signKey = new SecretKeySpec(secret.getBytes("utf-8"), "HmacSHA1")
+ val mac = Mac.getInstance("HmacSHA1")
+ mac.init(signKey)
+ val text = method + " " + uri + "\n" + date
+ "MWS " + clientId + ":" + Base64.encodeBase64String(mac.doFinal(text.getBytes("utf-8")))
+ }
+}
diff --git a/nsc/src/main/scala/com/meituan/octo/mnsc/utils/common.scala b/nsc/src/main/scala/com/meituan/octo/mnsc/utils/common.scala
new file mode 100644
index 0000000..65d4f7f
--- /dev/null
+++ b/nsc/src/main/scala/com/meituan/octo/mnsc/utils/common.scala
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2011-2018, Meituan Dianping. All Rights Reserved.
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+package com.meituan.octo.mnsc.utils
+
+import org.slf4j.{Logger, LoggerFactory}
+
+import scala.collection.JavaConverters._
+
+object common {
+ private final val LOG: Logger = LoggerFactory.getLogger(common.getClass)
+
+ def toList(enum: Enumeration) = enum.values.map {
+ x => Map("name" -> x.toString, "value" -> x.id).asJava
+ }.toList.sortBy(_.get("value").asInstanceOf[Int]).asJava
+
+ def toPairList(enum: Enumeration) = enum.values.map(x => Pair(x.toString, x.id)).toList.asJava
+
+ def toStringList(enum: Enumeration) = enum.values.map(x => '"' + x.toString + ',' + x.id + '"').toList.asJava
+
+ def toMap(enum: Enumeration) = enum.values.map(x => (x.toString -> x.id)).toMap.asJava
+
+ def toMapById(enum: Enumeration) = enum.values.map(x => (x.id -> x.toString)).toMap.asJava
+
+ def toMap(cc: AnyRef) = {
+ (Map[String, Any]() /: cc.getClass.getDeclaredFields) {
+ (a, f) =>
+ f.setAccessible(true)
+ a + (f.getName -> f.get(cc))
+ }.toMap
+ }
+
+ def toJavaMap(cc: AnyRef) = {
+ toMap(cc).asJava
+ }
+
+ def notEmpty(s: String) = s != null && !s.trim.isEmpty
+
+ def notNull(s: String) = s != null
+
+}
diff --git a/nsc/src/main/scala/com/meituan/octo/mnsc/utils/ipCommon.scala b/nsc/src/main/scala/com/meituan/octo/mnsc/utils/ipCommon.scala
new file mode 100644
index 0000000..5e8074f
--- /dev/null
+++ b/nsc/src/main/scala/com/meituan/octo/mnsc/utils/ipCommon.scala
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2011-2018, Meituan Dianping. All Rights Reserved.
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+package com.meituan.octo.mnsc.utils
+
+import org.apache.commons.lang.StringUtils
+
+object ipCommon {
+ private final val ipRegex = "^(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|[1-9])\\." +
+ "(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\." +
+ "(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\." +
+ "(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)$"
+
+
+ def getPrefixOfIP(ip: String) = {
+ val ips = ip.split("\\.")
+ val prefix = List(ips(0), ips(1)).mkString(".")
+ s"$prefix."
+ }
+
+ def checkIP(ip: String) = {
+ if (StringUtils.isBlank(ip)) {
+ false
+ } else {
+ ip.trim.matches(ipRegex)
+ }
+ }
+
+}
diff --git a/nsc/src/main/scala/com/meituan/octo/mnsc/utils/mnscCommon.scala b/nsc/src/main/scala/com/meituan/octo/mnsc/utils/mnscCommon.scala
new file mode 100644
index 0000000..1dde191
--- /dev/null
+++ b/nsc/src/main/scala/com/meituan/octo/mnsc/utils/mnscCommon.scala
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2011-2018, Meituan Dianping. All Rights Reserved.
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+package com.meituan.octo.mnsc.utils
+
+import com.meituan.octo.mnsc.remote.zk
+import org.apache.commons.lang3.StringUtils
+import com.meituan.octo.mns.util.ProcessInfoUtil
+import org.slf4j.{Logger, LoggerFactory}
+
+import scala.collection.JavaConverters._
+
+
+object mnscCommon {
+ private val LOG: Logger = LoggerFactory.getLogger(mnscCommon.getClass)
+
+ val rootPre = "/octo/nameservice"
+
+ val zookeeperHost = "10.24.41.248:2188,10.24.41.248:2188,10.24.41.248:2188"
+ //10.20.63.232:2181,10.21.128.208:2181,10.20.60.152:2181
+
+ //provider线程第一执行delay时间模值
+ val initDelay4Provider = 100
+ //provider弱同步时间间隔
+ val renewInterval4Provider = 20
+
+ //provider强同步时间间隔为renewInterval4Provider * forceBorder4Provider
+ val forceBorder4Provider = 120
+
+ //provider-http弱同步时间间隔
+ val renewInterval4ProviderHttp = 20
+ //20秒
+ //provider-http强同步时间间隔renewInterval4ProviderHttp * forceBorder4ProviderHttp
+ val forceBorder4ProviderHttp = 120
+
+
+ //provider线程第一执行delay时间模值
+ val initDelay4HttpProperties = 3000
+
+ //每个zk节点建立的zkClient数量, mns-zk对单台主机的连接数做了限制
+ val singleHostCount4ZK = 2
+
+ val ENV = ProcessInfoUtil.getAppEnv.toLowerCase
+
+ private var appkeys = List[String]()
+
+ private val appkeysPath = s"$rootPre/$ENV"
+
+ private def getAppFromZK() = {
+ val testAppkeys = System.getProperty("mnscCacheLoadAppkeys4Test")
+ val remoteAppkeys =if(StringUtils.isNotEmpty(testAppkeys)){
+ testAppkeys.trim.split(",").toList
+ }else{
+ zk.children(appkeysPath).toList
+ }
+
+ if (remoteAppkeys.nonEmpty) {
+ appkeys = remoteAppkeys
+ }
+ appkeys
+ }
+
+ def allApp() = {
+ getAppFromZK()
+ }
+
+ def allAppkeysList() = {
+ getAppFromZK().asJava
+ }
+
+ def allAppkeys(isPar: Boolean) = {
+ if (isPar) {
+ mnscCommon.allApp().par
+ } else {
+ mnscCommon.allApp()
+ }
+ }
+}
diff --git a/nsc/src/main/scala/com/meituan/octo/mnsc/utils/zkCommon.scala b/nsc/src/main/scala/com/meituan/octo/mnsc/utils/zkCommon.scala
new file mode 100644
index 0000000..e1890f4
--- /dev/null
+++ b/nsc/src/main/scala/com/meituan/octo/mnsc/utils/zkCommon.scala
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2011-2018, Meituan Dianping. All Rights Reserved.
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+
+package com.meituan.octo.mnsc.utils
+
+import com.meituan.octo.mnsc.model.Path
+
+object zkCommon {
+ private val pre = mnscCommon.rootPre
+
+ def getProtocolPath(appkey: String, env: String, protocol: String) = {
+ if ("thrift" == protocol) {
+ s"$pre/$env/$appkey/${Path.provider}"
+
+ } else if ("http" == protocol) {
+ s"$pre/$env/$appkey/${Path.providerHttp}"
+ } else {
+ s"$pre/$env/$appkey/providers/$protocol"
+ }
+ }
+}
diff --git a/nsc/src/main/scala/com/meituan/octo/mnsc/zkWatcher/appProviderWatcher.scala b/nsc/src/main/scala/com/meituan/octo/mnsc/zkWatcher/appProviderWatcher.scala
new file mode 100644
index 0000000..1b514f4
--- /dev/null
+++ b/nsc/src/main/scala/com/meituan/octo/mnsc/zkWatcher/appProviderWatcher.scala
@@ -0,0 +1,149 @@
+/*
+ * Copyright (c) 2011-2018, Meituan Dianping. All Rights Reserved.
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+package com.meituan.octo.mnsc.zkWatcher
+
+import com.meituan.octo.mnsc.dataCache.{appProviderDataCache, appProviderHttpDataCache}
+import com.meituan.octo.mnsc.model.{Env, Path}
+import com.meituan.octo.mnsc.remote.zk
+import com.meituan.octo.mnsc.utils.mnscCommon
+import org.apache.curator.framework.api.CuratorWatcher
+import org.apache.zookeeper.WatchedEvent
+import org.apache.zookeeper.Watcher.Event.{EventType, KeeperState}
+import org.slf4j.{Logger, LoggerFactory}
+
+object appProviderWatcher {
+ private val LOG: Logger = LoggerFactory.getLogger(appProviderWatcher.getClass)
+ private val pre = mnscCommon.rootPre
+ private val prodPath = s"$pre/${Env.prod}"
+ private var apps = mnscCommon.allApp()
+
+ //watch provider节点下的服务节点是否有变更
+ class ProviderWatcher(appkey: String, env: String) extends CuratorWatcher {
+ def process(event: WatchedEvent): Unit = {
+ LOG.info(s"ProviderWatcher event $event for appKey|env = $appkey|$env")
+ val watcherPath = s"$pre/$env/$appkey/${Path.provider}"
+
+ event.getType match {
+ case EventType.NodeDataChanged =>
+ val watcherPath = event.getPath
+ val (_, mtime) = zk.getNodeVersion(watcherPath)
+ appProviderDataCache.mnscWatcherAction(appkey, env, Path.provider.toString)
+
+ val interval = System.currentTimeMillis - mtime
+ LOG.debug(s"ProviderWatcher process for appKey|env = $appkey|$env --> cost ${interval} ms")
+ case _ => //do nothing
+ }
+
+ /*避免reconnect时watcher instance 指数级增加,导致的OOM问题
+ 同时,加快新session中Watcher的playback速度,提高网络抖动后自愈的速度
+ */
+ if(EventType.NodeDataChanged == event.getType || KeeperState.Expired == event.getState){
+ zk.addDataWatcher(watcherPath, new ProviderWatcher(appkey, env))
+ }
+ }
+ }
+
+ //watch provider-http节点下的服务节点是否有变更
+ class ProviderHttpWatcher(appkey: String, env: String) extends CuratorWatcher {
+ def process(event: WatchedEvent): Unit = {
+ LOG.info(s"ProviderHttpWatcher event $event for appKey|env = $appkey|$env")
+
+ val watcherPath = s"$pre/$env/$appkey/${Path.providerHttp}"
+
+ event.getType match {
+ case EventType.NodeDataChanged =>
+ val watcherPath = event.getPath
+ val (_, mtime) = zk.getNodeVersion(watcherPath)
+ appProviderHttpDataCache.mnscWatcherAction(appkey, env, Path.providerHttp.toString)
+
+ val interval = System.currentTimeMillis - mtime
+ LOG.debug(s"ProviderHttpWatcher process for appKey|env = $appkey|$env --> cost ${interval} ms")
+ case _ => //do nothing
+ }
+
+ /*避免reconnect时watcher instance 指数级增加,导致的OOM问题
+ 同时,加快新session中Watcher的playback速度,提高网络抖动后自愈的速度
+ */
+ if(EventType.NodeDataChanged == event.getType || KeeperState.Expired == event.getState){
+ zk.addDataWatcher(watcherPath, new ProviderHttpWatcher(appkey, env))
+ }
+ }
+ }
+
+ //watch是否有appKey的新增或删除
+ class appWatcher(path: String) extends CuratorWatcher {
+ def process(event: WatchedEvent): Unit = {
+ LOG.info(s"appWatcher event $event for path=$path")
+
+ event.getType match {
+ case EventType.NodeChildrenChanged =>
+ val newApps = mnscCommon.allApp()
+ LOG.info(s"new apps $newApps")
+ newApps.filter(!apps.contains(_)).foreach {
+ appkey => registryProviderWatcher4AllEnv(appkey)
+ }
+
+ appProviderDataCache.deleteNonexistentAppKey()
+ appProviderHttpDataCache.deleteNonexistentAppKey()
+
+ apps = newApps
+
+ case _ => //do nothing
+ }
+
+ if(EventType.NodeDataChanged == event.getType ||
+ EventType.NodeChildrenChanged == event.getType ||
+ KeeperState.Expired == event.getState) {
+ zk.addChildrenWatcher(path, new appWatcher(path))
+ }
+
+ }
+ }
+
+ def registryProviderWatcher4AllEnv(appkey: String) = {
+ Env.values.foreach {
+ env =>
+ val providerWatcherPath = s"$pre/$env/$appkey/${Path.provider}"
+ zk.addDataWatcher(providerWatcherPath, new ProviderWatcher(appkey, env.toString))
+ val providerHTTPWatcherPath = s"$pre/$env/$appkey/${Path.providerHttp}"
+ zk.addDataWatcher(providerHTTPWatcherPath, new ProviderHttpWatcher(appkey, env.toString))
+ }
+ }
+
+ def initWatcherApp() = {
+ val watcherPath = prodPath
+ zk.addChildrenWatcher(watcherPath, new appWatcher(prodPath))
+ }
+
+ def initWatcherProvider() = {
+ LOG.info("init provider watcher")
+ apps.par.foreach {
+ appkey =>
+ registryProviderWatcher4AllEnv(appkey)
+ }
+ }
+
+ def initWatcher() = {
+ initWatcherApp()
+ initWatcherProvider()
+ }
+}
diff --git a/nsc/src/test/java/com/meituan/octo/mnsc/MNSCacheApiTest.java b/nsc/src/test/java/com/meituan/octo/mnsc/MNSCacheApiTest.java
new file mode 100644
index 0000000..7c201d9
--- /dev/null
+++ b/nsc/src/test/java/com/meituan/octo/mnsc/MNSCacheApiTest.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2011-2018, Meituan Dianping. All Rights Reserved.
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+package com.meituan.octo.mnsc;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.meituan.octo.mnsc.service.apiProviders;
+import com.meituan.octo.mnsc.utils.mnscCommon;
+import com.meituan.octo.mnsc.service.apiService;
+import org.junit.Test;
+import play.libs.Json;
+
+import java.util.HashMap;
+
+public class MNSCacheApiTest extends SpringBaseTest {
+ @Test
+ public void getProviders() throws Exception {
+ assert(Json.parse(apiProviders.getProviders("com.sankuai.inf.sg_sentinel", 3, "thrift")).get("ret").asInt() == 200);
+ assert(Json.parse(apiProviders.getProviders("com.sankuai.inf.msgp", 3, "http")).get("ret").asInt() == 200);
+ assert(Json.parse(apiProviders.getProviders("com.sankuai.invalid.appkey", 3, "thrift")).get("ret").asInt() == 404);
+ }
+
+ @Test
+ public void getAllAppkeys() throws Exception {
+ assert(!mnscCommon.allAppkeysList().isEmpty());
+ }
+
+ @Test
+ public void getSentinels() throws Exception {
+ String ip = "10.20.50.135";
+ String env = "prod";
+ String appkey = "com.sankuai.inf.sg_sentinel";
+ HashMap result = new ObjectMapper().readValue(apiService.getServiceList(appkey.trim(), env.trim(), ip.trim()), HashMap.class);
+ System.out.println(result.get("data"));
+ assert(result.get("ret").equals(200));
+ }
+}
\ No newline at end of file
diff --git a/nsc/src/test/java/com/meituan/octo/mnsc/MNSCacheServiceTest.java b/nsc/src/test/java/com/meituan/octo/mnsc/MNSCacheServiceTest.java
new file mode 100644
index 0000000..480b3e7
--- /dev/null
+++ b/nsc/src/test/java/com/meituan/octo/mnsc/MNSCacheServiceTest.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2011-2018, Meituan Dianping. All Rights Reserved.
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+package com.meituan.octo.mnsc;
+
+import com.meituan.octo.mnsc.service.mnscService;
+import com.meituan.octo.mnsc.web.api.ProvidersController;
+import com.octo.mnsc.idl.thrift.model.mnsc_dataConstants;
+import com.octo.mnsc.idl.thrift.model.MnsRequest;
+import com.octo.mnsc.idl.thrift.model.Protocols;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class MNSCacheServiceTest extends SpringBaseTest{
+ static final Logger LOG = LoggerFactory.getLogger(ProvidersController.class);
+
+ @Test
+ public void getAppKeyByIP() throws Exception {
+ long start = System.currentTimeMillis();
+ assert(!mnscService.getAppkeyListByIP("10.72.221.226").isEmpty());
+ System.out.println(System.currentTimeMillis() - start);
+ }
+
+ @Test
+ public void getProvidersByIP() throws Exception {
+ assert(!mnscService.getProvidersByIP("10.72.221.226").defaultMNSCache.isEmpty());
+ }
+
+ @Test
+ public void getMNSCacheWithVersionCheck() throws Exception {
+ MnsRequest request = new MnsRequest();
+ request.appkey = "com.sankuai.inf.sg_sentinel";
+ request.env = "prod";
+ request.protoctol= Protocols.THRIFT;
+ assert(mnscService.getMnsc(request).code == mnsc_dataConstants.SUCCESS);
+
+ request.appkey = "com.sankuai.invalid.appkey";
+ assert(mnscService.getMnsc(request).code == mnsc_dataConstants.NOT_FOUND);
+
+ request.appkey = "com.sankuai.inf.msgp";
+ request.protoctol= Protocols.HTTP;
+ assert(mnscService.getMnsc(request).code == mnsc_dataConstants.SUCCESS);
+
+ request.appkey = "com.sankuai.invalid.appkey";
+ assert(mnscService.getMnsc(request).code == mnsc_dataConstants.NOT_FOUND);
+ }
+
+ @Test
+ public void getMNSCacheByAppkeys() throws Exception {
+ List appkeys = new ArrayList();
+ appkeys.add("com.sankuai.inf.sg_sentinel");
+ appkeys.add("com.sankuai.inf.msgp");
+ appkeys.add("com.sankuai.invalid.appkey");
+ assert(!mnscService.getMNSCacheByAppkeys(appkeys, "thrift").cache.get("com.sankuai.inf.sg_sentinel").get("prod").isEmpty());
+ assert(mnscService.getMNSCacheByAppkeys(appkeys, "thrift").cache.get("com.sankuai.invalid.appkey").get("prod").isEmpty());
+
+ assert(!mnscService.getMNSCacheByAppkeys(appkeys, "http").cache.get("com.sankuai.inf.msgp").get("prod").isEmpty());
+ assert(mnscService.getMNSCacheByAppkeys(appkeys, "http").cache.get("com.sankuai.invalid.appkey").get("prod").isEmpty());
+ }
+
+ @Test
+ public void getMNSCache() throws Exception {
+ assert(!mnscService.getMnsc("com.sankuai.inf.sg_sentinel","0|0|1","prod").defaultMNSCache.isEmpty());
+ assert(mnscService.getMnsc("com.sankuai.inf.sg_sentinel","0|0|99999999","prod").code == mnsc_dataConstants.NOT_MODIFIED);
+ }
+
+ @Test
+ public void getMNSCacheHttp() throws Exception {
+ assert(!mnscService.getMNSCache4HLB("com.sankuai.inf.msgp","0|0|1","prod").defaultMNSCache.isEmpty());
+ assert(mnscService.getMNSCache4HLB("com.sankuai.inf.msgp","0|0|99999999","prod").code == mnsc_dataConstants.NOT_MODIFIED);
+
+ assert(mnscService.getMnsc("com.sankuai.invalid.appkey","0|0|1","prod").code == mnsc_dataConstants.NOT_FOUND);
+ assert(mnscService.getMNSCache4HLB("com.sankuai.invalid.appkey","0|0|99999999","prod").code == mnsc_dataConstants.NOT_FOUND);
+ }
+ /*@Test
+ public void getSG_Agent() throws Exception {
+ System.out.println(apiService.getServiceList("com.sankuai.inf.sg_sentinel", "test", "10.22.16.146"));
+ }*/
+
+}
diff --git a/nsc/src/test/java/com/meituan/octo/mnsc/SpringBaseTest.java b/nsc/src/test/java/com/meituan/octo/mnsc/SpringBaseTest.java
new file mode 100644
index 0000000..29369de
--- /dev/null
+++ b/nsc/src/test/java/com/meituan/octo/mnsc/SpringBaseTest.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2011-2018, Meituan Dianping. All Rights Reserved.
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+package com.meituan.octo.mnsc;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration({"classpath:applicationContext.xml"})
+public class SpringBaseTest {
+
+ @BeforeClass
+ public static void init(){
+ String appkeys = "com.sankuai.inf.sg_sentinel,com.sankuai.inf.msgp,com.sankuai.octo.tmy";
+ System.setProperty("mnscCacheLoadAppkeys4Test", appkeys);
+ }
+ @Test
+ public void test(){}
+}
diff --git a/nsc/src/test/resources/applicationContext.xml b/nsc/src/test/resources/applicationContext.xml
new file mode 100644
index 0000000..c4b2e63
--- /dev/null
+++ b/nsc/src/test/resources/applicationContext.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/nsc/src/test/resources/log4j2.xml b/nsc/src/test/resources/log4j2.xml
new file mode 100644
index 0000000..4e4c30a
--- /dev/null
+++ b/nsc/src/test/resources/log4j2.xml
@@ -0,0 +1,28 @@
+
+
+
+ com.meituan.octo.mnsc
+ mnsc-server
+
+
+
+
+
+
+
+ %d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/nsc/src/test/resources/webmvc-config.xml b/nsc/src/test/resources/webmvc-config.xml
new file mode 100644
index 0000000..cc918f8
--- /dev/null
+++ b/nsc/src/test/resources/webmvc-config.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/nsc/src/test/scala/com/meituan/octo/mnsc/test/EnvSuite.scala b/nsc/src/test/scala/com/meituan/octo/mnsc/test/EnvSuite.scala
new file mode 100644
index 0000000..3be0091
--- /dev/null
+++ b/nsc/src/test/scala/com/meituan/octo/mnsc/test/EnvSuite.scala
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2011-2018, Meituan Dianping. All Rights Reserved.
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+package com.meituan.octo.mnsc.test
+
+import com.meituan.octo.mnsc.model.Env
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+import org.scalatest.{BeforeAndAfter, FunSuite}
+import org.junit.Assert.assertEquals
+
+@RunWith(classOf[JUnitRunner])
+class EnvSuite extends FunSuite with BeforeAndAfter {
+ test("envInvalid") {
+ assertEquals(false, Env.isValid(4))
+ assertEquals(true, Env.isValid(1))
+ assertEquals(true, Env.isValid(2))
+ assertEquals(true, Env.isValid(3))
+ }
+}
+
diff --git a/nsc/src/test/scala/com/meituan/octo/mnsc/test/ServiceSuite.scala b/nsc/src/test/scala/com/meituan/octo/mnsc/test/ServiceSuite.scala
new file mode 100644
index 0000000..8f2f920
--- /dev/null
+++ b/nsc/src/test/scala/com/meituan/octo/mnsc/test/ServiceSuite.scala
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2011-2018, Meituan Dianping. All Rights Reserved.
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+package com.meituan.octo.mnsc.test
+
+import com.octo.mnsc.idl.thrift.service.MNSCacheService
+import org.apache.thrift.protocol.{TBinaryProtocol, TProtocol}
+import org.apache.thrift.transport.{TFramedTransport, TSocket}
+import org.joda.time.DateTime
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+import org.scalatest.{BeforeAndAfter, FunSuite}
+
+import scala.collection.parallel.ForkJoinTaskSupport
+
+@RunWith(classOf[JUnitRunner])
+class ServiceSuite extends FunSuite with BeforeAndAfter {
+
+ test("service") {
+ val timeout = 3000
+ val ip = "127.0.0.1"
+ val port = 8091
+ val transport = new TFramedTransport(new TSocket(ip, port, timeout), 16384000)
+ val protocol: TProtocol = new TBinaryProtocol(transport)
+ val mnsc = new MNSCacheService.Client(protocol)
+ val appkey = "com.sankuai.cos.mtconfi"
+ val env = "prod"
+ // val path = List("/mns/sankuai", env, appkey, Path.provider).mkString("/")
+ // val version = zk.getNodeVersion(path)
+ transport.open
+ while (true) {
+ val start = new DateTime().getMillis
+ println(mnsc.getMNSCache(appkey, "0", env))
+ val end = new DateTime().getMillis
+ println(s"cost ${end - start}")
+ Thread.sleep(2000)
+ }
+ }
+
+ test("par") {
+ val a = (0 to 30).toList.par
+ a.tasksupport = new ForkJoinTaskSupport(new scala.concurrent.forkjoin.ForkJoinPool(1000))
+ val b = (0 to 100000).toList.par
+ b.tasksupport = new ForkJoinTaskSupport(new scala.concurrent.forkjoin.ForkJoinPool(1000))
+ val result = a.map {
+ x =>
+ val at = Thread.currentThread().getName
+ println(b.map(x => Thread.currentThread().getName).distinct.length)
+ at
+ }.distinct.length
+ println("ss" + result)
+ }
+}
diff --git a/nsc/src/test/scala/com/meituan/octo/mnsc/test/mnscDataCacheSuite.scala b/nsc/src/test/scala/com/meituan/octo/mnsc/test/mnscDataCacheSuite.scala
new file mode 100644
index 0000000..48c9f19
--- /dev/null
+++ b/nsc/src/test/scala/com/meituan/octo/mnsc/test/mnscDataCacheSuite.scala
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2011-2018, Meituan Dianping. All Rights Reserved.
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+package com.meituan.octo.mnsc.test
+
+import com.meituan.octo.mnsc.dataCache._
+import com.meituan.octo.mnsc.model.Path
+import com.meituan.octo.mnsc.service.mnscService
+import com.octo.mnsc.idl.thrift.model.{mnsc_dataConstants, MnsRequest, Protocols}
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+import org.scalatest.{BeforeAndAfter, FunSuite}
+
+
+@RunWith(classOf[JUnitRunner])
+class mnscServiceSuite extends FunSuite with BeforeAndAfter {
+ test("test ip affiliation") {
+ val apps = new java.util.ArrayList[String]()
+ apps.add("com.sankuai.inf.sg_sentinel")
+ apps.add("com.sankuai.inf.msgp")
+ val thrift_cache = mnscService.getMNSCacheByAppkeys(apps, "thrift")
+ println(thrift_cache.cache)
+ assert(thrift_cache.cache.get("com.sankuai.inf.sg_sentinel").get("prod").isEmpty)
+ val http_cache = mnscService.getMNSCacheByAppkeys(apps, "http")
+ assert(http_cache.cache.get("com.sankuai.inf.msgp").get("prod").isEmpty)
+
+ assert(mnscService.getAppkeyListByIP("10.72.221.226").isEmpty)
+ assert(mnscService.getProvidersByIP("10.72.221.226").defaultMNSCache.isEmpty)
+
+ appProviderDataCache.renewAllProviderForce(Path.provider.toString, true)
+ appProviderHttpDataCache.renewAllProviderForce(Path.providerHttp.toString, true)
+
+ assert(!mnscService.getAppkeyListByIP("10.72.221.226").isEmpty)
+ assert(!mnscService.getProvidersByIP("10.72.221.226").defaultMNSCache.isEmpty)
+ }
+
+ test("get MNSCache service API1") {
+ assert(!mnscService.getMnsc("com.sankuai.inf.sg_sentinel","0|0|1","prod").defaultMNSCache.isEmpty)
+ assert(mnscService.getMnsc("com.sankuai.inf.sg_sentinel","0|0|99999999","prod").code == mnsc_dataConstants.NOT_MODIFIED)
+ assert(!mnscService.getMNSCache4HLB("com.sankuai.inf.msgp","0|0|1","prod").defaultMNSCache.isEmpty)
+ assert(mnscService.getMNSCache4HLB("com.sankuai.inf.msgp","0|0|99999999","prod").code == mnsc_dataConstants.NOT_MODIFIED)
+
+ assert(mnscService.getMnsc("com.sankuai.invalid.appkey","0|0|1","prod").code == mnsc_dataConstants.NOT_FOUND)
+ assert(mnscService.getMNSCache4HLB("com.sankuai.invalid.appkey","0|0|99999999","prod").code == mnsc_dataConstants.NOT_FOUND)
+ }
+
+ test("get MNSCache service API2") {
+ val request = new MnsRequest()
+ request.appkey = "com.sankuai.inf.sg_sentinel"
+ request.env = "prod"
+ request.protoctol= Protocols.THRIFT
+ assert(mnscService.getMnsc(request).code == mnsc_dataConstants.SUCCESS)
+
+ request.appkey = "com.sankuai.invalid.appkey"
+ assert(mnscService.getMnsc(request).code == mnsc_dataConstants.NOT_FOUND)
+
+ request.appkey = "com.sankuai.inf.msgp"
+ request.protoctol= Protocols.HTTP
+ assert(mnscService.getMnsc(request).code == mnsc_dataConstants.SUCCESS)
+
+ request.appkey = "com.sankuai.invalid.appkey"
+ assert(mnscService.getMnsc(request).code == mnsc_dataConstants.NOT_FOUND)
+ }
+}
\ No newline at end of file
diff --git a/nsc/src/test/scala/com/meituan/octo/mnsc/test/providerCacheSuite.scala b/nsc/src/test/scala/com/meituan/octo/mnsc/test/providerCacheSuite.scala
new file mode 100644
index 0000000..e5fcd04
--- /dev/null
+++ b/nsc/src/test/scala/com/meituan/octo/mnsc/test/providerCacheSuite.scala
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2011-2018, Meituan Dianping. All Rights Reserved.
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+package com.meituan.octo.mnsc.test
+
+import com.meituan.octo.mnsc.dataCache._
+import com.meituan.octo.mnsc.model.Path
+import com.meituan.octo.mnsc.model.service.CacheValue
+import com.meituan.octo.mnsc.service.apiProviders
+import com.octo.naming.common.thrift.model.SGService
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+import org.scalatest.{BeforeAndAfter, FunSuite}
+
+
+@RunWith(classOf[JUnitRunner])
+class providerCacheSuite extends FunSuite with BeforeAndAfter {
+ test("getPovidersCache") {
+ val thrift_valid_services = appProvidersCommCache.getProviderCache("com.sankuai.inf.sg_sentinel", 3, "thrift")
+ assert(thrift_valid_services.Providers.nonEmpty)
+ val thrift_invalid_services = appProvidersCommCache.getProviderCache("com.sankuai.inf.sg_sentinel", 3, "http")
+ assert(thrift_invalid_services.Providers.isEmpty)
+
+ val http_valid_services = appProvidersCommCache.getProviderCache("com.sankuai.inf.msgp", 3, "thrift")
+ assert(http_valid_services.Providers.isEmpty)
+ val http_invalid_services = appProvidersCommCache.getProviderCache("com.sankuai.inf.msgp", 3, "http")
+ assert(http_invalid_services.Providers.nonEmpty)
+
+ val api_service = apiProviders.getProviders("com.sankuai.inf.sg_sentinel", 3, "thrift")
+ assert(api_service.nonEmpty)
+ }
+
+ test("get provider cache from remote") {
+ //appProviderDataCache.renewAllProviderForce(Path.provider.toString, true)
+ val emptyValue = CacheValue("invalid-version", List[SGService]())
+
+ //thrift
+ val local_cache = appProviderDataCache.getProviderCache("com.sankuai.inf.sg_sentinel", "prod", false)
+ assert(local_cache.getOrElse(emptyValue).version == "invalid-version")
+ assert(local_cache.getOrElse(emptyValue).SGServices.isEmpty)
+
+ val remote_cache = appProviderDataCache.getProviderCache("com.sankuai.inf.sg_sentinel", "prod", true)
+ assert(remote_cache.getOrElse(emptyValue).version != "invalid-version")
+ assert(remote_cache.getOrElse(emptyValue).SGServices.nonEmpty)
+
+ //http
+ val local_cache_http = appProviderHttpDataCache.getProviderHttpCache("com.sankuai.inf.msgp", "prod", false)
+ assert(local_cache_http.getOrElse(emptyValue).version == "invalid-version")
+ assert(local_cache_http.getOrElse(emptyValue).SGServices.isEmpty)
+
+ val remote_cache_http = appProviderHttpDataCache.getProviderHttpCache("com.sankuai.inf.msgp", "prod", true)
+ assert(remote_cache_http.getOrElse(emptyValue).version != "invalid-version")
+ assert(remote_cache_http.getOrElse(emptyValue).SGServices.nonEmpty)
+ }
+
+ test("get provider cache from local") {
+ val emptyValue = CacheValue("invalid-version", List[SGService]())
+
+ appProviderDataCache.renewAllProviderForce(Path.provider.toString, true)
+ val cache = appProviderDataCache.getProviderCache("com.sankuai.inf.sg_sentinel", "prod", false)
+ assert(cache.getOrElse(emptyValue).version != "invalid-version")
+ assert(cache.getOrElse(emptyValue).SGServices.nonEmpty)
+ val invalidCache = appProviderDataCache.getProviderCache("com.sankuai.invalid.test", "prod", false)
+ assert(invalidCache.getOrElse(emptyValue).version == "invalid-version")
+ assert(invalidCache.getOrElse(emptyValue).SGServices.isEmpty)
+
+ appProviderHttpDataCache.renewAllProviderForce(Path.providerHttp.toString, true)
+ val cache_http = appProviderHttpDataCache.getProviderHttpCache("com.sankuai.inf.msgp", "prod", false)
+ assert(cache_http.getOrElse(emptyValue).version != "invalid-version")
+ assert(cache_http.getOrElse(emptyValue).SGServices.nonEmpty)
+
+ val invalid_cache_http = appProviderHttpDataCache.getProviderHttpCache("com.sankuai.invalid.test", "prod", false)
+ assert(invalid_cache_http.getOrElse(emptyValue).version == "invalid-version")
+ assert(invalid_cache_http.getOrElse(emptyValue).SGServices.isEmpty)
+ }
+}
+
+@RunWith(classOf[JUnitRunner])
+class providerCacheScheduleSuite extends FunSuite with BeforeAndAfter {
+ test("schedule job worker") {
+ val emptyValue = CacheValue("invalid-version", List[SGService]())
+ val cache = appProviderDataCache.getProviderCache("com.sankuai.inf.sg_sentinel", "prod", false)
+ assert(cache.getOrElse(emptyValue).version == "invalid-version")
+
+ val cache_http = appProviderHttpDataCache.getProviderHttpCache("com.sankuai.inf.msgp", "prod", false)
+ assert(cache_http.getOrElse(emptyValue).version == "invalid-version")
+
+ appProviderHttpDataCache.doRenew()
+ appProviderDataCache.doRenew()
+ Thread.sleep(1000*60)
+
+ val cache_valid = appProviderDataCache.getProviderCache("com.sankuai.inf.sg_sentinel", "prod", false)
+ assert(cache_valid.getOrElse(emptyValue).version != "invalid-version")
+
+ val invalidCache = appProviderDataCache.getProviderCache("com.sankuai.invalid.test", "prod", false)
+ assert(invalidCache.getOrElse(emptyValue).version == "invalid-version")
+
+ val cache_http_valid = appProviderHttpDataCache.getProviderHttpCache("com.sankuai.inf.msgp", "prod", false)
+ assert(cache_http_valid.getOrElse(emptyValue).version != "invalid-version")
+
+ val invalid_cache_http = appProviderHttpDataCache.getProviderHttpCache("com.sankuai.invalid.test", "prod", false)
+ assert(invalid_cache_http.getOrElse(emptyValue).version == "invalid-version")
+
+ val ip_valid = "10.72.221.226"
+ val ip_invalid = "invalid_ip"
+ assert(appProviderDataCache.getProvidersByIP(ip_valid).nonEmpty)
+ assert(appProviderDataCache.getProvidersByIP(ip_invalid).isEmpty)
+
+ val http_ip_valid = "10.24.124.94"
+ assert(appProviderHttpDataCache.getProvidersByIP(http_ip_valid).nonEmpty)
+ assert(appProviderHttpDataCache.getProvidersByIP(ip_invalid).isEmpty)
+ }
+}
\ No newline at end of file
diff --git a/nsc/src/test/scala/com/meituan/octo/mnsc/test/zkSuite.scala b/nsc/src/test/scala/com/meituan/octo/mnsc/test/zkSuite.scala
new file mode 100644
index 0000000..0655a7f
--- /dev/null
+++ b/nsc/src/test/scala/com/meituan/octo/mnsc/test/zkSuite.scala
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 2011-2018, Meituan Dianping. All Rights Reserved.
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+package com.meituan.octo.mnsc.test
+
+import com.meituan.octo.mnsc.model.Path
+import com.meituan.octo.mnsc.remote.zk
+import com.meituan.octo.mnsc.service.apiProviders
+import com.meituan.octo.mnsc.utils.mnscCommon
+import com.meituan.octo.mnsc.zkWatcher.appProviderWatcher
+import com.octo.naming.common.thrift.model.SGService
+import org.apache.curator.framework.api.CuratorWatcher
+import org.apache.zookeeper.WatchedEvent
+import org.junit.runner.RunWith
+import org.scalatest.{BeforeAndAfter, FunSuite}
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+class zkSuite extends FunSuite with BeforeAndAfter with CuratorWatcher {
+ val env = "prod"
+ val appkey = "com.sankuai.octo.tmy"
+ val path = s"${mnscCommon.rootPre}/$env/$appkey/${Path.provider}"
+
+ val service = new SGService()
+ service.setAppkey(appkey)
+ .setVersion("thrift")
+ .setIp("10.4.229.159")
+ .setPort(8830)
+ .setWeight(10)
+ .setStatus(4)
+ .setRole(0)
+ .setEnvir(3)
+ .setLastUpdateTime(1543395127)
+ .setFweight(10.0)
+ .setServerType(0)
+ .setProtocol("thrift")
+ .setHeartbeatSupport(0)
+
+ test("test zk addDataWatcher") {
+ zk.addDataWatcher(path, this)
+ val services = new java.util.ArrayList[SGService]()
+ services.add(service)
+ Thread.sleep(1000*5)
+ apiProviders.postProviders(services)
+ Thread.sleep(1000*5)
+ }
+
+ override def process(event: WatchedEvent): Unit = {
+ assert(event.getPath == path)
+ println(zk.getData(event.getPath))
+ zk.addDataWatcher(path, this)
+ }
+
+
+ test ("test zk addChildrenWatcher") {
+ val services = new java.util.ArrayList[SGService]()
+ services.add(service)
+ apiProviders.deleteProviders(services)
+
+ zk.addChildrenWatcher(path,this)
+ Thread.sleep(1000*5)
+ apiProviders.postProviders(services)
+ Thread.sleep(1000*5)
+ }
+
+ test ("test version check") {
+ assert(zk.versionCompare("0|0|1", "0|0|2", false, (arg1: Long, arg2: Long) => arg1 <= arg2))
+ assert(!zk.versionCompare("0|0", "0|0|2", false, (arg1: Long, arg2: Long) => arg1 <= arg2))
+ assert(!zk.versionCompare("0|0|1", "0|0", false, (arg1: Long, arg2: Long) => arg1 <= arg2))
+ assert(!zk.versionCompare("0|0|3", "0|0|2", true, (arg1: Long, arg2: Long) => arg1 <= arg2))
+ assert(zk.versionCompare("0|0", "0|0|2", true, (arg1: Long, arg2: Long) => arg1 <= arg2))
+ assert(zk.versionCompare("0|0|3", "0|0", true, (arg1: Long, arg2: Long) => arg1 <= arg2))
+ }
+}
+
+@RunWith(classOf[JUnitRunner])
+class zkProviderSuite extends FunSuite with BeforeAndAfter {
+ val appkey = "com.sankuai.octo.tmy"
+
+ val service = new SGService()
+ service.setAppkey(appkey)
+ .setVersion("thrift")
+ .setIp("10.4.229.159")
+ .setPort(8830)
+ .setWeight(10)
+ .setStatus(4)
+ .setRole(0)
+ .setEnvir(3)
+ .setLastUpdateTime(1543395127)
+ .setFweight(10.0)
+ .setServerType(0)
+ .setProtocol("thrift")
+ .setHeartbeatSupport(0)
+
+ test ("init watcher for app") {
+ appProviderWatcher.initWatcher()
+
+ val services = new java.util.ArrayList[SGService]()
+ services.add(service)
+ apiProviders.postProviders(services)
+ Thread.sleep(1000*3)
+
+ apiProviders.postProviders(services)
+ Thread.sleep(1000*2)
+ }
+
+ service.setProtocol("http")
+ test ("init watcher for http app") {
+ appProviderWatcher.initWatcher()
+
+ val services = new java.util.ArrayList[SGService]()
+ services.add(service)
+ apiProviders.postProviders(services)
+ Thread.sleep(1000*3)
+
+ apiProviders.postProviders(services)
+ Thread.sleep(1000*2)
+ }
+
+ //TODO:watch是否有appKey的新增或删除
+}
\ No newline at end of file
diff --git a/scanner/.gitignore b/scanner/.gitignore
new file mode 100644
index 0000000..82eca33
--- /dev/null
+++ b/scanner/.gitignore
@@ -0,0 +1,25 @@
+/target/
+!.mvn/wrapper/maven-wrapper.jar
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/build/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
\ No newline at end of file
diff --git a/scanner/README.md b/scanner/README.md
new file mode 100644
index 0000000..e673822
--- /dev/null
+++ b/scanner/README.md
@@ -0,0 +1,56 @@
+# OCTO Scanner 介绍
+
+## 背景描述
+Scaner 是 OCTO 服务治理体系内的一个独立的服务健康检查子系统.
+
+开发语言: Java
+
+运行环境要求: JDK 1.8及以上、maven3、zookeeper
+
+组件依赖: [Dorado](https://github.com/Meituan-Dianping/octo-rpc/tree/master/dorado)
+
+主要功能点:
+
+1.持续检测 OCTO 系统内所有服务节点的端口存活状态, 并自动维护节点的状态信息
+
+
+## 整体架构
+
+
+## 设计细节
+### 自定义心跳
+对于 OCTO 系统内的服务提供者,Scanner支持使用应用层心跳来代替端口检测,能够更准确地判断服务节点的存活状态。
+
+### 快慢线程
+Scanner的扫描线程分为两类,正常节点和异常节点分为两个线程池扫描,用户也可以自定义两个线程池的线程数。
+
+### 超时重试
+对于检测超时的节点,Scanner会进行重试探测,避免网络抖动或闪断带来的影响
+
+### 检测关键参数
+ 端口连通性检查 -> Socket Refused.
+ 端口超时检查 -> Socket Timeout
+
+### 核心功能图示
+1.Provider 状态转换图
+
+
+## 快速上手
+### 编译安装dorado到本地maven仓库
+参考[Dorado 源码编译说明](https://github.com/Meituan-Dianping/octo-rpc/blob/master/dorado/dorado-doc/manual-developer/Compile.md)
+
+### 打包运行Scanner
+```bash
+git clone git@github.com:Meituan-Dianping/octo-ns.git
+
+cd octo-ns/scanner
+
+mvn clean package -Dmaven.test.skip=true
+
+cd target
+#需要在启动参数中指定zookeeper地址,也可以在src/main/resources/application.yaml指定
+java -Dzookeeper.url=xxx.xxx.xxx.xxx:xxxx -jar octo-scanner-0.0.1-SNAPSHOT.jar #日志会输出到当前路径下"octo-scanner/log/octo-scanner.log"文件
+
+```
+
+
diff --git a/scanner/docs/img/architecture.png b/scanner/docs/img/architecture.png
new file mode 100644
index 0000000..90bec8d
Binary files /dev/null and b/scanner/docs/img/architecture.png differ
diff --git a/scanner/docs/img/providerstatus.png b/scanner/docs/img/providerstatus.png
new file mode 100644
index 0000000..cc6a52d
Binary files /dev/null and b/scanner/docs/img/providerstatus.png differ
diff --git a/scanner/pom.xml b/scanner/pom.xml
new file mode 100644
index 0000000..54dba81
--- /dev/null
+++ b/scanner/pom.xml
@@ -0,0 +1,78 @@
+
+
+ 4.0.0
+
+ com.sankuai.octo
+ octo-scanner
+ 0.0.1-SNAPSHOT
+ jar
+
+ octo-scanner
+ octo scanner open source
+
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 1.5.18.RELEASE
+
+
+
+ UTF-8
+ UTF-8
+ 1.8
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter
+
+
+ org.springframework.boot
+ spring-boot-starter-logging
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-log4j2
+
+
+
+ org.apache.curator
+ curator-framework
+ 2.12.0
+
+
+
+ com.alibaba
+ fastjson
+ 1.2.47
+
+
+
+ com.meituan.octo
+ dorado
+ 1.0.0-SNAPSHOT
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
+
diff --git a/scanner/src/main/java/com/meituan/octo/mns/scanner/OctoScannerApplication.java b/scanner/src/main/java/com/meituan/octo/mns/scanner/OctoScannerApplication.java
new file mode 100644
index 0000000..0e80b98
--- /dev/null
+++ b/scanner/src/main/java/com/meituan/octo/mns/scanner/OctoScannerApplication.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2018 Meituan Dianping. All Rights Reserved.
+ *
+ * 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.
+ */
+
+package com.meituan.octo.mns.scanner;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.scheduling.annotation.EnableScheduling;
+
+@SpringBootApplication
+@EnableScheduling
+public class OctoScannerApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(OctoScannerApplication.class, args);
+ }
+}
diff --git a/scanner/src/main/java/com/meituan/octo/mns/scanner/configuration/CuratorConfiguration.java b/scanner/src/main/java/com/meituan/octo/mns/scanner/configuration/CuratorConfiguration.java
new file mode 100644
index 0000000..1e99545
--- /dev/null
+++ b/scanner/src/main/java/com/meituan/octo/mns/scanner/configuration/CuratorConfiguration.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2018 Meituan Dianping. All Rights Reserved.
+ *
+ * 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.
+ */
+
+package com.meituan.octo.mns.scanner.configuration;
+
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.CuratorFrameworkFactory;
+import org.apache.curator.retry.RetryForever;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class CuratorConfiguration {
+ @Bean
+ public CuratorFramework curatorFramework(@Value("${zookeeper.url}") String zkUrl) {
+ CuratorFramework client = CuratorFrameworkFactory.newClient(zkUrl, 10000, 10000, new RetryForever(10000));
+ client.start();
+ return client;
+ }
+}
diff --git a/scanner/src/main/java/com/meituan/octo/mns/scanner/configuration/ExecutorConfiguration.java b/scanner/src/main/java/com/meituan/octo/mns/scanner/configuration/ExecutorConfiguration.java
new file mode 100644
index 0000000..8fea4cf
--- /dev/null
+++ b/scanner/src/main/java/com/meituan/octo/mns/scanner/configuration/ExecutorConfiguration.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2018 Meituan Dianping. All Rights Reserved.
+ *
+ * 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.
+ */
+
+package com.meituan.octo.mns.scanner.configuration;
+
+import com.meituan.dorado.common.thread.DefaultThreadFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+
+@Configuration
+public class ExecutorConfiguration {
+ @Bean("aliveCheckExecutor")
+ public Executor aliveCheckExecutor(@Value("${executor.alive.threadCount}") int threadCount) {
+ return Executors.newFixedThreadPool(threadCount, new DefaultThreadFactory("aliveCheckExecutor"));
+ }
+
+ @Bean("deadCheckExecutor")
+ public Executor deadCheckExecutor(@Value("${executor.dead.threadCount}") int threadCount) {
+ return Executors.newFixedThreadPool(threadCount, new DefaultThreadFactory("deadCheckExecutor"));
+ }
+}
diff --git a/scanner/src/main/java/com/meituan/octo/mns/scanner/model/Provider.java b/scanner/src/main/java/com/meituan/octo/mns/scanner/model/Provider.java
new file mode 100644
index 0000000..98cc603
--- /dev/null
+++ b/scanner/src/main/java/com/meituan/octo/mns/scanner/model/Provider.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2018 Meituan Dianping. All Rights Reserved.
+ *
+ * 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.
+ */
+
+package com.meituan.octo.mns.scanner.model;
+
+public class Provider {
+ private String ip;
+ private int port;
+ private String env;
+ private String appkey;
+
+ public String getIpPort() {
+ return ip + ":" + port;
+ }
+
+ public String getIp() {
+ return ip;
+ }
+
+ public void setIp(String ip) {
+ this.ip = ip;
+ }
+
+ public int getPort() {
+ return port;
+ }
+
+ public void setPort(int port) {
+ this.port = port;
+ }
+
+ public String getEnv() {
+ return env;
+ }
+
+ public void setEnv(String env) {
+ this.env = env;
+ }
+
+ public String getAppkey() {
+ return appkey;
+ }
+
+ public void setAppkey(String appkey) {
+ this.appkey = appkey;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder("Provider{");
+ sb.append("ip='").append(ip).append('\'');
+ sb.append(", port=").append(port);
+ sb.append(", env='").append(env).append('\'');
+ sb.append(", appkey='").append(appkey).append('\'');
+ sb.append('}');
+ return sb.toString();
+ }
+}
diff --git a/scanner/src/main/java/com/meituan/octo/mns/scanner/service/ProviderDetectService.java b/scanner/src/main/java/com/meituan/octo/mns/scanner/service/ProviderDetectService.java
new file mode 100644
index 0000000..9360e1d
--- /dev/null
+++ b/scanner/src/main/java/com/meituan/octo/mns/scanner/service/ProviderDetectService.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2018 Meituan Dianping. All Rights Reserved.
+ *
+ * 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.
+ */
+
+package com.meituan.octo.mns.scanner.service;
+
+import com.alibaba.fastjson.JSONObject;
+import com.meituan.octo.mns.scanner.model.Provider;
+import com.meituan.octo.mns.scanner.util.Constant;
+import com.meituan.octo.mns.scanner.util.SocketDetector;
+import com.meituan.octo.mns.scanner.util.heartbeat.HeartbeatDetector;
+import org.apache.curator.framework.CuratorFramework;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import java.util.concurrent.Executor;
+import java.util.regex.Pattern;
+
+@Service
+public class ProviderDetectService {
+ private static final Logger log = LoggerFactory.getLogger(ProviderDetectService.class);
+ private static final Pattern IP_PORT_PATTERN = Pattern.compile("\\d+.\\d+.\\d+.\\d+:\\d+");
+
+ @Value("${zookeeper.basePath}")
+ private String basePath;
+
+ @Autowired
+ private CuratorFramework zkClient;
+
+ @Autowired
+ private Executor aliveCheckExecutor;
+
+ @Autowired
+ private Executor deadCheckExecutor;
+
+ @Autowired
+ private ProviderUpdateService updateService;
+
+ public void detect(long round, Provider provider) {
+ if (IP_PORT_PATTERN.matcher(provider.getIpPort()).matches()) {
+ JSONObject providerJson = getProviderJson(provider);
+ if (providerJson != null) {
+ int originalStatus = providerJson.getInteger("status");
+ Executor executor = null;
+
+ if (originalStatus == Constant.STATUS_STOPPED) {
+ log.info("round={}, detecting provider:{}, status:{}", round, provider, Constant.STATUS_STOPPED);
+ return;
+ } else if (originalStatus == Constant.STATUS_ALIVE) {
+ executor = aliveCheckExecutor;
+ } else {
+ executor = deadCheckExecutor;
+ }
+
+ executor.execute(() -> {
+ try {
+ Integer heartbeatType = providerJson.getInteger("heartbeatSupport");
+ if (heartbeatType == null) {
+ heartbeatType = 0;
+ }
+ int status;
+ if (Constant.HEARTBEAT_SUPPORT_SCANNER == heartbeatType
+ || Constant.HEARTBEAT_SUPPORT_BOTH == heartbeatType) {
+ status = HeartbeatDetector.detect(provider.getIp(), provider.getPort());
+ } else {
+ status = SocketDetector.detect(provider.getIp(), provider.getPort());
+ }
+ log.info("round={}, detecting provider:{}, status:{}", round, provider, status);
+ if (status != originalStatus) {
+ updateService.update(round, provider, providerJson, status);
+ }
+ } catch (Exception e) {
+ log.error("", e);
+ }
+ });
+ }
+ } else {
+ log.warn("invalid provider: {} ", provider);
+ }
+ }
+
+ private JSONObject getProviderJson(Provider provider) {
+ try {
+ byte[] data = zkClient.getData().forPath(
+ basePath + "/" + provider.getEnv() + "/" + provider.getAppkey() + "/provider/" + provider
+ .getIpPort());
+ return JSONObject.parseObject(new String(data));
+ } catch (Exception e) {
+ log.warn("get provider json exception:{}, message:{}", e.getClass(), e.getMessage());
+ }
+ return null;
+ }
+}
diff --git a/scanner/src/main/java/com/meituan/octo/mns/scanner/service/ProviderScanService.java b/scanner/src/main/java/com/meituan/octo/mns/scanner/service/ProviderScanService.java
new file mode 100644
index 0000000..d9e0f99
--- /dev/null
+++ b/scanner/src/main/java/com/meituan/octo/mns/scanner/service/ProviderScanService.java
@@ -0,0 +1,118 @@
+/*
+ * Copyright 2018 Meituan Dianping. All Rights Reserved.
+ *
+ * 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.
+ */
+
+package com.meituan.octo.mns.scanner.service;
+
+import com.meituan.octo.mns.scanner.model.Provider;
+import org.apache.curator.framework.CuratorFramework;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Service;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+@Service
+public class ProviderScanService {
+ private static final Logger log = LoggerFactory.getLogger(ProviderScanService.class);
+ private static final Pattern IP_PORT_PATTERN = Pattern.compile("\\d+.\\d+.\\d+.\\d+:\\d+");
+ private final AtomicLong scanRoundCounter = new AtomicLong(1);
+ private final String[] ENV_LIST = new String[] { "prod", "stage", "test" };
+ @Value("${zookeeper.basePath}")
+ private String basePath;
+
+ @Autowired
+ private CuratorFramework zkClient;
+
+ @Autowired
+ private ProviderDetectService detectService;
+
+ @Scheduled(fixedRate = 5000)
+ public void scanZk() {
+ try {
+ long start = System.currentTimeMillis();
+ long round = scanRoundCounter.getAndIncrement();
+ Set appkeys = getAllAppkeys();
+ appkeys.parallelStream().forEach(appkey -> {
+ log.info("round={}, scan appkey:{}", round, appkey);
+ try {
+ List providers = getProviders(appkey);
+ for (Provider provider : providers) {
+ try {
+ detectService.detect(round, provider);
+ } catch (Exception e) {
+ log.error("scan provider:{} exception:{}, message:{}", provider, e.getCause(),
+ e.getMessage());
+ }
+ }
+ } catch (Exception e) {
+ log.error("scan appkey:{} exception:{}, message:{}", appkey, e.getCause(), e.getMessage());
+ }
+ });
+ long end = System.currentTimeMillis();
+ log.info("round={}, scan {} appkeys cost {} ms", round, appkeys.size(), (end - start));
+ } catch (Exception e) {
+ log.error("scan zk exception:{}, message:{}", e.getCause(), e.getMessage());
+ }
+ }
+
+ private Set getAllAppkeys() {
+ return Arrays.stream(ENV_LIST).flatMap(env -> {
+ try {
+ return zkClient.getChildren().forPath(basePath + "/" + env).stream();
+ } catch (Exception e) {
+ return Stream.empty();
+ }
+ }).collect(Collectors.toSet());
+ }
+
+ private List getProviders(String appkey) {
+ try {
+ return Arrays.stream(ENV_LIST).flatMap(env -> {
+ try {
+ return zkClient.getChildren().forPath(basePath + "/" + env + "/" + appkey + "/provider").stream()
+ .map(ipPort -> {
+ if (!IP_PORT_PATTERN.matcher(ipPort).matches()) {
+ return null;
+ }
+ String ip = ipPort.split(":")[0];
+ int port = Integer.parseInt(ipPort.split(":")[1]);
+ Provider provider = new Provider();
+ provider.setIp(ip);
+ provider.setPort(port);
+ provider.setAppkey(appkey);
+ provider.setEnv(env);
+ return provider;
+ }).filter(Objects::nonNull);
+ } catch (Exception e) {
+ return null;
+ }
+ }).filter(Objects::nonNull).collect(Collectors.toList());
+ } catch (Exception e) {
+ return Collections.emptyList();
+ }
+ }
+}
diff --git a/scanner/src/main/java/com/meituan/octo/mns/scanner/service/ProviderUpdateService.java b/scanner/src/main/java/com/meituan/octo/mns/scanner/service/ProviderUpdateService.java
new file mode 100644
index 0000000..a4017a9
--- /dev/null
+++ b/scanner/src/main/java/com/meituan/octo/mns/scanner/service/ProviderUpdateService.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2018 Meituan Dianping. All Rights Reserved.
+ *
+ * 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.
+ */
+
+package com.meituan.octo.mns.scanner.service;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.meituan.octo.mns.scanner.model.Provider;
+import org.apache.curator.framework.CuratorFramework;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+@Service
+public class ProviderUpdateService {
+ private static final Logger log = LoggerFactory.getLogger(ProviderUpdateService.class);
+ @Value("${zookeeper.basePath}")
+ private String basePath;
+
+ @Autowired
+ private CuratorFramework zkClient;
+
+ public void update(long round, Provider provider, JSONObject providerJson, int status) {
+ log.info("round={}, updating provider:{}, status:{}", round, provider, status);
+ try {
+ long lastUpdateTime = System.currentTimeMillis() / 1000;
+ providerJson.put("status", status);
+ providerJson.put("lastUpdateTime", lastUpdateTime);
+ String providerPath =
+ basePath + "/" + provider.getEnv() + "/" + provider.getAppkey() + "/provider/" + provider
+ .getIpPort();
+ byte[] data = JSON.toJSONBytes(providerJson);
+ zkClient.setData().forPath(providerPath, data);
+ String serverPath = basePath + "/" + provider.getEnv() + "/" + provider.getAppkey() + "/provider";
+ byte[] serverPathData = zkClient.getData().forPath(serverPath);
+ JSONObject serverPathJson = JSON.parseObject(new String(serverPathData));
+ serverPathJson.put("lastUpdateTime", lastUpdateTime);
+ zkClient.setData().forPath(serverPath, serverPathData);
+ } catch (Exception e) {
+ log.error("update provider exception:{}, message:{}", e.getClass(), e.getMessage());
+ }
+ }
+}
diff --git a/scanner/src/main/java/com/meituan/octo/mns/scanner/util/Constant.java b/scanner/src/main/java/com/meituan/octo/mns/scanner/util/Constant.java
new file mode 100644
index 0000000..ccc66de
--- /dev/null
+++ b/scanner/src/main/java/com/meituan/octo/mns/scanner/util/Constant.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2018 Meituan Dianping. All Rights Reserved.
+ *
+ * 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.
+ */
+
+package com.meituan.octo.mns.scanner.util;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class Constant {
+ public static final int timeout;
+ public static final int STATUS_ALIVE = 2;
+ public static final int STATUS_DEAD = 0;
+ public static final int STATUS_STOPPED = 4;
+ public static final int HEARTBEAT_SUPPORT_SCANNER = 2;
+ public static final int HEARTBEAT_SUPPORT_BOTH = 3;
+ private static final Logger log = LoggerFactory.getLogger(Constant.class);
+ private static final int DEFAULT_TIMEOUT = 1000;
+
+ static {
+ int finalTimeout;
+ String timeoutValue = System.getProperty("provider.detect.timeout");
+ if (timeoutValue != null) {
+ try {
+ finalTimeout = Integer.parseInt(timeoutValue);
+ log.info("set timeout to {}", finalTimeout);
+ } catch (Exception e) {
+ log.warn("parse provider.detect.timeout exception, will use default value {}", DEFAULT_TIMEOUT);
+ finalTimeout = DEFAULT_TIMEOUT;
+ }
+ } else {
+ log.info("provider.detect.timeout is not provided, use default value {}", DEFAULT_TIMEOUT);
+ finalTimeout = DEFAULT_TIMEOUT;
+ }
+ timeout = finalTimeout;
+ }
+}
diff --git a/scanner/src/main/java/com/meituan/octo/mns/scanner/util/SocketDetector.java b/scanner/src/main/java/com/meituan/octo/mns/scanner/util/SocketDetector.java
new file mode 100644
index 0000000..160d307
--- /dev/null
+++ b/scanner/src/main/java/com/meituan/octo/mns/scanner/util/SocketDetector.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2018 Meituan Dianping. All Rights Reserved.
+ *
+ * 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.
+ */
+
+package com.meituan.octo.mns.scanner.util;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.net.Socket;
+import java.net.SocketException;
+import java.net.SocketTimeoutException;
+
+public class SocketDetector {
+ private static final Logger log = LoggerFactory.getLogger(SocketDetector.class);
+
+ public static int detect(String ip, int port) {
+ Socket socket = new Socket();
+ initSocket(socket);
+ try {
+ socket.connect(new InetSocketAddress(ip, port), Constant.timeout);
+ return Constant.STATUS_ALIVE;
+ } catch (SocketTimeoutException e) {
+ return detectAgain(ip, port);
+ } catch (Exception e) {
+ log.warn("provider:{}:{}, exception:{}", ip, port, e.getMessage());
+ return Constant.STATUS_DEAD;
+ } finally {
+ try {
+ socket.close();
+ } catch (IOException e) {
+ //ignored
+ }
+ }
+ }
+
+ private static int detectAgain(String ip, int port) {
+ Socket socket = new Socket();
+ initSocket(socket);
+ try {
+ socket.connect(new InetSocketAddress(ip, port), Constant.timeout);
+ return Constant.STATUS_ALIVE;
+ } catch (Exception e) {
+ log.warn("provider:{}:{}, exception:{}", ip, port, e.getMessage());
+ return Constant.STATUS_DEAD;
+ } finally {
+ try {
+ socket.close();
+ } catch (IOException e) {
+ //ignored
+ }
+ }
+ }
+
+ private static void initSocket(Socket socket) {
+ try {
+ socket.setSoLinger(false, Constant.STATUS_DEAD);
+ socket.setTcpNoDelay(true);
+ socket.setSoTimeout(Constant.timeout);
+ } catch (SocketException e) {
+ log.error("init socket error", e);
+ }
+ }
+}
diff --git a/scanner/src/main/java/com/meituan/octo/mns/scanner/util/heartbeat/HeartbeatClient.java b/scanner/src/main/java/com/meituan/octo/mns/scanner/util/heartbeat/HeartbeatClient.java
new file mode 100644
index 0000000..1f67a95
--- /dev/null
+++ b/scanner/src/main/java/com/meituan/octo/mns/scanner/util/heartbeat/HeartbeatClient.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2018 Meituan Dianping. All Rights Reserved.
+ *
+ * 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.
+ */
+
+package com.meituan.octo.mns.scanner.util.heartbeat;
+
+import com.google.common.util.concurrent.SettableFuture;
+import com.meituan.dorado.codec.octo.meta.CallType;
+import com.meituan.dorado.codec.octo.meta.Header;
+import com.meituan.dorado.codec.octo.meta.MessageType;
+import com.meituan.dorado.codec.octo.meta.RequestInfo;
+import com.meituan.octo.mns.scanner.util.Constant;
+import io.netty.bootstrap.Bootstrap;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelInitializer;
+import io.netty.channel.ChannelOption;
+import io.netty.channel.EventLoopGroup;
+import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.channel.socket.SocketChannel;
+import io.netty.channel.socket.nio.NioSocketChannel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+public class HeartbeatClient {
+ private static final Logger log = LoggerFactory.getLogger(HeartbeatClient.class);
+ private static final Header header;
+ private static EventLoopGroup heartbeatGroup = new NioEventLoopGroup();
+
+ static {
+ header = new Header();
+ header.setMessageType((byte) MessageType.ScannerHeartbeat.getValue());
+
+ RequestInfo requestInfo = new RequestInfo();
+ requestInfo.setSequenceId(1);
+ requestInfo.setTimeout(Constant.timeout);
+ requestInfo.setServiceName("ScannerHeartbeat");
+ requestInfo.setCallType((byte) CallType.Reply.getValue());
+ header.setRequestInfo(requestInfo);
+ header.setMessageType(((byte) MessageType.ScannerHeartbeat.getValue()));
+ }
+
+ public static int detect(String ip, int port) {
+ SettableFuture result = SettableFuture.create();
+ Bootstrap bootstrap = new Bootstrap();
+ bootstrap.group(heartbeatGroup).option(ChannelOption.TCP_NODELAY, true).option(ChannelOption.SO_REUSEADDR, true)
+ .channel(NioSocketChannel.class).handler(new ChannelInitializer() {
+ @Override
+ protected void initChannel(SocketChannel socketChannel) throws Exception {
+ socketChannel.pipeline().addLast(new HeartbeatCodec()).addLast(new HeartbeatHandler(result));
+ }
+ });
+ Channel channel = null;
+ try {
+ ChannelFuture future = bootstrap.connect(ip, port);
+ future.get(Constant.timeout, TimeUnit.MILLISECONDS);
+ channel = future.channel();
+ if (channel.isActive() && channel.isWritable()) {
+ channel.writeAndFlush(header);
+ try {
+ return result.get(Constant.timeout, TimeUnit.MILLISECONDS);
+ } catch (TimeoutException e) {
+ log.warn("detect:{}:{} timeout, timeout:{}", ip, port, Constant.timeout);
+ return Constant.STATUS_DEAD;
+ } catch (Exception e) {
+ log.error("", e);
+ return Constant.STATUS_DEAD;
+ }
+ } else {
+ return Constant.STATUS_DEAD;
+ }
+ } catch (TimeoutException e) {
+ log.warn("detect:{}:{} timeout, timeout:{}", ip, port, Constant.timeout);
+ return Constant.STATUS_DEAD;
+ } catch (ExecutionException e) {
+ log.warn("detect:{}:{} exception, exception:{}, message:{}", ip, port, e.getClass(), e.getMessage());
+ return Constant.STATUS_DEAD;
+ } catch (Exception e) {
+ log.error("", e);
+ return Constant.STATUS_DEAD;
+ } finally {
+ if (channel != null) {
+ channel.disconnect();
+ }
+ }
+
+ }
+}
diff --git a/scanner/src/main/java/com/meituan/octo/mns/scanner/util/heartbeat/HeartbeatCodec.java b/scanner/src/main/java/com/meituan/octo/mns/scanner/util/heartbeat/HeartbeatCodec.java
new file mode 100644
index 0000000..e7ef326
--- /dev/null
+++ b/scanner/src/main/java/com/meituan/octo/mns/scanner/util/heartbeat/HeartbeatCodec.java
@@ -0,0 +1,121 @@
+/*
+ * Copyright 2018 Meituan Dianping. All Rights Reserved.
+ *
+ * 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.
+ */
+
+package com.meituan.octo.mns.scanner.util.heartbeat;
+
+import com.meituan.dorado.codec.octo.DoradoCodec;
+import com.meituan.dorado.codec.octo.meta.Header;
+import com.meituan.dorado.common.exception.ProtocolException;
+import com.meituan.dorado.transport.meta.DefaultRequest;
+import com.meituan.dorado.util.BytesUtil;
+import com.meituan.dorado.util.CompressUtil;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.handler.codec.ByteToMessageCodec;
+import org.apache.thrift.TDeserializer;
+import org.apache.thrift.TException;
+import org.apache.thrift.TSerializer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+
+public class HeartbeatCodec extends ByteToMessageCodec {
+ private static final Logger log = LoggerFactory.getLogger(HeartbeatCodec.class);
+ private static final DoradoCodec codec = new DoradoCodec();
+
+ @Override
+ protected void encode(ChannelHandlerContext channelHandlerContext, Header header, ByteBuf byteBuf)
+ throws Exception {
+ byte[] headerBytes;
+ try {
+ headerBytes = new TSerializer().serialize(header);
+ } catch (TException e) {
+ log.error("", e);
+ return;
+ }
+
+ DefaultRequest request = new DefaultRequest();
+ request.setDoChecksum(false);
+ request.setCompressType(CompressUtil.CompressType.NO);
+ request.setVersion((byte) 0x00);
+ request.setSerialize((byte) 0x01);
+
+ byte[] total = codec.generateSendMessageBuff(request, headerBytes, new byte[0]);
+ byteBuf.writeBytes(total);
+ }
+
+ @Override
+ protected void decode(ChannelHandlerContext channelHandlerContext, ByteBuf byteBuf, List list)
+ throws Exception {
+ if (byteBuf.readableBytes() < 10) {
+ return;
+ }
+ byte[] buffer = new byte[byteBuf.readableBytes()];
+ byteBuf.markReaderIndex();
+ byteBuf.readBytes(buffer);
+ if (!isXMDProtocol(buffer)) {
+ throw new RuntimeException();
+ } else {
+ byte[] headerBodyBytes = this.getHeaderBodyBuff(buffer);
+ int headerBodyLength = headerBodyBytes.length;
+ short headerLength = BytesUtil.bytes2short(buffer, 8);
+ byte[] headerBytes = new byte[headerLength];
+ System.arraycopy(headerBodyBytes, 0, headerBytes, 0, headerLength);
+ byte[] bodyBytes = new byte[headerBodyLength - headerLength];
+ System.arraycopy(headerBodyBytes, headerLength, bodyBytes, 0, headerBodyLength - headerLength);
+
+ Header header = null;
+
+ try {
+ header = decodeXMDHeader(headerBytes);
+ list.add(header);
+ } catch (TException var13) {
+ throw new ProtocolException("Deserialize XMD header failed.", var13);
+ }
+ }
+
+ }
+
+ private Header decodeXMDHeader(byte[] headerBytes) throws TException {
+ TDeserializer deserializer = new TDeserializer();
+ Header header = new Header();
+ deserializer.deserialize(header, headerBytes);
+ return header;
+ }
+
+ private boolean isXMDProtocol(byte[] buffer) {
+ short magic = BytesUtil.bytes2short(buffer, 0);
+ return magic == -21574;
+ }
+
+ private byte[] getHeaderBodyBuff(byte[] buffer) {
+ int readerIndex = 4;
+ int totalLength = BytesUtil.bytes2int(buffer, readerIndex);
+ readerIndex += 6;
+
+ int msgNeedLength = totalLength + 8;
+ if (buffer.length < msgNeedLength) {
+ throw new RuntimeException("Message length less than need length");
+ }
+
+ int headerBodyLength = totalLength - 2;
+
+ byte[] headerBodyBytes = new byte[headerBodyLength];
+ System.arraycopy(buffer, readerIndex, headerBodyBytes, 0, headerBodyLength);
+ return headerBodyBytes;
+ }
+}
diff --git a/scanner/src/main/java/com/meituan/octo/mns/scanner/util/heartbeat/HeartbeatDetector.java b/scanner/src/main/java/com/meituan/octo/mns/scanner/util/heartbeat/HeartbeatDetector.java
new file mode 100644
index 0000000..390913c
--- /dev/null
+++ b/scanner/src/main/java/com/meituan/octo/mns/scanner/util/heartbeat/HeartbeatDetector.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2018 Meituan Dianping. All Rights Reserved.
+ *
+ * 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.
+ */
+
+package com.meituan.octo.mns.scanner.util.heartbeat;
+
+public class HeartbeatDetector {
+ public static int detect(String ip, int port) {
+ return HeartbeatClient.detect(ip, port);
+ }
+}
diff --git a/scanner/src/main/java/com/meituan/octo/mns/scanner/util/heartbeat/HeartbeatHandler.java b/scanner/src/main/java/com/meituan/octo/mns/scanner/util/heartbeat/HeartbeatHandler.java
new file mode 100644
index 0000000..bbf067b
--- /dev/null
+++ b/scanner/src/main/java/com/meituan/octo/mns/scanner/util/heartbeat/HeartbeatHandler.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2018 Meituan Dianping. All Rights Reserved.
+ *
+ * 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.
+ */
+
+package com.meituan.octo.mns.scanner.util.heartbeat;
+
+import com.google.common.util.concurrent.SettableFuture;
+import com.meituan.dorado.codec.octo.meta.Header;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.SimpleChannelInboundHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class HeartbeatHandler extends SimpleChannelInboundHandler {
+ private static final Logger log = LoggerFactory.getLogger(HeartbeatHandler.class);
+ private final SettableFuture result;
+
+ public HeartbeatHandler(SettableFuture result) {
+ this.result = result;
+ }
+
+ @Override
+ protected void channelRead0(ChannelHandlerContext channelHandlerContext, Header header) throws Exception {
+ result.set(header.getHeartbeatInfo().getStatus());
+ }
+
+ @Override
+ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
+ log.error("", cause);
+ ctx.close();
+ }
+}
diff --git a/scanner/src/main/resources/application.yaml b/scanner/src/main/resources/application.yaml
new file mode 100644
index 0000000..5419207
--- /dev/null
+++ b/scanner/src/main/resources/application.yaml
@@ -0,0 +1,9 @@
+zookeeper:
+ basePath: /octo/nameservice
+ #url: 127.0.0.1:2181
+
+executor:
+ alive:
+ threadCount: 16
+ dead:
+ threadCount: 16
\ No newline at end of file
diff --git a/scanner/src/main/resources/log4j2.xml b/scanner/src/main/resources/log4j2.xml
new file mode 100644
index 0000000..3d71035
--- /dev/null
+++ b/scanner/src/main/resources/log4j2.xml
@@ -0,0 +1,27 @@
+
+
+
+
+ %d{yyyy-MM-dd HH:mm:ss.SSS} %5p [%15.15t] %-40.40c{1.} : %m%n%ex
+
+ octo-scanner/log
+
+
+
+
+
+ ${LOG_PATTERN}
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sdk/mns-invoker/README.md b/sdk/mns-invoker/README.md
new file mode 100644
index 0000000..b6826c0
--- /dev/null
+++ b/sdk/mns-invoker/README.md
@@ -0,0 +1,389 @@
+# 1 概述说明
+Mns-Invoker是OCTO-NS的轻量级SDK,提供服务注册与注销,服务发现,基础工具类等功能。
+
+# 2 服务注册和发现
+## 2.1 服务注册
+### 描述
+用于注册thrift和http协议的服务节点
+
+```
+public static void registServiceWithCmd(int uptCmd, SGService sgService) throws TException
+```
+
+### 请求参数
+
+参数名 | 参数类型 | 描述
+------------- | ------------- | ------------
+uptCmd | int | 注册服务的命令码
+sgService | SGService | 参见相关结构体一节
+
+注册服务的命令码:
+
+0,重置(代表后面的serviceName list就是该应用支持的全量接口);
+1,增加(代表后面的serviceName list是该应用新增的接口);
+2,减少(代表后面的serviceName list是该应用删除的接口)。
+
+【NOTE】
+
+服务注册和注销的接口是异步的,因此,注册完后,获取服务列表的接口调用需要一定的反应时间,在正常情况下是20秒内。
+
+### 请求示例
+```
+String providerAppkey = "com.XXX.XXX.server";
+SGService service = getDefaultSGService(providerAppkey, 5198, true);
+ service.setProtocol("thrift");
+ MnsInvoker.registServiceWithCmd(0,service);
+private static SGService getDefaultSGService(final String appkey, final int port, final boolean isThrift) {
+ String protocol = isThrift ? "thrift" : "http";
+ SGService service = new SGService();
+ service.setAppkey(appkey);
+ service.setPort(port);
+ service.setVersion("original");
+ service.setIp(localIp);
+ service.setLastUpdateTime((int) (System.currentTimeMillis() / 1000));
+ service.setServerType(isThrift ? 0 : 1);
+ service.setWeight(10);
+ service.setFweight(10.d);
+ return service;
+}
+```
+## 2.2 服务注销
+### 描述
+用于注销thrift和http协议的服务节点
+
+```
+public static void unRegisterService(SGService sgService) throws TException
+```
+
+### 请求参数
+参数名 | 参数类型 | 描述
+------------- | ------------- | ------------
+sgService | SGService | 参见相关结构体一节
+
+【NOTE】
+
+注销接口不会从OCTO上删除节点。调用该接口会有以下变化:
+
+* 如果服务器上的status不等于4(禁用),则status的值会直接置成0,忽略调用者在sgService中设定的值。否则,status保持为4。
+* 使用sgService的version,extend值覆盖服务器上的旧值
+* lastUpdateTime改为当前系统的时间(sg_agent所在的机器)
+
+### 请求示例
+
+~~~
+MnsInvoker.unRegisterService(getSGService());
+// SGService的appkey,port,localIp,protocal,version等变量请自定义
+private SGService getSGService() {
+ SGService service = new SGService();
+ service.setAppkey(appKey)
+ .setPort(port).setIp(localIP)
+ .setLastUpdateTime((int) (System.currentTimeMillis() / 1000))
+ .setServerType(1)
+ .setWeight(10).setFweight(10.d)
+ .setProtocol(protocal);
+ service.setStatus(fb_status.DEAD.getValue())//fb_status.DEAD值为0
+ .setVersion(version);
+ return service;
+}
+~~~
+
+## 2.3 服务发现
+### 描述
+获取自定义协议的服务节点
+
+~~~
+public static List getServiceList(ProtocolRequest req)
+public static List getOriginServiceList(ProtocolRequest req)
+~~~
+
+### 请求参数
+参数名 | 参数类型 | 描述
+------------- | ------------- | ------------
+req | ProtocolRequest | 参见相关结构体一节
+
+### 返回值
+参数类型 | 描述
+------------- | ------------
+List | 不会返回null,但会返回空列表
+
+【NOTE】
+
+服务节点的获取接口,在第一次获取时,会去远程获取并保存到内存中,此后的调用都是读缓存。而服务节点列表由专门的线程进行更新,读写分离,因此该接口不会堵塞。第一次从远程获取的timeout = 300毫秒,服务节点列表的更新周期在5秒内。
+
+### 请求示例
+~~~
+final String consumerAppkey = "XXX";
+final String remoteAppkey = "XXX";
+ProtocolRequest httpReq = new ProtocolRequest()
+ .setLocalAppkey(consumerAppkey)
+ .setRemoteAppkey(remoteAppkey)
+ .setProtocol("http");
+ProtocolRequest thriftReq = new ProtocolRequest()
+ .setLocalAppkey(consumerAppkey)
+ .setRemoteAppkey(remoteAppkey)
+ .setProtocol("thrift");
+
+List httpList = MnsInvoker.getServiceList(httpReq);
+List thriftList = MnsInvoker.getServiceList(thriftReq);
+~~~
+## 2.4 服务列表监听
+### 描述
+为自定义协议的请求添加或删除监听器,监听器的作用是当服务列表发生变化时产生回调。
+
+~~~
+public static int addServiceListener(ProtocolRequest req, IServiceListChangeListener listener)
+public static int removeServiceListener(ProtocolRequest req, IServiceListChangeListener listener)
+~~~
+### 请求参数
+参数名 | 参数类型 | 描述
+------------- | ------------- | ------------
+req | ProtocolRequest | 参见相关结构体一节
+listener | IServiceListChangeListener | 服务监听器
+oldList | List | 旧服务列表
+newList | List | 新服务列表
+addList | List | 新增服务节点
+deletedList | List | 被删除的服务节点
+modifiedList | List | 发生变化的服务节点
+### 返回值
+参数类型 | 描述
+------------- | ------------
+int | 成功返回0,失败返回-1
+
+【NOTE】
+
+* SGService里面的appkey,ip,envir,port,protocol字段一般不会有改变,以下字段的变更会触发modifiedList:status,weight,fweight,version,role,serviceInfo
+* mns-invoker对于所有的服务列表监听器只起了一个线程去触发回调callback,因此,强烈建议用户不要在监听器的chaned()方法中做有阻塞的操作,否则会阻塞所有的监听器。
+* 可以对同一份服务列表添加多个监听器,但监听器必须是不同的(hashCode不同)。
+* 强烈建议用户不要自行修改ProtocolRequest和IServiceListChangeListener的hashCode和equals方法。
+
+~~~
+ProtocolRequest thriftReq = new ProtocolRequest()
+ .setLocalAppkey(localAppkey)
+ .setRemoteAppkey(remoteAppkey)
+ .setProtocol("thrift");
+IServiceListChangeListener thriftListener = new MyListener();
+MnsInvoker.addServiceListener(thriftReq, thriftListener);
+//进行服务注册or注销逻辑
+MnsInvoker.removeServiceListener(thriftReq, thriftListener);
+private class MyListener implements IServiceListChangeListener {
+ @Override
+ public void changed(ProtocolRequest req, List oldList, List newList, List addList, List deletedList, List modifiedList) {
+ //以下为自定义的业务逻辑,本例只打印变量内容。
+ System.out.println("req protocol: " + req.getProtocol());
+ if (!addList.isEmpty()) {
+ addCallback = true;
+ print("addList:", addList);
+ }
+ if (!deletedList.isEmpty()) {
+ deletedCallback = true;
+ print("deletedList:", deletedList);
+ }
+
+ }
+ private void print(String msg, List list) {
+ System.out.println(msg);
+ for (SGService service : list) {
+ System.out.println(service);
+ }
+ }
+ }
+~~~
+
+# 4 工具类
+## 4.1 根据ip查询idc内网信息
+### 描述
+根据ip列表获取对应的idc信息
+
+~~~
+public static Map getIdcInfo(List ips) throws MnsException
+~~~
+
+### 请求参数
+参数名 | 参数类型 | 描述
+------------- | ------------- | ------------
+ips | List | ip列表
+
+### 返回值
+参数类型 | 描述
+------------- | ------------
+Map | key为传入ip,valude为Idc信息,未查询到的返回Idc(unknown, unknown, unknown)
+
+## 4.2 全部idc内网信息获取
+### 描述
+查询获取对应的idc信息
+
+~~~
+public static List getIdcs()
+~~~
+
+### 返回值
+参数类型 | 描述
+------------- | ------------
+List | 所有Idc信息的列表
+
+## 4.3 查询本机ipv4地址
+### 描述
+查询本机ipv4地址
+
+~~~
+public static String getLocalIpV4()
+~~~
+
+### 返回值
+参数类型 | 描述
+------------- | ------------
+String | 返回ipv4
+
+## 4.4 查询本机环境
+### 描述
+查询本机octo.cfg配置文件里记录的环境信息
+
+~~~
+public static String getAppEnv()
+~~~
+
+### 返回值
+参数类型 | 描述
+------------- | ------------
+String | 环境信息,prod、stage、dev、ppe、test其中之一
+
+## 4.5 查询本机是否为线上环境
+### 描述
+查询本机octo.cfg配置文件里记录的环境是否属于线上环境
+
+~~~
+public static boolean isLocalHostOnline()
+~~~
+
+### 返回值
+参数类型 | 描述
+------------- | ------------
+boolean | true为线上环境,即prod或stage,其他dev、ppe、test均为线下环境
+## 4.6 查询Mns的zookeeper地址
+### 描述
+查询本机octo.cfg配置文件里面记录的服务注册中心mns的zookeeper地址
+
+~~~
+public static String getMnsZKUrl()
+~~~
+
+### 返回值
+参数类型 | 描述
+------------- | ------------
+String | ip:port连接的字符串,如配置文件不存在返回null。
+## 4.7 查询Mnsc服务的域名
+### 描述
+查询本机octo.cfg配置文件记录的mnsc服务域名
+
+~~~
+public static String getMnsZKUrl()
+~~~
+### 返回值
+参数类型 | 描述
+------------- | ------------
+String | 以http://开头的域名,如配置文件不存在返回null。
+
+## 4.8 查询idc文件的存储目录
+### 描述
+查询本机octo.cfg配置文件记录的idc文件位置
+
+~~~
+public static String getIdcPath()
+~~~
+### 返回值
+参数类型 | 描述
+------------- | ------------
+String | idc文件所在位置,如配置文件不存在返回null。
+
+## 4.9 查询sg_agent代理的端口号
+### 描述
+查询本机octo.cfg配置文件记录的sg_agent端口号
+
+~~~
+public static int getSgagentPort()
+~~~
+### 返回值
+参数类型 | 描述
+------------- | ------------
+int | 端口号
+## 4.10 查询sg_agent代理的appkey
+### 描述
+查询本机octo.cfg配置文件记录的sg_agent的appkey
+
+~~~
+public static String getSgagentAppkey() // sg_agent本地代理的appkey
+public static String getSgsentinelAppkey() // sg_sentinel即哨兵的appkey
+~~~
+
+### 返回值
+参数类型 | 描述
+------------- | ------------
+String | appkey,如配置文件不存在返回null。
+
+# 5 相关结构体
+## 5.1 ProtocolRequest
+~~~
+struct ProtocolRequest {
+
+1:string localAppkey;
+
+2:string remoteAppkey;
+
+3:string protocol;
+
+4:string serviceName;
+
+}
+
+/*
+
+*因为是由thrift产生的类,如果该结构体的字段顺序发生变化,则对应的带参的构造方法也会随着变化,
+
+*为了更好地兼容,因此,不建议使用带参的构造方法。
+
+*建议构建方式如下
+
+*/
+
+ProtocolRequest req = new ProtocolRequest();
+
+req.setLocalAppkey("本地appkey")
+
+.setRemoteAppkey("服务端appkey")
+
+.setProtocol("协议");
+~~~
+## 5.2 SGService
+~~~
+struct SGService
+
+{
+
+1:string appkey; //不能为空
+
+2:string version;
+
+3:string ip; //不能为空
+
+4:i32 port; //不能为空
+
+5:i32 weight; //一般设置为10
+
+6:i32 status; //2正常状态,0未启动
+
+7:i32 role; //backup角色,当其他服务无法服务的时候,启用backup状态;0(主)1(备)
+
+8:i32 envir; //运行环境,线上:prod=3,stage=2, 线下:dev=3,ppe=2,test=1
+
+9:i32 lastUpdateTime; //最后修改时间
+
+10:string extend; //扩展
+
+11:double fweight; //浮点型权重 一般设置为10.0
+
+12:i32 serverType; //用于区分http(1)和thrift(0)
+
+13:string protocol; //协议
+
+}
+~~~
\ No newline at end of file
diff --git a/sdk/mns-invoker/docs/Compile.md b/sdk/mns-invoker/docs/Compile.md
new file mode 100644
index 0000000..185df78
--- /dev/null
+++ b/sdk/mns-invoker/docs/Compile.md
@@ -0,0 +1,29 @@
+
+# mns-invoker 源码编译说明
+
+## 1.下载工程
+```
+ git clone https://github.com/Meituan-Dianping/octo-ns.git
+```
+
+## 2.构建Jar包
+环境要求:
+
+- Java version >= 1.8
+- Maven version >= 3.2
+
+切换到mns-invoker目录
+
+```
+cd sdk/mns-invoker
+```
+
+本地install,执行后在本地仓库~/.m2/repository/com/meituan/octo/mns-invoker/(假如你的仓库位置是~/
+.m2/repository)下可以找到mns-invoker的jar
+
+```
+# 切换到mns-invoker 目录下
+mvn clean install -Dmaven.test.skip=true
+```
+
+```
diff --git a/sdk/mns-invoker/pom.xml b/sdk/mns-invoker/pom.xml
new file mode 100644
index 0000000..2f98cef
--- /dev/null
+++ b/sdk/mns-invoker/pom.xml
@@ -0,0 +1,146 @@
+
+
+ 4.0.0
+
+ com.meituan.octo
+ mns-invoker
+ 1.0.0
+
+
+ 1.7
+ 2.9.5
+ 3.1
+ UTF-8
+ 3.0.3
+ 1024m
+
+
+
+
+ com.meituan.octo
+ idl-common
+ 1.0.0
+
+
+ org.apache.commons
+ commons-lang3
+ ${commons-lang3.version}
+
+
+ com.fasterxml.jackson.core
+ jackson-core
+ ${jackson.version}
+
+
+ com.fasterxml.jackson.core
+ jackson-annotations
+ ${jackson.version}
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ ${jackson.version}
+
+
+ org.slf4j
+ slf4j-api
+ 1.7.12
+
+
+ junit
+ junit
+ test
+ 4.12
+
+
+ org.apache.logging.log4j
+ log4j-api
+ test
+ 2.5
+
+
+ org.apache.logging.log4j
+ log4j-slf4j-impl
+ test
+ 2.5
+
+
+ org.apache.logging.log4j
+ log4j-core
+ test
+ 2.5
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 2.14
+
+ true
+
+ **/*Test*.java
+
+
+
+
+ org.apache.maven.plugins
+ maven-deploy-plugin
+ 2.7
+
+
+ org.apache.maven.plugins
+ maven-install-plugin
+ 2.4
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.0
+
+ ${java.version}
+ ${java.version}
+ ${project.build.sourceEncoding}
+ ${octo.build.jvmsize}
+ true
+ true
+
+
+
+
+ org.apache.maven.plugins
+ maven-resources-plugin
+ 2.6
+
+ ${project.build.sourceEncoding}
+
+
+
+
+ org.apache.maven.plugins
+ maven-source-plugin
+ 2.2.1
+
+
+ attach-sources
+ package
+
+ jar-no-fork
+ test-jar-no-fork
+
+
+
+
+
+
+
+ ${basedir}/src/test/resources
+ true
+
+
+
+
diff --git a/sdk/mns-invoker/src/main/java/com/meituan/octo/mns/Consts.java b/sdk/mns-invoker/src/main/java/com/meituan/octo/mns/Consts.java
new file mode 100644
index 0000000..b2cf089
--- /dev/null
+++ b/sdk/mns-invoker/src/main/java/com/meituan/octo/mns/Consts.java
@@ -0,0 +1,56 @@
+/*
+* Copyright (c) 2011-2018, Meituan Dianping. All Rights Reserved.
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you 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.
+*/
+package com.meituan.octo.mns;
+
+import com.meituan.octo.mns.util.ProcessInfoUtil;
+
+public class Consts {
+ public static final String LOCALHOST = "127.0.0.1";
+ // public static final boolean isOnline = ProcessInfoUtil.isLocalHostOnline();
+
+ // private static final String mnsUrl = isOnline ? "http://mns.sankuai.com" : "http://mns.inf.test.sankuai.com";
+
+
+ public static final String UNKNOWN = "unknown";
+ public static final int DEFALT_MAX_RESPONSE_MESSAGE_BYTES = 10 * 1024 * 1024;
+ public static final int DEFAULT_TIMEOUT_IN_MILLS = 5000;
+ public static final int SERVICES_THRESHOLD = 10;
+ public static final int RETRY_TIMES = 3;
+ public static final int CONNECT_TIMEOUT = 500;
+ public static final String GET_SERVER_LIST_API = ProcessInfoUtil.getMnsUrl() + "/api/servicelist?";
+
+ public static final int DEFAULT_UPDATE_TIME = 5;
+
+ public static final String CONFIG_FILE = "/data/webapps/octo.cfg";
+
+
+ public static final String ENV_KEY = "env";
+ public static final String IDC_PATH = "idc_path";
+ public static final String SG_AGENT_PORT = "port";
+ public static final String SG_SENTINEL_APPKEY = "sg_sentinel_appkey";
+ public static final String SGAENT_APPKEY = "sgagent_appkey";
+ public static final String MNSZK_URL = "mnszk_url";
+ public static final String MNS_URL = "mns_url";
+
+ public static final String MNS_DEFAULT_VERSION = "original";
+
+
+}
diff --git a/sdk/mns-invoker/src/main/java/com/meituan/octo/mns/InvokeProxy.java b/sdk/mns-invoker/src/main/java/com/meituan/octo/mns/InvokeProxy.java
new file mode 100644
index 0000000..0f0f180
--- /dev/null
+++ b/sdk/mns-invoker/src/main/java/com/meituan/octo/mns/InvokeProxy.java
@@ -0,0 +1,110 @@
+/*
+* Copyright (c) 2011-2018, Meituan Dianping. All Rights Reserved.
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you 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.
+*/
+package com.meituan.octo.mns;
+
+import com.meituan.octo.mns.model.SGAgentClient;
+import com.meituan.octo.mns.sentinel.AgentClientFactory;
+import com.octo.naming.service.thrift.model.ServiceAgent;
+import org.apache.thrift.transport.TTransportException;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.Arrays;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class InvokeProxy implements InvocationHandler {
+ private static final Logger LOG = LoggerFactory.getLogger(InvokeProxy.class);
+ private final SGAgentClient.ClientType type;
+ private static boolean isMock = false;
+ private static Object mockValue;
+
+ //lock
+ private static final Object MULTI_PROTO_LOCK = new Object();
+
+ public static void setIsMock(boolean isMock) {
+ InvokeProxy.isMock = isMock;
+ }
+
+ public static void setMockValue(Object mock) {
+ mockValue = mock;
+ }
+
+ public InvokeProxy(SGAgentClient.ClientType clientType) {
+ this.type = clientType;
+ }
+
+ public SGAgentClient.ClientType getType() {
+ return type;
+ }
+
+ public ServiceAgent.Iface getProxy() {
+ return (ServiceAgent.Iface) Proxy.newProxyInstance(ServiceAgent.class.getClassLoader(),
+ ServiceAgent.Client.class.getInterfaces(), this);
+ }
+
+ @Override
+ public Object invoke(Object proxy, Method method, Object[] args) {
+ Object result = null;
+
+ // to ensure proper use of locks, do not optimized the redundant case codes.
+ switch (type) {
+ case multiProto:
+ synchronized (MULTI_PROTO_LOCK) {
+ result = doInvoker(proxy, method, args);
+ }
+ break;
+ default:
+ // no lock for temp sg_agent connection.
+ result = doInvoker(proxy, method, args);
+ break;
+ }
+
+
+ return result;
+ }
+
+ private Object doInvoker(Object proxy, Method method, Object[] args) {
+ Object result = null;
+
+ // get the sg_agent connection
+ SGAgentClient client = AgentClientFactory.borrowClient(type);
+
+ try {
+ result = isMock ? mockValue : method.invoke(client.getIface(), args);
+
+ } catch (Exception e) {
+ LOG.debug("Invoker Exception, method: {} args: {}", method.getName(), Arrays.toString(args));
+ LOG.debug(e.getMessage(), e);
+
+ if (e.getCause() instanceof TTransportException) {
+ client.destory();
+ }
+
+ } finally {
+ // return the sg_agent connection
+ AgentClientFactory.returnClient(client);
+ }
+ return result;
+ }
+
+
+}
\ No newline at end of file
diff --git a/sdk/mns-invoker/src/main/java/com/meituan/octo/mns/MnsInvoker.java b/sdk/mns-invoker/src/main/java/com/meituan/octo/mns/MnsInvoker.java
new file mode 100644
index 0000000..30c8890
--- /dev/null
+++ b/sdk/mns-invoker/src/main/java/com/meituan/octo/mns/MnsInvoker.java
@@ -0,0 +1,71 @@
+/*
+* Copyright (c) 2011-2018, Meituan Dianping. All Rights Reserved.
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you 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.
+*/
+package com.meituan.octo.mns;
+
+import com.meituan.octo.mns.cache.MnsCacheManager;
+import com.meituan.octo.mns.listener.IServiceListChangeListener;
+import com.octo.naming.common.thrift.model.ProtocolRequest;
+import com.octo.naming.common.thrift.model.SGService;
+import org.apache.thrift.TException;
+
+import java.util.List;
+
+public class MnsInvoker {
+
+ private static MnsCacheManager cacheManager = new MnsCacheManager();
+
+ private static RegistryManager registryManager = new RegistryManager();
+
+
+ public static void registServiceWithCmd(int uptCmd, SGService sgService) throws TException {
+ registryManager.registerServiceWithCmd(uptCmd, sgService);
+ }
+
+ public static void unRegisterService(SGService sgService) throws TException {
+ registryManager.unRegisterService(sgService);
+ }
+
+
+ public static int addServiceListener(ProtocolRequest req, IServiceListChangeListener listener) {
+ return cacheManager.addServiceListListener(req, listener);
+ }
+
+ public static int removeServiceListener(ProtocolRequest req, IServiceListChangeListener listener) {
+ return cacheManager.removeServiceListListener(req, listener);
+ }
+
+ public static List getServiceList(ProtocolRequest req) {
+ return cacheManager.getServiceList(req);
+ }
+
+ public static List getOriginServiceList(ProtocolRequest req) {
+ return cacheManager.getOriginServiceList(req);
+ }
+
+ public static int addOriginServiceListener(ProtocolRequest req, IServiceListChangeListener listener) {
+ return cacheManager.addOriginServiceListListener(req, listener);
+ }
+
+ public static int removeOriginServiceListener(ProtocolRequest req, IServiceListChangeListener listener) {
+ return cacheManager.removeOriginServiceListListener(req, listener);
+ }
+
+}
diff --git a/sdk/mns-invoker/src/main/java/com/meituan/octo/mns/RegistryManager.java b/sdk/mns-invoker/src/main/java/com/meituan/octo/mns/RegistryManager.java
new file mode 100644
index 0000000..c0c17cf
--- /dev/null
+++ b/sdk/mns-invoker/src/main/java/com/meituan/octo/mns/RegistryManager.java
@@ -0,0 +1,104 @@
+/*
+* Copyright (c) 2011-2018, Meituan Dianping. All Rights Reserved.
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you 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.
+*/
+package com.meituan.octo.mns;
+
+import com.meituan.octo.mns.model.SGAgentClient;
+import com.meituan.octo.mns.util.IpUtil;
+import com.octo.naming.common.thrift.model.SGService;
+import com.octo.naming.service.thrift.model.ServiceAgent;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.thrift.TException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RegistryManager {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RegistryManager.class);
+ private final ServiceAgent.Iface tempClient = new InvokeProxy(SGAgentClient.ClientType.temp).getProxy();
+ private ExecutorService executors = Executors.newFixedThreadPool(1);
+
+
+ public void registerServiceWithCmd(final int cmd, final SGService sgService) throws TException {
+ if (!isSGServiceValid(sgService)) {
+ return;
+ }
+ executors.submit(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ synchronized (tempClient) {
+ LOG.info("Mns service provider registration, cmd ={} | param = {}", cmd,
+ sgService.toString());
+ tempClient.registServicewithCmd(cmd, sgService);
+ }
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ }
+ }
+ });
+ }
+
+ public void unRegisterService(final SGService sgService) throws TException {
+ if (!isSGServiceValid(sgService)) {
+ return;
+ }
+ executors.submit(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ synchronized (tempClient) {
+ LOG.info("Mns service provider unRegistration, param = {}", sgService.toString());
+ tempClient.unRegistService(sgService);
+ }
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ }
+ }
+ });
+ }
+
+
+ private static boolean isSGServiceValid(SGService service) {
+ if (null == service) {
+ LOG.error("Cannot register null.");
+ return false;
+ }
+ int port = service.getPort();
+ String appkey = service.getAppkey();
+ String ip = service.getIp();
+ if (port < 1) {
+ LOG.error("Invalid port: port|" + port + "|appkey:" + appkey);
+ return false;
+ }
+ if (StringUtils.isEmpty(appkey)) {
+ LOG.error("Invalid appKey: appkey|" + appkey);
+ return false;
+ }
+
+ if (!IpUtil.checkIP(ip)) {
+ LOG.error("Invalid ip: ip|" + ip + "|appkey:" + appkey);
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/sdk/mns-invoker/src/main/java/com/meituan/octo/mns/cache/CacheLoader.java b/sdk/mns-invoker/src/main/java/com/meituan/octo/mns/cache/CacheLoader.java
new file mode 100644
index 0000000..735aca9
--- /dev/null
+++ b/sdk/mns-invoker/src/main/java/com/meituan/octo/mns/cache/CacheLoader.java
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2011-2018, Meituan Dianping. All Rights Reserved.
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you 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.
+*/
+package com.meituan.octo.mns.cache;
+
+public interface CacheLoader {
+ V reload(R row, C column);
+}
diff --git a/sdk/mns-invoker/src/main/java/com/meituan/octo/mns/cache/MnsCache.java b/sdk/mns-invoker/src/main/java/com/meituan/octo/mns/cache/MnsCache.java
new file mode 100644
index 0000000..3d8f24c
--- /dev/null
+++ b/sdk/mns-invoker/src/main/java/com/meituan/octo/mns/cache/MnsCache.java
@@ -0,0 +1,69 @@
+/*
+* Copyright (c) 2011-2018, Meituan Dianping. All Rights Reserved.
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you 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.
+*/
+package com.meituan.octo.mns.cache;
+
+public class MnsCache {
+ private MultiMap cache = MultiMap.create();
+ private CacheLoader loader;
+
+ public MnsCache() {
+ }
+
+ public MnsCache(CacheLoader loader) {
+ this.loader = loader;
+ }
+
+ public static MnsCache create() {
+ MnsCache instance = new MnsCache();
+ return instance;
+ }
+
+ public static MnsCache create(
+ CacheLoader loader) {
+ MnsCache instance = new MnsCache(loader);
+ return instance;
+ }
+
+ public void put(R row, C column, V value) {
+ cache.put(row, column, value);
+ }
+
+ public V get(R row, C column) {
+ return cache.get(row, column);
+ }
+
+ public boolean contains(R row, C column) {
+ return cache.contains(row, column);
+ }
+
+ public void updateAll() {
+ if (loader != null) {
+ for (R row : cache.rows()) {
+ for (C column : cache.columns(row)) {
+ V value = loader.reload(row, column);
+ if (null != value) {
+ put(row, column, value);
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/sdk/mns-invoker/src/main/java/com/meituan/octo/mns/cache/MnsCacheManager.java b/sdk/mns-invoker/src/main/java/com/meituan/octo/mns/cache/MnsCacheManager.java
new file mode 100644
index 0000000..9109928
--- /dev/null
+++ b/sdk/mns-invoker/src/main/java/com/meituan/octo/mns/cache/MnsCacheManager.java
@@ -0,0 +1,157 @@
+/*
+* Copyright (c) 2011-2018, Meituan Dianping. All Rights Reserved.
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you 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.
+*/
+package com.meituan.octo.mns.cache;
+
+import com.meituan.octo.mns.Consts;
+import com.meituan.octo.mns.listener.IServiceListChangeListener;
+import com.meituan.octo.mns.util.ScheduleTaskFactory;
+import com.octo.naming.common.thrift.model.ProtocolRequest;
+import com.octo.naming.common.thrift.model.SGService;
+import org.apache.commons.lang3.StringUtils;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class MnsCacheManager {
+ private static final Logger LOG = LoggerFactory.getLogger(MnsCacheManager.class);
+
+ private ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1, new ScheduleTaskFactory("MnsCacheManager-Schedule"));
+
+ private ServiceCache protocolServiceCache = new ServiceCache();
+
+ private ServiceCache originServiceCache = new OriginServiceCache();
+
+
+ private enum ServiceCacheType {
+ PROTOCOL, ORIGIN
+ }
+
+
+ public MnsCacheManager() {
+ LOG.info("init MnsCacheManager, start update scheduler");
+ scheduler.scheduleWithFixedDelay(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ protocolServiceCache.updateAll();
+ originServiceCache.updateAll();
+ } catch (Exception e) {
+ LOG.debug("update mns cache exception, " + e.getMessage(), e);
+ }
+ }
+ }, 1, Consts.DEFAULT_UPDATE_TIME, TimeUnit.SECONDS);
+ }
+
+ private boolean isValid(ProtocolRequest req) {
+ boolean ret = (null != req)
+ && !(StringUtils.isEmpty(req.getRemoteAppkey()) && StringUtils.isEmpty(req.getServiceName()))
+ && !StringUtils.isEmpty(req.getProtocol());
+ if (!ret) {
+ LOG.error("Invalid ProtocolRequest, protocol and remoteAppkey/serviceName cannot be empty.");
+ }
+ return ret;
+ }
+
+ private String handleLocalAppkey(String localAppkey) {
+ if (null == localAppkey) {
+ LOG.debug("localAppkey is null, probably not set, please check the settings!");
+ localAppkey = "";
+ }
+ return localAppkey;
+ }
+
+ private void pretreatServiceListRequest(ProtocolRequest req) {
+ String curLocalAppkey = handleLocalAppkey(req.getLocalAppkey());
+
+ req.setLocalAppkey(StringUtils.trim(curLocalAppkey))
+ .setRemoteAppkey(StringUtils.trim(req.getRemoteAppkey()))
+ .setServiceName(StringUtils.trim(req.getServiceName()))
+ .setProtocol(StringUtils.trim(req.getProtocol()));
+ }
+
+ public List getServiceList(ProtocolRequest req) {
+ return getServiceListByType(req, ServiceCacheType.PROTOCOL);
+ }
+
+ public List getOriginServiceList(ProtocolRequest req) {
+ return getServiceListByType(req, ServiceCacheType.ORIGIN);
+ }
+
+ private List