Repository: hank-whu/rpc-benchmark Branch: master Commit: 1fd6fda3aae7 Files: 288 Total size: 1008.5 KB Directory structure: gitextract_s2n0yisx/ ├── .gitattributes ├── .gitignore ├── LICENSE ├── README.md ├── armeria-client/ │ ├── pom.xml │ └── src/ │ └── main/ │ └── java/ │ └── benchmark/ │ └── rpc/ │ └── Client.java ├── armeria-server/ │ ├── pom.xml │ └── src/ │ └── main/ │ └── java/ │ └── benchmark/ │ ├── rpc/ │ │ └── Server.java │ └── service/ │ └── ArmeriaUserServiceServerImpl.java ├── benchmark-base/ │ ├── .java-version │ ├── pom.xml │ └── src/ │ └── main/ │ └── java/ │ └── benchmark/ │ ├── bean/ │ │ ├── Page.java │ │ └── User.java │ ├── pool/ │ │ ├── ConcurrentObjectPool.java │ │ ├── LockObjectPool.java │ │ ├── UnsafeUtils.java │ │ ├── ViberObjectPool.java │ │ └── WaitStrategy.java │ ├── rpc/ │ │ ├── AbstractClient.java │ │ ├── protocol/ │ │ │ ├── Request.java │ │ │ └── Response.java │ │ ├── route/ │ │ │ └── RouteService.java │ │ └── util/ │ │ ├── ByteBufferUtils.java │ │ ├── HttpClientUtils.java │ │ └── JsonUtils.java │ └── service/ │ ├── ServiceRegister.java │ ├── UserService.java │ ├── UserServiceJsonHttpClientImpl.java │ └── UserServiceServerImpl.java ├── benchmark.java ├── brpc-client/ │ ├── pom.xml │ └── src/ │ └── main/ │ ├── java/ │ │ └── benchmark/ │ │ └── rpc/ │ │ └── Client.java │ └── resources/ │ └── logback.xml ├── brpc-server/ │ ├── pom.xml │ └── src/ │ └── main/ │ ├── java/ │ │ └── benchmark/ │ │ └── rpc/ │ │ └── Server.java │ └── resources/ │ └── logback.xml ├── dubbo-client/ │ ├── pom.xml │ └── src/ │ └── main/ │ ├── java/ │ │ └── benchmark/ │ │ └── rpc/ │ │ └── Client.java │ └── resources/ │ ├── consumer.xml │ └── logback.xml ├── dubbo-kryo-client/ │ ├── .gitignore │ ├── pom.xml │ └── src/ │ └── main/ │ ├── java/ │ │ └── benchmark/ │ │ └── rpc/ │ │ └── Client.java │ └── resources/ │ ├── consumer.xml │ └── logback.xml ├── dubbo-kryo-server/ │ ├── pom.xml │ └── src/ │ └── main/ │ ├── java/ │ │ └── benchmark/ │ │ └── rpc/ │ │ └── Server.java │ └── resources/ │ ├── logback.xml │ └── provider.xml ├── dubbo-server/ │ ├── pom.xml │ └── src/ │ └── main/ │ ├── java/ │ │ └── benchmark/ │ │ └── rpc/ │ │ └── Server.java │ └── resources/ │ ├── logback.xml │ └── provider.xml ├── grpc-client/ │ ├── .gitignore │ ├── pom.xml │ └── src/ │ └── main/ │ ├── java/ │ │ └── benchmark/ │ │ └── rpc/ │ │ ├── Client.java │ │ └── grpc/ │ │ ├── GrpcUserServiceClient.java │ │ └── UserServiceGrpcClientImpl.java │ ├── proto/ │ │ └── UserService.proto │ └── resources/ │ └── logback.xml ├── grpc-server/ │ ├── pom.xml │ └── src/ │ └── main/ │ ├── java/ │ │ └── benchmark/ │ │ └── rpc/ │ │ ├── Server.java │ │ └── grpc/ │ │ └── server/ │ │ └── UserServiceGrpcServerImpl.java │ ├── proto/ │ │ └── UserService.proto │ └── resources/ │ └── logback.xml ├── hprose-client/ │ ├── pom.xml │ └── src/ │ └── main/ │ ├── java/ │ │ └── benchmark/ │ │ └── rpc/ │ │ └── Client.java │ └── resources/ │ └── consumer.xml ├── hprose-server/ │ ├── pom.xml │ └── src/ │ └── main/ │ ├── java/ │ │ └── benchmark/ │ │ └── rpc/ │ │ └── Server.java │ └── resources/ │ └── provider.xml ├── jupiter-client/ │ ├── pom.xml │ └── src/ │ └── main/ │ ├── java/ │ │ └── benchmark/ │ │ ├── rpc/ │ │ │ └── Client.java │ │ └── service/ │ │ └── JupiterUserService.java │ └── resources/ │ ├── META-INF/ │ │ └── services/ │ │ └── org.jupiter.rpc.consumer.processor.ConsumerExecutorFactory │ ├── logback.xml │ └── spring-consumer.xml ├── jupiter-server/ │ ├── .gitignore │ ├── pom.xml │ └── src/ │ └── main/ │ ├── java/ │ │ └── benchmark/ │ │ ├── rpc/ │ │ │ └── Server.java │ │ └── service/ │ │ ├── JupiterUserService.java │ │ └── JupiterUserServiceServerImpl.java │ └── resources/ │ ├── META-INF/ │ │ └── services/ │ │ └── org.jupiter.rpc.provider.processor.ProviderExecutorFactory │ ├── logback.xml │ └── spring-provider.xml ├── motan-client/ │ ├── pom.xml │ └── src/ │ └── main/ │ ├── java/ │ │ └── benchmark/ │ │ ├── bean/ │ │ │ └── MotanUser.java │ │ ├── rpc/ │ │ │ └── Client.java │ │ └── service/ │ │ ├── MotanUserService.java │ │ └── MotanUserServiceServerImpl.java │ └── resources/ │ └── motan_client.xml ├── motan-server/ │ ├── .gitignore │ ├── pom.xml │ └── src/ │ └── main/ │ ├── java/ │ │ └── benchmark/ │ │ ├── bean/ │ │ │ └── MotanUser.java │ │ ├── rpc/ │ │ │ └── Server.java │ │ └── service/ │ │ ├── MotanUserService.java │ │ └── MotanUserServiceServerImpl.java │ └── resources/ │ └── motan_server.xml ├── netty-client/ │ ├── pom.xml │ └── src/ │ └── main/ │ ├── java/ │ │ └── benchmark/ │ │ └── rpc/ │ │ ├── Client.java │ │ └── netty/ │ │ ├── client/ │ │ │ ├── NettyClientConnector.java │ │ │ ├── UserServiceNettyClientImpl.java │ │ │ ├── codec/ │ │ │ │ ├── ProtocolDecoder.java │ │ │ │ └── ProtocolEncoder.java │ │ │ ├── future/ │ │ │ │ └── FutureContainer.java │ │ │ └── handler/ │ │ │ ├── BenchmarkChannelInitializer.java │ │ │ └── BenchmarkClientHandler.java │ │ └── serializer/ │ │ ├── BooleanSerializer.java │ │ ├── FastestSerializer.java │ │ ├── IntegerSerializer.java │ │ ├── LocalDateSerializer.java │ │ ├── LocalDateTimeSerializer.java │ │ ├── LocalTimeSerializer.java │ │ ├── LongSerializer.java │ │ ├── ObjectSerializer.java │ │ ├── Register.java │ │ ├── RequestSerializer.java │ │ ├── ResponseSerializer.java │ │ ├── Serializer.java │ │ ├── StringSerializer.java │ │ ├── UserPageSerializer.java │ │ ├── UserSerializer.java │ │ └── VoidSerializer.java │ └── resources/ │ └── logback.xml ├── netty-server/ │ ├── pom.xml │ └── src/ │ └── main/ │ └── java/ │ └── benchmark/ │ └── rpc/ │ ├── Server.java │ └── netty/ │ ├── serializer/ │ │ ├── BooleanSerializer.java │ │ ├── FastestSerializer.java │ │ ├── IntegerSerializer.java │ │ ├── LocalDateSerializer.java │ │ ├── LocalDateTimeSerializer.java │ │ ├── LocalTimeSerializer.java │ │ ├── LongSerializer.java │ │ ├── ObjectSerializer.java │ │ ├── Register.java │ │ ├── RequestSerializer.java │ │ ├── ResponseSerializer.java │ │ ├── Serializer.java │ │ ├── StringSerializer.java │ │ ├── UserPageSerializer.java │ │ ├── UserSerializer.java │ │ └── VoidSerializer.java │ └── server/ │ ├── codec/ │ │ ├── ProtocolDecoder.java │ │ └── ProtocolEncoder.java │ └── handler/ │ ├── BenchmarkChannelInitializer.java │ └── BenchmarkServerHandler.java ├── pom.xml ├── rapidoid-client/ │ ├── pom.xml │ └── src/ │ └── main/ │ └── java/ │ └── benchmark/ │ └── rpc/ │ └── Client.java ├── rapidoid-server/ │ ├── .gitignore │ ├── pom.xml │ └── src/ │ └── main/ │ └── java/ │ └── benchmark/ │ └── rpc/ │ ├── Server.java │ └── rapidoid/ │ └── server/ │ ├── CreateUserController.java │ ├── GetUserController.java │ ├── ListUserController.java │ └── UserExistController.java ├── rsocket-client/ │ ├── pom.xml │ └── src/ │ └── main/ │ ├── java/ │ │ └── benchmark/ │ │ └── rpc/ │ │ ├── Client.java │ │ └── rsocket/ │ │ └── UserServiceRsocketClientImpl.java │ └── proto/ │ └── UserService.proto ├── rsocket-server/ │ ├── pom.xml │ └── src/ │ └── main/ │ ├── java/ │ │ └── benchmark/ │ │ └── rpc/ │ │ ├── Server.java │ │ └── rsocket/ │ │ └── server/ │ │ └── UserServiceRsocketServerImpl.java │ └── proto/ │ └── UserService.proto ├── servicecomb-client/ │ ├── pom.xml │ └── src/ │ └── main/ │ ├── java/ │ │ └── benchmark/ │ │ └── rpc/ │ │ └── Client.java │ └── resources/ │ ├── META-INF/ │ │ └── spring/ │ │ └── benchmark.consumer.bean.xml │ ├── config/ │ │ └── log4j.demo.properties │ ├── log4j.properties │ └── microservice.yaml ├── servicecomb-server/ │ ├── pom.xml │ └── src/ │ └── main/ │ ├── java/ │ │ └── benchmark/ │ │ ├── rpc/ │ │ │ └── Server.java │ │ └── service/ │ │ └── ServiceCombUserServiceServerImpl.java │ └── resources/ │ ├── META-INF/ │ │ └── spring/ │ │ └── benchmark.provider.bean.xml │ ├── config/ │ │ └── log4j.demo.properties │ ├── log4j.properties │ └── microservice.yaml ├── sofa-client/ │ ├── pom.xml │ └── src/ │ └── main/ │ ├── java/ │ │ └── benchmark/ │ │ └── rpc/ │ │ └── Client.java │ └── resources/ │ └── logback.xml ├── sofa-server/ │ ├── .gitignore │ ├── pom.xml │ └── src/ │ └── main/ │ ├── java/ │ │ └── benchmark/ │ │ └── rpc/ │ │ └── Server.java │ └── resources/ │ └── logback.xml ├── springboot-client/ │ ├── pom.xml │ └── src/ │ └── main/ │ └── java/ │ └── benchmark/ │ └── rpc/ │ └── Client.java ├── springboot-server/ │ ├── .gitignore │ ├── pom.xml │ └── src/ │ └── main/ │ ├── java/ │ │ └── benchmark/ │ │ └── rpc/ │ │ ├── Server.java │ │ └── springboot/ │ │ └── server/ │ │ ├── CreateUserController.java │ │ ├── GetUserController.java │ │ ├── ListUserController.java │ │ └── UserExistController.java │ └── resources/ │ └── application.yml ├── springboot-undertow-client/ │ ├── .gitignore │ ├── pom.xml │ └── src/ │ └── main/ │ └── java/ │ └── benchmark/ │ └── rpc/ │ └── Client.java ├── springboot-undertow-server/ │ ├── .gitignore │ ├── pom.xml │ └── src/ │ └── main/ │ ├── java/ │ │ └── benchmark/ │ │ └── rpc/ │ │ ├── Server.java │ │ └── springboot/ │ │ └── server/ │ │ ├── CreateUserController.java │ │ ├── GetUserController.java │ │ ├── ListUserController.java │ │ └── UserExistController.java │ └── resources/ │ └── application.yml ├── springwebflux-client/ │ ├── .gitignore │ ├── pom.xml │ └── src/ │ └── main/ │ └── java/ │ └── benchmark/ │ └── rpc/ │ └── Client.java ├── springwebflux-server/ │ ├── .gitignore │ ├── pom.xml │ └── src/ │ └── main/ │ ├── java/ │ │ └── benchmark/ │ │ └── rpc/ │ │ ├── Server.java │ │ └── webflux/ │ │ └── server/ │ │ ├── CreateUserController.java │ │ ├── GetUserController.java │ │ ├── ListUserController.java │ │ └── UserExistController.java │ └── resources/ │ └── application.yml ├── thrift-client/ │ ├── .gitignore │ ├── pom.xml │ └── src/ │ └── main/ │ ├── java/ │ │ └── benchmark/ │ │ └── rpc/ │ │ ├── Client.java │ │ └── thrift/ │ │ ├── Converter.java │ │ ├── TServiceClientNoPrint.java │ │ ├── ThriftUserServiceClient.java │ │ ├── User.java │ │ ├── UserPage.java │ │ ├── UserService.java │ │ └── UserServiceThriftClientImpl.java │ ├── resources/ │ │ └── logback.xml │ └── thrift/ │ └── UserService.thrift ├── thrift-server/ │ ├── .gitignore │ ├── pom.xml │ └── src/ │ └── main/ │ ├── java/ │ │ └── benchmark/ │ │ └── rpc/ │ │ ├── Server.java │ │ └── thrift/ │ │ ├── Converter.java │ │ ├── User.java │ │ ├── UserPage.java │ │ ├── UserService.java │ │ └── UserServiceThriftServerImpl.java │ └── thrift/ │ ├── UserService.thrift │ └── gen-java/ │ └── benchmark/ │ └── rpc/ │ └── thrift/ │ ├── User.java │ ├── UserPage.java │ └── UserService.java ├── turbo-rest-client/ │ ├── pom.xml │ └── src/ │ └── main/ │ └── java/ │ └── benchmark/ │ ├── rpc/ │ │ └── Client.java │ └── service/ │ └── TurboUserServiceJsonHttpClientImpl.java ├── turbo-rest-server/ │ ├── .gitignore │ ├── pom.xml │ └── src/ │ └── main/ │ ├── java/ │ │ └── benchmark/ │ │ └── rpc/ │ │ ├── Server.java │ │ └── service/ │ │ ├── TurboUserService.java │ │ └── TurboUserServiceServerImpl.java │ └── resources/ │ └── logback.xml ├── turbo-rpc-client/ │ ├── .gitignore │ ├── pom.xml │ └── src/ │ └── main/ │ ├── java/ │ │ └── benchmark/ │ │ └── rpc/ │ │ ├── Client.java │ │ └── service/ │ │ └── TurboUserService.java │ └── resources/ │ ├── logback.xml │ └── turbo-client.conf ├── turbo-rpc-server/ │ ├── .gitignore │ ├── pom.xml │ └── src/ │ └── main/ │ ├── java/ │ │ └── benchmark/ │ │ └── rpc/ │ │ ├── Server.java │ │ └── service/ │ │ ├── TurboUserService.java │ │ └── TurboUserServiceServerImpl.java │ └── resources/ │ ├── logback.xml │ └── turbo-server.conf ├── undertow-async-client/ │ ├── .gitignore │ ├── pom.xml │ └── src/ │ └── main/ │ └── java/ │ └── benchmark/ │ └── rpc/ │ └── Client.java ├── undertow-async-server/ │ ├── .gitignore │ ├── pom.xml │ └── src/ │ └── main/ │ ├── java/ │ │ ├── benchmark/ │ │ │ └── rpc/ │ │ │ ├── Server.java │ │ │ └── undertow/ │ │ │ └── server/ │ │ │ ├── CreateUserHandler.java │ │ │ ├── GetUserHandler.java │ │ │ ├── ListUserHandler.java │ │ │ └── UserExistHandler.java │ │ └── io/ │ │ └── undertow/ │ │ └── async/ │ │ ├── handler/ │ │ │ └── AsyncHttpHandler.java │ │ ├── io/ │ │ │ ├── PooledByteBufferInputStream.java │ │ │ └── PooledByteBufferOutputStream.java │ │ └── util/ │ │ └── UnsafeUtils.java │ └── resources/ │ └── logback.xml ├── undertow-client/ │ ├── .gitignore │ ├── pom.xml │ └── src/ │ └── main/ │ └── java/ │ └── benchmark/ │ └── rpc/ │ └── Client.java └── undertow-server/ ├── .gitignore ├── pom.xml └── src/ └── main/ ├── java/ │ └── benchmark/ │ └── rpc/ │ ├── Server.java │ └── undertow/ │ └── server/ │ ├── CreateUserHandler.java │ ├── GetUserHandler.java │ ├── ListUserHandler.java │ └── UserExistHandler.java └── resources/ └── logback.xml ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitattributes ================================================ # Auto detect text files and perform LF normalization * text=auto ================================================ FILE: .gitignore ================================================ # Compiled class file *.class # Log file *.log # BlueJ files *.ctxt # Mobile Tools for Java (J2ME) .mtj.tmp/ # Package Files # *.jar *.war *.ear *.zip *.tar.gz *.rar *.gz # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* */.classpath */.factorypath */.project */.settings */.idea */target *.bak *.iml .idea .settings .project *.iml ================================================ FILE: LICENSE ================================================ 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. ================================================ FILE: README.md ================================================ # RPC Benchmark 几乎所有的 RPC 框架都宣称自己是“高性能”的, 那么实际结果到底如何呢, 让我们来做一个性能测试吧. ## 测试结果 - Round-5 2019-02-11 https://www.jianshu.com/p/cdd94d0853c3 - Round-4 2018-08-05 https://www.jianshu.com/p/72b98dc67d9d - Round-3 2018-05-12 https://www.jianshu.com/p/caf51f5cfbaa - Round-2 2018-03-25 https://www.jianshu.com/p/f0f494cfce94 - Round-1 2018-01-28 https://www.jianshu.com/p/18c95649b1a4 ## 测试说明 - 仅限于Java. - 客户端使用JMH进行压测, 32 线程, 3 轮预热 3 轮测试 每轮 10s - 每次运行前都会执行 ***killall java***, 但没有在每轮测试时重启操作系统 - 所有类库版本在发布时都是最新的, 除非存在bug - 所有框架都尽量参考该项目自带的Benchmark实现 - 将会一直持续, 不定期发布测试结果 - 更多说明请移步: [怎样对 RPC 进行有效的性能测试](https://www.jianshu.com/p/cbcdf05eaa5c) ## 测试用例 1. boolean existUser(String email), 判断某个 email 是否存在 2. boolean createUser(User user), 添加一个 User 3. User getUser(long id), 根据 id 获取一个用户 4. Page listUser(int pageNo), 获取用户列表 ## 运行说明 1. 需要两台机器,一台作为客户端,一台作为服务端 2. 系统要求为 linux x64, 至少 4GB ram 3. 客户端需要安装 jdk 11, maven 3 4. 服务端需要安装 jdk 11 5. 客户端服务端均需要设置 hosts > 10.0.0.88 benchmark-client
> 10.0.0.99 benchmark-server 6. 服务端需要添加用户 benchmark, 需要配置成客户端免密登录, 也就是客户端可以通过如下方式访问服务端 > ssh benchmark@benchmark-server "ls -lh" 7. 客户端执行如下命令, 结果输出到 benchmark/benchmark-result > git clone https://github.com/hank-whu/rpc-benchmark.git
> cd rpc-benchmark
> java benchmark.java ## 开发者必读 1. cd benchmark-base && mvn install 2. 配置好 hosts: benchmark-client benchmark-server 3. 修改或者实现 xxx-server xxx-client 4. 启动 Server, 然后启动 Client, 确保能不出错跑完所有测试项目 5. 提交 Pull Request ## 免责声明 - 能力所限错误在所难免, 本测试用例及测试结果仅供参考. - 如果你认为xx框架的代码或配置存在问题,那么欢迎发起Pull Request. - 利益相关: 本测试用例作者同时为 [turbo](https://github.com/hank-whu/turbo-rpc), [undertow-async](https://github.com/hank-whu/undertow-async) 的作者. ## 关注微信公众号: rpcBenchmark ![rpcBenchmark](https://github.com/hank-whu/rpc-benchmark/raw/master/rpcBenchmark.jpg) ================================================ FILE: armeria-client/pom.xml ================================================ 4.0.0 benchmark.rpc armeria-client round-5 jar armeria-client http://maven.apache.org 11 11 UTF-8 round-5 benchmark.rpc benchmark-base ${version.benchmark-base} junit junit 4.12 test org.apache.maven.plugins maven-compiler-plugin 3.8.0 ${maven.compiler.source} ${maven.compiler.target} UTF-8 org.apache.maven.plugins maven-resources-plugin 3.1.0 UTF-8 maven-assembly-plugin 3.1.0 jar-with-dependencies benchmark.rpc.Client make-assembly package single src/main/resources ================================================ FILE: armeria-client/src/main/java/benchmark/rpc/Client.java ================================================ package benchmark.rpc; import java.util.concurrent.TimeUnit; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; import benchmark.bean.Page; import benchmark.bean.User; import benchmark.service.UserService; import benchmark.service.UserServiceJsonHttpClientImpl; @State(Scope.Benchmark) public class Client extends AbstractClient { public static final int CONCURRENCY = 32; private final UserService userService = new UserServiceJsonHttpClientImpl(CONCURRENCY); @Override protected UserService getUserService() { return userService; } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public boolean existUser() throws Exception { return super.existUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public boolean createUser() throws Exception { return super.createUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public User getUser() throws Exception { return super.getUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public Page listUser() throws Exception { return super.listUser(); } public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder()// .include(Client.class.getSimpleName())// .warmupIterations(3)// .warmupTime(TimeValue.seconds(10))// .measurementIterations(3)// .measurementTime(TimeValue.seconds(10))// .threads(CONCURRENCY)// .forks(1)// .build(); new Runner(opt).run(); } } ================================================ FILE: armeria-server/pom.xml ================================================ 4.0.0 benchmark.rpc armeria-server round-5 jar armeria-server http://maven.apache.org 11 11 UTF-8 round-5 0.79.0 benchmark.rpc benchmark-base ${version.benchmark-base} com.linecorp.armeria armeria ${armeria.version} junit junit 4.12 test org.apache.maven.plugins maven-compiler-plugin 3.8.0 ${maven.compiler.source} ${maven.compiler.target} UTF-8 org.apache.maven.plugins maven-resources-plugin 3.1.0 UTF-8 maven-assembly-plugin 3.1.0 jar-with-dependencies benchmark.rpc.Server make-assembly package single src/main/resources ================================================ FILE: armeria-server/src/main/java/benchmark/rpc/Server.java ================================================ package benchmark.rpc; import java.net.InetSocketAddress; import com.linecorp.armeria.server.ServerBuilder; import benchmark.service.ArmeriaUserServiceServerImpl; public class Server { public static void main(String[] args) throws Exception { ServerBuilder sb = new ServerBuilder(); // Configure an HTTP port. sb.http(new InetSocketAddress("benchmark-server", 8080)); // Using an annotated service object: sb.annotatedService(new ArmeriaUserServiceServerImpl()); sb.build().start().join(); } } ================================================ FILE: armeria-server/src/main/java/benchmark/service/ArmeriaUserServiceServerImpl.java ================================================ package benchmark.service; import java.time.LocalDate; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.linecorp.armeria.common.HttpResponse; import com.linecorp.armeria.server.annotation.Get; import com.linecorp.armeria.server.annotation.Param; import com.linecorp.armeria.server.annotation.Post; import com.linecorp.armeria.server.annotation.RequestObject; import benchmark.bean.Page; import benchmark.bean.User; import benchmark.rpc.util.JsonUtils; /** * only for server * * @author Hank * */ public class ArmeriaUserServiceServerImpl { private final ObjectMapper objectMapper = JsonUtils.objectMapper; @Get("/user-exist") public HttpResponse existUser(@Param("email") String email) { if (email == null || email.isEmpty()) { return HttpResponse.of(String.valueOf(Boolean.TRUE)); } if (email.charAt(email.length() - 1) < '5') { return HttpResponse.of(String.valueOf(Boolean.FALSE)); } return HttpResponse.of(String.valueOf(Boolean.TRUE)); } @Get("/get-user") public HttpResponse getUser(@Param("id") long id) throws JsonProcessingException { User user = new User(); user.setId(id); user.setName("Doug Lea"); user.setSex(1); user.setBirthday(LocalDate.of(1968, 12, 8)); user.setEmail("dong.lea@gmail.com"); user.setMobile("18612345678"); user.setAddress("北京市 中关村 中关村大街1号 鼎好大厦 1605"); user.setIcon("https://www.baidu.com/img/bd_logo1.png"); user.setStatus(1); user.setCreateTime(LocalDateTime.now()); user.setUpdateTime(user.getCreateTime()); List permissions = new ArrayList<>(List.of(1, 2, 3, 4, 5, 6, 7, 8, 19, 88, 86, 89, 90, 91, 92)); user.setPermissions(permissions); return HttpResponse.of(objectMapper.writeValueAsString(user)); } @Get("/list-user") public HttpResponse listUser(@Param("pageNo") int pageNo) throws JsonProcessingException { List userList = new ArrayList<>(15); for (int i = 0; i < 15; i++) { User user = new User(); user.setId(i); user.setName("Doug Lea" + i); user.setSex(1); user.setBirthday(LocalDate.of(1968, 12, 8)); user.setEmail("dong.lea@gmail.com" + i); user.setMobile("18612345678" + i); user.setAddress("北京市 中关村 中关村大街1号 鼎好大厦 1605" + i); user.setIcon("https://www.baidu.com/img/bd_logo1.png" + i); user.setStatus(1); user.setCreateTime(LocalDateTime.now()); user.setUpdateTime(user.getCreateTime()); List permissions = new ArrayList<>(List.of(1, 2, 3, 4, 5, 6, 7, 8, 19, 88, 86, 89, 90, 91, 92)); user.setPermissions(permissions); userList.add(user); } Page page = new Page<>(); page.setPageNo(pageNo); page.setTotal(1000); page.setResult(userList); return HttpResponse.of(objectMapper.writeValueAsString(page)); } @Post("/create-user") public HttpResponse createUser(@RequestObject User user) { if (user == null) { return HttpResponse.of(String.valueOf(Boolean.FALSE)); } return HttpResponse.of(String.valueOf(Boolean.TRUE)); } } ================================================ FILE: benchmark-base/.java-version ================================================ 11 ================================================ FILE: benchmark-base/pom.xml ================================================ 4.0.0 benchmark.rpc benchmark-base round-5 jar benchmark-base http://maven.apache.org 11 11 UTF-8 1.21 1.2.3 4.5.7 2.9.8 4.0.2 1.6.0 1.0 22.2 1.2.15 org.openjdk.jmh jmh-core ${version.jmh} org.openjdk.jmh jmh-generator-annprocess ${version.jmh} ch.qos.logback logback-classic ${version.logback} org.apache.httpcomponents httpclient ${version.httpclient} com.fasterxml.jackson.core jackson-databind ${version.jackson} com.fasterxml.jackson.datatype jackson-datatype-jdk8 ${version.jackson} com.fasterxml.jackson.datatype jackson-datatype-jsr310 ${version.jackson} com.fasterxml.jackson.module jackson-module-afterburner ${version.jackson} com.esotericsoftware kryo ${version.kryo} io.protostuff protostuff-core ${version.protostuff} io.protostuff protostuff-runtime ${version.protostuff} javax.annotation jsr250-api ${version.jsr250} org.vibur vibur-object-pool ${version.vibur} com.conversantmedia disruptor ${version.conversantmedia-disruptor} org.apache.maven.plugins maven-compiler-plugin 3.8.0 ${maven.compiler.source} ${maven.compiler.target} UTF-8 org.apache.maven.plugins maven-resources-plugin 3.1.0 UTF-8 src/main/resources ================================================ FILE: benchmark-base/src/main/java/benchmark/bean/Page.java ================================================ package benchmark.bean; import java.io.Serializable; import java.util.List; public class Page implements Serializable { private static final long serialVersionUID = -7529237188686406553L; private int pageNo; private int total; private List result; public int getPageNo() { return pageNo; } public void setPageNo(int pageNo) { this.pageNo = pageNo; } public int getTotal() { return total; } public void setTotal(int total) { this.total = total; } public List getResult() { return result; } public void setResult(List result) { this.result = result; } @Override public String toString() { return "Page [pageNo=" + pageNo + ", total=" + total + ", result=" + result + "]"; } } ================================================ FILE: benchmark-base/src/main/java/benchmark/bean/User.java ================================================ package benchmark.bean; import java.io.Serializable; import java.time.LocalDate; import java.time.LocalDateTime; import java.util.List; public class User implements Serializable { private static final long serialVersionUID = 2566816725396650300L; private long id; private String name; private int sex; private LocalDate birthday; private String email; private String mobile; private String address; private String icon; private List permissions; private int status; private LocalDateTime createTime; private LocalDateTime updateTime; public long getId() { return id; } public void setId(long id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getSex() { return sex; } public void setSex(int sex) { this.sex = sex; } public LocalDate getBirthday() { return birthday; } public void setBirthday(LocalDate birthday) { this.birthday = birthday; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getMobile() { return mobile; } public void setMobile(String mobile) { this.mobile = mobile; } public String getAddress() { return address; } public void setAddress(String address) { this.address = address; } public String getIcon() { return icon; } public void setIcon(String icon) { this.icon = icon; } public List getPermissions() { return permissions; } public void setPermissions(List permissions) { this.permissions = permissions; } public int getStatus() { return status; } public void setStatus(int status) { this.status = status; } public LocalDateTime getCreateTime() { return createTime; } public void setCreateTime(LocalDateTime createTime) { this.createTime = createTime; } public LocalDateTime getUpdateTime() { return updateTime; } public void setUpdateTime(LocalDateTime updateTime) { this.updateTime = updateTime; } @Override public String toString() { return "User [id=" + id + ", name=" + name + ", sex=" + sex + ", birthday=" + birthday + ", email=" + email + ", mobile=" + mobile + ", address=" + address + ", icon=" + icon + ", permissions=" + permissions + ", status=" + status + ", createTime=" + createTime + ", updateTime=" + updateTime + "]"; } } ================================================ FILE: benchmark-base/src/main/java/benchmark/pool/ConcurrentObjectPool.java ================================================ package benchmark.pool; import static benchmark.pool.UnsafeUtils.unsafe; import java.io.Closeable; import java.io.IOException; import java.util.concurrent.ThreadLocalRandom; import java.util.function.Supplier; /** * @author Hank * * @param */ @SuppressWarnings("unchecked") public class ConcurrentObjectPool implements Closeable { private static final long EXCHANGE; private static final int ABASE; private static final int ASHIFT; private static final Object EMPTY = new Object(); private static final WaitStrategy WAIT_STRATEGY = new WaitStrategy(); private final int size; volatile long p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17; private final Object[] array; private final Object[] closeList; volatile long q0, q1, q2, q3, q4, q5, q6, q7, q8, q9, q10, q11, q12, q13, q14, q15, q16, q17; private volatile Object exchange = EMPTY; volatile long r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15, r16, r17; public ConcurrentObjectPool(int poolSize, Supplier producer) { this.size = poolSize; this.closeList = new Object[poolSize]; this.array = new Object[poolSize]; for (int i = 0; i < poolSize; i++) { T t = producer.get(); array[i] = t; closeList[i] = t; } } public T borrow() { T fast = exchange(); if (fast != null) {// 抢到了 return fast; } for (int i = 0; i < Integer.MAX_VALUE; i++) { int random = ThreadLocalRandom.current().nextInt(size); for (int j = 0; j < size; j++) { long offset = offset((random + j) % size); Object obj = unsafe().getObjectVolatile(array, offset); if (obj != EMPTY) { if (unsafe().compareAndSwapObject(array, offset, obj, EMPTY)) { return (T) obj; } else { break; } } } WAIT_STRATEGY.idle(i); } return null; } public void release(final T t) { if (t == null) { return; } final boolean exchanged = exchange(t); for (int i = 0; i < Integer.MAX_VALUE; i++) { int random = ThreadLocalRandom.current().nextInt(size); for (int j = 0; j < size; j++) { if (exchanged && !checkExchange(t)) { return; } long offset = offset((random + j) % size); Object obj = unsafe().getObjectVolatile(array, offset); if (obj == EMPTY) { if (exchanged && !cancelExchange(t)) {// 被其他线程抢走了 return; } if (unsafe().compareAndSwapObject(array, offset, obj, t)) {// 归还资源 return; } break; } } WAIT_STRATEGY.idle(i); } } private boolean exchange(final Object value) { return unsafe().compareAndSwapObject(this, EXCHANGE, EMPTY, value); } private boolean cancelExchange(final Object value) { return unsafe().compareAndSwapObject(this, EXCHANGE, value, EMPTY); } private boolean checkExchange(final Object value) { return value == exchange; } private T exchange() { Object fast = exchange; // 抢一下 if (fast != EMPTY && unsafe().compareAndSwapObject(this, EXCHANGE, fast, EMPTY)) { return (T) fast;// 抢到了 } // 没抢到 return null; } @Override public void close() throws IOException { for (int i = 0; i < closeList.length; i++) { Object obj = closeList[i]; if (obj instanceof AutoCloseable) { try { ((AutoCloseable) obj).close(); } catch (Exception e) { e.printStackTrace(); } } } } private static final long offset(int key) { return ((long) key << ASHIFT) + ABASE; } static { try { EXCHANGE = unsafe().objectFieldOffset(ConcurrentObjectPool.class.getDeclaredField("exchange")); ABASE = unsafe().arrayBaseOffset(Object[].class); int scale = unsafe().arrayIndexScale(Object[].class); if ((scale & (scale - 1)) != 0) { throw new Error("array index scale not a power of two"); } ASHIFT = 31 - Integer.numberOfLeadingZeros(scale); } catch (Exception e) { throw new Error(e); } } } ================================================ FILE: benchmark-base/src/main/java/benchmark/pool/LockObjectPool.java ================================================ package benchmark.pool; import java.io.Closeable; import java.io.IOException; import java.util.IdentityHashMap; import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; import java.util.function.Supplier; /** * @author Hank * * @param */ @SuppressWarnings("unchecked") public class LockObjectPool implements Closeable { static class ObjectWithLock { public final Object obj; public final Lock lock; public ObjectWithLock(Object obj) { this.obj = obj; this.lock = new ReentrantLock(); } } private final ObjectWithLock[] array; private final IdentityHashMap lockMap; private final int poolSize; public LockObjectPool(int poolSize, Supplier producer) { this.poolSize = poolSize; lockMap = new IdentityHashMap<>(poolSize * 2); array = new ObjectWithLock[poolSize]; for (int i = 0; i < poolSize; i++) { T t = producer.get(); ObjectWithLock objectWithLock = new ObjectWithLock(t); array[i] = objectWithLock; lockMap.put(t, objectWithLock); } } public T borrow() { int index = ThreadLocalRandom.current().nextInt(poolSize); ObjectWithLock objectWithLock = array[index]; objectWithLock.lock.lock(); return (T) objectWithLock.obj; } public void release(T t) { if (t == null) { return; } lockMap.get(t).lock.unlock(); } @Override public void close() throws IOException { for (int i = 0; i < array.length; i++) { Object obj = array[i].obj; if (obj instanceof AutoCloseable) { try { ((AutoCloseable) obj).close(); } catch (Exception e) { e.printStackTrace(); } } } } } ================================================ FILE: benchmark-base/src/main/java/benchmark/pool/UnsafeUtils.java ================================================ package benchmark.pool; import sun.misc.Unsafe; public class UnsafeUtils { final static private Unsafe _unsafe; static { Unsafe tmpUnsafe = null; try { java.lang.reflect.Field field = sun.misc.Unsafe.class.getDeclaredField("theUnsafe"); field.setAccessible(true); tmpUnsafe = (sun.misc.Unsafe) field.get(null); } catch (java.lang.Exception e) { throw new Error(e); } _unsafe = tmpUnsafe; } public static final Unsafe unsafe() { return _unsafe; } } ================================================ FILE: benchmark-base/src/main/java/benchmark/pool/ViberObjectPool.java ================================================ package benchmark.pool; import java.io.Closeable; import java.io.IOException; import java.util.function.Supplier; import org.vibur.objectpool.ConcurrentPool; import org.vibur.objectpool.PoolObjectFactory; import org.vibur.objectpool.PoolService; import org.vibur.objectpool.util.ConcurrentCollection; import org.vibur.objectpool.util.MultithreadConcurrentQueueCollection; public class ViberObjectPool implements Closeable { private final PoolService pool; public ViberObjectPool(int poolSize, Supplier producer) { PoolObjectFactory poolObjectFactory = new PoolObjectFactory() { @Override public T create() { return producer.get(); } @Override public boolean readyToTake(T obj) { return true; } @Override public boolean readyToRestore(T obj) { return true; } @Override public void destroy(T obj) { if (obj instanceof AutoCloseable) { try { ((AutoCloseable) obj).close(); } catch (Exception e) { e.printStackTrace(); } } } }; ConcurrentCollection concurrentCollection = new MultithreadConcurrentQueueCollection<>(poolSize); pool = new ConcurrentPool<>(concurrentCollection, poolObjectFactory, poolSize, poolSize, false); } public T borrow() { return pool.take(); } public void release(T t) { if (t == null) { return; } pool.restore(t); } @Override public void close() throws IOException { pool.close(); } } ================================================ FILE: benchmark-base/src/main/java/benchmark/pool/WaitStrategy.java ================================================ package benchmark.pool; import java.util.concurrent.locks.LockSupport; public final class WaitStrategy { public final int idle(final int idleCounter) { final int idled = idleCounter + 1; if (idleCounter < 10) { Thread.onSpinWait(); return idled; } if (idleCounter < 10 + 10) { Thread.yield(); return idled; } LockSupport.parkNanos(1L); return idled; } } ================================================ FILE: benchmark-base/src/main/java/benchmark/rpc/AbstractClient.java ================================================ package benchmark.rpc; import java.util.concurrent.atomic.AtomicInteger; import benchmark.bean.Page; import benchmark.bean.User; import benchmark.service.UserService; import benchmark.service.UserServiceServerImpl; public abstract class AbstractClient { private final AtomicInteger counter = new AtomicInteger(0); private final UserService _serviceUserService = new UserServiceServerImpl(); protected abstract UserService getUserService(); public boolean existUser() throws Exception { String email = String.valueOf(counter.getAndIncrement()); return getUserService().existUser(email); } public boolean createUser() throws Exception { int id = counter.getAndIncrement(); User user = _serviceUserService.getUser(id); return getUserService().createUser(user); } public User getUser() throws Exception { int id = counter.getAndIncrement(); return getUserService().getUser(id); } public Page listUser() throws Exception { int pageNo = counter.getAndIncrement(); return getUserService().listUser(pageNo); } } ================================================ FILE: benchmark-base/src/main/java/benchmark/rpc/protocol/Request.java ================================================ package benchmark.rpc.protocol; import java.io.Serializable; import java.util.Arrays; public class Request implements Serializable { private static final long serialVersionUID = 7798556948864269597L; private long requestId; private int serviceId; private Object[] params; public long getRequestId() { return requestId; } public void setRequestId(long requestId) { this.requestId = requestId; } public int getServiceId() { return serviceId; } public void setServiceId(int serviceId) { this.serviceId = serviceId; } public Object[] getParams() { return params; } public void setParams(Object[] params) { this.params = params; } @Override public String toString() { return "Request [requestId=" + requestId + ", serviceId=" + serviceId + ", params=" + Arrays.toString(params) + "]"; } } ================================================ FILE: benchmark-base/src/main/java/benchmark/rpc/protocol/Response.java ================================================ package benchmark.rpc.protocol; import java.io.Serializable; public class Response implements Serializable { private static final long serialVersionUID = -2827803061483152127L; private long requestId; private byte statusCode; private Object result; public long getRequestId() { return requestId; } public void setRequestId(long requestId) { this.requestId = requestId; } public byte getStatusCode() { return statusCode; } public void setStatusCode(byte statusCode) { this.statusCode = statusCode; } public Object getResult() { return result; } public void setResult(Object result) { this.result = result; } @Override public String toString() { return "Response [requestId=" + requestId + ", statusCode=" + statusCode + ", result=" + result + "]"; } } ================================================ FILE: benchmark-base/src/main/java/benchmark/rpc/route/RouteService.java ================================================ package benchmark.rpc.route; import static benchmark.service.ServiceRegister.CREATE_USER; import static benchmark.service.ServiceRegister.EXIST_USER; import static benchmark.service.ServiceRegister.GET_USER; import static benchmark.service.ServiceRegister.LIST_USER; import benchmark.bean.User; import benchmark.service.UserService; import benchmark.service.UserServiceServerImpl; public class RouteService { private final UserService userService = new UserServiceServerImpl(); public Object invoke(int serviceId, Object[] params) { switch (serviceId) { case EXIST_USER: return userService.existUser((String) params[0]); case CREATE_USER: return userService.createUser((User) params[0]); case GET_USER: return userService.getUser((Long) params[0]); case LIST_USER: return userService.listUser((Integer) params[0]); default: break; } return null; } } ================================================ FILE: benchmark-base/src/main/java/benchmark/rpc/util/ByteBufferUtils.java ================================================ package benchmark.rpc.util; import static java.nio.charset.StandardCharsets.UTF_8; import java.nio.ByteBuffer; public class ByteBufferUtils { public static ByteBuffer allocateDirect(String str) { return _allocateByteBuffer(str.getBytes(UTF_8), true); } public static ByteBuffer allocate(String str) { return _allocateByteBuffer(str.getBytes(UTF_8), false); } public static ByteBuffer allocate(byte[] bytes) { return _allocateByteBuffer(bytes, false); } private static ByteBuffer _allocateByteBuffer(byte[] bytes, boolean isDirect) { final ByteBuffer buffer = isDirect ? // ByteBuffer.allocateDirect(bytes.length) : // ByteBuffer.allocate(bytes.length); buffer.put(bytes); buffer.flip(); return buffer; } } ================================================ FILE: benchmark-base/src/main/java/benchmark/rpc/util/HttpClientUtils.java ================================================ package benchmark.rpc.util; import org.apache.http.client.config.RequestConfig; import org.apache.http.config.SocketConfig; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; public class HttpClientUtils { public static final int SOCKET_TIMEOUT = 60000; public static final int CONNECTION_REQUEST_TIMEOUT = 60000; public static final int CONNECT_TIMEOUT = 60000; public static CloseableHttpClient createHttpClient(int concurrency) { HttpClientBuilder builder = HttpClientBuilder.create(); PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(); connManager.setDefaultMaxPerRoute(concurrency); connManager.setMaxTotal(concurrency); RequestConfig requestConfig = RequestConfig.custom()// .setAuthenticationEnabled(true)// .setSocketTimeout(SOCKET_TIMEOUT)// .setConnectionRequestTimeout(CONNECTION_REQUEST_TIMEOUT)// .setConnectTimeout(CONNECT_TIMEOUT)// .setRedirectsEnabled(true)// .setRelativeRedirectsAllowed(true)// .setMaxRedirects(15)// .build(); SocketConfig socketConfig = SocketConfig.custom()// .setSoKeepAlive(true)// .setSoReuseAddress(true)// .build(); builder.setConnectionManager(connManager); builder.setDefaultSocketConfig(socketConfig); builder.setDefaultRequestConfig(requestConfig); return builder.build(); } } ================================================ FILE: benchmark-base/src/main/java/benchmark/rpc/util/JsonUtils.java ================================================ package benchmark.rpc.util; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import com.fasterxml.jackson.module.afterburner.AfterburnerModule; public class JsonUtils { public static final ObjectMapper objectMapper = new ObjectMapper(); static { objectMapper.registerModule(new Jdk8Module()); objectMapper.registerModule(new JavaTimeModule()); objectMapper.registerModule(new AfterburnerModule()); } } ================================================ FILE: benchmark-base/src/main/java/benchmark/service/ServiceRegister.java ================================================ package benchmark.service; public interface ServiceRegister { public static final int EXIST_USER = 0; public static final int CREATE_USER = 1; public static final int GET_USER = 2; public static final int LIST_USER = 3; } ================================================ FILE: benchmark-base/src/main/java/benchmark/service/UserService.java ================================================ package benchmark.service; import benchmark.bean.Page; import benchmark.bean.User; public interface UserService { public boolean existUser(String email); public boolean createUser(User user); public User getUser(long id); public Page listUser(int pageNo); } ================================================ FILE: benchmark-base/src/main/java/benchmark/service/UserServiceJsonHttpClientImpl.java ================================================ package benchmark.service; import java.nio.charset.StandardCharsets; import org.apache.http.HttpEntity; import org.apache.http.client.entity.EntityBuilder; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.util.EntityUtils; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; import benchmark.bean.Page; import benchmark.bean.User; import benchmark.rpc.util.HttpClientUtils; import benchmark.rpc.util.JsonUtils; /** * only for client * * @author Hank * */ public class UserServiceJsonHttpClientImpl implements UserService { private static final String URL_EXIST_USER = "http://benchmark-server:8080/user-exist?email="; private static final String URL_CREATE_USER = "http://benchmark-server:8080/create-user"; private static final String URL_GET_USER = "http://benchmark-server:8080/get-user?id="; private static final String URL_LIST_USER = "http://benchmark-server:8080/list-user?pageNo="; private final CloseableHttpClient client; private final ObjectMapper objectMapper = JsonUtils.objectMapper; private final JavaType userPageType = objectMapper.getTypeFactory()// .constructParametricType(Page.class, User.class); public UserServiceJsonHttpClientImpl(int concurrency) { client = HttpClientUtils.createHttpClient(concurrency); } @Override public boolean existUser(String email) { try { String url = URL_EXIST_USER + email; HttpGet request = new HttpGet(url); CloseableHttpResponse response = client.execute(request); String result = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8); return "true".equals(result); } catch (Exception e) { throw new RuntimeException(e); } } @Override public boolean createUser(User user) { try { byte[] bytes = objectMapper.writeValueAsBytes(user); HttpPost request = new HttpPost(URL_CREATE_USER); HttpEntity entity = EntityBuilder.create().setBinary(bytes).build(); request.setEntity(entity); CloseableHttpResponse response = client.execute(request); String result = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8); return "true".equals(result); } catch (Exception e) { throw new RuntimeException(e); } } @Override public User getUser(long id) { try { String url = URL_GET_USER + id; HttpGet request = new HttpGet(url); CloseableHttpResponse response = client.execute(request); byte[] bytes = EntityUtils.toByteArray(response.getEntity()); return objectMapper.readValue(bytes, User.class); } catch (Exception e) { throw new RuntimeException(e); } } @Override public Page listUser(int pageNo) { try { String url = URL_LIST_USER + pageNo; HttpGet request = new HttpGet(url); CloseableHttpResponse response = client.execute(request); byte[] bytes = EntityUtils.toByteArray(response.getEntity()); return objectMapper.readValue(bytes, userPageType); } catch (Exception e) { throw new RuntimeException(e); } } public static void main(String[] args) throws Exception { UserService userService = new UserServiceJsonHttpClientImpl(256); System.out.println(userService.existUser("1236")); System.out.println(userService.getUser(123)); System.out.println(userService.listUser(123)); } } ================================================ FILE: benchmark-base/src/main/java/benchmark/service/UserServiceServerImpl.java ================================================ package benchmark.service; import java.time.LocalDate; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import benchmark.bean.Page; import benchmark.bean.User; /** * only for server * * @author Hank * */ public class UserServiceServerImpl implements UserService { @Override public boolean existUser(String email) { if (email == null || email.isEmpty()) { return true; } if (email.charAt(email.length() - 1) < '5') { return false; } return true; } @Override public User getUser(long id) { User user = new User(); user.setId(id); user.setName(new String("Doug Lea")); user.setSex(1); user.setBirthday(LocalDate.of(1968, 12, 8)); user.setEmail(new String("dong.lea@gmail.com")); user.setMobile(new String("18612345678")); user.setAddress(new String("北京市 中关村 中关村大街1号 鼎好大厦 1605")); user.setIcon(new String("https://www.baidu.com/img/bd_logo1.png")); user.setStatus(1); user.setCreateTime(LocalDateTime.now()); user.setUpdateTime(user.getCreateTime()); List permissions = new ArrayList( Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 19, 88, 86, 89, 90, 91, 92)); user.setPermissions(permissions); return user; } @Override public Page listUser(int pageNo) { List userList = new ArrayList<>(15); for (int i = 0; i < 15; i++) { User user = new User(); user.setId(i); user.setName("Doug Lea" + i); user.setSex(1); user.setBirthday(LocalDate.of(1968, 12, 8)); user.setEmail("dong.lea@gmail.com" + i); user.setMobile("18612345678" + i); user.setAddress("北京市 中关村 中关村大街1号 鼎好大厦 1605" + i); user.setIcon("https://www.baidu.com/img/bd_logo1.png" + i); user.setStatus(1); user.setCreateTime(LocalDateTime.now()); user.setUpdateTime(user.getCreateTime()); List permissions = new ArrayList( Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 19, 88, 86, 89, 90, 91, 92)); user.setPermissions(permissions); userList.add(user); } Page page = new Page<>(); page.setPageNo(pageNo); page.setTotal(1000); page.setResult(userList); return page; } @Override public boolean createUser(User user) { if (user == null) { return false; } return true; } } ================================================ FILE: benchmark.java ================================================ import java.io.*; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.time.LocalDateTime; import java.util.Arrays; import java.util.Comparator; import java.util.List; import java.util.Objects; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; import java.util.stream.Stream; public class benchmark { private final static String jvmOps = "java -server -Xmx1g -Xms1g -XX:MaxDirectMemorySize=1g -XX:+UseG1GC"; private final static File resultFolder = new File("benchmark-result"); private final static List funOrder = List.of("existUser", "createUser", "getUser", "listUser"); Item emptyItem = new Item(null, Typ.Thrpt, null, 0D); public static void main(String[] args) throws Exception { installBenchmarkBase(); var allTasks = getAllTasks() .filter(t -> !t.startsWith("jupiter")) //.filter(t -> t.compareTo("jupiter") > 0) .collect(Collectors.toList()); System.out.println("找到以下benchmark项目:"); System.out.println(allTasks); allTasks.forEach(benchmark::benchmark); report(); } private static void installBenchmarkBase() throws Exception { exec("benchmark-base", "mvn clean install"); } private static Stream getAllTasks() { var folder = new File("."); return Stream.of(folder.list()) .filter(name -> name.endsWith("-client")) .map(name -> name.substring(0, name.length() - "-client".length())) .sorted(); } private static void benchmark(String taskName) { try { var serverPackage = packageAndGet(new File(taskName + "-server")); var clientPackage = packageAndGet(new File(taskName + "-client")); startServer(serverPackage); //等服务器启动起来在启动客户端 TimeUnit.SECONDS.sleep(5); startClient(clientPackage); stopServer(serverPackage); } catch (Exception e) { e.printStackTrace(); } } private static File packageAndGet(File project) throws Exception { exec(project, "mvn clean package", null); var childList = new File(project, "target").listFiles(); var opt = Stream.of(childList) .filter(f -> f.getName().endsWith("-jar-with-dependencies.jar")) .findFirst(); if (opt.isPresent()) { return opt.get(); } return Stream.of(childList) .filter(f -> !f.getName().startsWith("original-")) .filter(f -> f.getName().endsWith(".jar")) .findFirst() .get(); } private static String taskName(File pkg) { var name = pkg.getName(); if (name.endsWith("-jar-with-dependencies.jar")) { return name.substring(0, name.length() - "-jar-with-dependencies.jar".length()); } else { return name.substring(0, name.length() - ".jar".length()); } } private static void startServer(File serverPackage) throws Exception { var name = serverPackage.getName(); System.out.printf("start %s\r\n", name); var resultPath = taskName(serverPackage) + ".log"; //copy到benchmark-server exec(serverPackage.getParentFile(), "scp " + name + " benchmark@benchmark-server:~", null); if (name.contains("servicecomb")) { //杀掉benchmark-server上的老servicecomb-service-center进程 exec("ssh", "benchmark@benchmark-server", "killall service-center"); //benchmark-server上启动servicecomb-service-center服务 var downloadCommand = "wget https://mirrors.tuna.tsinghua.edu.cn/apache/servicecomb/servicecomb-service-center/1.1.0/apache-servicecomb-service-center-1.1.0-linux-amd64.tar.gz"; var unzipCommand = "tar xvf apache-servicecomb-service-center-1.1.0-linux-amd64.tar.gz"; var confCommand = "sed -i \"s/127.0.0.1/benchmark-server/g\" ~/apache-servicecomb-service-center-1.1.0-linux-amd64/conf/app.conf"; var runCommand = "bash apache-servicecomb-service-center-1.1.0-linux-amd64/start-service-center.sh"; exec("ssh", "benchmark@benchmark-server", downloadCommand); exec("ssh", "benchmark@benchmark-server", unzipCommand); exec("ssh", "benchmark@benchmark-server", confCommand); exec("ssh", "benchmark@benchmark-server", runCommand); } //杀掉benchmark-server上的老进程 exec("ssh", "benchmark@benchmark-server", "killall java"); //benchmark-server上启动服务器 var remoteCommand = String.format("nohup %s -jar %s >> %s &", jvmOps, name, resultPath); exec("ssh", "benchmark@benchmark-server", remoteCommand); } private static void stopServer(File serverPackage) throws Exception { var name = serverPackage.getName(); System.out.println("stop " + name); //benchmark-server上启动服务器 exec("ssh", "benchmark@benchmark-server", "killall java"); if (name.contains("servicecomb")) { //杀掉benchmark-server上的老servicecomb-service-center进程 exec("ssh", "benchmark@benchmark-server", "killall service-center"); } } private static void startClient(File clientPackage) throws Exception { var name = clientPackage.getName(); System.out.println("start " + name); var resultFile = new File(resultFolder, taskName(clientPackage) + ".log"); var command = jvmOps + " -jar " + name; //启动客户端 exec(clientPackage.getParentFile(), command, resultFile); } private static void exec(String path, String command) throws Exception { if (path != null) { exec(new File(path), command, null); } else { exec((File) null, command, null); } } private static void exec(String command) throws Exception { exec((File) null, command, null); } private static void exec(File file, String command, File redirect) throws Exception { var process = Runtime.getRuntime().exec(command, null, file); if (redirect != null && !redirect.exists()) { redirect.getParentFile().mkdirs(); } try (var inputStream = process.getInputStream(); var inputStreamReader = new InputStreamReader(inputStream, StandardCharsets.UTF_8); var reader = new BufferedReader(inputStreamReader); var output = redirect != null ? new FileOutputStream(redirect) : null;) { var line = ""; while ((line = reader.readLine()) != null) { System.out.println(line); if (output != null) { output.write(line.getBytes("UTF-8")); output.write("\r\n".getBytes("UTF-8")); } } } catch (Throwable t) { t.printStackTrace(); } process.waitFor(); process.destroy(); } private static void exec(String... commands) throws Exception { System.out.println(Arrays.toString(commands)); var process = Runtime.getRuntime().exec(commands); try (var inputStream = process.getInputStream(); var inputStreamReader = new InputStreamReader(inputStream, StandardCharsets.UTF_8); var reader = new BufferedReader(inputStreamReader);) { var line = ""; while ((line = reader.readLine()) != null) { System.out.println(line); } } catch (Throwable t) { t.printStackTrace(); } process.waitFor(); process.destroy(); } public static void report() throws Exception { var reportFile = new File(resultFolder, "benchmark-report.md"); var reportWriter = new FileWriter(reportFile, StandardCharsets.UTF_8); var props = System.getProperties(); reportWriter.write("# RPC性能报告\r\n"); reportWriter.write("> 生成时间: " + LocalDateTime.now() + "
\r\n"); reportWriter.write("> 运行环境: " + props.getProperty("os.name") + ", " + props.getProperty("java.vm.name") + " " + props.getProperty("java.runtime.version") + "
\r\n"); reportWriter.write("> 启动参数: " + jvmOps + "
\r\n"); reportWriter.write("\r\n"); var header = "| framework | thrpt (ops/ms) | avgt (ms) | p90 (ms) | p99 (ms) | p999 (ms) |\r\n" + "|:--- |:---:|:---:|:---:|:---:|:---:|\r\n"; Stream.of(resultFolder.listFiles()) .filter(f -> f.getName().endsWith(".log")) .filter(f -> f.getName().contains("-client-")) .flatMap(resultFile -> { var name = resultFile.getName(); var index = name.indexOf("-client-"); var task = name.substring(0, index); return uncheck(() -> Files .lines(resultFile.toPath(), StandardCharsets.UTF_8) .filter(line -> line.startsWith("Client.")) .map(line -> extract(task, line)) .filter(item -> item != null)); }) .collect(Collectors.groupingBy(i -> i.fun)) .entrySet() .stream() .sorted(Comparator.comparingInt(kv -> funOrder.indexOf(kv.getKey()))) .forEach(kv -> { var fun = kv.getKey(); var items = kv.getValue(); var records = toRecords(items); uncheck(() -> reportWriter.write("\r\n## " + fun + "\r\n")); uncheck(() -> reportWriter.write(header)); records.forEach(record -> { var line = Stream .of(record.task, record.thrpt, record.avgt, record.p90, record.p99, record.p999) .map(Objects::toString) .collect(Collectors.joining("|", "|", "|\r\n")); uncheck(() -> reportWriter.write(line)); }); uncheck(() -> reportWriter.write("\r\n")); }); reportWriter.flush(); reportWriter.close(); System.out.println("成功生成性能报告: " + reportFile.getAbsolutePath()); } private static List toRecords(List items) { return items .stream() .collect(Collectors.groupingBy(item -> item.task)) .values() .stream() .map(list -> { var task = list.get(0).task; var thrpt = getScore(list, Typ.Thrpt); var avgt = getScore(list, Typ.Avgt); var p90 = getScore(list, Typ.P90); var p99 = getScore(list, Typ.P99); var p999 = getScore(list, Typ.P999); return new Record(task, thrpt, avgt, p90, p99, p999); }) .sorted(Comparator.comparingDouble(r -> -r.thrpt)) .collect(Collectors.toList()); } private static double getScore(List items, Typ typ) { return items.stream().filter(i -> i.typ == typ).findFirst().get().score; } private static Item extract(String task, String line) { if (line == null || line.length() == 0) { return null; } if (line.contains(" thrpt ")) { var array = line.split("\\s+"); var fun = array[0].replace("Client.", ""); var score = Double.parseDouble(array[3]); return new Item(task, Typ.Thrpt, fun, score); } if (line.contains(" avgt ")) { var array = line.split("\\s+"); var fun = array[0].replace("Client.", ""); var score = Double.parseDouble(array[3]); return new Item(task, Typ.Avgt, fun, score); } if (line.contains("·p0.90 ")) { var array = line.split("\\s+"); var fun = array[0]; var begin = fun.indexOf(':') + 1; var end = fun.indexOf('·'); fun = fun.substring(begin, end); var score = Double.parseDouble(array[2]); return new Item(task, Typ.P90, fun, score); } if (line.contains("·p0.99 ")) { var array = line.split("\\s+"); var fun = array[0]; var begin = fun.indexOf(':') + 1; var end = fun.indexOf('·'); fun = fun.substring(begin, end); var score = Double.parseDouble(array[2]); return new Item(task, Typ.P99, fun, score); } if (line.contains("·p0.999 ")) { var array = line.split("\\s+"); var fun = array[0]; var begin = fun.indexOf(':') + 1; var end = fun.indexOf('·'); fun = fun.substring(begin, end); var score = Double.parseDouble(array[2]); return new Item(task, Typ.P999, fun, score); } return null; } private static T uncheck(UncheckedSupplier fun) { try { return fun.get(); } catch (Exception e) { throw new RuntimeException(e); } } private static void uncheck(UncheckedFunction fun) { try { fun.apply(); } catch (Exception e) { throw new RuntimeException(e); } } @FunctionalInterface private static interface UncheckedSupplier { T get() throws Exception; } @FunctionalInterface private static interface UncheckedFunction { void apply() throws Exception; } } enum Typ { Thrpt("Thrpt"), Avgt("Avgt"), P90("P90"), P99("P99"), P999("P999"); public final String name; private Typ(String name) { this.name = name; } } class Item { public final String task; public final Typ typ; public final String fun; public final double score; public Item(String task, Typ typ, String fun, double score) { this.task = task; this.typ = typ; this.fun = fun; this.score = score; } } class Record { public final String task; public final double thrpt; public final double avgt; public final double p90; public final double p99; public final double p999; public Record(String task, double thrpt, double avgt, double p90, double p99, double p999) { this.task = task; this.thrpt = thrpt; this.avgt = avgt; this.p90 = p90; this.p99 = p99; this.p999 = p999; } } ================================================ FILE: brpc-client/pom.xml ================================================ 4.0.0 benchmark.rpc brpc-client round-5 jar brpc-client http://maven.apache.org 11 11 UTF-8 round-5 2.5.1 benchmark.rpc benchmark-base ${version.benchmark-base} com.baidu brpc-java ${version.brpc} junit junit 4.12 test org.apache.maven.plugins maven-compiler-plugin 3.8.0 ${maven.compiler.source} ${maven.compiler.target} UTF-8 org.apache.maven.plugins maven-resources-plugin 3.1.0 UTF-8 maven-assembly-plugin 3.1.0 jar-with-dependencies benchmark.rpc.Client make-assembly package single src/main/resources ================================================ FILE: brpc-client/src/main/java/benchmark/rpc/Client.java ================================================ package benchmark.rpc; import benchmark.bean.Page; import benchmark.bean.User; import benchmark.service.UserService; import com.baidu.brpc.client.BrpcProxy; import com.baidu.brpc.client.RpcClient; import com.baidu.brpc.client.RpcClientOptions; import com.baidu.brpc.client.loadbalance.LoadBalanceStrategy; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; import java.io.IOException; import java.util.concurrent.TimeUnit; @State(Scope.Benchmark) public class Client extends AbstractClient { public static final int CONCURRENCY = 32; private final UserService userService; private final RpcClient rpcClient; public Client() { RpcClientOptions clientOption = new RpcClientOptions(); clientOption.setProtocolType(com.baidu.brpc.protocol.Options.ProtocolType.PROTOCOL_HTTP_JSON_VALUE); clientOption.setWriteTimeoutMillis(1000); clientOption.setReadTimeoutMillis(1000); clientOption.setMaxTotalConnections(1000); clientOption.setMinIdleConnections(10); clientOption.setLoadBalanceType(LoadBalanceStrategy.LOAD_BALANCE_RANDOM); clientOption.setCompressType(com.baidu.brpc.protocol.Options.CompressType.COMPRESS_TYPE_ZLIB); String serviceUrl = "list://benchmark-server:8002"; this.rpcClient = new RpcClient(serviceUrl, clientOption); this.userService = BrpcProxy.getProxy(rpcClient, UserService.class); } @Override protected UserService getUserService() { return userService; } @TearDown public void close() throws IOException { this.rpcClient.stop(); } @Benchmark @BenchmarkMode({Mode.Throughput, Mode.AverageTime, Mode.SampleTime}) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public boolean existUser() throws Exception { return super.existUser(); } @Benchmark @BenchmarkMode({Mode.Throughput, Mode.AverageTime, Mode.SampleTime}) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public boolean createUser() throws Exception { return super.createUser(); } @Benchmark @BenchmarkMode({Mode.Throughput, Mode.AverageTime, Mode.SampleTime}) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public User getUser() throws Exception { return super.getUser(); } @Benchmark @BenchmarkMode({Mode.Throughput, Mode.AverageTime, Mode.SampleTime}) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public Page listUser() throws Exception { return super.listUser(); } public static void main(String[] args) throws Exception { Options opt = new OptionsBuilder()// .include(Client.class.getSimpleName())// .warmupIterations(3)// .warmupTime(TimeValue.seconds(10))// .measurementIterations(3)// .measurementTime(TimeValue.seconds(10))// .threads(CONCURRENCY)// .forks(1)// .build(); new Runner(opt).run(); } } ================================================ FILE: brpc-client/src/main/resources/logback.xml ================================================ %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n logs/benchmark-rpc-client.log logs/benchmark-rpc-client.%d{yyyy-MM-dd}.log.gz %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n ================================================ FILE: brpc-server/pom.xml ================================================ 4.0.0 benchmark.rpc brpc-server round-5 jar brpc-server http://maven.apache.org 11 11 UTF-8 round-5 2.5.1 benchmark.rpc benchmark-base ${version.benchmark-base} com.baidu brpc-java ${version.brpc} junit junit 4.12 test org.apache.maven.plugins maven-compiler-plugin 3.8.0 ${maven.compiler.source} ${maven.compiler.target} UTF-8 org.apache.maven.plugins maven-resources-plugin 3.1.0 UTF-8 maven-assembly-plugin 3.1.0 jar-with-dependencies benchmark.rpc.Server make-assembly package single src/main/resources ================================================ FILE: brpc-server/src/main/java/benchmark/rpc/Server.java ================================================ package benchmark.rpc; import benchmark.service.UserServiceServerImpl; import com.baidu.brpc.protocol.Options; import com.baidu.brpc.server.RpcServer; import com.baidu.brpc.server.RpcServerOptions; public class Server { public static void main(String[] args) throws InterruptedException { int port = 8002; RpcServerOptions options = new RpcServerOptions(); options.setReceiveBufferSize(64 * 1024 * 1024); options.setSendBufferSize(64 * 1024 * 1024); options.setKeepAliveTime(20); options.setProtocolType(Options.ProtocolType.PROTOCOL_HTTP_JSON_VALUE); final RpcServer rpcServer = new RpcServer(port, options); rpcServer.registerService(new UserServiceServerImpl()); rpcServer.start(); System.out.println("START"); Thread.sleep(Long.MAX_VALUE); } } ================================================ FILE: brpc-server/src/main/resources/logback.xml ================================================ %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n logs/benchmark-rpc-client.log logs/benchmark-rpc-client.%d{yyyy-MM-dd}.log.gz %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n ================================================ FILE: dubbo-client/pom.xml ================================================ 4.0.0 benchmark.rpc dubbo-client round-5 jar dubbo-client http://maven.apache.org 11 11 UTF-8 round-5 2.7.3 benchmark.rpc benchmark-base ${version.benchmark-base} org.apache.dubbo dubbo ${version.dubbo} junit junit 4.12 test org.apache.maven.plugins maven-compiler-plugin 3.8.0 ${maven.compiler.source} ${maven.compiler.target} UTF-8 org.apache.maven.plugins maven-resources-plugin 3.1.0 UTF-8 maven-assembly-plugin 3.1.0 jar-with-dependencies benchmark.rpc.Client make-assembly package single src/main/resources ================================================ FILE: dubbo-client/src/main/java/benchmark/rpc/Client.java ================================================ package benchmark.rpc; import java.io.IOException; import java.util.concurrent.TimeUnit; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; import org.springframework.context.support.ClassPathXmlApplicationContext; import benchmark.bean.Page; import benchmark.bean.User; import benchmark.service.UserService; @State(Scope.Benchmark) public class Client extends AbstractClient { public static final int CONCURRENCY = 32; private final ClassPathXmlApplicationContext context; private final UserService userService; public Client() { context = new ClassPathXmlApplicationContext("consumer.xml"); context.start(); userService = (UserService) context.getBean("userService"); // 获取远程服务代理 } @Override protected UserService getUserService() { return userService; } @TearDown public void close() throws IOException { context.close(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public boolean existUser() throws Exception { return super.existUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public boolean createUser() throws Exception { return super.createUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public User getUser() throws Exception { return super.getUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public Page listUser() throws Exception { return super.listUser(); } public static void main(String[] args) throws Exception { Options opt = new OptionsBuilder()// .include(Client.class.getSimpleName())// .warmupIterations(3)// .warmupTime(TimeValue.seconds(10))// .measurementIterations(3)// .measurementTime(TimeValue.seconds(10))// .threads(CONCURRENCY)// .forks(1)// .build(); new Runner(opt).run(); } } ================================================ FILE: dubbo-client/src/main/resources/consumer.xml ================================================ ================================================ FILE: dubbo-client/src/main/resources/logback.xml ================================================ %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n logs/benchmark-rpc-client.log logs/benchmark-rpc-client.%d{yyyy-MM-dd}.log.gz %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n ================================================ FILE: dubbo-kryo-client/.gitignore ================================================ /.apt_generated_tests/ ================================================ FILE: dubbo-kryo-client/pom.xml ================================================ 4.0.0 benchmark.rpc dubbo-kryo-client round-5 jar dubbo-kryo-client http://maven.apache.org 11 11 UTF-8 round-5 2.7.3 benchmark.rpc benchmark-base ${version.benchmark-base} org.apache.dubbo dubbo ${version.dubbo} org.apache.dubbo dubbo-serialization-kryo ${version.dubbo} junit junit 4.12 test org.apache.maven.plugins maven-compiler-plugin 3.8.0 ${maven.compiler.source} ${maven.compiler.target} UTF-8 org.apache.maven.plugins maven-resources-plugin 3.1.0 UTF-8 maven-assembly-plugin 3.1.0 jar-with-dependencies benchmark.rpc.Client make-assembly package single src/main/resources ================================================ FILE: dubbo-kryo-client/src/main/java/benchmark/rpc/Client.java ================================================ package benchmark.rpc; import java.io.IOException; import java.util.concurrent.TimeUnit; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; import org.springframework.context.support.ClassPathXmlApplicationContext; import benchmark.bean.Page; import benchmark.bean.User; import benchmark.service.UserService; @State(Scope.Benchmark) public class Client extends AbstractClient { public static final int CONCURRENCY = 32; private final ClassPathXmlApplicationContext context; private final UserService userService; public Client() { context = new ClassPathXmlApplicationContext("consumer.xml"); context.start(); userService = (UserService) context.getBean("userService"); // 获取远程服务代理 } @Override protected UserService getUserService() { return userService; } @TearDown public void close() throws IOException { context.close(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public boolean existUser() throws Exception { return super.existUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public boolean createUser() throws Exception { return super.createUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public User getUser() throws Exception { return super.getUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public Page listUser() throws Exception { return super.listUser(); } public static void main(String[] args) throws Exception { Options opt = new OptionsBuilder()// .include(Client.class.getSimpleName())// .warmupIterations(3)// .warmupTime(TimeValue.seconds(10))// .measurementIterations(3)// .measurementTime(TimeValue.seconds(10))// .threads(CONCURRENCY)// .forks(1)// .build(); new Runner(opt).run(); } } ================================================ FILE: dubbo-kryo-client/src/main/resources/consumer.xml ================================================ ================================================ FILE: dubbo-kryo-client/src/main/resources/logback.xml ================================================ %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n logs/benchmark-rpc-client.log logs/benchmark-rpc-client.%d{yyyy-MM-dd}.log.gz %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n ================================================ FILE: dubbo-kryo-server/pom.xml ================================================ 4.0.0 benchmark.rpc dubbo-kryo-server round-5 jar dubbo-kryo-server http://maven.apache.org 11 11 UTF-8 round-5 2.7.3 benchmark.rpc benchmark-base ${version.benchmark-base} org.apache.dubbo dubbo ${version.dubbo} org.apache.dubbo dubbo-serialization-kryo ${version.dubbo} junit junit 4.12 test org.apache.maven.plugins maven-compiler-plugin 3.8.0 ${maven.compiler.source} ${maven.compiler.target} UTF-8 org.apache.maven.plugins maven-resources-plugin 3.1.0 UTF-8 maven-assembly-plugin 3.1.0 jar-with-dependencies benchmark.rpc.Server make-assembly package single src/main/resources ================================================ FILE: dubbo-kryo-server/src/main/java/benchmark/rpc/Server.java ================================================ package benchmark.rpc; import org.springframework.context.support.ClassPathXmlApplicationContext; public class Server { public static void main(String[] args) throws InterruptedException { try (ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("provider.xml");) { context.start(); Thread.sleep(Integer.MAX_VALUE); } } } ================================================ FILE: dubbo-kryo-server/src/main/resources/logback.xml ================================================ %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n logs/benchmark-rpc-client.log logs/benchmark-rpc-client.%d{yyyy-MM-dd}.log.gz %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n ================================================ FILE: dubbo-kryo-server/src/main/resources/provider.xml ================================================ ================================================ FILE: dubbo-server/pom.xml ================================================ 4.0.0 benchmark.rpc dubbo-server round-5 jar dubbo-server http://maven.apache.org 11 11 UTF-8 round-5 2.7.3 benchmark.rpc benchmark-base ${version.benchmark-base} org.apache.dubbo dubbo ${version.dubbo} junit junit 4.12 test org.apache.maven.plugins maven-compiler-plugin 3.8.0 ${maven.compiler.source} ${maven.compiler.target} UTF-8 org.apache.maven.plugins maven-resources-plugin 3.1.0 UTF-8 maven-assembly-plugin 3.1.0 jar-with-dependencies benchmark.rpc.Server make-assembly package single src/main/resources ================================================ FILE: dubbo-server/src/main/java/benchmark/rpc/Server.java ================================================ package benchmark.rpc; import org.springframework.context.support.ClassPathXmlApplicationContext; public class Server { public static void main(String[] args) throws InterruptedException { try (ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("provider.xml");) { context.start(); Thread.sleep(Integer.MAX_VALUE); } } } ================================================ FILE: dubbo-server/src/main/resources/logback.xml ================================================ %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n logs/benchmark-rpc-client.log logs/benchmark-rpc-client.%d{yyyy-MM-dd}.log.gz %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n ================================================ FILE: dubbo-server/src/main/resources/provider.xml ================================================ ================================================ FILE: grpc-client/.gitignore ================================================ /bin/ ================================================ FILE: grpc-client/pom.xml ================================================ 4.0.0 benchmark.rpc grpc-client round-5 jar grpc-client http://maven.apache.org 11 11 UTF-8 round-5 1.18.0 benchmark.rpc benchmark-base ${version.benchmark-base} io.grpc grpc-netty ${version.grpc} io.grpc grpc-protobuf ${version.grpc} io.grpc grpc-stub ${version.grpc} junit junit 4.12 test kr.motd.maven os-maven-plugin 1.6.1 org.xolstice.maven.plugins protobuf-maven-plugin 0.6.1 com.google.protobuf:protoc:3.6.0:exe:${os.detected.classifier} grpc-java io.grpc:protoc-gen-grpc-java:${version.grpc}:exe:${os.detected.classifier} compile compile-custom org.apache.maven.plugins maven-compiler-plugin 3.8.0 ${maven.compiler.source} ${maven.compiler.target} UTF-8 org.apache.maven.plugins maven-resources-plugin 3.1.0 UTF-8 maven-assembly-plugin 3.1.0 jar-with-dependencies benchmark.rpc.Client make-assembly package single src/main/resources src/main/proto ================================================ FILE: grpc-client/src/main/java/benchmark/rpc/Client.java ================================================ package benchmark.rpc; import java.io.IOException; import java.util.concurrent.TimeUnit; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; import benchmark.bean.Page; import benchmark.bean.User; import benchmark.rpc.grpc.UserServiceGrpcClientImpl; import benchmark.service.UserService; @State(Scope.Benchmark) public class Client extends AbstractClient { public static final int CONCURRENCY = 32; private final UserServiceGrpcClientImpl userService = new UserServiceGrpcClientImpl(); @Override protected UserService getUserService() { return userService; } @TearDown public void close() throws IOException { userService.close(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public boolean existUser() throws Exception { return super.existUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public boolean createUser() throws Exception { return super.createUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public User getUser() throws Exception { return super.getUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public Page listUser() throws Exception { return super.listUser(); } public static void main(String[] args) throws Exception { Client client = new Client(); for (int i = 0; i < 60; i++) { try { System.out.println(client.getUser()); break; } catch (Exception e) { Thread.sleep(1000); } } client.close(); Options opt = new OptionsBuilder()// .include(Client.class.getSimpleName())// .warmupIterations(3)// .warmupTime(TimeValue.seconds(10))// .measurementIterations(3)// .measurementTime(TimeValue.seconds(10))// .threads(CONCURRENCY)// .forks(1)// .build(); new Runner(opt).run(); } } ================================================ FILE: grpc-client/src/main/java/benchmark/rpc/grpc/GrpcUserServiceClient.java ================================================ package benchmark.rpc.grpc; import java.io.Closeable; import java.io.IOException; import java.util.concurrent.TimeUnit; import io.grpc.ManagedChannel; import io.grpc.ManagedChannelBuilder; public class GrpcUserServiceClient implements Closeable { public final ManagedChannel channel; public final UserServiceGrpc.UserServiceBlockingStub userServiceBlockingStub; public GrpcUserServiceClient(String host, int port) { ManagedChannelBuilder channelBuilder = ManagedChannelBuilder// .forAddress(host, port)// .idleTimeout(5, TimeUnit.SECONDS)// .usePlaintext(true); channel = channelBuilder.build(); userServiceBlockingStub = UserServiceGrpc.newBlockingStub(channel); } @Override public void close() throws IOException { try { channel.shutdown().awaitTermination(5, TimeUnit.SECONDS); } catch (InterruptedException e) { throw new IOException(e); } } } ================================================ FILE: grpc-client/src/main/java/benchmark/rpc/grpc/UserServiceGrpcClientImpl.java ================================================ package benchmark.rpc.grpc; import java.io.Closeable; import java.io.IOException; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.ZoneOffset; import java.util.ArrayList; import java.util.List; import java.util.concurrent.TimeUnit; import benchmark.bean.Page; import benchmark.bean.User; import benchmark.rpc.grpc.UserServiceOuterClass.CreateUserResponse; import benchmark.rpc.grpc.UserServiceOuterClass.GetUserRequest; import benchmark.rpc.grpc.UserServiceOuterClass.ListUserRequest; import benchmark.rpc.grpc.UserServiceOuterClass.UserExistRequest; import benchmark.rpc.grpc.UserServiceOuterClass.UserExistResponse; import benchmark.rpc.grpc.UserServiceOuterClass.UserPage; import benchmark.service.UserService; import io.grpc.ManagedChannel; import io.grpc.ManagedChannelBuilder; public class UserServiceGrpcClientImpl implements UserService, Closeable { private final String host = "benchmark-server"; private final int port = 8080; private final ManagedChannel channel; private final UserServiceGrpc.UserServiceBlockingStub userServiceBlockingStub; public UserServiceGrpcClientImpl() { ManagedChannelBuilder channelBuilder = ManagedChannelBuilder.forAddress(host, port).usePlaintext(true); channel = channelBuilder.build(); userServiceBlockingStub = UserServiceGrpc.newBlockingStub(channel); } @Override public void close() throws IOException { try { channel.shutdown().awaitTermination(5, TimeUnit.SECONDS); } catch (InterruptedException e) { e.printStackTrace(); } } @Override public boolean existUser(String email) { UserExistRequest request = UserExistRequest.newBuilder().setEmail(email).build(); UserExistResponse response = userServiceBlockingStub.userExist(request); return response.getExist(); } @Override public boolean createUser(User user) { benchmark.rpc.grpc.UserServiceOuterClass.User request = benchmark.rpc.grpc.UserServiceOuterClass.User .newBuilder()// .setId(user.getId())// .setName(user.getName())// .setSex(user.getSex())// .setBirthday((int) (user.getBirthday().toEpochDay()))// .setEmail(user.getEmail())// .setMobile(user.getMobile())// .setAddress(user.getAddress())// .setIcon(user.getIcon())// .addAllPermissions(user.getPermissions())// .setStatus(user.getStatus())// .setCreateTime(user.getCreateTime().toEpochSecond(ZoneOffset.UTC))// .setUpdateTime(user.getUpdateTime().toEpochSecond(ZoneOffset.UTC))// .build(); CreateUserResponse response = userServiceBlockingStub.createUser(request); return response.getSuccess(); } @Override public User getUser(long id) { GetUserRequest request = GetUserRequest.newBuilder().setId(id).build(); benchmark.rpc.grpc.UserServiceOuterClass.User response = userServiceBlockingStub.getUser(request); User user = new User(); user.setId(response.getId()); user.setName(response.getName()); user.setSex(response.getSex()); user.setBirthday(LocalDate.ofEpochDay(response.getBirthday())); user.setEmail(response.getEmail()); user.setMobile(response.getMobile()); user.setAddress(response.getAddress()); user.setIcon(response.getIcon()); user.setPermissions(response.getPermissionsList()); user.setStatus(response.getStatus()); user.setCreateTime(LocalDateTime.ofEpochSecond(response.getCreateTime(), 0, ZoneOffset.UTC)); user.setUpdateTime(LocalDateTime.ofEpochSecond(response.getUpdateTime(), 0, ZoneOffset.UTC)); return user; } @Override public Page listUser(int pageNo) { ListUserRequest request = ListUserRequest.newBuilder().setPageNo(pageNo).build(); UserPage response = userServiceBlockingStub.listUser(request); Page page = new Page<>(); page.setPageNo(response.getPageNo()); page.setTotal(response.getTotal()); List userList = new ArrayList<>(response.getResultCount()); for (benchmark.rpc.grpc.UserServiceOuterClass.User u : response.getResultList()) { User user = new User(); user.setId(u.getId()); user.setName(u.getName()); user.setSex(u.getSex()); user.setBirthday(LocalDate.ofEpochDay(u.getBirthday())); user.setEmail(u.getEmail()); user.setMobile(u.getMobile()); user.setAddress(u.getAddress()); user.setIcon(u.getIcon()); user.setPermissions(u.getPermissionsList()); user.setStatus(u.getStatus()); user.setCreateTime(LocalDateTime.ofEpochSecond(u.getCreateTime(), 0, ZoneOffset.UTC)); user.setUpdateTime(LocalDateTime.ofEpochSecond(u.getUpdateTime(), 0, ZoneOffset.UTC)); userList.add(user); } page.setResult(userList); return page; } } ================================================ FILE: grpc-client/src/main/proto/UserService.proto ================================================ syntax = "proto3"; package grpc; import public "google/protobuf/timestamp.proto"; option java_package = "benchmark.rpc.grpc"; service UserService { rpc userExist (UserExistRequest) returns (UserExistResponse) {} rpc createUser (User) returns (CreateUserResponse) {} rpc getUser (GetUserRequest) returns (User) {} rpc listUser (ListUserRequest) returns (UserPage) {} } message UserExistRequest { string email = 1; } message UserExistResponse { bool exist = 1; } message GetUserRequest { int64 id = 1; } message User { int64 id = 1; string name = 2; int32 sex = 3; int32 birthday = 4; string email = 5; string mobile = 6; string address = 7; string icon = 8; repeated int32 permissions = 9; int32 status = 10; int64 createTime = 11; int64 updateTime = 12; } message CreateUserResponse { bool success = 1; } message ListUserRequest { int32 pageNo = 1; } message UserPage { int32 pageNo = 1; int32 total = 2; repeated User result = 3; } ================================================ FILE: grpc-client/src/main/resources/logback.xml ================================================ %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n logs/benchmark-rpc-client.log logs/benchmark-rpc-client.%d{yyyy-MM-dd}.log.gz %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n ================================================ FILE: grpc-server/pom.xml ================================================ 4.0.0 benchmark.rpc grpc-server round-5 jar grpc-server http://maven.apache.org 11 11 UTF-8 round-5 1.18.0 benchmark.rpc benchmark-base ${version.benchmark-base} io.grpc grpc-netty ${version.grpc} io.grpc grpc-protobuf ${version.grpc} io.grpc grpc-stub ${version.grpc} junit junit 4.12 test kr.motd.maven os-maven-plugin 1.6.1 org.xolstice.maven.plugins protobuf-maven-plugin 0.6.1 com.google.protobuf:protoc:3.6.0:exe:${os.detected.classifier} grpc-java io.grpc:protoc-gen-grpc-java:${version.grpc}:exe:${os.detected.classifier} compile compile-custom org.apache.maven.plugins maven-compiler-plugin 3.8.0 ${maven.compiler.source} ${maven.compiler.target} UTF-8 org.apache.maven.plugins maven-resources-plugin 3.1.0 UTF-8 maven-assembly-plugin 3.1.0 jar-with-dependencies benchmark.rpc.Server make-assembly package single src/main/resources src/main/proto ================================================ FILE: grpc-server/src/main/java/benchmark/rpc/Server.java ================================================ package benchmark.rpc; import benchmark.rpc.grpc.server.UserServiceGrpcServerImpl; import io.grpc.ServerBuilder; public class Server { public static final String host = "benchmark-server"; public static final int port = 8080; public static void main(String[] args) throws Exception { ServerBuilder// .forPort(port)// .addService(new UserServiceGrpcServerImpl())// .build()// .start()// .awaitTermination(); } } ================================================ FILE: grpc-server/src/main/java/benchmark/rpc/grpc/server/UserServiceGrpcServerImpl.java ================================================ package benchmark.rpc.grpc.server; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.ZoneOffset; import java.util.ArrayList; import java.util.List; import benchmark.bean.Page; import benchmark.rpc.grpc.UserServiceGrpc.UserServiceImplBase; import benchmark.rpc.grpc.UserServiceOuterClass.CreateUserResponse; import benchmark.rpc.grpc.UserServiceOuterClass.GetUserRequest; import benchmark.rpc.grpc.UserServiceOuterClass.ListUserRequest; import benchmark.rpc.grpc.UserServiceOuterClass.User; import benchmark.rpc.grpc.UserServiceOuterClass.UserExistRequest; import benchmark.rpc.grpc.UserServiceOuterClass.UserExistResponse; import benchmark.rpc.grpc.UserServiceOuterClass.UserPage; import benchmark.service.UserService; import benchmark.service.UserServiceServerImpl; import io.grpc.stub.StreamObserver; public class UserServiceGrpcServerImpl extends UserServiceImplBase { private final UserService userService = new UserServiceServerImpl(); @Override public void userExist(UserExistRequest request, StreamObserver responseObserver) { String email = request.getEmail(); boolean isExist = userService.existUser(email); UserExistResponse reply = UserExistResponse.newBuilder().setExist(isExist).build(); responseObserver.onNext(reply); responseObserver.onCompleted(); } @Override public void getUser(GetUserRequest request, StreamObserver responseObserver) { long id = request.getId(); benchmark.bean.User user = userService.getUser(id); User reply = User.newBuilder()// .setId(user.getId())// .setName(user.getName())// .setSex(user.getSex())// .setBirthday((int) (user.getBirthday().toEpochDay()))// .setEmail(user.getEmail())// .setMobile(user.getMobile())// .setAddress(user.getAddress())// .setIcon(user.getIcon())// .addAllPermissions(user.getPermissions())// .setStatus(user.getStatus())// .setCreateTime(user.getCreateTime().toEpochSecond(ZoneOffset.UTC))// .setUpdateTime(user.getUpdateTime().toEpochSecond(ZoneOffset.UTC))// .build(); responseObserver.onNext(reply); responseObserver.onCompleted(); } @Override public void createUser(User request, StreamObserver responseObserver) { benchmark.bean.User user = new benchmark.bean.User(); user.setId(request.getId()); user.setName(request.getName()); user.setSex(request.getSex()); user.setBirthday(LocalDate.ofEpochDay(request.getBirthday())); user.setEmail(request.getEmail()); user.setMobile(request.getMobile()); user.setAddress(request.getAddress()); user.setIcon(request.getIcon()); user.setPermissions(request.getPermissionsList()); user.setStatus(request.getStatus()); user.setCreateTime(LocalDateTime.ofEpochSecond(request.getCreateTime(), 0, ZoneOffset.UTC)); user.setUpdateTime(LocalDateTime.ofEpochSecond(request.getUpdateTime(), 0, ZoneOffset.UTC)); boolean success = userService.createUser(user); CreateUserResponse reply = CreateUserResponse.newBuilder().setSuccess(success).build(); responseObserver.onNext(reply); responseObserver.onCompleted(); } @Override public void listUser(ListUserRequest request, StreamObserver responseObserver) { int pageNo = request.getPageNo(); Page page = userService.listUser(pageNo); List userList = new ArrayList<>(page.getResult().size()); for (benchmark.bean.User user : page.getResult()) { User u = User.newBuilder()// .setId(user.getId())// .setName(user.getName())// .setSex(user.getSex())// .setBirthday((int) (user.getBirthday().toEpochDay()))// .setEmail(user.getEmail())// .setMobile(user.getMobile())// .setAddress(user.getAddress())// .setIcon(user.getIcon())// .addAllPermissions(user.getPermissions())// .setStatus(user.getStatus())// .setCreateTime(user.getCreateTime().toEpochSecond(ZoneOffset.UTC))// .setUpdateTime(user.getUpdateTime().toEpochSecond(ZoneOffset.UTC))// .build(); userList.add(u); } UserPage reply = UserPage.newBuilder()// .setPageNo(page.getPageNo())// .setTotal(page.getTotal())// .addAllResult(userList)// .build(); responseObserver.onNext(reply); responseObserver.onCompleted(); } } ================================================ FILE: grpc-server/src/main/proto/UserService.proto ================================================ syntax = "proto3"; package grpc; import public "google/protobuf/timestamp.proto"; option java_package = "benchmark.rpc.grpc"; service UserService { rpc userExist (UserExistRequest) returns (UserExistResponse) {} rpc createUser (User) returns (CreateUserResponse) {} rpc getUser (GetUserRequest) returns (User) {} rpc listUser (ListUserRequest) returns (UserPage) {} } message UserExistRequest { string email = 1; } message UserExistResponse { bool exist = 1; } message GetUserRequest { int64 id = 1; } message User { int64 id = 1; string name = 2; int32 sex = 3; int32 birthday = 4; string email = 5; string mobile = 6; string address = 7; string icon = 8; repeated int32 permissions = 9; int32 status = 10; int64 createTime = 11; int64 updateTime = 12; } message CreateUserResponse { bool success = 1; } message ListUserRequest { int32 pageNo = 1; } message UserPage { int32 pageNo = 1; int32 total = 2; repeated User result = 3; } ================================================ FILE: grpc-server/src/main/resources/logback.xml ================================================ %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n logs/benchmark-rpc-server.log logs/benchmark-rpc-server.%d{yyyy-MM-dd}.log.gz %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n ================================================ FILE: hprose-client/pom.xml ================================================ 4.0.0 benchmark.rpc hprose-client round-5 jar hprose-client http://maven.apache.org 11 11 UTF-8 round-5 2.0.38 benchmark.rpc benchmark-base ${version.benchmark-base} org.hprose hprose-java ${version.hprose} org.openjdk.jmh jmh-core 1.19 org.openjdk.jmh jmh-generator-annprocess 1.19 junit junit 4.12 test org.apache.maven.plugins maven-compiler-plugin 3.8.0 ${maven.compiler.source} ${maven.compiler.target} UTF-8 org.apache.maven.plugins maven-resources-plugin 3.1.0 UTF-8 maven-assembly-plugin 3.1.0 jar-with-dependencies benchmark.rpc.Client make-assembly package single src/main/resources ================================================ FILE: hprose-client/src/main/java/benchmark/rpc/Client.java ================================================ package benchmark.rpc; import java.io.IOException; import java.util.concurrent.TimeUnit; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; import benchmark.bean.Page; import benchmark.bean.User; import benchmark.service.UserService; import hprose.client.HproseTcpClient; @State(Scope.Benchmark) public class Client extends AbstractClient { public static final int CONCURRENCY = 32; private final HproseTcpClient client = new HproseTcpClient("tcp://benchmark-server:8080"); private final UserService userService = client.useService(UserService.class); public Client() { client.setFullDuplex(true); client.setNoDelay(true); } @Override protected UserService getUserService() { return userService; } @TearDown public void close() throws IOException { client.close(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public boolean existUser() throws Exception { return super.existUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public boolean createUser() throws Exception { return super.createUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public User getUser() throws Exception { return super.getUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public Page listUser() throws Exception { return super.listUser(); } public static void main(String[] args) throws Exception { Options opt = new OptionsBuilder()// .include(Client.class.getSimpleName())// .warmupIterations(3)// .warmupTime(TimeValue.seconds(10))// .measurementIterations(3)// .measurementTime(TimeValue.seconds(10))// .threads(CONCURRENCY)// .forks(1)// .build(); new Runner(opt).run(); // HproseTcpClient client = new HproseTcpClient("tcp://127.0.0.1:8080"); // UserService userService = client.useService(UserService.class); // System.out.println(userService.existUser("1")); } } ================================================ FILE: hprose-client/src/main/resources/consumer.xml ================================================ ================================================ FILE: hprose-server/pom.xml ================================================ 4.0.0 benchmark.rpc hprose-server round-5 jar hprose-server http://maven.apache.org 11 11 UTF-8 round-5 2.0.38 benchmark.rpc benchmark-base ${version.benchmark-base} org.hprose hprose-java ${version.hprose} junit junit 4.12 test org.apache.maven.plugins maven-compiler-plugin 3.8.0 ${maven.compiler.source} ${maven.compiler.target} UTF-8 org.apache.maven.plugins maven-resources-plugin 3.1.0 UTF-8 maven-assembly-plugin 3.1.0 jar-with-dependencies benchmark.rpc.Server make-assembly package single src/main/resources ================================================ FILE: hprose-server/src/main/java/benchmark/rpc/Server.java ================================================ package benchmark.rpc; import benchmark.service.UserServiceServerImpl; import hprose.server.HproseTcpServer; public class Server { public static void main(String[] args) throws Exception { HproseTcpServer server = new HproseTcpServer("benchmark-server", 8080); server.add(new UserServiceServerImpl()); server.start(); System.out.println("START"); Thread.sleep(Long.MAX_VALUE); } } ================================================ FILE: hprose-server/src/main/resources/provider.xml ================================================ ================================================ FILE: jupiter-client/pom.xml ================================================ 4.0.0 benchmark.rpc jupiter-client round-5 jar jupiter-client http://maven.apache.org 11 11 UTF-8 round-5 1.3.1-beta-1 benchmark.rpc benchmark-base ${version.benchmark-base} org.jupiter-rpc jupiter-all ${version.jupiter} junit junit 4.12 test org.apache.maven.plugins maven-compiler-plugin 3.8.0 ${maven.compiler.source} ${maven.compiler.target} UTF-8 org.apache.maven.plugins maven-resources-plugin 3.1.0 UTF-8 org.apache.maven.plugins maven-shade-plugin 3.1.0 false shade META-INF/services/org.jupiter.rpc.provider.processor.ProviderExecutorFactory benchmark.rpc.Client ${maven.compile.source} ${maven.compile.target} src/main/resources ================================================ FILE: jupiter-client/src/main/java/benchmark/rpc/Client.java ================================================ package benchmark.rpc; import java.io.IOException; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import org.jupiter.common.util.SystemPropertyUtil; import org.jupiter.rpc.DefaultClient; import org.jupiter.rpc.JClient; import org.jupiter.rpc.consumer.ProxyFactory; import org.jupiter.transport.JConfig; import org.jupiter.transport.JConnection; import org.jupiter.transport.JConnector; import org.jupiter.transport.JOption; import org.jupiter.transport.UnresolvedAddress; import org.jupiter.transport.UnresolvedSocketAddress; import org.jupiter.transport.netty.JNettyTcpConnector; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; import benchmark.bean.Page; import benchmark.bean.User; import benchmark.service.JupiterUserService; import benchmark.service.UserService; import benchmark.service.UserServiceServerImpl; import io.netty.util.ResourceLeakDetector; @State(Scope.Benchmark) public class Client { public static final int CONCURRENCY = 32; private final AtomicInteger counter = new AtomicInteger(0); private final UserService _serviceUserService = new UserServiceServerImpl(); private final JupiterUserService userService; private final JClient client; public Client() { ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.DISABLED); SystemPropertyUtil .setProperty("jupiter.executor.factory.consumer.factory_name", "callerRuns"); SystemPropertyUtil.setProperty("jupiter.tracing.needed", "false"); client = new DefaultClient().withConnector(new JNettyTcpConnector(true)); JConfig config = client.connector().config(); config.setOption(JOption.WRITE_BUFFER_HIGH_WATER_MARK, 2048 * 1024); config.setOption(JOption.WRITE_BUFFER_LOW_WATER_MARK, 1024 * 1024); config.setOption(JOption.SO_RCVBUF, 256 * 1024); config.setOption(JOption.SO_SNDBUF, 256 * 1024); int workers = Runtime.getRuntime().availableProcessors(); UnresolvedAddress[] addresses = new UnresolvedAddress[workers]; JConnector connector = client.connector(); for (int i = 0; i < addresses.length; i++) { addresses[i] = new UnresolvedSocketAddress("benchmark-server", 18090); JConnection connection = connector.connect(addresses[i]); connector.connectionManager().manage(connection); } userService = ProxyFactory.factory(JupiterUserService.class).client(client).addProviderAddress(addresses) .newProxyInstance(); } @TearDown public void close() throws IOException { client.shutdownGracefully(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) public boolean existUser() throws Exception { String email = String.valueOf(counter.getAndIncrement()); return userService.existUser(email).join(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) public boolean createUser() throws Exception { int id = counter.getAndIncrement(); User user = _serviceUserService.getUser(id); return userService.createUser(user).join(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) public User getUser() throws Exception { int id = counter.getAndIncrement(); return userService.getUser(id).join(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) public Page listUser() throws Exception { int pageNo = counter.getAndIncrement(); return userService.listUser(pageNo).join(); } public static void main(String[] args) throws Exception { Client client = new Client(); System.out.println(client.getUser()); client.close(); Options opt = new OptionsBuilder()// .include(Client.class.getSimpleName())// .warmupIterations(3)// .warmupTime(TimeValue.seconds(10))// .measurementIterations(3)// .measurementTime(TimeValue.seconds(10))// .threads(CONCURRENCY)// .forks(1)// .build(); new Runner(opt).run(); } } ================================================ FILE: jupiter-client/src/main/java/benchmark/service/JupiterUserService.java ================================================ package benchmark.service; import java.util.concurrent.CompletableFuture; import org.jupiter.rpc.ServiceProvider; import benchmark.bean.Page; import benchmark.bean.User; @ServiceProvider(group = "test", name = "jupiterUserService") public interface JupiterUserService { CompletableFuture existUser(String email); CompletableFuture createUser(User user); CompletableFuture getUser(long id); CompletableFuture> listUser(int pageNo); } ================================================ FILE: jupiter-client/src/main/resources/META-INF/services/org.jupiter.rpc.consumer.processor.ConsumerExecutorFactory ================================================ org.jupiter.rpc.executor.CallerRunsExecutorFactory org.jupiter.rpc.executor.DisruptorExecutorFactory ================================================ FILE: jupiter-client/src/main/resources/logback.xml ================================================ %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n logs/benchmark-rpc-server.log logs/benchmark-rpc-server.%d{yyyy-MM-dd}.log.gz %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n ================================================ FILE: jupiter-client/src/main/resources/spring-consumer.xml ================================================ ================================================ FILE: jupiter-server/.gitignore ================================================ /.apt_generated_tests/ ================================================ FILE: jupiter-server/pom.xml ================================================ 4.0.0 benchmark.rpc jupiter-server round-5 jar jupiter-server http://maven.apache.org 11 11 UTF-8 round-5 1.3.1-beta-1 benchmark.rpc benchmark-base ${version.benchmark-base} org.jupiter-rpc jupiter-all ${version.jupiter} junit junit 4.12 test org.apache.maven.plugins maven-compiler-plugin 3.8.0 ${maven.compiler.source} ${maven.compiler.target} UTF-8 org.apache.maven.plugins maven-resources-plugin 3.1.0 UTF-8 org.apache.maven.plugins maven-shade-plugin 3.1.0 false shade META-INF/services/org.jupiter.rpc.provider.processor.ProviderExecutorFactory benchmark.rpc.Server ${maven.compile.source} ${maven.compile.target} src/main/resources ================================================ FILE: jupiter-server/src/main/java/benchmark/rpc/Server.java ================================================ package benchmark.rpc; import benchmark.service.JupiterUserServiceServerImpl; import io.netty.util.ResourceLeakDetector; import org.jupiter.common.util.SystemPropertyUtil; import org.jupiter.rpc.DefaultServer; import org.jupiter.rpc.JServer; import org.jupiter.transport.JConfig; import org.jupiter.transport.JOption; import org.jupiter.transport.netty.JNettyTcpAcceptor; public class Server { public static void main(String[] args) throws InterruptedException { ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.DISABLED); try { SystemPropertyUtil.setProperty("jupiter.executor.factory.provider.factory_name", "callerRuns"); SystemPropertyUtil.setProperty("jupiter.executor.factory.affinity.thread", "true"); SystemPropertyUtil.setProperty("jupiter.tracing.needed", "false"); JServer server = new DefaultServer().withAcceptor(new JNettyTcpAcceptor(18090, true)); JConfig config = server.acceptor().configGroup().child(); config.setOption(JOption.WRITE_BUFFER_HIGH_WATER_MARK, 2048 * 1024); config.setOption(JOption.WRITE_BUFFER_LOW_WATER_MARK, 1024 * 1024); config.setOption(JOption.SO_RCVBUF, 256 * 1024); config.setOption(JOption.SO_SNDBUF, 256 * 1024); server.serviceRegistry().provider(new JupiterUserServiceServerImpl()).register(); server.start(false); System.out.println("Jupiter started"); Thread.sleep(java.lang.Integer.MAX_VALUE); } catch (Throwable t) { t.printStackTrace(); } } } ================================================ FILE: jupiter-server/src/main/java/benchmark/service/JupiterUserService.java ================================================ package benchmark.service; import java.util.concurrent.CompletableFuture; import org.jupiter.rpc.ServiceProvider; import benchmark.bean.Page; import benchmark.bean.User; @ServiceProvider(group = "test", name = "jupiterUserService") public interface JupiterUserService { CompletableFuture existUser(String email); CompletableFuture createUser(User user); CompletableFuture getUser(long id); CompletableFuture> listUser(int pageNo); } ================================================ FILE: jupiter-server/src/main/java/benchmark/service/JupiterUserServiceServerImpl.java ================================================ package benchmark.service; import java.time.LocalDate; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.concurrent.CompletableFuture; import org.jupiter.rpc.ServiceProviderImpl; import benchmark.bean.Page; import benchmark.bean.User; /** * only for server * * @author Hank * */ @ServiceProviderImpl(version = "1.0.0") public class JupiterUserServiceServerImpl implements JupiterUserService { @Override public CompletableFuture existUser(String email) { if (email == null || email.isEmpty()) { return CompletableFuture.completedFuture(Boolean.TRUE); } if (email.charAt(email.length() - 1) < '5') { return CompletableFuture.completedFuture(Boolean.FALSE); } return CompletableFuture.completedFuture(Boolean.TRUE); } @Override public CompletableFuture getUser(long id) { User user = new User(); user.setId(id); user.setName(new String("Doug Lea")); user.setSex(1); user.setBirthday(LocalDate.of(1968, 12, 8)); user.setEmail(new String("dong.lea@gmail.com")); user.setMobile(new String("18612345678")); user.setAddress(new String("北京市 中关村 中关村大街1号 鼎好大厦 1605")); user.setIcon(new String("https://www.baidu.com/img/bd_logo1.png")); user.setStatus(1); user.setCreateTime(LocalDateTime.now()); user.setUpdateTime(user.getCreateTime()); List permissions = new ArrayList( Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 19, 88, 86, 89, 90, 91, 92)); user.setPermissions(permissions); return CompletableFuture.completedFuture(user); } @Override public CompletableFuture> listUser(int pageNo) { List userList = new ArrayList<>(15); for (int i = 0; i < 15; i++) { User user = new User(); user.setId(i); user.setName("Doug Lea" + i); user.setSex(1); user.setBirthday(LocalDate.of(1968, 12, 8)); user.setEmail("dong.lea@gmail.com" + i); user.setMobile("18612345678" + i); user.setAddress("北京市 中关村 中关村大街1号 鼎好大厦 1605" + i); user.setIcon("https://www.baidu.com/img/bd_logo1.png" + i); user.setStatus(1); user.setCreateTime(LocalDateTime.now()); user.setUpdateTime(user.getCreateTime()); List permissions = new ArrayList( Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 19, 88, 86, 89, 90, 91, 92)); user.setPermissions(permissions); userList.add(user); } Page page = new Page<>(); page.setPageNo(pageNo); page.setTotal(1000); page.setResult(userList); return CompletableFuture.completedFuture(page); } @Override public CompletableFuture createUser(User user) { if (user == null) { return CompletableFuture.completedFuture(Boolean.FALSE); } return CompletableFuture.completedFuture(Boolean.TRUE); } } ================================================ FILE: jupiter-server/src/main/resources/META-INF/services/org.jupiter.rpc.provider.processor.ProviderExecutorFactory ================================================ org.jupiter.rpc.executor.DisruptorExecutorFactory org.jupiter.rpc.executor.CallerRunsExecutorFactory org.jupiter.rpc.executor.ForkJoinPoolExecutorFactory ================================================ FILE: jupiter-server/src/main/resources/logback.xml ================================================ %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n logs/benchmark-rpc-server.log logs/benchmark-rpc-server.%d{yyyy-MM-dd}.log.gz %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n ================================================ FILE: jupiter-server/src/main/resources/spring-provider.xml ================================================ ================================================ FILE: motan-client/pom.xml ================================================ 4.0.0 benchmark.rpc motan-client round-5 jar motan-client http://maven.apache.org 11 11 UTF-8 round-5 1.1.3 5.1.4.RELEASE 1.7.25 benchmark.rpc benchmark-base ${version.benchmark-base} com.weibo motan-core ${version.motan} com.weibo motan-transport-netty ${version.motan} com.weibo motan-springsupport ${version.motan} com.weibo serialization-extension ${version.motan} org.springframework spring-context ${version.spring} org.slf4j slf4j-api ${version.slf4j} org.slf4j slf4j-log4j12 ${version.slf4j} junit junit 4.12 test org.apache.maven.plugins maven-compiler-plugin 3.8.0 ${maven.compiler.source} ${maven.compiler.target} UTF-8 org.apache.maven.plugins maven-resources-plugin 3.1.0 UTF-8 maven-assembly-plugin 3.1.0 jar-with-dependencies benchmark.rpc.Client make-assembly package single org.apache.maven.plugins maven-shade-plugin 3.1.0 false shade META-INF/services/com.weibo.api.motan.codec.Serialization src/main/resources ================================================ FILE: motan-client/src/main/java/benchmark/bean/MotanUser.java ================================================ package benchmark.bean; import java.io.Serializable; import java.util.Date; import java.util.List; public class MotanUser implements Serializable { private static final long serialVersionUID = -2058903653284131263L; private long id; private String name; private int sex; private Date birthday; private String email; private String mobile; private String address; private String icon; private List permissions; private int status; private Date createTime; private Date updateTime; public long getId() { return id; } public void setId(long id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getSex() { return sex; } public void setSex(int sex) { this.sex = sex; } public Date getBirthday() { return birthday; } public void setBirthday(Date birthday) { this.birthday = birthday; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getMobile() { return mobile; } public void setMobile(String mobile) { this.mobile = mobile; } public String getAddress() { return address; } public void setAddress(String address) { this.address = address; } public String getIcon() { return icon; } public void setIcon(String icon) { this.icon = icon; } public List getPermissions() { return permissions; } public void setPermissions(List permissions) { this.permissions = permissions; } public int getStatus() { return status; } public void setStatus(int status) { this.status = status; } public Date getCreateTime() { return createTime; } public void setCreateTime(Date createTime) { this.createTime = createTime; } public Date getUpdateTime() { return updateTime; } public void setUpdateTime(Date updateTime) { this.updateTime = updateTime; } @Override public String toString() { return "MotanUser{" + "id=" + id + ", name='" + name + '\'' + ", sex=" + sex + ", birthday=" + birthday + ", email='" + email + '\'' + ", mobile='" + mobile + '\'' + ", address='" + address + '\'' + ", icon='" + icon + '\'' + ", permissions=" + permissions + ", status=" + status + ", createTime=" + createTime + ", updateTime=" + updateTime + '}'; } } ================================================ FILE: motan-client/src/main/java/benchmark/rpc/Client.java ================================================ package benchmark.rpc; import java.io.IOException; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; import org.springframework.context.support.ClassPathXmlApplicationContext; import com.weibo.api.motan.closable.ShutDownHook; import com.weibo.api.motan.util.StatsUtil; import benchmark.bean.MotanUser; import benchmark.bean.Page; import benchmark.service.MotanUserService; import benchmark.service.MotanUserServiceServerImpl; @State(Scope.Benchmark) public class Client { public static final int CONCURRENCY = 32; private final AtomicInteger counter = new AtomicInteger(0); private final MotanUserService _serviceUserService = new MotanUserServiceServerImpl(); private final ClassPathXmlApplicationContext context; private final MotanUserService userService; public Client() { context = new ClassPathXmlApplicationContext("motan_client.xml"); context.start(); userService = (MotanUserService) context.getBean("userService"); // 获取远程服务代理 } @TearDown public void close() throws IOException { context.close(); ShutDownHook.runHook(true); if (!StatsUtil.executorService.isShutdown()) { StatsUtil.executorService.shutdownNow(); } } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) public boolean existUser() throws Exception { String email = String.valueOf(counter.getAndIncrement()); return userService.existUser(email); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) public boolean createUser() throws Exception { int id = counter.getAndIncrement(); MotanUser user = _serviceUserService.getUser(id); return userService.createUser(user); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) public MotanUser getUser() throws Exception { int id = counter.getAndIncrement(); return userService.getUser(id); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) public Page listUser() throws Exception { int pageNo = counter.getAndIncrement(); return userService.listUser(pageNo); } public static void main(String[] args) throws Exception { Client client = new Client(); for (int i = 0; i < 60; i++) { try { System.out.println(client.getUser().getAddress()); break; } catch (Exception e) { e.printStackTrace(); Thread.sleep(1000); } } client.close(); Options opt = new OptionsBuilder()// .include(Client.class.getSimpleName())// .warmupIterations(3)// .warmupTime(TimeValue.seconds(10))// .measurementIterations(3)// .measurementTime(TimeValue.seconds(10))// .threads(CONCURRENCY)// .forks(1)// .build(); new Runner(opt).run(); System.exit(1); // Client client = new Client(); // System.out.println(client.getUser()); } } ================================================ FILE: motan-client/src/main/java/benchmark/service/MotanUserService.java ================================================ package benchmark.service; import benchmark.bean.MotanUser; import benchmark.bean.Page; public interface MotanUserService { public boolean existUser(String email); public boolean createUser(MotanUser user); public MotanUser getUser(long id); public Page listUser(int pageNo); } ================================================ FILE: motan-client/src/main/java/benchmark/service/MotanUserServiceServerImpl.java ================================================ package benchmark.service; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; import java.util.List; import benchmark.bean.MotanUser; import benchmark.bean.Page; /** * only for server * * @author Hank * */ public class MotanUserServiceServerImpl implements MotanUserService { @Override public boolean existUser(String email) { if (email == null || email.isEmpty()) { return true; } if (email.charAt(email.length() - 1) < '5') { return false; } return true; } @Override public MotanUser getUser(long id) { MotanUser user = new MotanUser(); user.setId(id); user.setName(new String("Doug Lea")); user.setSex(1); user.setBirthday(new Date()); user.setEmail(new String("dong.lea@gmail.com")); user.setMobile(new String("18612345678")); user.setAddress(new String("北京市 中关村 中关村大街1号 鼎好大厦 1605")); user.setIcon(new String("https://www.baidu.com/img/bd_logo1.png")); user.setStatus(1); user.setCreateTime(new Date()); user.setUpdateTime(new Date()); List permissions = new ArrayList( Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 19, 88, 86, 89, 90, 91, 92)); user.setPermissions(permissions); return user; } @Override public Page listUser(int pageNo) { List userList = new ArrayList<>(15); for (int i = 0; i < 15; i++) { MotanUser user = new MotanUser(); user.setId(i); user.setName("Doug Lea" + i); user.setSex(1); user.setBirthday(new Date()); user.setEmail("dong.lea@gmail.com" + i); user.setMobile("18612345678" + i); user.setAddress("北京市 中关村 中关村大街1号 鼎好大厦 1605" + i); user.setIcon("https://www.baidu.com/img/bd_logo1.png" + i); user.setStatus(1); user.setCreateTime(new Date()); user.setUpdateTime(new Date()); List permissions = new ArrayList( Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 19, 88, 86, 89, 90, 91, 92)); user.setPermissions(permissions); userList.add(user); } Page page = new Page<>(); page.setPageNo(pageNo); page.setTotal(1000); page.setResult(userList); return page; } @Override public boolean createUser(MotanUser user) { if (user == null) { return false; } return true; } } ================================================ FILE: motan-client/src/main/resources/motan_client.xml ================================================ ================================================ FILE: motan-server/.gitignore ================================================ /.apt_generated_tests/ ================================================ FILE: motan-server/pom.xml ================================================ 4.0.0 benchmark.rpc motan-server round-5 jar motan-server http://maven.apache.org 11 11 UTF-8 round-5 1.1.3 5.1.4.RELEASE 1.7.25 benchmark.rpc benchmark-base ${version.benchmark-base} com.weibo motan-core ${version.motan} com.weibo motan-transport-netty ${version.motan} com.weibo motan-extension ${version.motan} pom com.weibo motan-springsupport ${version.motan} com.weibo serialization-extension ${version.motan} org.springframework spring-context ${version.spring} org.slf4j slf4j-api ${version.slf4j} org.slf4j slf4j-log4j12 ${version.slf4j} junit junit 4.12 test org.apache.maven.plugins maven-compiler-plugin 3.8.0 ${maven.compiler.source} ${maven.compiler.target} UTF-8 org.apache.maven.plugins maven-resources-plugin 3.1.0 UTF-8 maven-assembly-plugin 3.1.0 jar-with-dependencies benchmark.rpc.Server make-assembly package single org.apache.maven.plugins maven-shade-plugin 3.2.1 false shade META-INF/services/com.weibo.api.motan.codec.Serialization src/main/resources ================================================ FILE: motan-server/src/main/java/benchmark/bean/MotanUser.java ================================================ package benchmark.bean; import java.io.Serializable; import java.util.Date; import java.util.List; public class MotanUser implements Serializable { private static final long serialVersionUID = -2058903653284131263L; private long id; private String name; private int sex; private Date birthday; private String email; private String mobile; private String address; private String icon; private List permissions; private int status; private Date createTime; private Date updateTime; public long getId() { return id; } public void setId(long id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getSex() { return sex; } public void setSex(int sex) { this.sex = sex; } public Date getBirthday() { return birthday; } public void setBirthday(Date birthday) { this.birthday = birthday; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getMobile() { return mobile; } public void setMobile(String mobile) { this.mobile = mobile; } public String getAddress() { return address; } public void setAddress(String address) { this.address = address; } public String getIcon() { return icon; } public void setIcon(String icon) { this.icon = icon; } public List getPermissions() { return permissions; } public void setPermissions(List permissions) { this.permissions = permissions; } public int getStatus() { return status; } public void setStatus(int status) { this.status = status; } public Date getCreateTime() { return createTime; } public void setCreateTime(Date createTime) { this.createTime = createTime; } public Date getUpdateTime() { return updateTime; } public void setUpdateTime(Date updateTime) { this.updateTime = updateTime; } @Override public String toString() { return "MotanUser{" + "id=" + id + ", name='" + name + '\'' + ", sex=" + sex + ", birthday=" + birthday + ", email='" + email + '\'' + ", mobile='" + mobile + '\'' + ", address='" + address + '\'' + ", icon='" + icon + '\'' + ", permissions=" + permissions + ", status=" + status + ", createTime=" + createTime + ", updateTime=" + updateTime + '}'; } } ================================================ FILE: motan-server/src/main/java/benchmark/rpc/Server.java ================================================ package benchmark.rpc; import org.springframework.context.support.ClassPathXmlApplicationContext; public class Server { public static void main(String[] args) throws InterruptedException { try (ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("motan_server.xml");) { context.start(); Thread.sleep(Integer.MAX_VALUE); } } } ================================================ FILE: motan-server/src/main/java/benchmark/service/MotanUserService.java ================================================ package benchmark.service; import benchmark.bean.MotanUser; import benchmark.bean.Page; public interface MotanUserService { public boolean existUser(String email); public boolean createUser(MotanUser user); public MotanUser getUser(long id); public Page listUser(int pageNo); } ================================================ FILE: motan-server/src/main/java/benchmark/service/MotanUserServiceServerImpl.java ================================================ package benchmark.service; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; import java.util.List; import benchmark.bean.MotanUser; import benchmark.bean.Page; /** * only for server * * @author Hank * */ public class MotanUserServiceServerImpl implements MotanUserService { @Override public boolean existUser(String email) { if (email == null || email.isEmpty()) { return true; } if (email.charAt(email.length() - 1) < '5') { return false; } return true; } @Override public MotanUser getUser(long id) { MotanUser user = new MotanUser(); user.setId(id); user.setName(new String("Doug Lea")); user.setSex(1); user.setBirthday(new Date()); user.setEmail(new String("dong.lea@gmail.com")); user.setMobile(new String("18612345678")); user.setAddress(new String("北京市 中关村 中关村大街1号 鼎好大厦 1605")); user.setIcon(new String("https://www.baidu.com/img/bd_logo1.png")); user.setStatus(1); user.setCreateTime(new Date()); user.setUpdateTime(new Date()); List permissions = new ArrayList( Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 19, 88, 86, 89, 90, 91, 92)); user.setPermissions(permissions); return user; } @Override public Page listUser(int pageNo) { List userList = new ArrayList<>(15); for (int i = 0; i < 15; i++) { MotanUser user = new MotanUser(); user.setId(i); user.setName("Doug Lea" + i); user.setSex(1); user.setBirthday(new Date()); user.setEmail("dong.lea@gmail.com" + i); user.setMobile("18612345678" + i); user.setAddress("北京市 中关村 中关村大街1号 鼎好大厦 1605" + i); user.setIcon("https://www.baidu.com/img/bd_logo1.png" + i); user.setStatus(1); user.setCreateTime(new Date()); user.setUpdateTime(new Date()); List permissions = new ArrayList( Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 19, 88, 86, 89, 90, 91, 92)); user.setPermissions(permissions); userList.add(user); } Page page = new Page<>(); page.setPageNo(pageNo); page.setTotal(1000); page.setResult(userList); return page; } @Override public boolean createUser(MotanUser user) { if (user == null) { return false; } return true; } } ================================================ FILE: motan-server/src/main/resources/motan_server.xml ================================================ ================================================ FILE: netty-client/pom.xml ================================================ 4.0.0 benchmark.rpc netty-client round-5 jar netty-client http://maven.apache.org 11 11 UTF-8 round-5 4.1.33.Final benchmark.rpc benchmark-base ${version.benchmark-base} io.netty netty-codec ${netty.version} io.netty netty-transport-native-epoll ${netty.version} linux-x86_64 junit junit 4.12 test org.apache.maven.plugins maven-compiler-plugin 3.8.0 ${maven.compiler.source} ${maven.compiler.target} UTF-8 maven-assembly-plugin 3.1.0 jar-with-dependencies benchmark.rpc.Client make-assembly package single ================================================ FILE: netty-client/src/main/java/benchmark/rpc/Client.java ================================================ package benchmark.rpc; import java.io.IOException; import java.util.concurrent.TimeUnit; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; import benchmark.bean.Page; import benchmark.bean.User; import benchmark.rpc.netty.client.UserServiceNettyClientImpl; import benchmark.service.UserService; import io.netty.util.ResourceLeakDetector; import io.netty.util.ResourceLeakDetector.Level; @State(Scope.Benchmark) public class Client extends AbstractClient { public static final int CONCURRENCY = 32; private final UserServiceNettyClientImpl userService = new UserServiceNettyClientImpl(); static { ResourceLeakDetector.setLevel(Level.DISABLED); } @Override protected UserService getUserService() { return userService; } @TearDown public void close() throws IOException { userService.close(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public boolean existUser() throws Exception { return super.existUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public boolean createUser() throws Exception { return super.createUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public User getUser() throws Exception { return super.getUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public Page listUser() throws Exception { return super.listUser(); } public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder()// .include(Client.class.getSimpleName())// .warmupIterations(3)// .warmupTime(TimeValue.seconds(10))// .measurementIterations(3)// .measurementTime(TimeValue.seconds(10))// .threads(CONCURRENCY)// .forks(1)// .build(); new Runner(opt).run(); } } ================================================ FILE: netty-client/src/main/java/benchmark/rpc/netty/client/NettyClientConnector.java ================================================ package benchmark.rpc.netty.client; import java.io.Closeable; import java.io.IOException; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import benchmark.rpc.netty.client.future.FutureContainer; import benchmark.rpc.netty.client.handler.BenchmarkChannelInitializer; import benchmark.rpc.netty.serializer.FastestSerializer; import benchmark.rpc.protocol.Request; import benchmark.rpc.protocol.Response; import io.netty.bootstrap.Bootstrap; import io.netty.buffer.ByteBuf; import io.netty.channel.Channel; import io.netty.channel.ChannelOption; import io.netty.channel.EventLoopGroup; import io.netty.channel.WriteBufferWaterMark; import io.netty.channel.epoll.Epoll; import io.netty.channel.epoll.EpollChannelOption; import io.netty.channel.epoll.EpollEventLoopGroup; import io.netty.channel.epoll.EpollSocketChannel; import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.nio.NioSocketChannel; import io.netty.util.ResourceLeakDetector; import io.netty.util.ResourceLeakDetector.Level; import io.netty.util.concurrent.DefaultThreadFactory; import io.netty.util.internal.shaded.org.jctools.queues.atomic.MpscAtomicArrayQueue; public class NettyClientConnector implements Closeable { static { ResourceLeakDetector.setLevel(Level.DISABLED); } public static final int CONNECT_COUNT = 4; private final FutureContainer futureContainer = new FutureContainer(); private final String host; private final int port; private long defaultTimeout = 15_000L; private EventLoopGroup eventLoopGroup; private final Channel[] channels = new Channel[CONNECT_COUNT]; @SuppressWarnings("unchecked") private final MpscAtomicArrayQueue[] queues = new MpscAtomicArrayQueue[CONNECT_COUNT]; public NettyClientConnector(String host, int port) { this.host = host; this.port = port; } public void setDefaultTimeout(long defaultTimeout) { this.defaultTimeout = defaultTimeout; } public Response execute(Request request) throws InterruptedException, ExecutionException, TimeoutException { return execute(request, defaultTimeout, TimeUnit.MILLISECONDS); } public Response execute(Request request, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { final long requestId = request.getRequestId(); final CompletableFuture future = new CompletableFuture<>(); try { futureContainer.addFuture(requestId, future); int index = ThreadLocalRandom.current().nextInt(CONNECT_COUNT); Channel channel = channels[index]; MpscAtomicArrayQueue queue = queues[index]; while (!queue.offer(request)) { batchSend(channel, queue); } batchSend(channel, queue); return future.get(); } finally { futureContainer.remove(requestId); } } private void batchSend(Channel channel, MpscAtomicArrayQueue queue) { if (queue.isEmpty()) { return; } channel.eventLoop().execute(() -> { if (queue.isEmpty()) { return; } ByteBuf byteBuf = channel.alloc().ioBuffer(1024 * 4); for (int i = 0; i < 64; i++) { Request request = queue.poll(); if (request == null) { break; } try { FastestSerializer.writeRequest(byteBuf, request); } catch (Throwable t) { t.printStackTrace(); channel.close(); } } if (byteBuf.isReadable()) { channel.writeAndFlush(byteBuf, channel.voidPromise()); } else { byteBuf.release(); } }); } @Override public void close() throws IOException { for (int i = 0; i < channels.length; i++) { channels[i].close(); } if (eventLoopGroup != null) { eventLoopGroup.shutdownGracefully(); } } public void connect() throws InterruptedException { if (Epoll.isAvailable()) { if (eventLoopGroup == null) { eventLoopGroup = new EpollEventLoopGroup(0, new DefaultThreadFactory(NioEventLoopGroup.class)); } doConnect(eventLoopGroup, EpollSocketChannel.class, true); } else { if (eventLoopGroup == null) { eventLoopGroup = new NioEventLoopGroup(0, new DefaultThreadFactory(NioEventLoopGroup.class)); } doConnect(eventLoopGroup, NioSocketChannel.class, false); } } private void doConnect(EventLoopGroup loupGroup, Class serverChannelClass, boolean isEpoll) throws InterruptedException { final Bootstrap bootstrap = new Bootstrap(); if (isEpoll) { bootstrap.option(EpollChannelOption.SO_REUSEPORT, true); } bootstrap.option(ChannelOption.SO_REUSEADDR, true); bootstrap.option(ChannelOption.SO_RCVBUF, 256 * 1024); bootstrap.option(ChannelOption.SO_SNDBUF, 256 * 1024); bootstrap.option(ChannelOption.WRITE_BUFFER_WATER_MARK, // new WriteBufferWaterMark(1024 * 1024, 2048 * 1024)); bootstrap.group(loupGroup); bootstrap.channel(serverChannelClass); bootstrap.handler(new BenchmarkChannelInitializer(futureContainer)); for (int i = 0; i < CONNECT_COUNT; i++) { channels[i] = bootstrap.connect(host, port).sync().channel(); queues[i] = new MpscAtomicArrayQueue<>(4 * 1024); } } } ================================================ FILE: netty-client/src/main/java/benchmark/rpc/netty/client/UserServiceNettyClientImpl.java ================================================ package benchmark.rpc.netty.client; import java.io.Closeable; import java.io.IOException; import java.util.concurrent.atomic.AtomicLong; import benchmark.bean.Page; import benchmark.bean.User; import benchmark.rpc.protocol.Request; import benchmark.rpc.protocol.Response; import benchmark.service.ServiceRegister; import benchmark.service.UserService; public class UserServiceNettyClientImpl implements UserService, Closeable { public static final String host = "benchmark-server"; public static final int port = 8080; private final NettyClientConnector connector = new NettyClientConnector(host, port); private final AtomicLong requestCounter = new AtomicLong(); public UserServiceNettyClientImpl() { connect(); } @Override public void close() throws IOException { connector.close(); } private void connect() { try { connector.connect(); } catch (InterruptedException e) { throw new RuntimeException(e); } } @SuppressWarnings("unchecked") private T execute(int serviceId, Object... params) { long requestId = requestCounter.getAndIncrement(); try { Request request = new Request(); request.setRequestId(requestId); request.setServiceId(serviceId); request.setParams(params); Response response = connector.execute(request); return (T) response.getResult(); } catch (Exception e) { throw new RuntimeException(e); } } @Override public boolean existUser(String email) { return execute(ServiceRegister.EXIST_USER, email); } @Override public boolean createUser(User user) { return execute(ServiceRegister.CREATE_USER, user); } @Override public User getUser(long id) { return execute(ServiceRegister.GET_USER, id); } @Override public Page listUser(int pageNo) { return execute(ServiceRegister.LIST_USER, pageNo); } } ================================================ FILE: netty-client/src/main/java/benchmark/rpc/netty/client/codec/ProtocolDecoder.java ================================================ package benchmark.rpc.netty.client.codec; import benchmark.rpc.netty.serializer.FastestSerializer; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.LengthFieldBasedFrameDecoder; public class ProtocolDecoder extends LengthFieldBasedFrameDecoder { private static final int HEADER_FIELD_LENGTH = 4; public ProtocolDecoder(int maxFrameLength) { super(maxFrameLength, 0, HEADER_FIELD_LENGTH, 0, HEADER_FIELD_LENGTH); } @Override protected Object decode(ChannelHandlerContext ctx, ByteBuf in) throws Exception { ByteBuf buffer = (ByteBuf) super.decode(ctx, in); if (buffer != null) { try { return FastestSerializer.readResponse(buffer); } finally { buffer.release(); } } return null; } } ================================================ FILE: netty-client/src/main/java/benchmark/rpc/netty/client/codec/ProtocolEncoder.java ================================================ package benchmark.rpc.netty.client.codec; import benchmark.rpc.netty.serializer.FastestSerializer; import benchmark.rpc.protocol.Request; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.MessageToByteEncoder; public class ProtocolEncoder extends MessageToByteEncoder { protected void encode(ChannelHandlerContext ctx, Request request, ByteBuf buffer) throws Exception { FastestSerializer.writeRequest(buffer, request); } } ================================================ FILE: netty-client/src/main/java/benchmark/rpc/netty/client/future/FutureContainer.java ================================================ package benchmark.rpc.netty.client.future; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ConcurrentHashMap; import benchmark.rpc.protocol.Response; /** * * @author Hank * */ public final class FutureContainer { private final ConcurrentHashMap> futureMap = new ConcurrentHashMap<>(); public void addFuture(long requestId, CompletableFuture future) { futureMap.put(requestId, future); } public void remove(long requestId) { futureMap.remove(requestId); } public void notifyResponse(Response response) { CompletableFuture future = futureMap.remove(response.getRequestId()); if (future == null) { return; } future.complete(response); } } ================================================ FILE: netty-client/src/main/java/benchmark/rpc/netty/client/handler/BenchmarkChannelInitializer.java ================================================ package benchmark.rpc.netty.client.handler; import benchmark.rpc.netty.client.codec.ProtocolDecoder; import benchmark.rpc.netty.client.codec.ProtocolEncoder; import benchmark.rpc.netty.client.future.FutureContainer; import io.netty.channel.ChannelInitializer; import io.netty.channel.socket.SocketChannel; public class BenchmarkChannelInitializer extends ChannelInitializer { public static final int MAX_FRAME_LENGTH = 8 * 1024 * 1024; private final FutureContainer futureContainer; public BenchmarkChannelInitializer(FutureContainer futureContainer) { this.futureContainer = futureContainer; } @Override public void initChannel(SocketChannel ch) throws Exception { ch.pipeline()// .addLast("encoder", new ProtocolEncoder())// .addLast("decoder", new ProtocolDecoder(MAX_FRAME_LENGTH))// .addLast("handler", new BenchmarkClientHandler(futureContainer)); } } ================================================ FILE: netty-client/src/main/java/benchmark/rpc/netty/client/handler/BenchmarkClientHandler.java ================================================ package benchmark.rpc.netty.client.handler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import benchmark.rpc.netty.client.future.FutureContainer; import benchmark.rpc.protocol.Response; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.SimpleChannelInboundHandler; public class BenchmarkClientHandler extends SimpleChannelInboundHandler { private static final Logger LOGGER = LoggerFactory.getLogger(BenchmarkClientHandler.class); private final FutureContainer futureContainer; public BenchmarkClientHandler(FutureContainer futureContainer) { this.futureContainer = futureContainer; } protected void channelRead0(ChannelHandlerContext ctx, Response response) throws Exception { futureContainer.notifyResponse(response); } @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { LOGGER.error("Exception caught on {}, ", ctx.channel(), cause); ctx.channel().close(); } } ================================================ FILE: netty-client/src/main/java/benchmark/rpc/netty/serializer/BooleanSerializer.java ================================================ package benchmark.rpc.netty.serializer; import io.netty.buffer.ByteBuf; public class BooleanSerializer implements Serializer { @Override public void write(ByteBuf byteBuf, Boolean value) { byteBuf.writeBoolean(value); } @Override public Boolean read(ByteBuf byteBuf) { return byteBuf.readBoolean(); } @Override public Class typeClass() { return Boolean.class; } } ================================================ FILE: netty-client/src/main/java/benchmark/rpc/netty/serializer/FastestSerializer.java ================================================ package benchmark.rpc.netty.serializer; import java.io.IOException; import benchmark.rpc.protocol.Request; import benchmark.rpc.protocol.Response; import io.netty.buffer.ByteBuf; public class FastestSerializer { private static final RequestSerializer requestSerializer = new RequestSerializer(); private static final ResponseSerializer responseSerializer = new ResponseSerializer(); public static void writeRequest(ByteBuf byteBuf, Request request) throws IOException { int beginWriterIndex = byteBuf.writerIndex(); byteBuf.writeInt(0); requestSerializer.write(byteBuf, request); int finishWriterIndex = byteBuf.writerIndex(); int length = finishWriterIndex - beginWriterIndex - 4; byteBuf.setInt(beginWriterIndex, length); } public static Request readRequest(ByteBuf byteBuf) throws IOException { return requestSerializer.read(byteBuf); } public static void writeResponse(ByteBuf byteBuf, Response response) throws IOException { int beginWriterIndex = byteBuf.writerIndex(); byteBuf.writeInt(0); responseSerializer.write(byteBuf, response); int finishWriterIndex = byteBuf.writerIndex(); int length = finishWriterIndex - beginWriterIndex - 4; byteBuf.setInt(beginWriterIndex, length); } public static Response readResponse(ByteBuf byteBuf) throws IOException { return responseSerializer.read(byteBuf); } } ================================================ FILE: netty-client/src/main/java/benchmark/rpc/netty/serializer/IntegerSerializer.java ================================================ package benchmark.rpc.netty.serializer; import io.netty.buffer.ByteBuf; public class IntegerSerializer implements Serializer { @Override public void write(ByteBuf byteBuf, Integer value) { byteBuf.writeInt(value); } @Override public Integer read(ByteBuf byteBuf) { return byteBuf.readInt(); } @Override public Class typeClass() { return Integer.class; } } ================================================ FILE: netty-client/src/main/java/benchmark/rpc/netty/serializer/LocalDateSerializer.java ================================================ package benchmark.rpc.netty.serializer; import java.time.LocalDate; import io.netty.buffer.ByteBuf; public class LocalDateSerializer implements Serializer { @Override public void write(ByteBuf byteBuf, LocalDate localDate) { byteBuf.writeShort(localDate.getYear()); byteBuf.writeByte(localDate.getMonthValue()); byteBuf.writeByte(localDate.getDayOfMonth()); } @Override public LocalDate read(ByteBuf byteBuf) { int year = byteBuf.readShort(); int month = byteBuf.readByte(); int dayOfMonth = byteBuf.readByte(); return LocalDate.of(year, month, dayOfMonth); } @Override public Class typeClass() { return LocalDate.class; } } ================================================ FILE: netty-client/src/main/java/benchmark/rpc/netty/serializer/LocalDateTimeSerializer.java ================================================ package benchmark.rpc.netty.serializer; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; import io.netty.buffer.ByteBuf; public class LocalDateTimeSerializer implements Serializer { private final LocalDateSerializer localDateSerializer = new LocalDateSerializer(); private final LocalTimeSerializer localTimeSerializer = new LocalTimeSerializer(); @Override public void write(ByteBuf byteBuf, LocalDateTime localDateTime) { localDateSerializer.write(byteBuf, localDateTime.toLocalDate()); localTimeSerializer.write(byteBuf, localDateTime.toLocalTime()); } @Override public LocalDateTime read(ByteBuf byteBuf) { LocalDate localDate = localDateSerializer.read(byteBuf); LocalTime localTime = localTimeSerializer.read(byteBuf); return LocalDateTime.of(localDate, localTime); } @Override public Class typeClass() { return LocalDateTime.class; } } ================================================ FILE: netty-client/src/main/java/benchmark/rpc/netty/serializer/LocalTimeSerializer.java ================================================ package benchmark.rpc.netty.serializer; import java.time.LocalTime; import io.netty.buffer.ByteBuf; public class LocalTimeSerializer implements Serializer { @Override public void write(ByteBuf byteBuf, LocalTime localTime) { byteBuf.writeByte(localTime.getHour()); byteBuf.writeByte(localTime.getMinute()); byteBuf.writeByte(localTime.getSecond()); byteBuf.writeInt(localTime.getNano()); } @Override public LocalTime read(ByteBuf byteBuf) { int hour = byteBuf.readByte(); int minute = byteBuf.readByte(); int second = byteBuf.readByte(); int nanoOfSecond = byteBuf.readInt(); return LocalTime.of(hour, minute, second, nanoOfSecond); } @Override public Class typeClass() { return LocalTime.class; } } ================================================ FILE: netty-client/src/main/java/benchmark/rpc/netty/serializer/LongSerializer.java ================================================ package benchmark.rpc.netty.serializer; import io.netty.buffer.ByteBuf; public class LongSerializer implements Serializer { @Override public void write(ByteBuf byteBuf, Long value) { byteBuf.writeLong(value); } @Override public Long read(ByteBuf byteBuf) { return byteBuf.readLong(); } @Override public Class typeClass() { return Long.class; } } ================================================ FILE: netty-client/src/main/java/benchmark/rpc/netty/serializer/ObjectSerializer.java ================================================ package benchmark.rpc.netty.serializer; import io.netty.buffer.ByteBuf; @SuppressWarnings("unchecked") public class ObjectSerializer implements Serializer { @Override public void write(ByteBuf byteBuf, Object object) { if (object == null) { byteBuf.writeInt(0); return; } Class clazz = object.getClass(); int id = Register.id(clazz); Serializer serializer = (Serializer) Register.serializer(id); byteBuf.writeInt(id); serializer.write(byteBuf, object); } @Override public Object read(ByteBuf byteBuf) { int id = byteBuf.readInt(); Serializer serializer = (Serializer) Register.serializer(id); return serializer.read(byteBuf); } @Override public Class typeClass() { return Object.class; } } ================================================ FILE: netty-client/src/main/java/benchmark/rpc/netty/serializer/Register.java ================================================ package benchmark.rpc.netty.serializer; import java.util.IdentityHashMap; public class Register { private final static Serializer[] idToSerializer = new Serializer[16]; private final static IdentityHashMap, Integer> classToId = new IdentityHashMap<>(); private final static IdentityHashMap, Serializer> classToSerializer = new IdentityHashMap<>(); static { int index = 0; idToSerializer[index++] = new VoidSerializer(); idToSerializer[index++] = new IntegerSerializer(); idToSerializer[index++] = new LongSerializer(); idToSerializer[index++] = new BooleanSerializer(); idToSerializer[index++] = new StringSerializer(); idToSerializer[index++] = new LocalDateSerializer(); idToSerializer[index++] = new LocalTimeSerializer(); idToSerializer[index++] = new LocalDateTimeSerializer(); idToSerializer[index++] = new UserSerializer(); idToSerializer[index++] = new UserPageSerializer(); idToSerializer[index++] = new RequestSerializer(); for (int i = 0; i < index; i++) { Serializer serializer = idToSerializer[i]; Class clazz = serializer.typeClass(); classToSerializer.put(clazz, serializer); classToId.put(clazz, i); } } public static Serializer serializer(int id) { return idToSerializer[id]; } public static Serializer serializer(Class clazz) { return classToSerializer.get(clazz); } public static int id(Class clazz) { return classToId.get(clazz); } } ================================================ FILE: netty-client/src/main/java/benchmark/rpc/netty/serializer/RequestSerializer.java ================================================ package benchmark.rpc.netty.serializer; import benchmark.rpc.protocol.Request; import io.netty.buffer.ByteBuf; public class RequestSerializer implements Serializer { private final ObjectSerializer objectSerializer = new ObjectSerializer(); @Override public void write(ByteBuf byteBuf, Request request) { Object[] params = request.getParams(); byteBuf.writeLong(request.getRequestId()); byteBuf.writeInt(request.getServiceId()); byteBuf.writeInt(params.length); for (int i = 0; i < params.length; i++) { objectSerializer.write(byteBuf, params[i]); } } @Override public Request read(ByteBuf byteBuf) { long requestId = byteBuf.readLong(); int serviceId = byteBuf.readInt(); int size = byteBuf.readInt(); Object[] params = new Object[size]; for (int i = 0; i < size; i++) { params[i] = objectSerializer.read(byteBuf); } Request request = new Request(); request.setRequestId(requestId); request.setServiceId(serviceId); request.setParams(params); return request; } @Override public Class typeClass() { return Request.class; } } ================================================ FILE: netty-client/src/main/java/benchmark/rpc/netty/serializer/ResponseSerializer.java ================================================ package benchmark.rpc.netty.serializer; import benchmark.rpc.protocol.Response; import io.netty.buffer.ByteBuf; public class ResponseSerializer implements Serializer { private final ObjectSerializer objectSerializer = new ObjectSerializer(); @Override public void write(ByteBuf byteBuf, Response response) { byteBuf.writeLong(response.getRequestId()); byteBuf.writeByte(response.getStatusCode()); objectSerializer.write(byteBuf, response.getResult()); } @Override public Response read(ByteBuf byteBuf) { long requestId = byteBuf.readLong(); byte statusCode = byteBuf.readByte(); Object result = objectSerializer.read(byteBuf); Response response = new Response(); response.setRequestId(requestId); response.setStatusCode(statusCode); response.setResult(result); return response; } @Override public Class typeClass() { return Response.class; } } ================================================ FILE: netty-client/src/main/java/benchmark/rpc/netty/serializer/Serializer.java ================================================ package benchmark.rpc.netty.serializer; import io.netty.buffer.ByteBuf; public interface Serializer { public void write(ByteBuf byteBuf, T object); public T read(ByteBuf byteBuf); public Class typeClass(); } ================================================ FILE: netty-client/src/main/java/benchmark/rpc/netty/serializer/StringSerializer.java ================================================ package benchmark.rpc.netty.serializer; import java.nio.charset.StandardCharsets; import io.netty.buffer.ByteBuf; public class StringSerializer implements Serializer { @Override public void write(ByteBuf byteBuf, String str) { byte[] bytes = str.getBytes(StandardCharsets.UTF_8); byteBuf.writeInt(bytes.length); byteBuf.writeBytes(bytes); } @Override public String read(ByteBuf byteBuf) { int length = byteBuf.readInt(); byte[] bytes = new byte[length]; byteBuf.readBytes(bytes); return new String(bytes, StandardCharsets.UTF_8); } @Override public Class typeClass() { return String.class; } } ================================================ FILE: netty-client/src/main/java/benchmark/rpc/netty/serializer/UserPageSerializer.java ================================================ package benchmark.rpc.netty.serializer; import java.util.ArrayList; import java.util.List; import java.util.RandomAccess; import benchmark.bean.Page; import benchmark.bean.User; import io.netty.buffer.ByteBuf; public class UserPageSerializer implements Serializer> { private final UserSerializer userSerializer = new UserSerializer(); @Override public void write(ByteBuf byteBuf, Page userPage) { List userList = userPage.getResult(); byteBuf.writeInt(userPage.getPageNo()); byteBuf.writeInt(userPage.getTotal()); byteBuf.writeInt(userList.size()); if (userList instanceof RandomAccess) { for (int i = 0; i < userList.size(); i++) { userSerializer.write(byteBuf, userList.get(i)); } } else { for (User user : userList) { userSerializer.write(byteBuf, user); } } } @Override public Page read(ByteBuf byteBuf) { int pageNo = byteBuf.readInt(); int total = byteBuf.readInt(); int size = byteBuf.readInt(); List userList = new ArrayList<>(size); for (int i = 0; i < size; i++) { userList.add(userSerializer.read(byteBuf)); } Page userPage = new Page<>(); userPage.setPageNo(pageNo); userPage.setTotal(total); userPage.setResult(userList); return userPage; } @Override @SuppressWarnings("rawtypes") public Class typeClass() { return Page.class; } } ================================================ FILE: netty-client/src/main/java/benchmark/rpc/netty/serializer/UserSerializer.java ================================================ package benchmark.rpc.netty.serializer; import java.time.LocalDate; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; import java.util.RandomAccess; import benchmark.bean.User; import io.netty.buffer.ByteBuf; public class UserSerializer implements Serializer { private final StringSerializer stringSerializer = new StringSerializer(); private final LocalDateSerializer localDateSerializer = new LocalDateSerializer(); private final LocalDateTimeSerializer localDateTimeSerializer = new LocalDateTimeSerializer(); @Override public void write(ByteBuf byteBuf, User user) { byteBuf.writeLong(user.getId()); stringSerializer.write(byteBuf, user.getName()); byteBuf.writeInt(user.getSex()); localDateSerializer.write(byteBuf, user.getBirthday()); stringSerializer.write(byteBuf, user.getEmail()); stringSerializer.write(byteBuf, user.getMobile()); stringSerializer.write(byteBuf, user.getAddress()); stringSerializer.write(byteBuf, user.getIcon()); List permissions = user.getPermissions(); byteBuf.writeInt(user.getPermissions().size()); if (permissions instanceof RandomAccess) { for (int i = 0; i < permissions.size(); i++) { byteBuf.writeInt(permissions.get(i)); } } else { for (int permission : permissions) { byteBuf.writeInt(permission); } } byteBuf.writeInt(user.getStatus()); localDateTimeSerializer.write(byteBuf, user.getCreateTime()); localDateTimeSerializer.write(byteBuf, user.getUpdateTime()); } @Override public User read(ByteBuf byteBuf) { long id = byteBuf.readLong(); String name = stringSerializer.read(byteBuf); int sex = byteBuf.readInt(); LocalDate birthday = localDateSerializer.read(byteBuf); String email = stringSerializer.read(byteBuf); String mobile = stringSerializer.read(byteBuf); String address = stringSerializer.read(byteBuf); String icon = stringSerializer.read(byteBuf); int size = byteBuf.readInt(); List permissions = new ArrayList<>(size); for (int i = 0; i < size; i++) { permissions.add(byteBuf.readInt()); } int status = byteBuf.readInt(); LocalDateTime createTime = localDateTimeSerializer.read(byteBuf); LocalDateTime updateTime = localDateTimeSerializer.read(byteBuf); User user = new User(); user.setId(id); user.setName(name); user.setSex(sex); user.setBirthday(birthday); user.setEmail(email); user.setMobile(mobile); user.setAddress(address); user.setIcon(icon); user.setPermissions(permissions); user.setStatus(status); user.setCreateTime(createTime); user.setUpdateTime(updateTime); return user; } @Override public Class typeClass() { return User.class; } } ================================================ FILE: netty-client/src/main/java/benchmark/rpc/netty/serializer/VoidSerializer.java ================================================ package benchmark.rpc.netty.serializer; import io.netty.buffer.ByteBuf; public class VoidSerializer implements Serializer { @Override public void write(ByteBuf byteBuf, Void value) { } @Override public Void read(ByteBuf byteBuf) { return null; } @Override public Class typeClass() { return Void.class; } } ================================================ FILE: netty-client/src/main/resources/logback.xml ================================================ %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n logs/benchmark-rpc-client.log logs/benchmark-netty-client.%d{yyyy-MM-dd}.log.gz %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n ================================================ FILE: netty-server/pom.xml ================================================ 4.0.0 rpc-benchmark netty-server round-5 jar netty-server http://maven.apache.org 11 11 UTF-8 round-5 4.1.33.Final benchmark.rpc benchmark-base ${version.benchmark-base} io.netty netty-codec ${netty.version} io.netty netty-transport-native-epoll ${netty.version} linux-x86_64 junit junit 4.12 test org.apache.maven.plugins maven-compiler-plugin 3.8.0 ${maven.compiler.source} ${maven.compiler.target} UTF-8 maven-assembly-plugin 3.1.0 jar-with-dependencies benchmark.rpc.Server make-assembly package single ================================================ FILE: netty-server/src/main/java/benchmark/rpc/Server.java ================================================ package benchmark.rpc; import java.net.InetSocketAddress; import benchmark.rpc.netty.server.handler.BenchmarkChannelInitializer; import io.netty.bootstrap.ServerBootstrap; import io.netty.channel.Channel; import io.netty.channel.ChannelOption; import io.netty.channel.EventLoopGroup; import io.netty.channel.ServerChannel; import io.netty.channel.WriteBufferWaterMark; import io.netty.channel.epoll.Epoll; import io.netty.channel.epoll.EpollChannelOption; import io.netty.channel.epoll.EpollEventLoopGroup; import io.netty.channel.epoll.EpollServerSocketChannel; import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.socket.nio.NioServerSocketChannel; import io.netty.util.ResourceLeakDetector; import io.netty.util.ResourceLeakDetector.Level; public class Server { public static final String host = "benchmark-server"; public static final int port = 8080; static { ResourceLeakDetector.setLevel(Level.DISABLED); } public static void main(String[] args) throws InterruptedException { if (Epoll.isAvailable()) { doRun(// new EpollEventLoopGroup(), // EpollServerSocketChannel.class, // true); } else { doRun(// new NioEventLoopGroup(), // NioServerSocketChannel.class, // false); } } private static void doRun(EventLoopGroup loupGroup, Class serverChannelClass, boolean isEpoll) throws InterruptedException { try { InetSocketAddress inet = new InetSocketAddress(port); ServerBootstrap b = new ServerBootstrap(); if (isEpoll) { b.option(EpollChannelOption.SO_REUSEPORT, true); } b.option(ChannelOption.SO_BACKLOG, 1024 * 8); b.option(ChannelOption.SO_REUSEADDR, true); b.option(ChannelOption.SO_RCVBUF, 256 * 1024); b.group(loupGroup).channel(serverChannelClass).childHandler(new BenchmarkChannelInitializer()); b.childOption(ChannelOption.SO_REUSEADDR, true); b.childOption(ChannelOption.SO_REUSEADDR, true); b.childOption(ChannelOption.SO_RCVBUF, 256 * 1024); b.childOption(ChannelOption.SO_SNDBUF, 256 * 1024); b.childOption(ChannelOption.WRITE_BUFFER_WATER_MARK, // new WriteBufferWaterMark(1024 * 1024, 2048 * 1024)); Channel ch = b.bind(inet).sync().channel(); System.out.printf("Httpd started. Listening on: %s%n", inet.toString()); ch.closeFuture().sync(); } finally { loupGroup.shutdownGracefully().sync(); } } } ================================================ FILE: netty-server/src/main/java/benchmark/rpc/netty/serializer/BooleanSerializer.java ================================================ package benchmark.rpc.netty.serializer; import io.netty.buffer.ByteBuf; public class BooleanSerializer implements Serializer { @Override public void write(ByteBuf byteBuf, Boolean value) { byteBuf.writeBoolean(value); } @Override public Boolean read(ByteBuf byteBuf) { return byteBuf.readBoolean(); } @Override public Class typeClass() { return Boolean.class; } } ================================================ FILE: netty-server/src/main/java/benchmark/rpc/netty/serializer/FastestSerializer.java ================================================ package benchmark.rpc.netty.serializer; import java.io.IOException; import benchmark.rpc.protocol.Request; import benchmark.rpc.protocol.Response; import io.netty.buffer.ByteBuf; public class FastestSerializer { private static final RequestSerializer requestSerializer = new RequestSerializer(); private static final ResponseSerializer responseSerializer = new ResponseSerializer(); public static void writeRequest(ByteBuf byteBuf, Request request) throws IOException { int beginWriterIndex = byteBuf.writerIndex(); byteBuf.writeInt(0); requestSerializer.write(byteBuf, request); int finishWriterIndex = byteBuf.writerIndex(); int length = finishWriterIndex - beginWriterIndex - 4; byteBuf.setInt(beginWriterIndex, length); } public static Request readRequest(ByteBuf byteBuf) throws IOException { return requestSerializer.read(byteBuf); } public static void writeResponse(ByteBuf byteBuf, Response response) throws IOException { int beginWriterIndex = byteBuf.writerIndex(); byteBuf.writeInt(0); responseSerializer.write(byteBuf, response); int finishWriterIndex = byteBuf.writerIndex(); int length = finishWriterIndex - beginWriterIndex - 4; byteBuf.setInt(beginWriterIndex, length); } public static Response readResponse(ByteBuf byteBuf) throws IOException { return responseSerializer.read(byteBuf); } } ================================================ FILE: netty-server/src/main/java/benchmark/rpc/netty/serializer/IntegerSerializer.java ================================================ package benchmark.rpc.netty.serializer; import io.netty.buffer.ByteBuf; public class IntegerSerializer implements Serializer { @Override public void write(ByteBuf byteBuf, Integer value) { byteBuf.writeInt(value); } @Override public Integer read(ByteBuf byteBuf) { return byteBuf.readInt(); } @Override public Class typeClass() { return Integer.class; } } ================================================ FILE: netty-server/src/main/java/benchmark/rpc/netty/serializer/LocalDateSerializer.java ================================================ package benchmark.rpc.netty.serializer; import java.time.LocalDate; import io.netty.buffer.ByteBuf; public class LocalDateSerializer implements Serializer { @Override public void write(ByteBuf byteBuf, LocalDate localDate) { byteBuf.writeShort(localDate.getYear()); byteBuf.writeByte(localDate.getMonthValue()); byteBuf.writeByte(localDate.getDayOfMonth()); } @Override public LocalDate read(ByteBuf byteBuf) { int year = byteBuf.readShort(); int month = byteBuf.readByte(); int dayOfMonth = byteBuf.readByte(); return LocalDate.of(year, month, dayOfMonth); } @Override public Class typeClass() { return LocalDate.class; } } ================================================ FILE: netty-server/src/main/java/benchmark/rpc/netty/serializer/LocalDateTimeSerializer.java ================================================ package benchmark.rpc.netty.serializer; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; import io.netty.buffer.ByteBuf; public class LocalDateTimeSerializer implements Serializer { private final LocalDateSerializer localDateSerializer = new LocalDateSerializer(); private final LocalTimeSerializer localTimeSerializer = new LocalTimeSerializer(); @Override public void write(ByteBuf byteBuf, LocalDateTime localDateTime) { localDateSerializer.write(byteBuf, localDateTime.toLocalDate()); localTimeSerializer.write(byteBuf, localDateTime.toLocalTime()); } @Override public LocalDateTime read(ByteBuf byteBuf) { LocalDate localDate = localDateSerializer.read(byteBuf); LocalTime localTime = localTimeSerializer.read(byteBuf); return LocalDateTime.of(localDate, localTime); } @Override public Class typeClass() { return LocalDateTime.class; } } ================================================ FILE: netty-server/src/main/java/benchmark/rpc/netty/serializer/LocalTimeSerializer.java ================================================ package benchmark.rpc.netty.serializer; import java.time.LocalTime; import io.netty.buffer.ByteBuf; public class LocalTimeSerializer implements Serializer { @Override public void write(ByteBuf byteBuf, LocalTime localTime) { byteBuf.writeByte(localTime.getHour()); byteBuf.writeByte(localTime.getMinute()); byteBuf.writeByte(localTime.getSecond()); byteBuf.writeInt(localTime.getNano()); } @Override public LocalTime read(ByteBuf byteBuf) { int hour = byteBuf.readByte(); int minute = byteBuf.readByte(); int second = byteBuf.readByte(); int nanoOfSecond = byteBuf.readInt(); return LocalTime.of(hour, minute, second, nanoOfSecond); } @Override public Class typeClass() { return LocalTime.class; } } ================================================ FILE: netty-server/src/main/java/benchmark/rpc/netty/serializer/LongSerializer.java ================================================ package benchmark.rpc.netty.serializer; import io.netty.buffer.ByteBuf; public class LongSerializer implements Serializer { @Override public void write(ByteBuf byteBuf, Long value) { byteBuf.writeLong(value); } @Override public Long read(ByteBuf byteBuf) { return byteBuf.readLong(); } @Override public Class typeClass() { return Long.class; } } ================================================ FILE: netty-server/src/main/java/benchmark/rpc/netty/serializer/ObjectSerializer.java ================================================ package benchmark.rpc.netty.serializer; import io.netty.buffer.ByteBuf; @SuppressWarnings("unchecked") public class ObjectSerializer implements Serializer { @Override public void write(ByteBuf byteBuf, Object object) { if (object == null) { byteBuf.writeInt(0); return; } Class clazz = object.getClass(); int id = Register.id(clazz); Serializer serializer = (Serializer) Register.serializer(id); byteBuf.writeInt(id); serializer.write(byteBuf, object); } @Override public Object read(ByteBuf byteBuf) { int id = byteBuf.readInt(); Serializer serializer = (Serializer) Register.serializer(id); return serializer.read(byteBuf); } @Override public Class typeClass() { return Object.class; } } ================================================ FILE: netty-server/src/main/java/benchmark/rpc/netty/serializer/Register.java ================================================ package benchmark.rpc.netty.serializer; import java.util.IdentityHashMap; public class Register { private final static Serializer[] idToSerializer = new Serializer[16]; private final static IdentityHashMap, Integer> classToId = new IdentityHashMap<>(); private final static IdentityHashMap, Serializer> classToSerializer = new IdentityHashMap<>(); static { int index = 0; idToSerializer[index++] = new VoidSerializer(); idToSerializer[index++] = new IntegerSerializer(); idToSerializer[index++] = new LongSerializer(); idToSerializer[index++] = new BooleanSerializer(); idToSerializer[index++] = new StringSerializer(); idToSerializer[index++] = new LocalDateSerializer(); idToSerializer[index++] = new LocalTimeSerializer(); idToSerializer[index++] = new LocalDateTimeSerializer(); idToSerializer[index++] = new UserSerializer(); idToSerializer[index++] = new UserPageSerializer(); idToSerializer[index++] = new RequestSerializer(); for (int i = 0; i < index; i++) { Serializer serializer = idToSerializer[i]; Class clazz = serializer.typeClass(); classToSerializer.put(clazz, serializer); classToId.put(clazz, i); } } public static Serializer serializer(int id) { return idToSerializer[id]; } public static Serializer serializer(Class clazz) { return classToSerializer.get(clazz); } public static int id(Class clazz) { return classToId.get(clazz); } } ================================================ FILE: netty-server/src/main/java/benchmark/rpc/netty/serializer/RequestSerializer.java ================================================ package benchmark.rpc.netty.serializer; import benchmark.rpc.protocol.Request; import io.netty.buffer.ByteBuf; public class RequestSerializer implements Serializer { private final ObjectSerializer objectSerializer = new ObjectSerializer(); @Override public void write(ByteBuf byteBuf, Request request) { Object[] params = request.getParams(); byteBuf.writeLong(request.getRequestId()); byteBuf.writeInt(request.getServiceId()); byteBuf.writeInt(params.length); for (int i = 0; i < params.length; i++) { objectSerializer.write(byteBuf, params[i]); } } @Override public Request read(ByteBuf byteBuf) { long requestId = byteBuf.readLong(); int serviceId = byteBuf.readInt(); int size = byteBuf.readInt(); Object[] params = new Object[size]; for (int i = 0; i < size; i++) { params[i] = objectSerializer.read(byteBuf); } Request request = new Request(); request.setRequestId(requestId); request.setServiceId(serviceId); request.setParams(params); return request; } @Override public Class typeClass() { return Request.class; } } ================================================ FILE: netty-server/src/main/java/benchmark/rpc/netty/serializer/ResponseSerializer.java ================================================ package benchmark.rpc.netty.serializer; import benchmark.rpc.protocol.Response; import io.netty.buffer.ByteBuf; public class ResponseSerializer implements Serializer { private final ObjectSerializer objectSerializer = new ObjectSerializer(); @Override public void write(ByteBuf byteBuf, Response response) { byteBuf.writeLong(response.getRequestId()); byteBuf.writeByte(response.getStatusCode()); objectSerializer.write(byteBuf, response.getResult()); } @Override public Response read(ByteBuf byteBuf) { long requestId = byteBuf.readLong(); byte statusCode = byteBuf.readByte(); Object result = objectSerializer.read(byteBuf); Response response = new Response(); response.setRequestId(requestId); response.setStatusCode(statusCode); response.setResult(result); return response; } @Override public Class typeClass() { return Response.class; } } ================================================ FILE: netty-server/src/main/java/benchmark/rpc/netty/serializer/Serializer.java ================================================ package benchmark.rpc.netty.serializer; import io.netty.buffer.ByteBuf; public interface Serializer { public void write(ByteBuf byteBuf, T object); public T read(ByteBuf byteBuf); public Class typeClass(); } ================================================ FILE: netty-server/src/main/java/benchmark/rpc/netty/serializer/StringSerializer.java ================================================ package benchmark.rpc.netty.serializer; import java.nio.charset.StandardCharsets; import io.netty.buffer.ByteBuf; public class StringSerializer implements Serializer { @Override public void write(ByteBuf byteBuf, String str) { byte[] bytes = str.getBytes(StandardCharsets.UTF_8); byteBuf.writeInt(bytes.length); byteBuf.writeBytes(bytes); } @Override public String read(ByteBuf byteBuf) { int length = byteBuf.readInt(); byte[] bytes = new byte[length]; byteBuf.readBytes(bytes); return new String(bytes, StandardCharsets.UTF_8); } @Override public Class typeClass() { return String.class; } } ================================================ FILE: netty-server/src/main/java/benchmark/rpc/netty/serializer/UserPageSerializer.java ================================================ package benchmark.rpc.netty.serializer; import java.util.ArrayList; import java.util.List; import java.util.RandomAccess; import benchmark.bean.Page; import benchmark.bean.User; import io.netty.buffer.ByteBuf; public class UserPageSerializer implements Serializer> { private final UserSerializer userSerializer = new UserSerializer(); @Override public void write(ByteBuf byteBuf, Page userPage) { List userList = userPage.getResult(); byteBuf.writeInt(userPage.getPageNo()); byteBuf.writeInt(userPage.getTotal()); byteBuf.writeInt(userList.size()); if (userList instanceof RandomAccess) { for (int i = 0; i < userList.size(); i++) { userSerializer.write(byteBuf, userList.get(i)); } } else { for (User user : userList) { userSerializer.write(byteBuf, user); } } } @Override public Page read(ByteBuf byteBuf) { int pageNo = byteBuf.readInt(); int total = byteBuf.readInt(); int size = byteBuf.readInt(); List userList = new ArrayList<>(size); for (int i = 0; i < size; i++) { userList.add(userSerializer.read(byteBuf)); } Page userPage = new Page<>(); userPage.setPageNo(pageNo); userPage.setTotal(total); userPage.setResult(userList); return userPage; } @Override @SuppressWarnings("rawtypes") public Class typeClass() { return Page.class; } } ================================================ FILE: netty-server/src/main/java/benchmark/rpc/netty/serializer/UserSerializer.java ================================================ package benchmark.rpc.netty.serializer; import java.time.LocalDate; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; import java.util.RandomAccess; import benchmark.bean.User; import io.netty.buffer.ByteBuf; public class UserSerializer implements Serializer { private final StringSerializer stringSerializer = new StringSerializer(); private final LocalDateSerializer localDateSerializer = new LocalDateSerializer(); private final LocalDateTimeSerializer localDateTimeSerializer = new LocalDateTimeSerializer(); @Override public void write(ByteBuf byteBuf, User user) { byteBuf.writeLong(user.getId()); stringSerializer.write(byteBuf, user.getName()); byteBuf.writeInt(user.getSex()); localDateSerializer.write(byteBuf, user.getBirthday()); stringSerializer.write(byteBuf, user.getEmail()); stringSerializer.write(byteBuf, user.getMobile()); stringSerializer.write(byteBuf, user.getAddress()); stringSerializer.write(byteBuf, user.getIcon()); List permissions = user.getPermissions(); byteBuf.writeInt(user.getPermissions().size()); if (permissions instanceof RandomAccess) { for (int i = 0; i < permissions.size(); i++) { byteBuf.writeInt(permissions.get(i)); } } else { for (int permission : permissions) { byteBuf.writeInt(permission); } } byteBuf.writeInt(user.getStatus()); localDateTimeSerializer.write(byteBuf, user.getCreateTime()); localDateTimeSerializer.write(byteBuf, user.getUpdateTime()); } @Override public User read(ByteBuf byteBuf) { long id = byteBuf.readLong(); String name = stringSerializer.read(byteBuf); int sex = byteBuf.readInt(); LocalDate birthday = localDateSerializer.read(byteBuf); String email = stringSerializer.read(byteBuf); String mobile = stringSerializer.read(byteBuf); String address = stringSerializer.read(byteBuf); String icon = stringSerializer.read(byteBuf); int size = byteBuf.readInt(); List permissions = new ArrayList<>(size); for (int i = 0; i < size; i++) { permissions.add(byteBuf.readInt()); } int status = byteBuf.readInt(); LocalDateTime createTime = localDateTimeSerializer.read(byteBuf); LocalDateTime updateTime = localDateTimeSerializer.read(byteBuf); User user = new User(); user.setId(id); user.setName(name); user.setSex(sex); user.setBirthday(birthday); user.setEmail(email); user.setMobile(mobile); user.setAddress(address); user.setIcon(icon); user.setPermissions(permissions); user.setStatus(status); user.setCreateTime(createTime); user.setUpdateTime(updateTime); return user; } @Override public Class typeClass() { return User.class; } } ================================================ FILE: netty-server/src/main/java/benchmark/rpc/netty/serializer/VoidSerializer.java ================================================ package benchmark.rpc.netty.serializer; import io.netty.buffer.ByteBuf; public class VoidSerializer implements Serializer { @Override public void write(ByteBuf byteBuf, Void value) { } @Override public Void read(ByteBuf byteBuf) { return null; } @Override public Class typeClass() { return Void.class; } } ================================================ FILE: netty-server/src/main/java/benchmark/rpc/netty/server/codec/ProtocolDecoder.java ================================================ package benchmark.rpc.netty.server.codec; import benchmark.rpc.netty.serializer.FastestSerializer; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.LengthFieldBasedFrameDecoder; public class ProtocolDecoder extends LengthFieldBasedFrameDecoder { private static final int HEADER_FIELD_LENGTH = 4; public ProtocolDecoder(int maxFrameLength) { super(maxFrameLength, 0, HEADER_FIELD_LENGTH, 0, HEADER_FIELD_LENGTH); } @Override protected Object decode(ChannelHandlerContext ctx, ByteBuf in) throws Exception { ByteBuf buffer = (ByteBuf) super.decode(ctx, in); if (buffer != null) { try { return FastestSerializer.readRequest(buffer); } finally { buffer.release(); } } return null; } } ================================================ FILE: netty-server/src/main/java/benchmark/rpc/netty/server/codec/ProtocolEncoder.java ================================================ package benchmark.rpc.netty.server.codec; import benchmark.rpc.netty.serializer.FastestSerializer; import benchmark.rpc.protocol.Response; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.MessageToByteEncoder; public class ProtocolEncoder extends MessageToByteEncoder { protected void encode(ChannelHandlerContext ctx, Response response, ByteBuf buffer) throws Exception { FastestSerializer.writeResponse(buffer, response); } } ================================================ FILE: netty-server/src/main/java/benchmark/rpc/netty/server/handler/BenchmarkChannelInitializer.java ================================================ package benchmark.rpc.netty.server.handler; import benchmark.rpc.netty.server.codec.ProtocolDecoder; import benchmark.rpc.netty.server.codec.ProtocolEncoder; import io.netty.channel.ChannelInitializer; import io.netty.channel.socket.SocketChannel; public class BenchmarkChannelInitializer extends ChannelInitializer { public static final int MAX_FRAME_LENGTH = 8 * 1024 * 1024; @Override public void initChannel(SocketChannel ch) throws Exception { ch.pipeline()// .addLast("encoder", new ProtocolEncoder())// .addLast("decoder", new ProtocolDecoder(MAX_FRAME_LENGTH))// .addLast("handler", new BenchmarkServerHandler()); } } ================================================ FILE: netty-server/src/main/java/benchmark/rpc/netty/server/handler/BenchmarkServerHandler.java ================================================ package benchmark.rpc.netty.server.handler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import benchmark.rpc.protocol.Request; import benchmark.rpc.protocol.Response; import benchmark.rpc.route.RouteService; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.SimpleChannelInboundHandler; public class BenchmarkServerHandler extends SimpleChannelInboundHandler { private static final Logger LOGGER = LoggerFactory.getLogger(BenchmarkServerHandler.class); private final RouteService routeService = new RouteService(); protected void channelRead0(ChannelHandlerContext ctx, Request msg) throws Exception { final long requestId = msg.getRequestId(); final int serviceId = msg.getServiceId(); final Object[] params = msg.getParams(); Object result = routeService.invoke(serviceId, params); Response response = new Response(); response.setRequestId(requestId); response.setStatusCode((byte) 1); response.setResult(result); ctx.writeAndFlush(response, ctx.voidPromise()); } @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { LOGGER.error("Exception caught on {}, ", ctx.channel(), cause); ctx.channel().close(); } } ================================================ FILE: pom.xml ================================================ 4.0.0 benchmark.rpc rpc-benchmark round-5 pom rpc-benchmark benchmark-base armeria-client armeria-server dubbo-client dubbo-server dubbo-kryo-client dubbo-kryo-server grpc-client grpc-server hprose-client hprose-server jupiter-client jupiter-server motan-client motan-server netty-client netty-server rapidoid-client rapidoid-server servicecomb-client servicecomb-server sofa-client sofa-server springboot-client springboot-server springboot-undertow-client springboot-undertow-server springwebflux-client springwebflux-server thrift-client thrift-server turbo-rpc-client turbo-rpc-server turbo-rest-client turbo-rest-server undertow-async-client undertow-async-server undertow-client undertow-server brpc-client brpc-server rsocket-server rsocket-client org.apache.maven.plugins maven-compiler-plugin 3.8.0 11 11 UTF-8 ================================================ FILE: rapidoid-client/pom.xml ================================================ 4.0.0 benchmark.rpc rapidoid-client round-5 jar rapidoid-client http://maven.apache.org 11 11 UTF-8 round-5 benchmark.rpc benchmark-base ${version.benchmark-base} junit junit 4.12 test org.apache.maven.plugins maven-compiler-plugin 3.8.0 ${maven.compiler.source} ${maven.compiler.target} UTF-8 org.apache.maven.plugins maven-resources-plugin 3.1.0 UTF-8 maven-assembly-plugin 3.1.0 jar-with-dependencies benchmark.rpc.Client make-assembly package single src/main/resources ================================================ FILE: rapidoid-client/src/main/java/benchmark/rpc/Client.java ================================================ package benchmark.rpc; import java.util.concurrent.TimeUnit; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; import benchmark.bean.Page; import benchmark.bean.User; import benchmark.service.UserService; import benchmark.service.UserServiceJsonHttpClientImpl; @State(Scope.Benchmark) public class Client extends AbstractClient { public static final int CONCURRENCY = 32; private final UserService userService = new UserServiceJsonHttpClientImpl(CONCURRENCY); @Override protected UserService getUserService() { return userService; } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public boolean existUser() throws Exception { return super.existUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public boolean createUser() throws Exception { return super.createUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public User getUser() throws Exception { return super.getUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public Page listUser() throws Exception { return super.listUser(); } public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder()// .include(Client.class.getSimpleName())// .warmupIterations(3)// .warmupTime(TimeValue.seconds(10))// .measurementIterations(3)// .measurementTime(TimeValue.seconds(10))// .threads(CONCURRENCY)// .forks(1)// .build(); new Runner(opt).run(); } } ================================================ FILE: rapidoid-server/.gitignore ================================================ /.apt_generated_tests/ ================================================ FILE: rapidoid-server/pom.xml ================================================ 4.0.0 benchmark.rpc rapidoid-server round-5 jar rapidoid-server http://maven.apache.org 11 11 UTF-8 round-5 5.5.5 benchmark.rpc benchmark-base ${version.benchmark-base} org.rapidoid rapidoid-web ${version.rapidoid} junit junit 4.12 test org.apache.maven.plugins maven-compiler-plugin 3.8.0 ${maven.compiler.source} ${maven.compiler.target} UTF-8 org.apache.maven.plugins maven-resources-plugin 3.1.0 UTF-8 maven-assembly-plugin 3.1.0 jar-with-dependencies benchmark.rpc.Server make-assembly package single src/main/resources ================================================ FILE: rapidoid-server/src/main/java/benchmark/rpc/Server.java ================================================ package benchmark.rpc; import org.rapidoid.config.Conf; import org.rapidoid.setup.App; import org.rapidoid.setup.My; import org.rapidoid.setup.On; import benchmark.rpc.util.JsonUtils; public class Server { public static final String host = "benchmark-server"; public static final int port = 8080; public static void main(String[] args) { App.bootstrap(args); My.custom().objectMapper(JsonUtils.objectMapper); Conf.HTTP.set("maxPipeline", 256); Conf.HTTP.set("timeout", 0); Conf.HTTP.sub("mandatoryHeaders").set("connection", false); On.port(port); } } ================================================ FILE: rapidoid-server/src/main/java/benchmark/rpc/rapidoid/server/CreateUserController.java ================================================ package benchmark.rpc.rapidoid.server; import org.rapidoid.annotation.Controller; import org.rapidoid.annotation.GET; import benchmark.bean.User; import benchmark.service.UserService; import benchmark.service.UserServiceServerImpl; @Controller public class CreateUserController { private final UserService userService = new UserServiceServerImpl(); @GET("create-user") public boolean createUser(User user) { return userService.createUser(user); } } ================================================ FILE: rapidoid-server/src/main/java/benchmark/rpc/rapidoid/server/GetUserController.java ================================================ package benchmark.rpc.rapidoid.server; import org.rapidoid.annotation.Controller; import org.rapidoid.annotation.GET; import benchmark.bean.User; import benchmark.service.UserService; import benchmark.service.UserServiceServerImpl; @Controller public class GetUserController { private final UserService userService = new UserServiceServerImpl(); @GET("get-user") public User getUser(int id) { User user = userService.getUser(id); return user; } } ================================================ FILE: rapidoid-server/src/main/java/benchmark/rpc/rapidoid/server/ListUserController.java ================================================ package benchmark.rpc.rapidoid.server; import org.rapidoid.annotation.Controller; import org.rapidoid.annotation.GET; import benchmark.bean.Page; import benchmark.bean.User; import benchmark.service.UserService; import benchmark.service.UserServiceServerImpl; @Controller public class ListUserController { private final UserService userService = new UserServiceServerImpl(); @GET("list-user") public Page getUser(int pageNo) { Page userList = userService.listUser(pageNo); return userList; } } ================================================ FILE: rapidoid-server/src/main/java/benchmark/rpc/rapidoid/server/UserExistController.java ================================================ package benchmark.rpc.rapidoid.server; import org.rapidoid.annotation.Controller; import org.rapidoid.annotation.GET; import benchmark.service.UserService; import benchmark.service.UserServiceServerImpl; @Controller public class UserExistController { private final UserService userService = new UserServiceServerImpl(); @GET("user-exist") public boolean emailExist(String email) { return userService.existUser(email); } } ================================================ FILE: rsocket-client/pom.xml ================================================ rpc-benchmark benchmark.rpc round-5 4.0.0 rsocket-client rsocket-client http://maven.apache.org 11 11 UTF-8 round-5 0.2.17 0.12.2-RC4 1.18.0 3.6.1 benchmark.rpc benchmark-base ${version.benchmark-base} io.rsocket rsocket-transport-netty ${version.rsocket-transport-netty} io.rsocket.rpc rsocket-rpc-core ${version.rsocket-rpc-core} io.rsocket.rpc rsocket-rpc-protobuf com.google.protobuf protobuf-java ${version.protobuf} junit junit 4.11 test kr.motd.maven os-maven-plugin 1.6.1 org.codehaus.mojo build-helper-maven-plugin generate-sources add-source ${project.build.directory}/generated-sources/protobuf/java ${project.build.directory}/generated-sources/protobuf/rsocketRpc org.xolstice.maven.plugins protobuf-maven-plugin 0.6.1 com.google.protobuf:protoc:3.6.0:exe:${os.detected.classifier} rsocketRpc io.rsocket.rpc:rsocket-rpc-protobuf:${version.rsocket-rpc-core}:exe:${os.detected.classifier} compile compile-custom org.apache.maven.plugins maven-compiler-plugin 3.8.0 ${maven.compiler.source} ${maven.compiler.target} UTF-8 org.apache.maven.plugins maven-resources-plugin 3.1.0 UTF-8 maven-assembly-plugin 3.1.0 jar-with-dependencies benchmark.rpc.Client make-assembly package single src/main/resources src/main/proto ================================================ FILE: rsocket-client/src/main/java/benchmark/rpc/Client.java ================================================ package benchmark.rpc; import benchmark.bean.Page; import benchmark.bean.User; import benchmark.rpc.rsocket.UserServiceRsocketClientImpl; import benchmark.service.UserService; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; import java.io.IOException; import java.util.concurrent.TimeUnit; @State(Scope.Benchmark) public class Client extends AbstractClient{ public static final int CONCURRENCY = 32; UserServiceRsocketClientImpl userService = new UserServiceRsocketClientImpl(); @Override protected UserService getUserService() { return userService; } @TearDown public void close() throws IOException { userService.close(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public boolean existUser() throws Exception { return super.existUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public boolean createUser() throws Exception { return super.createUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public User getUser() throws Exception { return super.getUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public Page listUser() throws Exception { return super.listUser(); } public static void main(String[] args) throws Exception { Client client = new Client(); for (int i = 0; i < 60; i++) { try { System.out.println(client.getUser()); break; } catch (Exception e) { Thread.sleep(1000); } } client.close(); Options opt = new OptionsBuilder()// .include(Client.class.getSimpleName())// .warmupIterations(3)// .warmupTime(TimeValue.seconds(10))// .measurementIterations(3)// .measurementTime(TimeValue.seconds(10))// .threads(CONCURRENCY)// .forks(1)// .build(); new Runner(opt).run(); } } ================================================ FILE: rsocket-client/src/main/java/benchmark/rpc/rsocket/UserServiceRsocketClientImpl.java ================================================ package benchmark.rpc.rsocket; import benchmark.bean.Page; import benchmark.bean.User; import benchmark.rpc.grpc.UserServiceClient; import benchmark.rpc.grpc.UserServiceOuterClass; import benchmark.service.UserService; import io.rsocket.RSocket; import io.rsocket.RSocketFactory; import io.rsocket.transport.netty.client.TcpClientTransport; import java.io.Closeable; import java.io.IOException; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.ZoneOffset; import java.util.List; import java.util.stream.Collectors; public class UserServiceRsocketClientImpl implements UserService, Closeable { RSocket rSocket; UserServiceClient userServiceClient; public UserServiceRsocketClientImpl() { this.rSocket = RSocketFactory.connect().transport(TcpClientTransport.create(8080)).start().block(); this.userServiceClient = new UserServiceClient(rSocket); } @Override public boolean existUser(String email) { UserServiceOuterClass.UserExistRequest request = UserServiceOuterClass.UserExistRequest.newBuilder() .setEmail(email) .build(); return userServiceClient.userExist(request).block().getExist(); } @Override public boolean createUser(User user) { UserServiceOuterClass.User param = UserServiceOuterClass.User.newBuilder() .setId(user.getId())// .setName(user.getName())// .setSex(user.getSex())// .setBirthday((int) (user.getBirthday().toEpochDay()))// .setEmail(user.getEmail())// .setMobile(user.getMobile())// .setAddress(user.getAddress())// .setIcon(user.getIcon())// .addAllPermissions(user.getPermissions())// .setStatus(user.getStatus())// .setCreateTime(user.getCreateTime().toEpochSecond(ZoneOffset.UTC))// .setUpdateTime(user.getUpdateTime().toEpochSecond(ZoneOffset.UTC))// .build(); return userServiceClient.createUser(param).block().getSuccess(); } @Override public User getUser(long id) { UserServiceOuterClass.GetUserRequest request = UserServiceOuterClass.GetUserRequest.newBuilder() .setId(id) .build(); return userServiceClient.getUser(request).map(response -> { return from(response); }).block(); } private User from(UserServiceOuterClass.User response){ User user = new User(); user.setId(response.getId()); user.setName(response.getName()); user.setSex(response.getSex()); user.setBirthday(LocalDate.ofEpochDay(response.getBirthday())); user.setEmail(response.getEmail()); user.setMobile(response.getMobile()); user.setAddress(response.getAddress()); user.setIcon(response.getIcon()); user.setPermissions(response.getPermissionsList()); user.setStatus(response.getStatus()); user.setCreateTime(LocalDateTime.ofEpochSecond(response.getCreateTime(), 0, ZoneOffset.UTC)); user.setUpdateTime(LocalDateTime.ofEpochSecond(response.getUpdateTime(), 0, ZoneOffset.UTC)); return user; } @Override public Page listUser(int pageNo) { UserServiceOuterClass.ListUserRequest request = UserServiceOuterClass.ListUserRequest.newBuilder() .setPageNo(pageNo) .build(); Page page = new Page<>(); UserServiceOuterClass.UserPage userPage = userServiceClient.listUser(request).block(); page.setPageNo(userPage.getPageNo()); page.setTotal(userPage.getTotal()); List userList = userPage.getResultList() .stream() .map(response -> from(response)) .collect(Collectors.toList()); page.setResult(userList); return page; } @Override public void close() throws IOException { } } ================================================ FILE: rsocket-client/src/main/proto/UserService.proto ================================================ syntax = "proto3"; package grpc; import public "google/protobuf/timestamp.proto"; option java_package = "benchmark.rpc.grpc"; service UserService { rpc userExist (UserExistRequest) returns (UserExistResponse) {} rpc createUser (User) returns (CreateUserResponse) {} rpc getUser (GetUserRequest) returns (User) {} rpc listUser (ListUserRequest) returns (UserPage) {} } message UserExistRequest { string email = 1; } message UserExistResponse { bool exist = 1; } message GetUserRequest { int64 id = 1; } message User { int64 id = 1; string name = 2; int32 sex = 3; int32 birthday = 4; string email = 5; string mobile = 6; string address = 7; string icon = 8; repeated int32 permissions = 9; int32 status = 10; int64 createTime = 11; int64 updateTime = 12; } message CreateUserResponse { bool success = 1; } message ListUserRequest { int32 pageNo = 1; } message UserPage { int32 pageNo = 1; int32 total = 2; repeated User result = 3; } ================================================ FILE: rsocket-server/pom.xml ================================================ 4.0.0 benchmark.rpc rsocket-server round-5 jar rsocket-server http://maven.apache.org 11 11 UTF-8 round-5 0.2.17 0.12.2-RC4 1.18.0 3.6.1 benchmark.rpc benchmark-base ${version.benchmark-base} io.rsocket rsocket-transport-netty ${version.rsocket-transport-netty} io.rsocket.rpc rsocket-rpc-core ${version.rsocket-rpc-core} io.rsocket.rpc rsocket-rpc-protobuf com.google.protobuf protobuf-java ${version.protobuf} junit junit 4.11 test kr.motd.maven os-maven-plugin 1.6.1 org.codehaus.mojo build-helper-maven-plugin generate-sources add-source ${project.build.directory}/generated-sources/protobuf/java ${project.build.directory}/generated-sources/protobuf/rsocketRpc org.xolstice.maven.plugins protobuf-maven-plugin 0.6.1 com.google.protobuf:protoc:3.6.0:exe:${os.detected.classifier} rsocketRpc io.rsocket.rpc:rsocket-rpc-protobuf:${version.rsocket-rpc-core}:exe:${os.detected.classifier} compile compile-custom org.apache.maven.plugins maven-compiler-plugin 3.8.0 ${maven.compiler.source} ${maven.compiler.target} UTF-8 org.apache.maven.plugins maven-resources-plugin 3.1.0 UTF-8 maven-assembly-plugin 3.1.0 jar-with-dependencies benchmark.rpc.Server make-assembly package single src/main/resources src/main/proto ================================================ FILE: rsocket-server/src/main/java/benchmark/rpc/Server.java ================================================ package benchmark.rpc; import benchmark.rpc.grpc.UserServiceServer; import benchmark.rpc.rsocket.server.UserServiceRsocketServerImpl; import io.rsocket.RSocketFactory; import io.rsocket.rpc.rsocket.RequestHandlingRSocket; import io.rsocket.transport.netty.server.CloseableChannel; import io.rsocket.transport.netty.server.TcpServerTransport; import reactor.core.publisher.Mono; import java.util.Optional; public class Server { public static void main(String[] args){ UserServiceServer userServiceServer = new UserServiceServer(new UserServiceRsocketServerImpl(), Optional.empty(), Optional.empty()); CloseableChannel closeableChannel = RSocketFactory.receive() .acceptor( (setup, sendingSocket) -> Mono.just(new RequestHandlingRSocket(userServiceServer))) .transport(TcpServerTransport.create(8080)) .start() .block(); // Block so we don't exit closeableChannel.onClose().block(); } } ================================================ FILE: rsocket-server/src/main/java/benchmark/rpc/rsocket/server/UserServiceRsocketServerImpl.java ================================================ package benchmark.rpc.rsocket.server; import benchmark.bean.Page; import benchmark.bean.User; import benchmark.rpc.grpc.UserService; import benchmark.rpc.grpc.UserServiceOuterClass; import benchmark.service.UserServiceServerImpl; import io.netty.buffer.ByteBuf; import reactor.core.publisher.Mono; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.ZoneOffset; import java.util.ArrayList; import java.util.List; public class UserServiceRsocketServerImpl implements UserService { private final benchmark.service.UserService userService = new UserServiceServerImpl(); @Override public Mono userExist(UserServiceOuterClass.UserExistRequest message, ByteBuf metadata) { String email = message.getEmail(); boolean isExist = userService.existUser(email); return Mono.just(UserServiceOuterClass.UserExistResponse.newBuilder().setExist(isExist).build()); } @Override public Mono createUser(UserServiceOuterClass.User message, ByteBuf metadata) { benchmark.bean.User user = new benchmark.bean.User(); user.setId(message.getId()); user.setName(message.getName()); user.setSex(message.getSex()); user.setBirthday(LocalDate.ofEpochDay(message.getBirthday())); user.setEmail(message.getEmail()); user.setMobile(message.getMobile()); user.setAddress(message.getAddress()); user.setIcon(message.getIcon()); user.setPermissions(message.getPermissionsList()); user.setStatus(message.getStatus()); user.setCreateTime(LocalDateTime.ofEpochSecond(message.getCreateTime(), 0, ZoneOffset.UTC)); user.setUpdateTime(LocalDateTime.ofEpochSecond(message.getUpdateTime(), 0, ZoneOffset.UTC)); boolean success = userService.createUser(user); UserServiceOuterClass.CreateUserResponse reply = UserServiceOuterClass.CreateUserResponse.newBuilder().setSuccess(success).build(); return Mono.just(reply); } @Override public Mono getUser(UserServiceOuterClass.GetUserRequest message, ByteBuf metadata) { long id = message.getId(); benchmark.bean.User user = userService.getUser(id); UserServiceOuterClass.User reply = UserServiceOuterClass.User.newBuilder()// .setId(user.getId())// .setName(user.getName())// .setSex(user.getSex())// .setBirthday((int) (user.getBirthday().toEpochDay()))// .setEmail(user.getEmail())// .setMobile(user.getMobile())// .setAddress(user.getAddress())// .setIcon(user.getIcon())// .addAllPermissions(user.getPermissions())// .setStatus(user.getStatus())// .setCreateTime(user.getCreateTime().toEpochSecond(ZoneOffset.UTC))// .setUpdateTime(user.getUpdateTime().toEpochSecond(ZoneOffset.UTC))// .build(); return Mono.just(reply); } @Override public Mono listUser(UserServiceOuterClass.ListUserRequest message, ByteBuf metadata) { int pageNo = message.getPageNo(); Page page = userService.listUser(pageNo); List userList = new ArrayList<>(page.getResult().size()); for (benchmark.bean.User user : page.getResult()) { UserServiceOuterClass.User u = UserServiceOuterClass.User.newBuilder()// .setId(user.getId())// .setName(user.getName())// .setSex(user.getSex())// .setBirthday((int) (user.getBirthday().toEpochDay()))// .setEmail(user.getEmail())// .setMobile(user.getMobile())// .setAddress(user.getAddress())// .setIcon(user.getIcon())// .addAllPermissions(user.getPermissions())// .setStatus(user.getStatus())// .setCreateTime(user.getCreateTime().toEpochSecond(ZoneOffset.UTC))// .setUpdateTime(user.getUpdateTime().toEpochSecond(ZoneOffset.UTC))// .build(); userList.add(u); } UserServiceOuterClass.UserPage reply = UserServiceOuterClass.UserPage.newBuilder()// .setPageNo(page.getPageNo())// .setTotal(page.getTotal())// .addAllResult(userList)// .build(); return Mono.just(reply); } } ================================================ FILE: rsocket-server/src/main/proto/UserService.proto ================================================ syntax = "proto3"; package grpc; import public "google/protobuf/timestamp.proto"; option java_package = "benchmark.rpc.grpc"; service UserService { rpc userExist (UserExistRequest) returns (UserExistResponse) {} rpc createUser (User) returns (CreateUserResponse) {} rpc getUser (GetUserRequest) returns (User) {} rpc listUser (ListUserRequest) returns (UserPage) {} } message UserExistRequest { string email = 1; } message UserExistResponse { bool exist = 1; } message GetUserRequest { int64 id = 1; } message User { int64 id = 1; string name = 2; int32 sex = 3; int32 birthday = 4; string email = 5; string mobile = 6; string address = 7; string icon = 8; repeated int32 permissions = 9; int32 status = 10; int64 createTime = 11; int64 updateTime = 12; } message CreateUserResponse { bool success = 1; } message ListUserRequest { int32 pageNo = 1; } message UserPage { int32 pageNo = 1; int32 total = 2; repeated User result = 3; } ================================================ FILE: servicecomb-client/pom.xml ================================================ 4.0.0 benchmark.rpc servicecomb-client round-5 jar servicecomb-client http://maven.apache.org 11 11 UTF-8 round-5 1.1.0 3.8.1 1.7.25 2.3.1 benchmark.rpc benchmark-base ${version.benchmark-base} ch.qos.logback logback-classic org.apache.servicecomb provider-pojo ${servicecomb.version} org.apache.servicecomb transport-highway ${servicecomb.version} org.apache.commons commons-lang3 ${version.commons-lang3} org.slf4j slf4j-log4j12 ${version.slf4j} javax.xml.ws jaxws-api ${version.jaxws-api} junit junit 4.12 test org.apache.maven.plugins maven-compiler-plugin 3.8.0 ${maven.compiler.source} ${maven.compiler.target} UTF-8 org.apache.maven.plugins maven-resources-plugin 3.1.0 UTF-8 org.springframework.boot spring-boot-maven-plugin true benchmark.rpc.Client repackage src/main/resources ================================================ FILE: servicecomb-client/src/main/java/benchmark/rpc/Client.java ================================================ package benchmark.rpc; import java.util.concurrent.TimeUnit; import org.apache.servicecomb.foundation.common.utils.BeanUtils; import org.apache.servicecomb.foundation.common.utils.Log4jUtils; import org.apache.servicecomb.provider.pojo.RpcReference; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; import org.springframework.stereotype.Component; import benchmark.bean.Page; import benchmark.bean.User; import benchmark.service.UserService; import io.netty.util.concurrent.GlobalEventExecutor; @State(Scope.Benchmark) @Component public class Client extends AbstractClient { public static final int CONCURRENCY = 32; @RpcReference(microserviceName = "benchmark", schemaId = "benchmark") private static UserService userService; static { Object exec = GlobalEventExecutor.INSTANCE; System.out.println(exec); try { Log4jUtils.init(); } catch (Exception e) { e.printStackTrace(); } BeanUtils.init(); } @Override protected UserService getUserService() { return userService; } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public boolean existUser() throws Exception { return super.existUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public boolean createUser() throws Exception { return super.createUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public User getUser() throws Exception { return super.getUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public Page listUser() throws Exception { return super.listUser(); } public static void main(String[] args) throws Exception { Client client = new Client(); for (int i = 0; i < 60; i++) { try { System.out.println(client.existUser()); System.out.println(client.createUser()); System.out.println(client.getUser()); System.out.println(client.listUser()); break; } catch (Exception e) { e.printStackTrace(); Thread.sleep(1000); } } Options opt = new OptionsBuilder()// .include(Client.class.getSimpleName())// .warmupIterations(3)// .warmupTime(TimeValue.seconds(10))// .measurementIterations(3)// .measurementTime(TimeValue.seconds(10))// .threads(CONCURRENCY)// .forks(0)// .build(); new Runner(opt).run(); System.exit(1); } } ================================================ FILE: servicecomb-client/src/main/resources/META-INF/spring/benchmark.consumer.bean.xml ================================================ ================================================ FILE: servicecomb-client/src/main/resources/config/log4j.demo.properties ================================================ # # 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. # paas.logs.dir=target/logs/ paas.logs.file=benchmark.log log4j.rootLogger=WARN,paas,stdout ================================================ FILE: servicecomb-client/src/main/resources/log4j.properties ================================================ # # 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. # paas.logs.dir=target/logs/ paas.logs.file=benchmark.log log4j.rootLogger=WARN,paas,stdout ================================================ FILE: servicecomb-client/src/main/resources/microservice.yaml ================================================ ## --------------------------------------------------------------------------- ## 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. ## --------------------------------------------------------------------------- APPLICATION_ID: rpc-benchmark service_description: name: benchmarkClient version: 0.0.1 servicecomb: service: registry: address: http://benchmark-server:30100 highway: client: thread-count: 2 isolation: Consumer: enabled: false references: benchmark: version-rule: 0.0.1 ================================================ FILE: servicecomb-server/pom.xml ================================================ 4.0.0 benchmark.rpc servicecomb-server round-5 jar servicecomb-server http://maven.apache.org 11 11 UTF-8 round-5 1.1.0 3.8.1 1.7.25 2.3.1 benchmark.rpc benchmark-base ${version.benchmark-base} ch.qos.logback logback-classic org.apache.servicecomb provider-pojo ${servicecomb.version} org.apache.servicecomb transport-highway ${servicecomb.version} org.apache.commons commons-lang3 ${version.commons-lang3} org.slf4j slf4j-log4j12 ${version.slf4j} javax.xml.ws jaxws-api ${version.jaxws-api} junit junit 4.12 test org.apache.maven.plugins maven-compiler-plugin 3.8.0 ${maven.compiler.source} ${maven.compiler.target} UTF-8 org.apache.maven.plugins maven-resources-plugin 3.1.0 UTF-8 org.springframework.boot spring-boot-maven-plugin true benchmark.rpc.Server repackage src/main/resources ================================================ FILE: servicecomb-server/src/main/java/benchmark/rpc/Server.java ================================================ package benchmark.rpc; import org.apache.servicecomb.foundation.common.utils.BeanUtils; import org.apache.servicecomb.foundation.common.utils.Log4jUtils; import io.netty.util.concurrent.GlobalEventExecutor; public class Server { public static void main(String[] args) throws Exception { Object exec = GlobalEventExecutor.INSTANCE; System.out.println(exec); Log4jUtils.init(); BeanUtils.init(); } } ================================================ FILE: servicecomb-server/src/main/java/benchmark/service/ServiceCombUserServiceServerImpl.java ================================================ package benchmark.service; import java.time.LocalDate; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import org.apache.servicecomb.provider.pojo.RpcSchema; import benchmark.bean.Page; import benchmark.bean.User; @RpcSchema(schemaId = "benchmark") public class ServiceCombUserServiceServerImpl implements UserService { @Override public boolean existUser(String email) { if (email == null || email.isEmpty()) { return true; } if (email.charAt(email.length() - 1) < '5') { return false; } return true; } @Override public User getUser(long id) { User user = new User(); user.setId(id); user.setName(new String("Doug Lea")); user.setSex(1); user.setBirthday(LocalDate.of(1968, 12, 8)); user.setEmail(new String("dong.lea@gmail.com")); user.setMobile(new String("18612345678")); user.setAddress(new String("北京市 中关村 中关村大街1号 鼎好大厦 1605")); user.setIcon(new String("https://www.baidu.com/img/bd_logo1.png")); user.setStatus(1); user.setCreateTime(LocalDateTime.now()); user.setUpdateTime(user.getCreateTime()); List permissions = new ArrayList( Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 19, 88, 86, 89, 90, 91, 92)); user.setPermissions(permissions); return user; } @Override public Page listUser(int pageNo) { List userList = new ArrayList<>(15); for (int i = 0; i < 15; i++) { User user = new User(); user.setId(i); user.setName("Doug Lea" + i); user.setSex(1); user.setBirthday(LocalDate.of(1968, 12, 8)); user.setEmail("dong.lea@gmail.com" + i); user.setMobile("18612345678" + i); user.setAddress("北京市 中关村 中关村大街1号 鼎好大厦 1605" + i); user.setIcon("https://www.baidu.com/img/bd_logo1.png" + i); user.setStatus(1); user.setCreateTime(LocalDateTime.now()); user.setUpdateTime(user.getCreateTime()); List permissions = new ArrayList( Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 19, 88, 86, 89, 90, 91, 92)); user.setPermissions(permissions); userList.add(user); } Page page = new Page<>(); page.setPageNo(pageNo); page.setTotal(1000); page.setResult(userList); return page; } @Override public boolean createUser(User user) { if (user == null) { return false; } return true; } } ================================================ FILE: servicecomb-server/src/main/resources/META-INF/spring/benchmark.provider.bean.xml ================================================ ================================================ FILE: servicecomb-server/src/main/resources/config/log4j.demo.properties ================================================ # # 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. # paas.logs.dir=target/logs/ paas.logs.file=benchmark.log log4j.rootLogger=WARN,paas,stdout ================================================ FILE: servicecomb-server/src/main/resources/log4j.properties ================================================ # # 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. # paas.logs.dir=target/logs/ paas.logs.file=benchmark.log log4j.rootLogger=WARN,paas,stdout ================================================ FILE: servicecomb-server/src/main/resources/microservice.yaml ================================================ ## --------------------------------------------------------------------------- ## 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. ## --------------------------------------------------------------------------- APPLICATION_ID: rpc-benchmark service_description: name: benchmark version: 0.0.1 servicecomb: service: registry: address: http://benchmark-server:30100 highway: address: benchmark-server:8080 server: thread-count: 2 ================================================ FILE: sofa-client/pom.xml ================================================ 4.0.0 benchmark.rpc sofa-client round-5 jar sofa-client http://maven.apache.org 11 11 UTF-8 round-5 5.5.0 benchmark.rpc benchmark-base ${version.benchmark-base} com.alipay.sofa sofa-rpc-all ${version.sofa} junit junit 4.12 test org.apache.maven.plugins maven-compiler-plugin 3.8.0 lib ${maven.compiler.source} ${maven.compiler.target} UTF-8 org.apache.maven.plugins maven-resources-plugin 3.1.0 UTF-8 maven-assembly-plugin 3.1.0 jar-with-dependencies benchmark.rpc.Client make-assembly package single src/main/resources ================================================ FILE: sofa-client/src/main/java/benchmark/rpc/Client.java ================================================ package benchmark.rpc; import java.io.IOException; import java.util.concurrent.TimeUnit; import com.alipay.sofa.rpc.config.ConsumerConfig; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; import benchmark.bean.Page; import benchmark.bean.User; import benchmark.service.UserService; @State(Scope.Benchmark) public class Client extends AbstractClient { public static final int CONCURRENCY = 32; private final UserService userService; public Client() { ConsumerConfig consumerConfig = new ConsumerConfig() .setInterfaceId(UserService.class.getName()) .setProtocol("bolt") // 指定协议 .setDirectUrl("bolt://benchmark-server:12200"); userService = consumerConfig.refer(); } @Override protected UserService getUserService() { return userService; } @TearDown public void close() throws IOException { } @Benchmark @BenchmarkMode({Mode.Throughput, Mode.AverageTime, Mode.SampleTime}) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public boolean existUser() throws Exception { return super.existUser(); } @Benchmark @BenchmarkMode({Mode.Throughput, Mode.AverageTime, Mode.SampleTime}) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public boolean createUser() throws Exception { return super.createUser(); } @Benchmark @BenchmarkMode({Mode.Throughput, Mode.AverageTime, Mode.SampleTime}) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public User getUser() throws Exception { return super.getUser(); } @Benchmark @BenchmarkMode({Mode.Throughput, Mode.AverageTime, Mode.SampleTime}) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public Page listUser() throws Exception { return super.listUser(); } public static void main(String[] args) throws Exception { Options opt = new OptionsBuilder()// .include(Client.class.getSimpleName())// .warmupIterations(3)// .warmupTime(TimeValue.seconds(10))// .measurementIterations(3)// .measurementTime(TimeValue.seconds(10))// .threads(CONCURRENCY)// .forks(1)// .build(); new Runner(opt).run(); } } ================================================ FILE: sofa-client/src/main/resources/logback.xml ================================================ %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n logs/benchmark-rpc-client.log logs/benchmark-rpc-client.%d{yyyy-MM-dd}.log.gz %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n ================================================ FILE: sofa-server/.gitignore ================================================ /bin/ ================================================ FILE: sofa-server/pom.xml ================================================ 4.0.0 benchmark.rpc sofa-server round-5 jar sofa-server http://maven.apache.org 11 11 UTF-8 round-5 5.5.0 benchmark.rpc benchmark-base ${version.benchmark-base} com.alipay.sofa sofa-rpc-all ${version.sofa} junit junit 4.12 test org.apache.maven.plugins maven-compiler-plugin 3.8.0 ${maven.compiler.source} ${maven.compiler.target} UTF-8 org.apache.maven.plugins maven-resources-plugin 3.1.0 UTF-8 maven-assembly-plugin 3.1.0 jar-with-dependencies benchmark.rpc.Server make-assembly package single src/main/resources ================================================ FILE: sofa-server/src/main/java/benchmark/rpc/Server.java ================================================ package benchmark.rpc; import benchmark.service.UserService; import benchmark.service.UserServiceServerImpl; import com.alipay.sofa.rpc.config.ProviderConfig; import com.alipay.sofa.rpc.config.ServerConfig; public class Server { public static void main(String[] args) { ServerConfig serverConfig = new ServerConfig() .setProtocol("bolt") .setPort(12200) .setDaemon(false); ProviderConfig providerConfig = new ProviderConfig() .setInterfaceId(UserService.class.getName()) .setRef(new UserServiceServerImpl()) .setServer(serverConfig); providerConfig.export(); } } ================================================ FILE: sofa-server/src/main/resources/logback.xml ================================================ %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n logs/benchmark-rpc-client.log logs/benchmark-rpc-client.%d{yyyy-MM-dd}.log.gz %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n ================================================ FILE: springboot-client/pom.xml ================================================ 4.0.0 benchmark.rpc springboot-client round-5 jar springboot-client http://maven.apache.org 11 11 UTF-8 round-5 benchmark.rpc benchmark-base ${version.benchmark-base} junit junit 4.12 test org.apache.maven.plugins maven-compiler-plugin 3.8.0 ${maven.compiler.source} ${maven.compiler.target} UTF-8 org.apache.maven.plugins maven-resources-plugin 3.1.0 UTF-8 maven-assembly-plugin 3.1.0 jar-with-dependencies benchmark.rpc.Client make-assembly package single src/main/resources ================================================ FILE: springboot-client/src/main/java/benchmark/rpc/Client.java ================================================ package benchmark.rpc; import java.util.concurrent.TimeUnit; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; import benchmark.bean.Page; import benchmark.bean.User; import benchmark.service.UserService; import benchmark.service.UserServiceJsonHttpClientImpl; @State(Scope.Benchmark) public class Client extends AbstractClient { public static final int CONCURRENCY = 32; private final UserService userService = new UserServiceJsonHttpClientImpl(CONCURRENCY); @Override protected UserService getUserService() { return userService; } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public boolean existUser() throws Exception { return super.existUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public boolean createUser() throws Exception { return super.createUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public User getUser() throws Exception { return super.getUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public Page listUser() throws Exception { return super.listUser(); } public static void main(String[] args) throws RunnerException, InterruptedException { Client client = new Client(); for (int i = 0; i < 60; i++) { try { System.out.println(client.getUser()); break; } catch (Exception e) { Thread.sleep(1000); } } Options opt = new OptionsBuilder()// .include(Client.class.getSimpleName())// .warmupIterations(3)// .warmupTime(TimeValue.seconds(10))// .measurementIterations(3)// .measurementTime(TimeValue.seconds(10))// .threads(CONCURRENCY)// .forks(1)// .build(); new Runner(opt).run(); } } ================================================ FILE: springboot-server/.gitignore ================================================ /.apt_generated_tests/ ================================================ FILE: springboot-server/pom.xml ================================================ 4.0.0 benchmark.rpc springboot-server round-5 jar springboot-server http://maven.apache.org 11 11 UTF-8 round-5 2.1.2.RELEASE benchmark.rpc benchmark-base ${version.benchmark-base} org.springframework.boot spring-boot-starter-web ${version.spring-boot} junit junit 4.12 test org.apache.maven.plugins maven-compiler-plugin 3.8.0 ${maven.compiler.source} ${maven.compiler.target} UTF-8 org.apache.maven.plugins maven-resources-plugin 3.1.0 UTF-8 org.springframework.boot spring-boot-maven-plugin true benchmark.rpc.Server repackage ================================================ FILE: springboot-server/src/main/java/benchmark/rpc/Server.java ================================================ package benchmark.rpc; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication(scanBasePackages = { "benchmark.rpc.springboot" }) public class Server { public static void main(String[] args) { SpringApplication.run(Server.class, args); } } ================================================ FILE: springboot-server/src/main/java/benchmark/rpc/springboot/server/CreateUserController.java ================================================ package benchmark.rpc.springboot.server; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RestController; import benchmark.bean.User; import benchmark.service.UserService; import benchmark.service.UserServiceServerImpl; @RestController public class CreateUserController { private final UserService userService = new UserServiceServerImpl(); @PostMapping("create-user") public boolean createUser(User user) { return userService.createUser(user); } } ================================================ FILE: springboot-server/src/main/java/benchmark/rpc/springboot/server/GetUserController.java ================================================ package benchmark.rpc.springboot.server; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import benchmark.bean.User; import benchmark.service.UserService; import benchmark.service.UserServiceServerImpl; @RestController public class GetUserController { private final UserService userService = new UserServiceServerImpl(); @GetMapping("get-user") public User getUser(int id) { User user = userService.getUser(id); return user; } } ================================================ FILE: springboot-server/src/main/java/benchmark/rpc/springboot/server/ListUserController.java ================================================ package benchmark.rpc.springboot.server; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import benchmark.bean.Page; import benchmark.bean.User; import benchmark.service.UserService; import benchmark.service.UserServiceServerImpl; @RestController public class ListUserController { private final UserService userService = new UserServiceServerImpl(); @GetMapping("list-user") public Page getUser(int pageNo) { Page userList = userService.listUser(pageNo); return userList; } } ================================================ FILE: springboot-server/src/main/java/benchmark/rpc/springboot/server/UserExistController.java ================================================ package benchmark.rpc.springboot.server; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import benchmark.service.UserService; import benchmark.service.UserServiceServerImpl; @RestController public class UserExistController { private final UserService userService = new UserServiceServerImpl(); @GetMapping("user-exist") public boolean emailExist(String email) { return userService.existUser(email); } } ================================================ FILE: springboot-server/src/main/resources/application.yml ================================================ server: address: benchmark-server port: 8080 ================================================ FILE: springboot-undertow-client/.gitignore ================================================ /.apt_generated_tests/ ================================================ FILE: springboot-undertow-client/pom.xml ================================================ 4.0.0 benchmark.rpc springboot-undertow-client round-5 jar springboot-undertow-client http://maven.apache.org 11 11 UTF-8 round-5 benchmark.rpc benchmark-base ${version.benchmark-base} junit junit 4.12 test org.apache.maven.plugins maven-compiler-plugin 3.8.0 ${maven.compiler.source} ${maven.compiler.target} UTF-8 org.apache.maven.plugins maven-resources-plugin 3.1.0 UTF-8 maven-assembly-plugin 3.1.0 jar-with-dependencies benchmark.rpc.Client make-assembly package single src/main/resources ================================================ FILE: springboot-undertow-client/src/main/java/benchmark/rpc/Client.java ================================================ package benchmark.rpc; import java.util.concurrent.TimeUnit; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; import benchmark.bean.Page; import benchmark.bean.User; import benchmark.service.UserService; import benchmark.service.UserServiceJsonHttpClientImpl; @State(Scope.Benchmark) public class Client extends AbstractClient { public static final int CONCURRENCY = 32; private final UserService userService = new UserServiceJsonHttpClientImpl(CONCURRENCY); @Override protected UserService getUserService() { return userService; } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public boolean existUser() throws Exception { return super.existUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public boolean createUser() throws Exception { return super.createUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public User getUser() throws Exception { return super.getUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public Page listUser() throws Exception { return super.listUser(); } public static void main(String[] args) throws RunnerException, InterruptedException { Client client = new Client(); for (int i = 0; i < 60; i++) { try { System.out.println(client.getUser()); break; } catch (Exception e) { Thread.sleep(1000); } } Options opt = new OptionsBuilder()// .include(Client.class.getSimpleName())// .warmupIterations(3)// .warmupTime(TimeValue.seconds(10))// .measurementIterations(3)// .measurementTime(TimeValue.seconds(10))// .threads(CONCURRENCY)// .forks(1)// .build(); new Runner(opt).run(); } } ================================================ FILE: springboot-undertow-server/.gitignore ================================================ /.apt_generated_tests/ ================================================ FILE: springboot-undertow-server/pom.xml ================================================ 4.0.0 benchmark.rpc springboot-undertow-server round-5 jar springboot-undertow-server http://maven.apache.org 11 11 UTF-8 round-5 2.1.2.RELEASE benchmark.rpc benchmark-base ${version.benchmark-base} org.springframework.boot spring-boot-starter-web ${version.spring-boot} org.springframework.boot spring-boot-starter-tomcat org.springframework.boot spring-boot-starter-undertow ${version.spring-boot} junit junit 4.12 test org.apache.maven.plugins maven-compiler-plugin 3.8.0 ${maven.compiler.source} ${maven.compiler.target} UTF-8 org.apache.maven.plugins maven-resources-plugin 3.1.0 UTF-8 org.springframework.boot spring-boot-maven-plugin true benchmark.rpc.Server repackage ================================================ FILE: springboot-undertow-server/src/main/java/benchmark/rpc/Server.java ================================================ package benchmark.rpc; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication(scanBasePackages = { "benchmark.rpc.springboot" }) public class Server { public static void main(String[] args) { SpringApplication.run(Server.class, args); } } ================================================ FILE: springboot-undertow-server/src/main/java/benchmark/rpc/springboot/server/CreateUserController.java ================================================ package benchmark.rpc.springboot.server; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RestController; import benchmark.bean.User; import benchmark.service.UserService; import benchmark.service.UserServiceServerImpl; @RestController public class CreateUserController { private final UserService userService = new UserServiceServerImpl(); @PostMapping("create-user") public boolean createUser(User user) { return userService.createUser(user); } } ================================================ FILE: springboot-undertow-server/src/main/java/benchmark/rpc/springboot/server/GetUserController.java ================================================ package benchmark.rpc.springboot.server; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import benchmark.bean.User; import benchmark.service.UserService; import benchmark.service.UserServiceServerImpl; @RestController public class GetUserController { private final UserService userService = new UserServiceServerImpl(); @GetMapping("get-user") public User getUser(int id) { User user = userService.getUser(id); return user; } } ================================================ FILE: springboot-undertow-server/src/main/java/benchmark/rpc/springboot/server/ListUserController.java ================================================ package benchmark.rpc.springboot.server; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import benchmark.bean.Page; import benchmark.bean.User; import benchmark.service.UserService; import benchmark.service.UserServiceServerImpl; @RestController public class ListUserController { private final UserService userService = new UserServiceServerImpl(); @GetMapping("list-user") public Page getUser(int pageNo) { Page userList = userService.listUser(pageNo); return userList; } } ================================================ FILE: springboot-undertow-server/src/main/java/benchmark/rpc/springboot/server/UserExistController.java ================================================ package benchmark.rpc.springboot.server; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import benchmark.service.UserService; import benchmark.service.UserServiceServerImpl; @RestController public class UserExistController { private final UserService userService = new UserServiceServerImpl(); @GetMapping("user-exist") public boolean emailExist(String email) { return userService.existUser(email); } } ================================================ FILE: springboot-undertow-server/src/main/resources/application.yml ================================================ server: address: benchmark-server port: 8080 ================================================ FILE: springwebflux-client/.gitignore ================================================ /.apt_generated_tests/ ================================================ FILE: springwebflux-client/pom.xml ================================================ 4.0.0 benchmark.rpc springwebflux-client round-5 jar springwebflux-client http://maven.apache.org 11 11 UTF-8 round-5 benchmark.rpc benchmark-base ${version.benchmark-base} junit junit 4.12 test org.apache.maven.plugins maven-compiler-plugin 3.8.0 ${maven.compiler.source} ${maven.compiler.target} UTF-8 org.apache.maven.plugins maven-resources-plugin 3.1.0 UTF-8 maven-assembly-plugin 3.1.0 jar-with-dependencies benchmark.rpc.Client make-assembly package single src/main/resources ================================================ FILE: springwebflux-client/src/main/java/benchmark/rpc/Client.java ================================================ package benchmark.rpc; import java.util.concurrent.TimeUnit; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; import benchmark.bean.Page; import benchmark.bean.User; import benchmark.service.UserService; import benchmark.service.UserServiceJsonHttpClientImpl; @State(Scope.Benchmark) public class Client extends AbstractClient { public static final int CONCURRENCY = 32; private final UserService userService = new UserServiceJsonHttpClientImpl(CONCURRENCY); @Override protected UserService getUserService() { return userService; } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public boolean existUser() throws Exception { return super.existUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public boolean createUser() throws Exception { return super.createUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public User getUser() throws Exception { return super.getUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public Page listUser() throws Exception { return super.listUser(); } public static void main(String[] args) throws RunnerException, InterruptedException { Client client = new Client(); for (int i = 0; i < 60; i++) { try { System.out.println(client.getUser()); break; } catch (Exception e) { Thread.sleep(1000); } } Options opt = new OptionsBuilder()// .include(Client.class.getSimpleName())// .warmupIterations(3)// .warmupTime(TimeValue.seconds(10))// .measurementIterations(3)// .measurementTime(TimeValue.seconds(10))// .threads(CONCURRENCY)// .forks(1)// .build(); new Runner(opt).run(); } } ================================================ FILE: springwebflux-server/.gitignore ================================================ /.apt_generated_tests/ ================================================ FILE: springwebflux-server/pom.xml ================================================ 4.0.0 benchmark.rpc springwebflux-server round-5 jar springwebflux-server http://maven.apache.org 11 11 UTF-8 round-5 2.1.2.RELEASE central Central Repository http://repo1.maven.org/maven2/ false io.spring.repo.maven.release http://repo.spring.io/release/ true io.spring.repo.maven.milestone http://repo.spring.io/milestone/ true central Central Repository http://repo1.maven.org/maven2/ false io.spring.repo.maven.release http://repo.spring.io/release/ true io.spring.repo.maven.milestone http://repo.spring.io/milestone/ true benchmark.rpc benchmark-base ${version.benchmark-base} org.springframework.boot spring-boot-starter ${spring-boot.version} org.springframework.boot spring-boot-starter-webflux ${spring-boot.version} junit junit 4.12 test org.apache.maven.plugins maven-compiler-plugin 3.8.0 ${maven.compiler.source} ${maven.compiler.target} UTF-8 org.apache.maven.plugins maven-resources-plugin 3.1.0 UTF-8 org.springframework.boot spring-boot-maven-plugin ${spring-boot.version} true benchmark.rpc.Server repackage src/main/resources ================================================ FILE: springwebflux-server/src/main/java/benchmark/rpc/Server.java ================================================ package benchmark.rpc; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Primary; import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; import org.springframework.web.reactive.config.EnableWebFlux; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import com.fasterxml.jackson.module.afterburner.AfterburnerModule; @SpringBootApplication(scanBasePackages = { "benchmark.rpc.webflux" }) @EnableWebFlux public class Server { public static void main(String[] args) { SpringApplication.run(Server.class, args); } @Bean @Primary public ObjectMapper objectMapper(Jackson2ObjectMapperBuilder builder) { ObjectMapper objectMapper = builder.createXmlMapper(false).build(); objectMapper.registerModule(new Jdk8Module()); objectMapper.registerModule(new JavaTimeModule()); objectMapper.registerModule(new AfterburnerModule()); return objectMapper; } } ================================================ FILE: springwebflux-server/src/main/java/benchmark/rpc/webflux/server/CreateUserController.java ================================================ package benchmark.rpc.webflux.server; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RestController; import benchmark.bean.User; import benchmark.service.UserService; import benchmark.service.UserServiceServerImpl; import reactor.core.publisher.Mono; @RestController public class CreateUserController { private final UserService userService = new UserServiceServerImpl(); @PostMapping("create-user") public Mono createUser(User user) { return Mono.fromCallable(() -> userService.createUser(user)); } } ================================================ FILE: springwebflux-server/src/main/java/benchmark/rpc/webflux/server/GetUserController.java ================================================ package benchmark.rpc.webflux.server; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import benchmark.bean.User; import benchmark.service.UserService; import benchmark.service.UserServiceServerImpl; import reactor.core.publisher.Mono; @RestController public class GetUserController { private final UserService userService = new UserServiceServerImpl(); @GetMapping("get-user") public Mono getUser(int id) { return Mono.fromCallable(() -> userService.getUser(id)); } } ================================================ FILE: springwebflux-server/src/main/java/benchmark/rpc/webflux/server/ListUserController.java ================================================ package benchmark.rpc.webflux.server; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import benchmark.bean.Page; import benchmark.bean.User; import benchmark.service.UserService; import benchmark.service.UserServiceServerImpl; import reactor.core.publisher.Mono; @RestController public class ListUserController { private final UserService userService = new UserServiceServerImpl(); @GetMapping("list-user") public Mono> getUser(int pageNo) { return Mono.fromCallable(() -> userService.listUser(pageNo)); } } ================================================ FILE: springwebflux-server/src/main/java/benchmark/rpc/webflux/server/UserExistController.java ================================================ package benchmark.rpc.webflux.server; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import benchmark.service.UserService; import benchmark.service.UserServiceServerImpl; import reactor.core.publisher.Mono; @RestController public class UserExistController { private final UserService userService = new UserServiceServerImpl(); @GetMapping("user-exist") public Mono emailExist(String email) { return Mono.fromCallable(() -> userService.existUser(email)); } } ================================================ FILE: springwebflux-server/src/main/resources/application.yml ================================================ server: address: benchmark-server port: 8080 ================================================ FILE: thrift-client/.gitignore ================================================ /bin/ ================================================ FILE: thrift-client/pom.xml ================================================ 4.0.0 benchmark.rpc thrift-client round-5 jar thrift-client http://maven.apache.org 11 11 UTF-8 round-5 0.12.0 benchmark.rpc benchmark-base ${version.benchmark-base} org.apache.thrift libthrift ${version.thrift} junit junit 4.12 test org.apache.maven.plugins maven-compiler-plugin 3.8.0 ${maven.compiler.source} ${maven.compiler.target} UTF-8 org.apache.maven.plugins maven-resources-plugin 3.1.0 UTF-8 maven-assembly-plugin 3.1.0 jar-with-dependencies benchmark.rpc.Client make-assembly package single src/main/resources src/main/thrift ================================================ FILE: thrift-client/src/main/java/benchmark/rpc/Client.java ================================================ package benchmark.rpc; import java.io.IOException; import java.util.concurrent.TimeUnit; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; import benchmark.bean.Page; import benchmark.bean.User; import benchmark.rpc.thrift.UserServiceThriftClientImpl; import benchmark.service.UserService; @State(Scope.Benchmark) public class Client extends AbstractClient { public static final int CONCURRENCY = 32; private final UserServiceThriftClientImpl userService = new UserServiceThriftClientImpl(); @Override protected UserService getUserService() { return userService; } @TearDown public void close() throws IOException { userService.close(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public boolean existUser() throws Exception { return super.existUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public boolean createUser() throws Exception { return super.createUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public User getUser() throws Exception { return super.getUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public Page listUser() throws Exception { return super.listUser(); } public static void main(String[] args) throws Exception { Client client = new Client(); for (int i = 0; i < 60; i++) { try { System.out.println(client.getUser()); break; } catch (Exception e) { Thread.sleep(1000); } } client.close(); Options opt = new OptionsBuilder()// .include(Client.class.getSimpleName())// .warmupIterations(3)// .warmupTime(TimeValue.seconds(10))// .measurementIterations(3)// .measurementTime(TimeValue.seconds(10))// .threads(CONCURRENCY)// .forks(1)// .build(); new Runner(opt).run(); } } ================================================ FILE: thrift-client/src/main/java/benchmark/rpc/thrift/Converter.java ================================================ package benchmark.rpc.thrift; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.ZoneOffset; public class Converter { public static benchmark.rpc.thrift.User toThrift(benchmark.bean.User user) { benchmark.rpc.thrift.User thriftUser = new benchmark.rpc.thrift.User(); thriftUser.setId(user.getId()); thriftUser.setName(user.getName()); thriftUser.setSex(user.getSex()); thriftUser.setBirthday((int) (user.getBirthday().toEpochDay())); thriftUser.setEmail(user.getEmail()); thriftUser.setMobile(user.getMobile()); thriftUser.setAddress(user.getAddress()); thriftUser.setIcon(user.getIcon()); thriftUser.setPermissions(user.getPermissions()); thriftUser.setStatus(user.getStatus()); thriftUser.setCreateTime(user.getCreateTime().toEpochSecond(ZoneOffset.UTC)); thriftUser.setUpdateTime(user.getUpdateTime().toEpochSecond(ZoneOffset.UTC)); return thriftUser; } public static benchmark.bean.User toRaw(benchmark.rpc.thrift.User user) { benchmark.bean.User rawUser = new benchmark.bean.User(); rawUser.setId(user.getId()); rawUser.setName(user.getName()); rawUser.setSex(user.getSex()); rawUser.setBirthday(LocalDate.ofEpochDay(user.getBirthday())); rawUser.setEmail(user.getEmail()); rawUser.setMobile(user.getMobile()); rawUser.setAddress(user.getAddress()); rawUser.setIcon(user.getIcon()); rawUser.setPermissions(user.getPermissions()); rawUser.setStatus(user.getStatus()); rawUser.setCreateTime(LocalDateTime.ofEpochSecond(user.getCreateTime(), 0, ZoneOffset.UTC)); rawUser.setUpdateTime(LocalDateTime.ofEpochSecond(user.getUpdateTime(), 0, ZoneOffset.UTC)); return rawUser; } } ================================================ FILE: thrift-client/src/main/java/benchmark/rpc/thrift/TServiceClientNoPrint.java ================================================ /* * 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 benchmark.rpc.thrift; import org.apache.thrift.TApplicationException; import org.apache.thrift.TBase; import org.apache.thrift.TException; import org.apache.thrift.protocol.TMessage; import org.apache.thrift.protocol.TMessageType; import org.apache.thrift.protocol.TProtocol; /** * A TServiceClient is used to communicate with a TService implementation across * protocols and transports. */ public abstract class TServiceClientNoPrint extends org.apache.thrift.TServiceClient { public TServiceClientNoPrint(TProtocol prot) { super(prot); } public TServiceClientNoPrint(TProtocol iprot, TProtocol oprot) { super(iprot, oprot); } @Override protected void receiveBase(TBase result, String methodName) throws TException { TMessage msg = iprot_.readMessageBegin(); if (msg.type == TMessageType.EXCEPTION) { TApplicationException x = new TApplicationException(); x.read(iprot_); iprot_.readMessageEnd(); throw x; } // System.out.format("Received %d%n", msg.seqid); if (msg.seqid != seqid_) { throw new TApplicationException(TApplicationException.BAD_SEQUENCE_ID, String.format( "%s failed: out of sequence response: expected %d but got %d", methodName, seqid_, msg.seqid)); } result.read(iprot_); iprot_.readMessageEnd(); } } ================================================ FILE: thrift-client/src/main/java/benchmark/rpc/thrift/ThriftUserServiceClient.java ================================================ package benchmark.rpc.thrift; import java.io.Closeable; import java.io.IOException; import org.apache.thrift.protocol.TBinaryProtocol; import org.apache.thrift.protocol.TProtocol; import org.apache.thrift.transport.TFramedTransport; import org.apache.thrift.transport.TSocket; import org.apache.thrift.transport.TTransport; import org.apache.thrift.transport.TTransportException; public class ThriftUserServiceClient implements Closeable { // not thread safe public final TTransport transport; public final TProtocol protocol; public final UserService.Client client; public ThriftUserServiceClient(String host, int port) { transport = new TFramedTransport(new TSocket(host, port)); protocol = new TBinaryProtocol(transport); client = new UserService.Client(protocol); try { transport.open(); } catch (TTransportException e) { throw new Error(e); } } @Override public void close() throws IOException { transport.close(); } } ================================================ FILE: thrift-client/src/main/java/benchmark/rpc/thrift/User.java ================================================ /** * Autogenerated by Thrift Compiler (0.10.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated */ package benchmark.rpc.thrift; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) @javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.10.0)", date = "2018-01-02") public class User implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("User"); private static final org.apache.thrift.protocol.TField ID_FIELD_DESC = new org.apache.thrift.protocol.TField("id", org.apache.thrift.protocol.TType.I64, (short)1); private static final org.apache.thrift.protocol.TField NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("name", org.apache.thrift.protocol.TType.STRING, (short)2); private static final org.apache.thrift.protocol.TField SEX_FIELD_DESC = new org.apache.thrift.protocol.TField("sex", org.apache.thrift.protocol.TType.I32, (short)3); private static final org.apache.thrift.protocol.TField BIRTHDAY_FIELD_DESC = new org.apache.thrift.protocol.TField("birthday", org.apache.thrift.protocol.TType.I32, (short)4); private static final org.apache.thrift.protocol.TField EMAIL_FIELD_DESC = new org.apache.thrift.protocol.TField("email", org.apache.thrift.protocol.TType.STRING, (short)5); private static final org.apache.thrift.protocol.TField MOBILE_FIELD_DESC = new org.apache.thrift.protocol.TField("mobile", org.apache.thrift.protocol.TType.STRING, (short)6); private static final org.apache.thrift.protocol.TField ADDRESS_FIELD_DESC = new org.apache.thrift.protocol.TField("address", org.apache.thrift.protocol.TType.STRING, (short)7); private static final org.apache.thrift.protocol.TField ICON_FIELD_DESC = new org.apache.thrift.protocol.TField("icon", org.apache.thrift.protocol.TType.STRING, (short)8); private static final org.apache.thrift.protocol.TField PERMISSIONS_FIELD_DESC = new org.apache.thrift.protocol.TField("permissions", org.apache.thrift.protocol.TType.LIST, (short)9); private static final org.apache.thrift.protocol.TField STATUS_FIELD_DESC = new org.apache.thrift.protocol.TField("status", org.apache.thrift.protocol.TType.I32, (short)10); private static final org.apache.thrift.protocol.TField CREATE_TIME_FIELD_DESC = new org.apache.thrift.protocol.TField("createTime", org.apache.thrift.protocol.TType.I64, (short)11); private static final org.apache.thrift.protocol.TField UPDATE_TIME_FIELD_DESC = new org.apache.thrift.protocol.TField("updateTime", org.apache.thrift.protocol.TType.I64, (short)12); private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new UserStandardSchemeFactory(); private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new UserTupleSchemeFactory(); public long id; // required public java.lang.String name; // required public int sex; // required public int birthday; // required public java.lang.String email; // required public java.lang.String mobile; // required public java.lang.String address; // required public java.lang.String icon; // required public java.util.List permissions; // required public int status; // required public long createTime; // required public long updateTime; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { ID((short)1, "id"), NAME((short)2, "name"), SEX((short)3, "sex"), BIRTHDAY((short)4, "birthday"), EMAIL((short)5, "email"), MOBILE((short)6, "mobile"), ADDRESS((short)7, "address"), ICON((short)8, "icon"), PERMISSIONS((short)9, "permissions"), STATUS((short)10, "status"), CREATE_TIME((short)11, "createTime"), UPDATE_TIME((short)12, "updateTime"); private static final java.util.Map byName = new java.util.HashMap(); static { for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 1: // ID return ID; case 2: // NAME return NAME; case 3: // SEX return SEX; case 4: // BIRTHDAY return BIRTHDAY; case 5: // EMAIL return EMAIL; case 6: // MOBILE return MOBILE; case 7: // ADDRESS return ADDRESS; case 8: // ICON return ICON; case 9: // PERMISSIONS return PERMISSIONS; case 10: // STATUS return STATUS; case 11: // CREATE_TIME return CREATE_TIME; case 12: // UPDATE_TIME return UPDATE_TIME; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(java.lang.String name) { return byName.get(name); } private final short _thriftId; private final java.lang.String _fieldName; _Fields(short thriftId, java.lang.String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public java.lang.String getFieldName() { return _fieldName; } } // isset id assignments private static final int __ID_ISSET_ID = 0; private static final int __SEX_ISSET_ID = 1; private static final int __BIRTHDAY_ISSET_ID = 2; private static final int __STATUS_ISSET_ID = 3; private static final int __CREATETIME_ISSET_ID = 4; private static final int __UPDATETIME_ISSET_ID = 5; private byte __isset_bitfield = 0; public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.ID, new org.apache.thrift.meta_data.FieldMetaData("id", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))); tmpMap.put(_Fields.NAME, new org.apache.thrift.meta_data.FieldMetaData("name", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); tmpMap.put(_Fields.SEX, new org.apache.thrift.meta_data.FieldMetaData("sex", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); tmpMap.put(_Fields.BIRTHDAY, new org.apache.thrift.meta_data.FieldMetaData("birthday", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); tmpMap.put(_Fields.EMAIL, new org.apache.thrift.meta_data.FieldMetaData("email", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); tmpMap.put(_Fields.MOBILE, new org.apache.thrift.meta_data.FieldMetaData("mobile", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); tmpMap.put(_Fields.ADDRESS, new org.apache.thrift.meta_data.FieldMetaData("address", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); tmpMap.put(_Fields.ICON, new org.apache.thrift.meta_data.FieldMetaData("icon", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); tmpMap.put(_Fields.PERMISSIONS, new org.apache.thrift.meta_data.FieldMetaData("permissions", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)))); tmpMap.put(_Fields.STATUS, new org.apache.thrift.meta_data.FieldMetaData("status", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); tmpMap.put(_Fields.CREATE_TIME, new org.apache.thrift.meta_data.FieldMetaData("createTime", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))); tmpMap.put(_Fields.UPDATE_TIME, new org.apache.thrift.meta_data.FieldMetaData("updateTime", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(User.class, metaDataMap); } public User() { } public User( long id, java.lang.String name, int sex, int birthday, java.lang.String email, java.lang.String mobile, java.lang.String address, java.lang.String icon, java.util.List permissions, int status, long createTime, long updateTime) { this(); this.id = id; setIdIsSet(true); this.name = name; this.sex = sex; setSexIsSet(true); this.birthday = birthday; setBirthdayIsSet(true); this.email = email; this.mobile = mobile; this.address = address; this.icon = icon; this.permissions = permissions; this.status = status; setStatusIsSet(true); this.createTime = createTime; setCreateTimeIsSet(true); this.updateTime = updateTime; setUpdateTimeIsSet(true); } /** * Performs a deep copy on other. */ public User(User other) { __isset_bitfield = other.__isset_bitfield; this.id = other.id; if (other.isSetName()) { this.name = other.name; } this.sex = other.sex; this.birthday = other.birthday; if (other.isSetEmail()) { this.email = other.email; } if (other.isSetMobile()) { this.mobile = other.mobile; } if (other.isSetAddress()) { this.address = other.address; } if (other.isSetIcon()) { this.icon = other.icon; } if (other.isSetPermissions()) { java.util.List __this__permissions = new java.util.ArrayList(other.permissions); this.permissions = __this__permissions; } this.status = other.status; this.createTime = other.createTime; this.updateTime = other.updateTime; } public User deepCopy() { return new User(this); } @Override public void clear() { setIdIsSet(false); this.id = 0; this.name = null; setSexIsSet(false); this.sex = 0; setBirthdayIsSet(false); this.birthday = 0; this.email = null; this.mobile = null; this.address = null; this.icon = null; this.permissions = null; setStatusIsSet(false); this.status = 0; setCreateTimeIsSet(false); this.createTime = 0; setUpdateTimeIsSet(false); this.updateTime = 0; } public long getId() { return this.id; } public User setId(long id) { this.id = id; setIdIsSet(true); return this; } public void unsetId() { __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __ID_ISSET_ID); } /** Returns true if field id is set (has been assigned a value) and false otherwise */ public boolean isSetId() { return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __ID_ISSET_ID); } public void setIdIsSet(boolean value) { __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __ID_ISSET_ID, value); } public java.lang.String getName() { return this.name; } public User setName(java.lang.String name) { this.name = name; return this; } public void unsetName() { this.name = null; } /** Returns true if field name is set (has been assigned a value) and false otherwise */ public boolean isSetName() { return this.name != null; } public void setNameIsSet(boolean value) { if (!value) { this.name = null; } } public int getSex() { return this.sex; } public User setSex(int sex) { this.sex = sex; setSexIsSet(true); return this; } public void unsetSex() { __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __SEX_ISSET_ID); } /** Returns true if field sex is set (has been assigned a value) and false otherwise */ public boolean isSetSex() { return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __SEX_ISSET_ID); } public void setSexIsSet(boolean value) { __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __SEX_ISSET_ID, value); } public int getBirthday() { return this.birthday; } public User setBirthday(int birthday) { this.birthday = birthday; setBirthdayIsSet(true); return this; } public void unsetBirthday() { __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __BIRTHDAY_ISSET_ID); } /** Returns true if field birthday is set (has been assigned a value) and false otherwise */ public boolean isSetBirthday() { return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __BIRTHDAY_ISSET_ID); } public void setBirthdayIsSet(boolean value) { __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __BIRTHDAY_ISSET_ID, value); } public java.lang.String getEmail() { return this.email; } public User setEmail(java.lang.String email) { this.email = email; return this; } public void unsetEmail() { this.email = null; } /** Returns true if field email is set (has been assigned a value) and false otherwise */ public boolean isSetEmail() { return this.email != null; } public void setEmailIsSet(boolean value) { if (!value) { this.email = null; } } public java.lang.String getMobile() { return this.mobile; } public User setMobile(java.lang.String mobile) { this.mobile = mobile; return this; } public void unsetMobile() { this.mobile = null; } /** Returns true if field mobile is set (has been assigned a value) and false otherwise */ public boolean isSetMobile() { return this.mobile != null; } public void setMobileIsSet(boolean value) { if (!value) { this.mobile = null; } } public java.lang.String getAddress() { return this.address; } public User setAddress(java.lang.String address) { this.address = address; return this; } public void unsetAddress() { this.address = null; } /** Returns true if field address is set (has been assigned a value) and false otherwise */ public boolean isSetAddress() { return this.address != null; } public void setAddressIsSet(boolean value) { if (!value) { this.address = null; } } public java.lang.String getIcon() { return this.icon; } public User setIcon(java.lang.String icon) { this.icon = icon; return this; } public void unsetIcon() { this.icon = null; } /** Returns true if field icon is set (has been assigned a value) and false otherwise */ public boolean isSetIcon() { return this.icon != null; } public void setIconIsSet(boolean value) { if (!value) { this.icon = null; } } public int getPermissionsSize() { return (this.permissions == null) ? 0 : this.permissions.size(); } public java.util.Iterator getPermissionsIterator() { return (this.permissions == null) ? null : this.permissions.iterator(); } public void addToPermissions(int elem) { if (this.permissions == null) { this.permissions = new java.util.ArrayList(); } this.permissions.add(elem); } public java.util.List getPermissions() { return this.permissions; } public User setPermissions(java.util.List permissions) { this.permissions = permissions; return this; } public void unsetPermissions() { this.permissions = null; } /** Returns true if field permissions is set (has been assigned a value) and false otherwise */ public boolean isSetPermissions() { return this.permissions != null; } public void setPermissionsIsSet(boolean value) { if (!value) { this.permissions = null; } } public int getStatus() { return this.status; } public User setStatus(int status) { this.status = status; setStatusIsSet(true); return this; } public void unsetStatus() { __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __STATUS_ISSET_ID); } /** Returns true if field status is set (has been assigned a value) and false otherwise */ public boolean isSetStatus() { return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __STATUS_ISSET_ID); } public void setStatusIsSet(boolean value) { __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __STATUS_ISSET_ID, value); } public long getCreateTime() { return this.createTime; } public User setCreateTime(long createTime) { this.createTime = createTime; setCreateTimeIsSet(true); return this; } public void unsetCreateTime() { __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __CREATETIME_ISSET_ID); } /** Returns true if field createTime is set (has been assigned a value) and false otherwise */ public boolean isSetCreateTime() { return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __CREATETIME_ISSET_ID); } public void setCreateTimeIsSet(boolean value) { __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __CREATETIME_ISSET_ID, value); } public long getUpdateTime() { return this.updateTime; } public User setUpdateTime(long updateTime) { this.updateTime = updateTime; setUpdateTimeIsSet(true); return this; } public void unsetUpdateTime() { __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __UPDATETIME_ISSET_ID); } /** Returns true if field updateTime is set (has been assigned a value) and false otherwise */ public boolean isSetUpdateTime() { return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __UPDATETIME_ISSET_ID); } public void setUpdateTimeIsSet(boolean value) { __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __UPDATETIME_ISSET_ID, value); } public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case ID: if (value == null) { unsetId(); } else { setId((java.lang.Long)value); } break; case NAME: if (value == null) { unsetName(); } else { setName((java.lang.String)value); } break; case SEX: if (value == null) { unsetSex(); } else { setSex((java.lang.Integer)value); } break; case BIRTHDAY: if (value == null) { unsetBirthday(); } else { setBirthday((java.lang.Integer)value); } break; case EMAIL: if (value == null) { unsetEmail(); } else { setEmail((java.lang.String)value); } break; case MOBILE: if (value == null) { unsetMobile(); } else { setMobile((java.lang.String)value); } break; case ADDRESS: if (value == null) { unsetAddress(); } else { setAddress((java.lang.String)value); } break; case ICON: if (value == null) { unsetIcon(); } else { setIcon((java.lang.String)value); } break; case PERMISSIONS: if (value == null) { unsetPermissions(); } else { setPermissions((java.util.List)value); } break; case STATUS: if (value == null) { unsetStatus(); } else { setStatus((java.lang.Integer)value); } break; case CREATE_TIME: if (value == null) { unsetCreateTime(); } else { setCreateTime((java.lang.Long)value); } break; case UPDATE_TIME: if (value == null) { unsetUpdateTime(); } else { setUpdateTime((java.lang.Long)value); } break; } } public java.lang.Object getFieldValue(_Fields field) { switch (field) { case ID: return getId(); case NAME: return getName(); case SEX: return getSex(); case BIRTHDAY: return getBirthday(); case EMAIL: return getEmail(); case MOBILE: return getMobile(); case ADDRESS: return getAddress(); case ICON: return getIcon(); case PERMISSIONS: return getPermissions(); case STATUS: return getStatus(); case CREATE_TIME: return getCreateTime(); case UPDATE_TIME: return getUpdateTime(); } throw new java.lang.IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { case ID: return isSetId(); case NAME: return isSetName(); case SEX: return isSetSex(); case BIRTHDAY: return isSetBirthday(); case EMAIL: return isSetEmail(); case MOBILE: return isSetMobile(); case ADDRESS: return isSetAddress(); case ICON: return isSetIcon(); case PERMISSIONS: return isSetPermissions(); case STATUS: return isSetStatus(); case CREATE_TIME: return isSetCreateTime(); case UPDATE_TIME: return isSetUpdateTime(); } throw new java.lang.IllegalStateException(); } @Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof User) return this.equals((User)that); return false; } public boolean equals(User that) { if (that == null) return false; if (this == that) return true; boolean this_present_id = true; boolean that_present_id = true; if (this_present_id || that_present_id) { if (!(this_present_id && that_present_id)) return false; if (this.id != that.id) return false; } boolean this_present_name = true && this.isSetName(); boolean that_present_name = true && that.isSetName(); if (this_present_name || that_present_name) { if (!(this_present_name && that_present_name)) return false; if (!this.name.equals(that.name)) return false; } boolean this_present_sex = true; boolean that_present_sex = true; if (this_present_sex || that_present_sex) { if (!(this_present_sex && that_present_sex)) return false; if (this.sex != that.sex) return false; } boolean this_present_birthday = true; boolean that_present_birthday = true; if (this_present_birthday || that_present_birthday) { if (!(this_present_birthday && that_present_birthday)) return false; if (this.birthday != that.birthday) return false; } boolean this_present_email = true && this.isSetEmail(); boolean that_present_email = true && that.isSetEmail(); if (this_present_email || that_present_email) { if (!(this_present_email && that_present_email)) return false; if (!this.email.equals(that.email)) return false; } boolean this_present_mobile = true && this.isSetMobile(); boolean that_present_mobile = true && that.isSetMobile(); if (this_present_mobile || that_present_mobile) { if (!(this_present_mobile && that_present_mobile)) return false; if (!this.mobile.equals(that.mobile)) return false; } boolean this_present_address = true && this.isSetAddress(); boolean that_present_address = true && that.isSetAddress(); if (this_present_address || that_present_address) { if (!(this_present_address && that_present_address)) return false; if (!this.address.equals(that.address)) return false; } boolean this_present_icon = true && this.isSetIcon(); boolean that_present_icon = true && that.isSetIcon(); if (this_present_icon || that_present_icon) { if (!(this_present_icon && that_present_icon)) return false; if (!this.icon.equals(that.icon)) return false; } boolean this_present_permissions = true && this.isSetPermissions(); boolean that_present_permissions = true && that.isSetPermissions(); if (this_present_permissions || that_present_permissions) { if (!(this_present_permissions && that_present_permissions)) return false; if (!this.permissions.equals(that.permissions)) return false; } boolean this_present_status = true; boolean that_present_status = true; if (this_present_status || that_present_status) { if (!(this_present_status && that_present_status)) return false; if (this.status != that.status) return false; } boolean this_present_createTime = true; boolean that_present_createTime = true; if (this_present_createTime || that_present_createTime) { if (!(this_present_createTime && that_present_createTime)) return false; if (this.createTime != that.createTime) return false; } boolean this_present_updateTime = true; boolean that_present_updateTime = true; if (this_present_updateTime || that_present_updateTime) { if (!(this_present_updateTime && that_present_updateTime)) return false; if (this.updateTime != that.updateTime) return false; } return true; } @Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(id); hashCode = hashCode * 8191 + ((isSetName()) ? 131071 : 524287); if (isSetName()) hashCode = hashCode * 8191 + name.hashCode(); hashCode = hashCode * 8191 + sex; hashCode = hashCode * 8191 + birthday; hashCode = hashCode * 8191 + ((isSetEmail()) ? 131071 : 524287); if (isSetEmail()) hashCode = hashCode * 8191 + email.hashCode(); hashCode = hashCode * 8191 + ((isSetMobile()) ? 131071 : 524287); if (isSetMobile()) hashCode = hashCode * 8191 + mobile.hashCode(); hashCode = hashCode * 8191 + ((isSetAddress()) ? 131071 : 524287); if (isSetAddress()) hashCode = hashCode * 8191 + address.hashCode(); hashCode = hashCode * 8191 + ((isSetIcon()) ? 131071 : 524287); if (isSetIcon()) hashCode = hashCode * 8191 + icon.hashCode(); hashCode = hashCode * 8191 + ((isSetPermissions()) ? 131071 : 524287); if (isSetPermissions()) hashCode = hashCode * 8191 + permissions.hashCode(); hashCode = hashCode * 8191 + status; hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(createTime); hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(updateTime); return hashCode; } @Override public int compareTo(User other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = java.lang.Boolean.valueOf(isSetId()).compareTo(other.isSetId()); if (lastComparison != 0) { return lastComparison; } if (isSetId()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.id, other.id); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetName()).compareTo(other.isSetName()); if (lastComparison != 0) { return lastComparison; } if (isSetName()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.name, other.name); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetSex()).compareTo(other.isSetSex()); if (lastComparison != 0) { return lastComparison; } if (isSetSex()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.sex, other.sex); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetBirthday()).compareTo(other.isSetBirthday()); if (lastComparison != 0) { return lastComparison; } if (isSetBirthday()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.birthday, other.birthday); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetEmail()).compareTo(other.isSetEmail()); if (lastComparison != 0) { return lastComparison; } if (isSetEmail()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.email, other.email); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetMobile()).compareTo(other.isSetMobile()); if (lastComparison != 0) { return lastComparison; } if (isSetMobile()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.mobile, other.mobile); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetAddress()).compareTo(other.isSetAddress()); if (lastComparison != 0) { return lastComparison; } if (isSetAddress()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.address, other.address); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetIcon()).compareTo(other.isSetIcon()); if (lastComparison != 0) { return lastComparison; } if (isSetIcon()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.icon, other.icon); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetPermissions()).compareTo(other.isSetPermissions()); if (lastComparison != 0) { return lastComparison; } if (isSetPermissions()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.permissions, other.permissions); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetStatus()).compareTo(other.isSetStatus()); if (lastComparison != 0) { return lastComparison; } if (isSetStatus()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.status, other.status); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetCreateTime()).compareTo(other.isSetCreateTime()); if (lastComparison != 0) { return lastComparison; } if (isSetCreateTime()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.createTime, other.createTime); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetUpdateTime()).compareTo(other.isSetUpdateTime()); if (lastComparison != 0) { return lastComparison; } if (isSetUpdateTime()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.updateTime, other.updateTime); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { scheme(iprot).read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { scheme(oprot).write(oprot, this); } @Override public java.lang.String toString() { java.lang.StringBuilder sb = new java.lang.StringBuilder("User("); boolean first = true; sb.append("id:"); sb.append(this.id); first = false; if (!first) sb.append(", "); sb.append("name:"); if (this.name == null) { sb.append("null"); } else { sb.append(this.name); } first = false; if (!first) sb.append(", "); sb.append("sex:"); sb.append(this.sex); first = false; if (!first) sb.append(", "); sb.append("birthday:"); sb.append(this.birthday); first = false; if (!first) sb.append(", "); sb.append("email:"); if (this.email == null) { sb.append("null"); } else { sb.append(this.email); } first = false; if (!first) sb.append(", "); sb.append("mobile:"); if (this.mobile == null) { sb.append("null"); } else { sb.append(this.mobile); } first = false; if (!first) sb.append(", "); sb.append("address:"); if (this.address == null) { sb.append("null"); } else { sb.append(this.address); } first = false; if (!first) sb.append(", "); sb.append("icon:"); if (this.icon == null) { sb.append("null"); } else { sb.append(this.icon); } first = false; if (!first) sb.append(", "); sb.append("permissions:"); if (this.permissions == null) { sb.append("null"); } else { sb.append(this.permissions); } first = false; if (!first) sb.append(", "); sb.append("status:"); sb.append(this.status); first = false; if (!first) sb.append(", "); sb.append("createTime:"); sb.append(this.createTime); first = false; if (!first) sb.append(", "); sb.append("updateTime:"); sb.append(this.updateTime); first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields // check for sub-struct validity } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { try { // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. __isset_bitfield = 0; read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class UserStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public UserStandardScheme getScheme() { return new UserStandardScheme(); } } private static class UserStandardScheme extends org.apache.thrift.scheme.StandardScheme { public void read(org.apache.thrift.protocol.TProtocol iprot, User struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 1: // ID if (schemeField.type == org.apache.thrift.protocol.TType.I64) { struct.id = iprot.readI64(); struct.setIdIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 2: // NAME if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.name = iprot.readString(); struct.setNameIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 3: // SEX if (schemeField.type == org.apache.thrift.protocol.TType.I32) { struct.sex = iprot.readI32(); struct.setSexIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 4: // BIRTHDAY if (schemeField.type == org.apache.thrift.protocol.TType.I32) { struct.birthday = iprot.readI32(); struct.setBirthdayIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 5: // EMAIL if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.email = iprot.readString(); struct.setEmailIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 6: // MOBILE if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.mobile = iprot.readString(); struct.setMobileIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 7: // ADDRESS if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.address = iprot.readString(); struct.setAddressIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 8: // ICON if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.icon = iprot.readString(); struct.setIconIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 9: // PERMISSIONS if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { org.apache.thrift.protocol.TList _list0 = iprot.readListBegin(); struct.permissions = new java.util.ArrayList(_list0.size); int _elem1; for (int _i2 = 0; _i2 < _list0.size; ++_i2) { _elem1 = iprot.readI32(); struct.permissions.add(_elem1); } iprot.readListEnd(); } struct.setPermissionsIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 10: // STATUS if (schemeField.type == org.apache.thrift.protocol.TType.I32) { struct.status = iprot.readI32(); struct.setStatusIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 11: // CREATE_TIME if (schemeField.type == org.apache.thrift.protocol.TType.I64) { struct.createTime = iprot.readI64(); struct.setCreateTimeIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 12: // UPDATE_TIME if (schemeField.type == org.apache.thrift.protocol.TType.I64) { struct.updateTime = iprot.readI64(); struct.setUpdateTimeIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, User struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); oprot.writeFieldBegin(ID_FIELD_DESC); oprot.writeI64(struct.id); oprot.writeFieldEnd(); if (struct.name != null) { oprot.writeFieldBegin(NAME_FIELD_DESC); oprot.writeString(struct.name); oprot.writeFieldEnd(); } oprot.writeFieldBegin(SEX_FIELD_DESC); oprot.writeI32(struct.sex); oprot.writeFieldEnd(); oprot.writeFieldBegin(BIRTHDAY_FIELD_DESC); oprot.writeI32(struct.birthday); oprot.writeFieldEnd(); if (struct.email != null) { oprot.writeFieldBegin(EMAIL_FIELD_DESC); oprot.writeString(struct.email); oprot.writeFieldEnd(); } if (struct.mobile != null) { oprot.writeFieldBegin(MOBILE_FIELD_DESC); oprot.writeString(struct.mobile); oprot.writeFieldEnd(); } if (struct.address != null) { oprot.writeFieldBegin(ADDRESS_FIELD_DESC); oprot.writeString(struct.address); oprot.writeFieldEnd(); } if (struct.icon != null) { oprot.writeFieldBegin(ICON_FIELD_DESC); oprot.writeString(struct.icon); oprot.writeFieldEnd(); } if (struct.permissions != null) { oprot.writeFieldBegin(PERMISSIONS_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, struct.permissions.size())); for (int _iter3 : struct.permissions) { oprot.writeI32(_iter3); } oprot.writeListEnd(); } oprot.writeFieldEnd(); } oprot.writeFieldBegin(STATUS_FIELD_DESC); oprot.writeI32(struct.status); oprot.writeFieldEnd(); oprot.writeFieldBegin(CREATE_TIME_FIELD_DESC); oprot.writeI64(struct.createTime); oprot.writeFieldEnd(); oprot.writeFieldBegin(UPDATE_TIME_FIELD_DESC); oprot.writeI64(struct.updateTime); oprot.writeFieldEnd(); oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class UserTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public UserTupleScheme getScheme() { return new UserTupleScheme(); } } private static class UserTupleScheme extends org.apache.thrift.scheme.TupleScheme { @Override public void write(org.apache.thrift.protocol.TProtocol prot, User struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet optionals = new java.util.BitSet(); if (struct.isSetId()) { optionals.set(0); } if (struct.isSetName()) { optionals.set(1); } if (struct.isSetSex()) { optionals.set(2); } if (struct.isSetBirthday()) { optionals.set(3); } if (struct.isSetEmail()) { optionals.set(4); } if (struct.isSetMobile()) { optionals.set(5); } if (struct.isSetAddress()) { optionals.set(6); } if (struct.isSetIcon()) { optionals.set(7); } if (struct.isSetPermissions()) { optionals.set(8); } if (struct.isSetStatus()) { optionals.set(9); } if (struct.isSetCreateTime()) { optionals.set(10); } if (struct.isSetUpdateTime()) { optionals.set(11); } oprot.writeBitSet(optionals, 12); if (struct.isSetId()) { oprot.writeI64(struct.id); } if (struct.isSetName()) { oprot.writeString(struct.name); } if (struct.isSetSex()) { oprot.writeI32(struct.sex); } if (struct.isSetBirthday()) { oprot.writeI32(struct.birthday); } if (struct.isSetEmail()) { oprot.writeString(struct.email); } if (struct.isSetMobile()) { oprot.writeString(struct.mobile); } if (struct.isSetAddress()) { oprot.writeString(struct.address); } if (struct.isSetIcon()) { oprot.writeString(struct.icon); } if (struct.isSetPermissions()) { { oprot.writeI32(struct.permissions.size()); for (int _iter4 : struct.permissions) { oprot.writeI32(_iter4); } } } if (struct.isSetStatus()) { oprot.writeI32(struct.status); } if (struct.isSetCreateTime()) { oprot.writeI64(struct.createTime); } if (struct.isSetUpdateTime()) { oprot.writeI64(struct.updateTime); } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, User struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet incoming = iprot.readBitSet(12); if (incoming.get(0)) { struct.id = iprot.readI64(); struct.setIdIsSet(true); } if (incoming.get(1)) { struct.name = iprot.readString(); struct.setNameIsSet(true); } if (incoming.get(2)) { struct.sex = iprot.readI32(); struct.setSexIsSet(true); } if (incoming.get(3)) { struct.birthday = iprot.readI32(); struct.setBirthdayIsSet(true); } if (incoming.get(4)) { struct.email = iprot.readString(); struct.setEmailIsSet(true); } if (incoming.get(5)) { struct.mobile = iprot.readString(); struct.setMobileIsSet(true); } if (incoming.get(6)) { struct.address = iprot.readString(); struct.setAddressIsSet(true); } if (incoming.get(7)) { struct.icon = iprot.readString(); struct.setIconIsSet(true); } if (incoming.get(8)) { { org.apache.thrift.protocol.TList _list5 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); struct.permissions = new java.util.ArrayList(_list5.size); int _elem6; for (int _i7 = 0; _i7 < _list5.size; ++_i7) { _elem6 = iprot.readI32(); struct.permissions.add(_elem6); } } struct.setPermissionsIsSet(true); } if (incoming.get(9)) { struct.status = iprot.readI32(); struct.setStatusIsSet(true); } if (incoming.get(10)) { struct.createTime = iprot.readI64(); struct.setCreateTimeIsSet(true); } if (incoming.get(11)) { struct.updateTime = iprot.readI64(); struct.setUpdateTimeIsSet(true); } } } private static S scheme(org.apache.thrift.protocol.TProtocol proto) { return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); } } ================================================ FILE: thrift-client/src/main/java/benchmark/rpc/thrift/UserPage.java ================================================ /** * Autogenerated by Thrift Compiler (0.10.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated */ package benchmark.rpc.thrift; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) @javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.10.0)", date = "2018-01-02") public class UserPage implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("UserPage"); private static final org.apache.thrift.protocol.TField PAGE_NO_FIELD_DESC = new org.apache.thrift.protocol.TField("pageNo", org.apache.thrift.protocol.TType.I32, (short)1); private static final org.apache.thrift.protocol.TField TOTAL_FIELD_DESC = new org.apache.thrift.protocol.TField("total", org.apache.thrift.protocol.TType.I32, (short)2); private static final org.apache.thrift.protocol.TField RESULT_FIELD_DESC = new org.apache.thrift.protocol.TField("result", org.apache.thrift.protocol.TType.LIST, (short)3); private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new UserPageStandardSchemeFactory(); private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new UserPageTupleSchemeFactory(); public int pageNo; // required public int total; // required public java.util.List result; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { PAGE_NO((short)1, "pageNo"), TOTAL((short)2, "total"), RESULT((short)3, "result"); private static final java.util.Map byName = new java.util.HashMap(); static { for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 1: // PAGE_NO return PAGE_NO; case 2: // TOTAL return TOTAL; case 3: // RESULT return RESULT; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(java.lang.String name) { return byName.get(name); } private final short _thriftId; private final java.lang.String _fieldName; _Fields(short thriftId, java.lang.String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public java.lang.String getFieldName() { return _fieldName; } } // isset id assignments private static final int __PAGENO_ISSET_ID = 0; private static final int __TOTAL_ISSET_ID = 1; private byte __isset_bitfield = 0; public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.PAGE_NO, new org.apache.thrift.meta_data.FieldMetaData("pageNo", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); tmpMap.put(_Fields.TOTAL, new org.apache.thrift.meta_data.FieldMetaData("total", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); tmpMap.put(_Fields.RESULT, new org.apache.thrift.meta_data.FieldMetaData("result", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, User.class)))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(UserPage.class, metaDataMap); } public UserPage() { } public UserPage( int pageNo, int total, java.util.List result) { this(); this.pageNo = pageNo; setPageNoIsSet(true); this.total = total; setTotalIsSet(true); this.result = result; } /** * Performs a deep copy on other. */ public UserPage(UserPage other) { __isset_bitfield = other.__isset_bitfield; this.pageNo = other.pageNo; this.total = other.total; if (other.isSetResult()) { java.util.List __this__result = new java.util.ArrayList(other.result.size()); for (User other_element : other.result) { __this__result.add(new User(other_element)); } this.result = __this__result; } } public UserPage deepCopy() { return new UserPage(this); } @Override public void clear() { setPageNoIsSet(false); this.pageNo = 0; setTotalIsSet(false); this.total = 0; this.result = null; } public int getPageNo() { return this.pageNo; } public UserPage setPageNo(int pageNo) { this.pageNo = pageNo; setPageNoIsSet(true); return this; } public void unsetPageNo() { __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __PAGENO_ISSET_ID); } /** Returns true if field pageNo is set (has been assigned a value) and false otherwise */ public boolean isSetPageNo() { return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __PAGENO_ISSET_ID); } public void setPageNoIsSet(boolean value) { __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __PAGENO_ISSET_ID, value); } public int getTotal() { return this.total; } public UserPage setTotal(int total) { this.total = total; setTotalIsSet(true); return this; } public void unsetTotal() { __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __TOTAL_ISSET_ID); } /** Returns true if field total is set (has been assigned a value) and false otherwise */ public boolean isSetTotal() { return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __TOTAL_ISSET_ID); } public void setTotalIsSet(boolean value) { __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __TOTAL_ISSET_ID, value); } public int getResultSize() { return (this.result == null) ? 0 : this.result.size(); } public java.util.Iterator getResultIterator() { return (this.result == null) ? null : this.result.iterator(); } public void addToResult(User elem) { if (this.result == null) { this.result = new java.util.ArrayList(); } this.result.add(elem); } public java.util.List getResult() { return this.result; } public UserPage setResult(java.util.List result) { this.result = result; return this; } public void unsetResult() { this.result = null; } /** Returns true if field result is set (has been assigned a value) and false otherwise */ public boolean isSetResult() { return this.result != null; } public void setResultIsSet(boolean value) { if (!value) { this.result = null; } } public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case PAGE_NO: if (value == null) { unsetPageNo(); } else { setPageNo((java.lang.Integer)value); } break; case TOTAL: if (value == null) { unsetTotal(); } else { setTotal((java.lang.Integer)value); } break; case RESULT: if (value == null) { unsetResult(); } else { setResult((java.util.List)value); } break; } } public java.lang.Object getFieldValue(_Fields field) { switch (field) { case PAGE_NO: return getPageNo(); case TOTAL: return getTotal(); case RESULT: return getResult(); } throw new java.lang.IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { case PAGE_NO: return isSetPageNo(); case TOTAL: return isSetTotal(); case RESULT: return isSetResult(); } throw new java.lang.IllegalStateException(); } @Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof UserPage) return this.equals((UserPage)that); return false; } public boolean equals(UserPage that) { if (that == null) return false; if (this == that) return true; boolean this_present_pageNo = true; boolean that_present_pageNo = true; if (this_present_pageNo || that_present_pageNo) { if (!(this_present_pageNo && that_present_pageNo)) return false; if (this.pageNo != that.pageNo) return false; } boolean this_present_total = true; boolean that_present_total = true; if (this_present_total || that_present_total) { if (!(this_present_total && that_present_total)) return false; if (this.total != that.total) return false; } boolean this_present_result = true && this.isSetResult(); boolean that_present_result = true && that.isSetResult(); if (this_present_result || that_present_result) { if (!(this_present_result && that_present_result)) return false; if (!this.result.equals(that.result)) return false; } return true; } @Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + pageNo; hashCode = hashCode * 8191 + total; hashCode = hashCode * 8191 + ((isSetResult()) ? 131071 : 524287); if (isSetResult()) hashCode = hashCode * 8191 + result.hashCode(); return hashCode; } @Override public int compareTo(UserPage other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = java.lang.Boolean.valueOf(isSetPageNo()).compareTo(other.isSetPageNo()); if (lastComparison != 0) { return lastComparison; } if (isSetPageNo()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.pageNo, other.pageNo); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetTotal()).compareTo(other.isSetTotal()); if (lastComparison != 0) { return lastComparison; } if (isSetTotal()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.total, other.total); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetResult()).compareTo(other.isSetResult()); if (lastComparison != 0) { return lastComparison; } if (isSetResult()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.result, other.result); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { scheme(iprot).read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { scheme(oprot).write(oprot, this); } @Override public java.lang.String toString() { java.lang.StringBuilder sb = new java.lang.StringBuilder("UserPage("); boolean first = true; sb.append("pageNo:"); sb.append(this.pageNo); first = false; if (!first) sb.append(", "); sb.append("total:"); sb.append(this.total); first = false; if (!first) sb.append(", "); sb.append("result:"); if (this.result == null) { sb.append("null"); } else { sb.append(this.result); } first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields // check for sub-struct validity } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { try { // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. __isset_bitfield = 0; read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class UserPageStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public UserPageStandardScheme getScheme() { return new UserPageStandardScheme(); } } private static class UserPageStandardScheme extends org.apache.thrift.scheme.StandardScheme { public void read(org.apache.thrift.protocol.TProtocol iprot, UserPage struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 1: // PAGE_NO if (schemeField.type == org.apache.thrift.protocol.TType.I32) { struct.pageNo = iprot.readI32(); struct.setPageNoIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 2: // TOTAL if (schemeField.type == org.apache.thrift.protocol.TType.I32) { struct.total = iprot.readI32(); struct.setTotalIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 3: // RESULT if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { org.apache.thrift.protocol.TList _list8 = iprot.readListBegin(); struct.result = new java.util.ArrayList(_list8.size); User _elem9; for (int _i10 = 0; _i10 < _list8.size; ++_i10) { _elem9 = new User(); _elem9.read(iprot); struct.result.add(_elem9); } iprot.readListEnd(); } struct.setResultIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, UserPage struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); oprot.writeFieldBegin(PAGE_NO_FIELD_DESC); oprot.writeI32(struct.pageNo); oprot.writeFieldEnd(); oprot.writeFieldBegin(TOTAL_FIELD_DESC); oprot.writeI32(struct.total); oprot.writeFieldEnd(); if (struct.result != null) { oprot.writeFieldBegin(RESULT_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.result.size())); for (User _iter11 : struct.result) { _iter11.write(oprot); } oprot.writeListEnd(); } oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class UserPageTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public UserPageTupleScheme getScheme() { return new UserPageTupleScheme(); } } private static class UserPageTupleScheme extends org.apache.thrift.scheme.TupleScheme { @Override public void write(org.apache.thrift.protocol.TProtocol prot, UserPage struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet optionals = new java.util.BitSet(); if (struct.isSetPageNo()) { optionals.set(0); } if (struct.isSetTotal()) { optionals.set(1); } if (struct.isSetResult()) { optionals.set(2); } oprot.writeBitSet(optionals, 3); if (struct.isSetPageNo()) { oprot.writeI32(struct.pageNo); } if (struct.isSetTotal()) { oprot.writeI32(struct.total); } if (struct.isSetResult()) { { oprot.writeI32(struct.result.size()); for (User _iter12 : struct.result) { _iter12.write(oprot); } } } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, UserPage struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet incoming = iprot.readBitSet(3); if (incoming.get(0)) { struct.pageNo = iprot.readI32(); struct.setPageNoIsSet(true); } if (incoming.get(1)) { struct.total = iprot.readI32(); struct.setTotalIsSet(true); } if (incoming.get(2)) { { org.apache.thrift.protocol.TList _list13 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); struct.result = new java.util.ArrayList(_list13.size); User _elem14; for (int _i15 = 0; _i15 < _list13.size; ++_i15) { _elem14 = new User(); _elem14.read(iprot); struct.result.add(_elem14); } } struct.setResultIsSet(true); } } } private static S scheme(org.apache.thrift.protocol.TProtocol proto) { return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); } } ================================================ FILE: thrift-client/src/main/java/benchmark/rpc/thrift/UserService.java ================================================ /** * Autogenerated by Thrift Compiler (0.10.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated */ package benchmark.rpc.thrift; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) @javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.10.0)", date = "2018-01-02") public class UserService { public interface Iface { public boolean userExist(java.lang.String email) throws org.apache.thrift.TException; public boolean createUser(User user) throws org.apache.thrift.TException; public User getUser(long id) throws org.apache.thrift.TException; public UserPage listUser(int pageNo) throws org.apache.thrift.TException; } public interface AsyncIface { public void userExist(java.lang.String email, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; public void createUser(User user, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; public void getUser(long id, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; public void listUser(int pageNo, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; } public static class Client extends TServiceClientNoPrint implements Iface { public static class Factory implements org.apache.thrift.TServiceClientFactory { public Factory() {} public Client getClient(org.apache.thrift.protocol.TProtocol prot) { return new Client(prot); } public Client getClient(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) { return new Client(iprot, oprot); } } public Client(org.apache.thrift.protocol.TProtocol prot) { super(prot, prot); } public Client(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) { super(iprot, oprot); } public boolean userExist(java.lang.String email) throws org.apache.thrift.TException { send_userExist(email); return recv_userExist(); } public void send_userExist(java.lang.String email) throws org.apache.thrift.TException { userExist_args args = new userExist_args(); args.setEmail(email); sendBase("userExist", args); } public boolean recv_userExist() throws org.apache.thrift.TException { userExist_result result = new userExist_result(); receiveBase(result, "userExist"); if (result.isSetSuccess()) { return result.success; } throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "userExist failed: unknown result"); } public boolean createUser(User user) throws org.apache.thrift.TException { send_createUser(user); return recv_createUser(); } public void send_createUser(User user) throws org.apache.thrift.TException { createUser_args args = new createUser_args(); args.setUser(user); sendBase("createUser", args); } public boolean recv_createUser() throws org.apache.thrift.TException { createUser_result result = new createUser_result(); receiveBase(result, "createUser"); if (result.isSetSuccess()) { return result.success; } throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "createUser failed: unknown result"); } public User getUser(long id) throws org.apache.thrift.TException { send_getUser(id); return recv_getUser(); } public void send_getUser(long id) throws org.apache.thrift.TException { getUser_args args = new getUser_args(); args.setId(id); sendBase("getUser", args); } public User recv_getUser() throws org.apache.thrift.TException { getUser_result result = new getUser_result(); receiveBase(result, "getUser"); if (result.isSetSuccess()) { return result.success; } throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getUser failed: unknown result"); } public UserPage listUser(int pageNo) throws org.apache.thrift.TException { send_listUser(pageNo); return recv_listUser(); } public void send_listUser(int pageNo) throws org.apache.thrift.TException { listUser_args args = new listUser_args(); args.setPageNo(pageNo); sendBase("listUser", args); } public UserPage recv_listUser() throws org.apache.thrift.TException { listUser_result result = new listUser_result(); receiveBase(result, "listUser"); if (result.isSetSuccess()) { return result.success; } throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "listUser failed: unknown result"); } } public static class AsyncClient extends org.apache.thrift.async.TAsyncClient implements AsyncIface { public static class Factory implements org.apache.thrift.async.TAsyncClientFactory { private org.apache.thrift.async.TAsyncClientManager clientManager; private org.apache.thrift.protocol.TProtocolFactory protocolFactory; public Factory(org.apache.thrift.async.TAsyncClientManager clientManager, org.apache.thrift.protocol.TProtocolFactory protocolFactory) { this.clientManager = clientManager; this.protocolFactory = protocolFactory; } public AsyncClient getAsyncClient(org.apache.thrift.transport.TNonblockingTransport transport) { return new AsyncClient(protocolFactory, clientManager, transport); } } public AsyncClient(org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.async.TAsyncClientManager clientManager, org.apache.thrift.transport.TNonblockingTransport transport) { super(protocolFactory, clientManager, transport); } public void userExist(java.lang.String email, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { checkReady(); userExist_call method_call = new userExist_call(email, resultHandler, this, ___protocolFactory, ___transport); this.___currentMethod = method_call; ___manager.call(method_call); } public static class userExist_call extends org.apache.thrift.async.TAsyncMethodCall { private java.lang.String email; public userExist_call(java.lang.String email, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { super(client, protocolFactory, transport, resultHandler, false); this.email = email; } public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("userExist", org.apache.thrift.protocol.TMessageType.CALL, 0)); userExist_args args = new userExist_args(); args.setEmail(email); args.write(prot); prot.writeMessageEnd(); } public java.lang.Boolean getResult() throws org.apache.thrift.TException { if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { throw new java.lang.IllegalStateException("Method call not finished!"); } org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); return (new Client(prot)).recv_userExist(); } } public void createUser(User user, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { checkReady(); createUser_call method_call = new createUser_call(user, resultHandler, this, ___protocolFactory, ___transport); this.___currentMethod = method_call; ___manager.call(method_call); } public static class createUser_call extends org.apache.thrift.async.TAsyncMethodCall { private User user; public createUser_call(User user, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { super(client, protocolFactory, transport, resultHandler, false); this.user = user; } public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("createUser", org.apache.thrift.protocol.TMessageType.CALL, 0)); createUser_args args = new createUser_args(); args.setUser(user); args.write(prot); prot.writeMessageEnd(); } public java.lang.Boolean getResult() throws org.apache.thrift.TException { if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { throw new java.lang.IllegalStateException("Method call not finished!"); } org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); return (new Client(prot)).recv_createUser(); } } public void getUser(long id, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { checkReady(); getUser_call method_call = new getUser_call(id, resultHandler, this, ___protocolFactory, ___transport); this.___currentMethod = method_call; ___manager.call(method_call); } public static class getUser_call extends org.apache.thrift.async.TAsyncMethodCall { private long id; public getUser_call(long id, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { super(client, protocolFactory, transport, resultHandler, false); this.id = id; } public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("getUser", org.apache.thrift.protocol.TMessageType.CALL, 0)); getUser_args args = new getUser_args(); args.setId(id); args.write(prot); prot.writeMessageEnd(); } public User getResult() throws org.apache.thrift.TException { if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { throw new java.lang.IllegalStateException("Method call not finished!"); } org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); return (new Client(prot)).recv_getUser(); } } public void listUser(int pageNo, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { checkReady(); listUser_call method_call = new listUser_call(pageNo, resultHandler, this, ___protocolFactory, ___transport); this.___currentMethod = method_call; ___manager.call(method_call); } public static class listUser_call extends org.apache.thrift.async.TAsyncMethodCall { private int pageNo; public listUser_call(int pageNo, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { super(client, protocolFactory, transport, resultHandler, false); this.pageNo = pageNo; } public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("listUser", org.apache.thrift.protocol.TMessageType.CALL, 0)); listUser_args args = new listUser_args(); args.setPageNo(pageNo); args.write(prot); prot.writeMessageEnd(); } public UserPage getResult() throws org.apache.thrift.TException { if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { throw new java.lang.IllegalStateException("Method call not finished!"); } org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); return (new Client(prot)).recv_listUser(); } } } public static class Processor extends org.apache.thrift.TBaseProcessor implements org.apache.thrift.TProcessor { private static final org.slf4j.Logger _LOGGER = org.slf4j.LoggerFactory.getLogger(Processor.class.getName()); public Processor(I iface) { super(iface, getProcessMap(new java.util.HashMap>())); } protected Processor(I iface, java.util.Map> processMap) { super(iface, getProcessMap(processMap)); } private static java.util.Map> getProcessMap(java.util.Map> processMap) { processMap.put("userExist", new userExist()); processMap.put("createUser", new createUser()); processMap.put("getUser", new getUser()); processMap.put("listUser", new listUser()); return processMap; } public static class userExist extends org.apache.thrift.ProcessFunction { public userExist() { super("userExist"); } public userExist_args getEmptyArgsInstance() { return new userExist_args(); } protected boolean isOneway() { return false; } public userExist_result getResult(I iface, userExist_args args) throws org.apache.thrift.TException { userExist_result result = new userExist_result(); result.success = iface.userExist(args.email); result.setSuccessIsSet(true); return result; } } public static class createUser extends org.apache.thrift.ProcessFunction { public createUser() { super("createUser"); } public createUser_args getEmptyArgsInstance() { return new createUser_args(); } protected boolean isOneway() { return false; } public createUser_result getResult(I iface, createUser_args args) throws org.apache.thrift.TException { createUser_result result = new createUser_result(); result.success = iface.createUser(args.user); result.setSuccessIsSet(true); return result; } } public static class getUser extends org.apache.thrift.ProcessFunction { public getUser() { super("getUser"); } public getUser_args getEmptyArgsInstance() { return new getUser_args(); } protected boolean isOneway() { return false; } public getUser_result getResult(I iface, getUser_args args) throws org.apache.thrift.TException { getUser_result result = new getUser_result(); result.success = iface.getUser(args.id); return result; } } public static class listUser extends org.apache.thrift.ProcessFunction { public listUser() { super("listUser"); } public listUser_args getEmptyArgsInstance() { return new listUser_args(); } protected boolean isOneway() { return false; } public listUser_result getResult(I iface, listUser_args args) throws org.apache.thrift.TException { listUser_result result = new listUser_result(); result.success = iface.listUser(args.pageNo); return result; } } } public static class AsyncProcessor extends org.apache.thrift.TBaseAsyncProcessor { private static final org.slf4j.Logger _LOGGER = org.slf4j.LoggerFactory.getLogger(AsyncProcessor.class.getName()); public AsyncProcessor(I iface) { super(iface, getProcessMap(new java.util.HashMap>())); } protected AsyncProcessor(I iface, java.util.Map> processMap) { super(iface, getProcessMap(processMap)); } private static java.util.Map> getProcessMap(java.util.Map> processMap) { processMap.put("userExist", new userExist()); processMap.put("createUser", new createUser()); processMap.put("getUser", new getUser()); processMap.put("listUser", new listUser()); return processMap; } public static class userExist extends org.apache.thrift.AsyncProcessFunction { public userExist() { super("userExist"); } public userExist_args getEmptyArgsInstance() { return new userExist_args(); } public org.apache.thrift.async.AsyncMethodCallback getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) { final org.apache.thrift.AsyncProcessFunction fcall = this; return new org.apache.thrift.async.AsyncMethodCallback() { public void onComplete(java.lang.Boolean o) { userExist_result result = new userExist_result(); result.success = o; result.setSuccessIsSet(true); try { fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); } catch (org.apache.thrift.transport.TTransportException e) { _LOGGER.error("TTransportException writing to internal frame buffer", e); fb.close(); } catch (java.lang.Exception e) { _LOGGER.error("Exception writing to internal frame buffer", e); onError(e); } } public void onError(java.lang.Exception e) { byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; org.apache.thrift.TSerializable msg; userExist_result result = new userExist_result(); if (e instanceof org.apache.thrift.transport.TTransportException) { _LOGGER.error("TTransportException inside handler", e); fb.close(); return; } else if (e instanceof org.apache.thrift.TApplicationException) { _LOGGER.error("TApplicationException inside handler", e); msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; msg = (org.apache.thrift.TApplicationException)e; } else { _LOGGER.error("Exception inside handler", e); msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); } try { fcall.sendResponse(fb,msg,msgType,seqid); } catch (java.lang.Exception ex) { _LOGGER.error("Exception writing to internal frame buffer", ex); fb.close(); } } }; } protected boolean isOneway() { return false; } public void start(I iface, userExist_args args, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { iface.userExist(args.email,resultHandler); } } public static class createUser extends org.apache.thrift.AsyncProcessFunction { public createUser() { super("createUser"); } public createUser_args getEmptyArgsInstance() { return new createUser_args(); } public org.apache.thrift.async.AsyncMethodCallback getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) { final org.apache.thrift.AsyncProcessFunction fcall = this; return new org.apache.thrift.async.AsyncMethodCallback() { public void onComplete(java.lang.Boolean o) { createUser_result result = new createUser_result(); result.success = o; result.setSuccessIsSet(true); try { fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); } catch (org.apache.thrift.transport.TTransportException e) { _LOGGER.error("TTransportException writing to internal frame buffer", e); fb.close(); } catch (java.lang.Exception e) { _LOGGER.error("Exception writing to internal frame buffer", e); onError(e); } } public void onError(java.lang.Exception e) { byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; org.apache.thrift.TSerializable msg; createUser_result result = new createUser_result(); if (e instanceof org.apache.thrift.transport.TTransportException) { _LOGGER.error("TTransportException inside handler", e); fb.close(); return; } else if (e instanceof org.apache.thrift.TApplicationException) { _LOGGER.error("TApplicationException inside handler", e); msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; msg = (org.apache.thrift.TApplicationException)e; } else { _LOGGER.error("Exception inside handler", e); msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); } try { fcall.sendResponse(fb,msg,msgType,seqid); } catch (java.lang.Exception ex) { _LOGGER.error("Exception writing to internal frame buffer", ex); fb.close(); } } }; } protected boolean isOneway() { return false; } public void start(I iface, createUser_args args, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { iface.createUser(args.user,resultHandler); } } public static class getUser extends org.apache.thrift.AsyncProcessFunction { public getUser() { super("getUser"); } public getUser_args getEmptyArgsInstance() { return new getUser_args(); } public org.apache.thrift.async.AsyncMethodCallback getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) { final org.apache.thrift.AsyncProcessFunction fcall = this; return new org.apache.thrift.async.AsyncMethodCallback() { public void onComplete(User o) { getUser_result result = new getUser_result(); result.success = o; try { fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); } catch (org.apache.thrift.transport.TTransportException e) { _LOGGER.error("TTransportException writing to internal frame buffer", e); fb.close(); } catch (java.lang.Exception e) { _LOGGER.error("Exception writing to internal frame buffer", e); onError(e); } } public void onError(java.lang.Exception e) { byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; org.apache.thrift.TSerializable msg; getUser_result result = new getUser_result(); if (e instanceof org.apache.thrift.transport.TTransportException) { _LOGGER.error("TTransportException inside handler", e); fb.close(); return; } else if (e instanceof org.apache.thrift.TApplicationException) { _LOGGER.error("TApplicationException inside handler", e); msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; msg = (org.apache.thrift.TApplicationException)e; } else { _LOGGER.error("Exception inside handler", e); msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); } try { fcall.sendResponse(fb,msg,msgType,seqid); } catch (java.lang.Exception ex) { _LOGGER.error("Exception writing to internal frame buffer", ex); fb.close(); } } }; } protected boolean isOneway() { return false; } public void start(I iface, getUser_args args, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { iface.getUser(args.id,resultHandler); } } public static class listUser extends org.apache.thrift.AsyncProcessFunction { public listUser() { super("listUser"); } public listUser_args getEmptyArgsInstance() { return new listUser_args(); } public org.apache.thrift.async.AsyncMethodCallback getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) { final org.apache.thrift.AsyncProcessFunction fcall = this; return new org.apache.thrift.async.AsyncMethodCallback() { public void onComplete(UserPage o) { listUser_result result = new listUser_result(); result.success = o; try { fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); } catch (org.apache.thrift.transport.TTransportException e) { _LOGGER.error("TTransportException writing to internal frame buffer", e); fb.close(); } catch (java.lang.Exception e) { _LOGGER.error("Exception writing to internal frame buffer", e); onError(e); } } public void onError(java.lang.Exception e) { byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; org.apache.thrift.TSerializable msg; listUser_result result = new listUser_result(); if (e instanceof org.apache.thrift.transport.TTransportException) { _LOGGER.error("TTransportException inside handler", e); fb.close(); return; } else if (e instanceof org.apache.thrift.TApplicationException) { _LOGGER.error("TApplicationException inside handler", e); msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; msg = (org.apache.thrift.TApplicationException)e; } else { _LOGGER.error("Exception inside handler", e); msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); } try { fcall.sendResponse(fb,msg,msgType,seqid); } catch (java.lang.Exception ex) { _LOGGER.error("Exception writing to internal frame buffer", ex); fb.close(); } } }; } protected boolean isOneway() { return false; } public void start(I iface, listUser_args args, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { iface.listUser(args.pageNo,resultHandler); } } } public static class userExist_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("userExist_args"); private static final org.apache.thrift.protocol.TField EMAIL_FIELD_DESC = new org.apache.thrift.protocol.TField("email", org.apache.thrift.protocol.TType.STRING, (short)1); private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new userExist_argsStandardSchemeFactory(); private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new userExist_argsTupleSchemeFactory(); public java.lang.String email; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { EMAIL((short)1, "email"); private static final java.util.Map byName = new java.util.HashMap(); static { for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 1: // EMAIL return EMAIL; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(java.lang.String name) { return byName.get(name); } private final short _thriftId; private final java.lang.String _fieldName; _Fields(short thriftId, java.lang.String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public java.lang.String getFieldName() { return _fieldName; } } // isset id assignments public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.EMAIL, new org.apache.thrift.meta_data.FieldMetaData("email", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(userExist_args.class, metaDataMap); } public userExist_args() { } public userExist_args( java.lang.String email) { this(); this.email = email; } /** * Performs a deep copy on other. */ public userExist_args(userExist_args other) { if (other.isSetEmail()) { this.email = other.email; } } public userExist_args deepCopy() { return new userExist_args(this); } @Override public void clear() { this.email = null; } public java.lang.String getEmail() { return this.email; } public userExist_args setEmail(java.lang.String email) { this.email = email; return this; } public void unsetEmail() { this.email = null; } /** Returns true if field email is set (has been assigned a value) and false otherwise */ public boolean isSetEmail() { return this.email != null; } public void setEmailIsSet(boolean value) { if (!value) { this.email = null; } } public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case EMAIL: if (value == null) { unsetEmail(); } else { setEmail((java.lang.String)value); } break; } } public java.lang.Object getFieldValue(_Fields field) { switch (field) { case EMAIL: return getEmail(); } throw new java.lang.IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { case EMAIL: return isSetEmail(); } throw new java.lang.IllegalStateException(); } @Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof userExist_args) return this.equals((userExist_args)that); return false; } public boolean equals(userExist_args that) { if (that == null) return false; if (this == that) return true; boolean this_present_email = true && this.isSetEmail(); boolean that_present_email = true && that.isSetEmail(); if (this_present_email || that_present_email) { if (!(this_present_email && that_present_email)) return false; if (!this.email.equals(that.email)) return false; } return true; } @Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + ((isSetEmail()) ? 131071 : 524287); if (isSetEmail()) hashCode = hashCode * 8191 + email.hashCode(); return hashCode; } @Override public int compareTo(userExist_args other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = java.lang.Boolean.valueOf(isSetEmail()).compareTo(other.isSetEmail()); if (lastComparison != 0) { return lastComparison; } if (isSetEmail()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.email, other.email); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { scheme(iprot).read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { scheme(oprot).write(oprot, this); } @Override public java.lang.String toString() { java.lang.StringBuilder sb = new java.lang.StringBuilder("userExist_args("); boolean first = true; sb.append("email:"); if (this.email == null) { sb.append("null"); } else { sb.append(this.email); } first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields // check for sub-struct validity } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { try { read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class userExist_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public userExist_argsStandardScheme getScheme() { return new userExist_argsStandardScheme(); } } private static class userExist_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme { public void read(org.apache.thrift.protocol.TProtocol iprot, userExist_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 1: // EMAIL if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.email = iprot.readString(); struct.setEmailIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, userExist_args struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.email != null) { oprot.writeFieldBegin(EMAIL_FIELD_DESC); oprot.writeString(struct.email); oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class userExist_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public userExist_argsTupleScheme getScheme() { return new userExist_argsTupleScheme(); } } private static class userExist_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme { @Override public void write(org.apache.thrift.protocol.TProtocol prot, userExist_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet optionals = new java.util.BitSet(); if (struct.isSetEmail()) { optionals.set(0); } oprot.writeBitSet(optionals, 1); if (struct.isSetEmail()) { oprot.writeString(struct.email); } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, userExist_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { struct.email = iprot.readString(); struct.setEmailIsSet(true); } } } private static S scheme(org.apache.thrift.protocol.TProtocol proto) { return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); } } public static class userExist_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("userExist_result"); private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.BOOL, (short)0); private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new userExist_resultStandardSchemeFactory(); private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new userExist_resultTupleSchemeFactory(); public boolean success; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { SUCCESS((short)0, "success"); private static final java.util.Map byName = new java.util.HashMap(); static { for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 0: // SUCCESS return SUCCESS; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(java.lang.String name) { return byName.get(name); } private final short _thriftId; private final java.lang.String _fieldName; _Fields(short thriftId, java.lang.String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public java.lang.String getFieldName() { return _fieldName; } } // isset id assignments private static final int __SUCCESS_ISSET_ID = 0; private byte __isset_bitfield = 0; public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(userExist_result.class, metaDataMap); } public userExist_result() { } public userExist_result( boolean success) { this(); this.success = success; setSuccessIsSet(true); } /** * Performs a deep copy on other. */ public userExist_result(userExist_result other) { __isset_bitfield = other.__isset_bitfield; this.success = other.success; } public userExist_result deepCopy() { return new userExist_result(this); } @Override public void clear() { setSuccessIsSet(false); this.success = false; } public boolean isSuccess() { return this.success; } public userExist_result setSuccess(boolean success) { this.success = success; setSuccessIsSet(true); return this; } public void unsetSuccess() { __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __SUCCESS_ISSET_ID); } /** Returns true if field success is set (has been assigned a value) and false otherwise */ public boolean isSetSuccess() { return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __SUCCESS_ISSET_ID); } public void setSuccessIsSet(boolean value) { __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __SUCCESS_ISSET_ID, value); } public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case SUCCESS: if (value == null) { unsetSuccess(); } else { setSuccess((java.lang.Boolean)value); } break; } } public java.lang.Object getFieldValue(_Fields field) { switch (field) { case SUCCESS: return isSuccess(); } throw new java.lang.IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { case SUCCESS: return isSetSuccess(); } throw new java.lang.IllegalStateException(); } @Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof userExist_result) return this.equals((userExist_result)that); return false; } public boolean equals(userExist_result that) { if (that == null) return false; if (this == that) return true; boolean this_present_success = true; boolean that_present_success = true; if (this_present_success || that_present_success) { if (!(this_present_success && that_present_success)) return false; if (this.success != that.success) return false; } return true; } @Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + ((success) ? 131071 : 524287); return hashCode; } @Override public int compareTo(userExist_result other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = java.lang.Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess()); if (lastComparison != 0) { return lastComparison; } if (isSetSuccess()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { scheme(iprot).read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { scheme(oprot).write(oprot, this); } @Override public java.lang.String toString() { java.lang.StringBuilder sb = new java.lang.StringBuilder("userExist_result("); boolean first = true; sb.append("success:"); sb.append(this.success); first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields // check for sub-struct validity } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { try { // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. __isset_bitfield = 0; read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class userExist_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public userExist_resultStandardScheme getScheme() { return new userExist_resultStandardScheme(); } } private static class userExist_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme { public void read(org.apache.thrift.protocol.TProtocol iprot, userExist_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 0: // SUCCESS if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) { struct.success = iprot.readBool(); struct.setSuccessIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, userExist_result struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.isSetSuccess()) { oprot.writeFieldBegin(SUCCESS_FIELD_DESC); oprot.writeBool(struct.success); oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class userExist_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public userExist_resultTupleScheme getScheme() { return new userExist_resultTupleScheme(); } } private static class userExist_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme { @Override public void write(org.apache.thrift.protocol.TProtocol prot, userExist_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet optionals = new java.util.BitSet(); if (struct.isSetSuccess()) { optionals.set(0); } oprot.writeBitSet(optionals, 1); if (struct.isSetSuccess()) { oprot.writeBool(struct.success); } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, userExist_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { struct.success = iprot.readBool(); struct.setSuccessIsSet(true); } } } private static S scheme(org.apache.thrift.protocol.TProtocol proto) { return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); } } public static class createUser_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("createUser_args"); private static final org.apache.thrift.protocol.TField USER_FIELD_DESC = new org.apache.thrift.protocol.TField("user", org.apache.thrift.protocol.TType.STRUCT, (short)1); private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new createUser_argsStandardSchemeFactory(); private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new createUser_argsTupleSchemeFactory(); public User user; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { USER((short)1, "user"); private static final java.util.Map byName = new java.util.HashMap(); static { for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 1: // USER return USER; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(java.lang.String name) { return byName.get(name); } private final short _thriftId; private final java.lang.String _fieldName; _Fields(short thriftId, java.lang.String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public java.lang.String getFieldName() { return _fieldName; } } // isset id assignments public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.USER, new org.apache.thrift.meta_data.FieldMetaData("user", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, User.class))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(createUser_args.class, metaDataMap); } public createUser_args() { } public createUser_args( User user) { this(); this.user = user; } /** * Performs a deep copy on other. */ public createUser_args(createUser_args other) { if (other.isSetUser()) { this.user = new User(other.user); } } public createUser_args deepCopy() { return new createUser_args(this); } @Override public void clear() { this.user = null; } public User getUser() { return this.user; } public createUser_args setUser(User user) { this.user = user; return this; } public void unsetUser() { this.user = null; } /** Returns true if field user is set (has been assigned a value) and false otherwise */ public boolean isSetUser() { return this.user != null; } public void setUserIsSet(boolean value) { if (!value) { this.user = null; } } public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case USER: if (value == null) { unsetUser(); } else { setUser((User)value); } break; } } public java.lang.Object getFieldValue(_Fields field) { switch (field) { case USER: return getUser(); } throw new java.lang.IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { case USER: return isSetUser(); } throw new java.lang.IllegalStateException(); } @Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof createUser_args) return this.equals((createUser_args)that); return false; } public boolean equals(createUser_args that) { if (that == null) return false; if (this == that) return true; boolean this_present_user = true && this.isSetUser(); boolean that_present_user = true && that.isSetUser(); if (this_present_user || that_present_user) { if (!(this_present_user && that_present_user)) return false; if (!this.user.equals(that.user)) return false; } return true; } @Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + ((isSetUser()) ? 131071 : 524287); if (isSetUser()) hashCode = hashCode * 8191 + user.hashCode(); return hashCode; } @Override public int compareTo(createUser_args other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = java.lang.Boolean.valueOf(isSetUser()).compareTo(other.isSetUser()); if (lastComparison != 0) { return lastComparison; } if (isSetUser()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.user, other.user); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { scheme(iprot).read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { scheme(oprot).write(oprot, this); } @Override public java.lang.String toString() { java.lang.StringBuilder sb = new java.lang.StringBuilder("createUser_args("); boolean first = true; sb.append("user:"); if (this.user == null) { sb.append("null"); } else { sb.append(this.user); } first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields // check for sub-struct validity if (user != null) { user.validate(); } } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { try { read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class createUser_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public createUser_argsStandardScheme getScheme() { return new createUser_argsStandardScheme(); } } private static class createUser_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme { public void read(org.apache.thrift.protocol.TProtocol iprot, createUser_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 1: // USER if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { struct.user = new User(); struct.user.read(iprot); struct.setUserIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, createUser_args struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.user != null) { oprot.writeFieldBegin(USER_FIELD_DESC); struct.user.write(oprot); oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class createUser_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public createUser_argsTupleScheme getScheme() { return new createUser_argsTupleScheme(); } } private static class createUser_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme { @Override public void write(org.apache.thrift.protocol.TProtocol prot, createUser_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet optionals = new java.util.BitSet(); if (struct.isSetUser()) { optionals.set(0); } oprot.writeBitSet(optionals, 1); if (struct.isSetUser()) { struct.user.write(oprot); } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, createUser_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { struct.user = new User(); struct.user.read(iprot); struct.setUserIsSet(true); } } } private static S scheme(org.apache.thrift.protocol.TProtocol proto) { return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); } } public static class createUser_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("createUser_result"); private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.BOOL, (short)0); private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new createUser_resultStandardSchemeFactory(); private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new createUser_resultTupleSchemeFactory(); public boolean success; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { SUCCESS((short)0, "success"); private static final java.util.Map byName = new java.util.HashMap(); static { for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 0: // SUCCESS return SUCCESS; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(java.lang.String name) { return byName.get(name); } private final short _thriftId; private final java.lang.String _fieldName; _Fields(short thriftId, java.lang.String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public java.lang.String getFieldName() { return _fieldName; } } // isset id assignments private static final int __SUCCESS_ISSET_ID = 0; private byte __isset_bitfield = 0; public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(createUser_result.class, metaDataMap); } public createUser_result() { } public createUser_result( boolean success) { this(); this.success = success; setSuccessIsSet(true); } /** * Performs a deep copy on other. */ public createUser_result(createUser_result other) { __isset_bitfield = other.__isset_bitfield; this.success = other.success; } public createUser_result deepCopy() { return new createUser_result(this); } @Override public void clear() { setSuccessIsSet(false); this.success = false; } public boolean isSuccess() { return this.success; } public createUser_result setSuccess(boolean success) { this.success = success; setSuccessIsSet(true); return this; } public void unsetSuccess() { __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __SUCCESS_ISSET_ID); } /** Returns true if field success is set (has been assigned a value) and false otherwise */ public boolean isSetSuccess() { return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __SUCCESS_ISSET_ID); } public void setSuccessIsSet(boolean value) { __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __SUCCESS_ISSET_ID, value); } public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case SUCCESS: if (value == null) { unsetSuccess(); } else { setSuccess((java.lang.Boolean)value); } break; } } public java.lang.Object getFieldValue(_Fields field) { switch (field) { case SUCCESS: return isSuccess(); } throw new java.lang.IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { case SUCCESS: return isSetSuccess(); } throw new java.lang.IllegalStateException(); } @Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof createUser_result) return this.equals((createUser_result)that); return false; } public boolean equals(createUser_result that) { if (that == null) return false; if (this == that) return true; boolean this_present_success = true; boolean that_present_success = true; if (this_present_success || that_present_success) { if (!(this_present_success && that_present_success)) return false; if (this.success != that.success) return false; } return true; } @Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + ((success) ? 131071 : 524287); return hashCode; } @Override public int compareTo(createUser_result other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = java.lang.Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess()); if (lastComparison != 0) { return lastComparison; } if (isSetSuccess()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { scheme(iprot).read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { scheme(oprot).write(oprot, this); } @Override public java.lang.String toString() { java.lang.StringBuilder sb = new java.lang.StringBuilder("createUser_result("); boolean first = true; sb.append("success:"); sb.append(this.success); first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields // check for sub-struct validity } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { try { // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. __isset_bitfield = 0; read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class createUser_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public createUser_resultStandardScheme getScheme() { return new createUser_resultStandardScheme(); } } private static class createUser_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme { public void read(org.apache.thrift.protocol.TProtocol iprot, createUser_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 0: // SUCCESS if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) { struct.success = iprot.readBool(); struct.setSuccessIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, createUser_result struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.isSetSuccess()) { oprot.writeFieldBegin(SUCCESS_FIELD_DESC); oprot.writeBool(struct.success); oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class createUser_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public createUser_resultTupleScheme getScheme() { return new createUser_resultTupleScheme(); } } private static class createUser_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme { @Override public void write(org.apache.thrift.protocol.TProtocol prot, createUser_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet optionals = new java.util.BitSet(); if (struct.isSetSuccess()) { optionals.set(0); } oprot.writeBitSet(optionals, 1); if (struct.isSetSuccess()) { oprot.writeBool(struct.success); } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, createUser_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { struct.success = iprot.readBool(); struct.setSuccessIsSet(true); } } } private static S scheme(org.apache.thrift.protocol.TProtocol proto) { return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); } } public static class getUser_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getUser_args"); private static final org.apache.thrift.protocol.TField ID_FIELD_DESC = new org.apache.thrift.protocol.TField("id", org.apache.thrift.protocol.TType.I64, (short)1); private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new getUser_argsStandardSchemeFactory(); private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new getUser_argsTupleSchemeFactory(); public long id; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { ID((short)1, "id"); private static final java.util.Map byName = new java.util.HashMap(); static { for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 1: // ID return ID; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(java.lang.String name) { return byName.get(name); } private final short _thriftId; private final java.lang.String _fieldName; _Fields(short thriftId, java.lang.String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public java.lang.String getFieldName() { return _fieldName; } } // isset id assignments private static final int __ID_ISSET_ID = 0; private byte __isset_bitfield = 0; public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.ID, new org.apache.thrift.meta_data.FieldMetaData("id", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getUser_args.class, metaDataMap); } public getUser_args() { } public getUser_args( long id) { this(); this.id = id; setIdIsSet(true); } /** * Performs a deep copy on other. */ public getUser_args(getUser_args other) { __isset_bitfield = other.__isset_bitfield; this.id = other.id; } public getUser_args deepCopy() { return new getUser_args(this); } @Override public void clear() { setIdIsSet(false); this.id = 0; } public long getId() { return this.id; } public getUser_args setId(long id) { this.id = id; setIdIsSet(true); return this; } public void unsetId() { __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __ID_ISSET_ID); } /** Returns true if field id is set (has been assigned a value) and false otherwise */ public boolean isSetId() { return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __ID_ISSET_ID); } public void setIdIsSet(boolean value) { __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __ID_ISSET_ID, value); } public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case ID: if (value == null) { unsetId(); } else { setId((java.lang.Long)value); } break; } } public java.lang.Object getFieldValue(_Fields field) { switch (field) { case ID: return getId(); } throw new java.lang.IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { case ID: return isSetId(); } throw new java.lang.IllegalStateException(); } @Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof getUser_args) return this.equals((getUser_args)that); return false; } public boolean equals(getUser_args that) { if (that == null) return false; if (this == that) return true; boolean this_present_id = true; boolean that_present_id = true; if (this_present_id || that_present_id) { if (!(this_present_id && that_present_id)) return false; if (this.id != that.id) return false; } return true; } @Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(id); return hashCode; } @Override public int compareTo(getUser_args other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = java.lang.Boolean.valueOf(isSetId()).compareTo(other.isSetId()); if (lastComparison != 0) { return lastComparison; } if (isSetId()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.id, other.id); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { scheme(iprot).read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { scheme(oprot).write(oprot, this); } @Override public java.lang.String toString() { java.lang.StringBuilder sb = new java.lang.StringBuilder("getUser_args("); boolean first = true; sb.append("id:"); sb.append(this.id); first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields // check for sub-struct validity } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { try { // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. __isset_bitfield = 0; read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class getUser_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public getUser_argsStandardScheme getScheme() { return new getUser_argsStandardScheme(); } } private static class getUser_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme { public void read(org.apache.thrift.protocol.TProtocol iprot, getUser_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 1: // ID if (schemeField.type == org.apache.thrift.protocol.TType.I64) { struct.id = iprot.readI64(); struct.setIdIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, getUser_args struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); oprot.writeFieldBegin(ID_FIELD_DESC); oprot.writeI64(struct.id); oprot.writeFieldEnd(); oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class getUser_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public getUser_argsTupleScheme getScheme() { return new getUser_argsTupleScheme(); } } private static class getUser_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme { @Override public void write(org.apache.thrift.protocol.TProtocol prot, getUser_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet optionals = new java.util.BitSet(); if (struct.isSetId()) { optionals.set(0); } oprot.writeBitSet(optionals, 1); if (struct.isSetId()) { oprot.writeI64(struct.id); } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, getUser_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { struct.id = iprot.readI64(); struct.setIdIsSet(true); } } } private static S scheme(org.apache.thrift.protocol.TProtocol proto) { return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); } } public static class getUser_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getUser_result"); private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRUCT, (short)0); private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new getUser_resultStandardSchemeFactory(); private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new getUser_resultTupleSchemeFactory(); public User success; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { SUCCESS((short)0, "success"); private static final java.util.Map byName = new java.util.HashMap(); static { for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 0: // SUCCESS return SUCCESS; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(java.lang.String name) { return byName.get(name); } private final short _thriftId; private final java.lang.String _fieldName; _Fields(short thriftId, java.lang.String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public java.lang.String getFieldName() { return _fieldName; } } // isset id assignments public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, User.class))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getUser_result.class, metaDataMap); } public getUser_result() { } public getUser_result( User success) { this(); this.success = success; } /** * Performs a deep copy on other. */ public getUser_result(getUser_result other) { if (other.isSetSuccess()) { this.success = new User(other.success); } } public getUser_result deepCopy() { return new getUser_result(this); } @Override public void clear() { this.success = null; } public User getSuccess() { return this.success; } public getUser_result setSuccess(User success) { this.success = success; return this; } public void unsetSuccess() { this.success = null; } /** Returns true if field success is set (has been assigned a value) and false otherwise */ public boolean isSetSuccess() { return this.success != null; } public void setSuccessIsSet(boolean value) { if (!value) { this.success = null; } } public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case SUCCESS: if (value == null) { unsetSuccess(); } else { setSuccess((User)value); } break; } } public java.lang.Object getFieldValue(_Fields field) { switch (field) { case SUCCESS: return getSuccess(); } throw new java.lang.IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { case SUCCESS: return isSetSuccess(); } throw new java.lang.IllegalStateException(); } @Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof getUser_result) return this.equals((getUser_result)that); return false; } public boolean equals(getUser_result that) { if (that == null) return false; if (this == that) return true; boolean this_present_success = true && this.isSetSuccess(); boolean that_present_success = true && that.isSetSuccess(); if (this_present_success || that_present_success) { if (!(this_present_success && that_present_success)) return false; if (!this.success.equals(that.success)) return false; } return true; } @Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + ((isSetSuccess()) ? 131071 : 524287); if (isSetSuccess()) hashCode = hashCode * 8191 + success.hashCode(); return hashCode; } @Override public int compareTo(getUser_result other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = java.lang.Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess()); if (lastComparison != 0) { return lastComparison; } if (isSetSuccess()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { scheme(iprot).read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { scheme(oprot).write(oprot, this); } @Override public java.lang.String toString() { java.lang.StringBuilder sb = new java.lang.StringBuilder("getUser_result("); boolean first = true; sb.append("success:"); if (this.success == null) { sb.append("null"); } else { sb.append(this.success); } first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields // check for sub-struct validity if (success != null) { success.validate(); } } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { try { read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class getUser_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public getUser_resultStandardScheme getScheme() { return new getUser_resultStandardScheme(); } } private static class getUser_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme { public void read(org.apache.thrift.protocol.TProtocol iprot, getUser_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 0: // SUCCESS if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { struct.success = new User(); struct.success.read(iprot); struct.setSuccessIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, getUser_result struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.success != null) { oprot.writeFieldBegin(SUCCESS_FIELD_DESC); struct.success.write(oprot); oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class getUser_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public getUser_resultTupleScheme getScheme() { return new getUser_resultTupleScheme(); } } private static class getUser_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme { @Override public void write(org.apache.thrift.protocol.TProtocol prot, getUser_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet optionals = new java.util.BitSet(); if (struct.isSetSuccess()) { optionals.set(0); } oprot.writeBitSet(optionals, 1); if (struct.isSetSuccess()) { struct.success.write(oprot); } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, getUser_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { struct.success = new User(); struct.success.read(iprot); struct.setSuccessIsSet(true); } } } private static S scheme(org.apache.thrift.protocol.TProtocol proto) { return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); } } public static class listUser_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("listUser_args"); private static final org.apache.thrift.protocol.TField PAGE_NO_FIELD_DESC = new org.apache.thrift.protocol.TField("pageNo", org.apache.thrift.protocol.TType.I32, (short)1); private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new listUser_argsStandardSchemeFactory(); private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new listUser_argsTupleSchemeFactory(); public int pageNo; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { PAGE_NO((short)1, "pageNo"); private static final java.util.Map byName = new java.util.HashMap(); static { for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 1: // PAGE_NO return PAGE_NO; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(java.lang.String name) { return byName.get(name); } private final short _thriftId; private final java.lang.String _fieldName; _Fields(short thriftId, java.lang.String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public java.lang.String getFieldName() { return _fieldName; } } // isset id assignments private static final int __PAGENO_ISSET_ID = 0; private byte __isset_bitfield = 0; public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.PAGE_NO, new org.apache.thrift.meta_data.FieldMetaData("pageNo", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(listUser_args.class, metaDataMap); } public listUser_args() { } public listUser_args( int pageNo) { this(); this.pageNo = pageNo; setPageNoIsSet(true); } /** * Performs a deep copy on other. */ public listUser_args(listUser_args other) { __isset_bitfield = other.__isset_bitfield; this.pageNo = other.pageNo; } public listUser_args deepCopy() { return new listUser_args(this); } @Override public void clear() { setPageNoIsSet(false); this.pageNo = 0; } public int getPageNo() { return this.pageNo; } public listUser_args setPageNo(int pageNo) { this.pageNo = pageNo; setPageNoIsSet(true); return this; } public void unsetPageNo() { __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __PAGENO_ISSET_ID); } /** Returns true if field pageNo is set (has been assigned a value) and false otherwise */ public boolean isSetPageNo() { return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __PAGENO_ISSET_ID); } public void setPageNoIsSet(boolean value) { __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __PAGENO_ISSET_ID, value); } public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case PAGE_NO: if (value == null) { unsetPageNo(); } else { setPageNo((java.lang.Integer)value); } break; } } public java.lang.Object getFieldValue(_Fields field) { switch (field) { case PAGE_NO: return getPageNo(); } throw new java.lang.IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { case PAGE_NO: return isSetPageNo(); } throw new java.lang.IllegalStateException(); } @Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof listUser_args) return this.equals((listUser_args)that); return false; } public boolean equals(listUser_args that) { if (that == null) return false; if (this == that) return true; boolean this_present_pageNo = true; boolean that_present_pageNo = true; if (this_present_pageNo || that_present_pageNo) { if (!(this_present_pageNo && that_present_pageNo)) return false; if (this.pageNo != that.pageNo) return false; } return true; } @Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + pageNo; return hashCode; } @Override public int compareTo(listUser_args other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = java.lang.Boolean.valueOf(isSetPageNo()).compareTo(other.isSetPageNo()); if (lastComparison != 0) { return lastComparison; } if (isSetPageNo()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.pageNo, other.pageNo); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { scheme(iprot).read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { scheme(oprot).write(oprot, this); } @Override public java.lang.String toString() { java.lang.StringBuilder sb = new java.lang.StringBuilder("listUser_args("); boolean first = true; sb.append("pageNo:"); sb.append(this.pageNo); first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields // check for sub-struct validity } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { try { // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. __isset_bitfield = 0; read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class listUser_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public listUser_argsStandardScheme getScheme() { return new listUser_argsStandardScheme(); } } private static class listUser_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme { public void read(org.apache.thrift.protocol.TProtocol iprot, listUser_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 1: // PAGE_NO if (schemeField.type == org.apache.thrift.protocol.TType.I32) { struct.pageNo = iprot.readI32(); struct.setPageNoIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, listUser_args struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); oprot.writeFieldBegin(PAGE_NO_FIELD_DESC); oprot.writeI32(struct.pageNo); oprot.writeFieldEnd(); oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class listUser_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public listUser_argsTupleScheme getScheme() { return new listUser_argsTupleScheme(); } } private static class listUser_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme { @Override public void write(org.apache.thrift.protocol.TProtocol prot, listUser_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet optionals = new java.util.BitSet(); if (struct.isSetPageNo()) { optionals.set(0); } oprot.writeBitSet(optionals, 1); if (struct.isSetPageNo()) { oprot.writeI32(struct.pageNo); } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, listUser_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { struct.pageNo = iprot.readI32(); struct.setPageNoIsSet(true); } } } private static S scheme(org.apache.thrift.protocol.TProtocol proto) { return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); } } public static class listUser_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("listUser_result"); private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRUCT, (short)0); private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new listUser_resultStandardSchemeFactory(); private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new listUser_resultTupleSchemeFactory(); public UserPage success; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { SUCCESS((short)0, "success"); private static final java.util.Map byName = new java.util.HashMap(); static { for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 0: // SUCCESS return SUCCESS; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(java.lang.String name) { return byName.get(name); } private final short _thriftId; private final java.lang.String _fieldName; _Fields(short thriftId, java.lang.String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public java.lang.String getFieldName() { return _fieldName; } } // isset id assignments public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, UserPage.class))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(listUser_result.class, metaDataMap); } public listUser_result() { } public listUser_result( UserPage success) { this(); this.success = success; } /** * Performs a deep copy on other. */ public listUser_result(listUser_result other) { if (other.isSetSuccess()) { this.success = new UserPage(other.success); } } public listUser_result deepCopy() { return new listUser_result(this); } @Override public void clear() { this.success = null; } public UserPage getSuccess() { return this.success; } public listUser_result setSuccess(UserPage success) { this.success = success; return this; } public void unsetSuccess() { this.success = null; } /** Returns true if field success is set (has been assigned a value) and false otherwise */ public boolean isSetSuccess() { return this.success != null; } public void setSuccessIsSet(boolean value) { if (!value) { this.success = null; } } public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case SUCCESS: if (value == null) { unsetSuccess(); } else { setSuccess((UserPage)value); } break; } } public java.lang.Object getFieldValue(_Fields field) { switch (field) { case SUCCESS: return getSuccess(); } throw new java.lang.IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { case SUCCESS: return isSetSuccess(); } throw new java.lang.IllegalStateException(); } @Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof listUser_result) return this.equals((listUser_result)that); return false; } public boolean equals(listUser_result that) { if (that == null) return false; if (this == that) return true; boolean this_present_success = true && this.isSetSuccess(); boolean that_present_success = true && that.isSetSuccess(); if (this_present_success || that_present_success) { if (!(this_present_success && that_present_success)) return false; if (!this.success.equals(that.success)) return false; } return true; } @Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + ((isSetSuccess()) ? 131071 : 524287); if (isSetSuccess()) hashCode = hashCode * 8191 + success.hashCode(); return hashCode; } @Override public int compareTo(listUser_result other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = java.lang.Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess()); if (lastComparison != 0) { return lastComparison; } if (isSetSuccess()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { scheme(iprot).read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { scheme(oprot).write(oprot, this); } @Override public java.lang.String toString() { java.lang.StringBuilder sb = new java.lang.StringBuilder("listUser_result("); boolean first = true; sb.append("success:"); if (this.success == null) { sb.append("null"); } else { sb.append(this.success); } first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields // check for sub-struct validity if (success != null) { success.validate(); } } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { try { read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class listUser_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public listUser_resultStandardScheme getScheme() { return new listUser_resultStandardScheme(); } } private static class listUser_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme { public void read(org.apache.thrift.protocol.TProtocol iprot, listUser_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 0: // SUCCESS if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { struct.success = new UserPage(); struct.success.read(iprot); struct.setSuccessIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, listUser_result struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.success != null) { oprot.writeFieldBegin(SUCCESS_FIELD_DESC); struct.success.write(oprot); oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class listUser_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public listUser_resultTupleScheme getScheme() { return new listUser_resultTupleScheme(); } } private static class listUser_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme { @Override public void write(org.apache.thrift.protocol.TProtocol prot, listUser_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet optionals = new java.util.BitSet(); if (struct.isSetSuccess()) { optionals.set(0); } oprot.writeBitSet(optionals, 1); if (struct.isSetSuccess()) { struct.success.write(oprot); } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, listUser_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { struct.success = new UserPage(); struct.success.read(iprot); struct.setSuccessIsSet(true); } } } private static S scheme(org.apache.thrift.protocol.TProtocol proto) { return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); } } } ================================================ FILE: thrift-client/src/main/java/benchmark/rpc/thrift/UserServiceThriftClientImpl.java ================================================ package benchmark.rpc.thrift; import java.io.Closeable; import java.io.IOException; import java.util.ArrayList; import java.util.List; import benchmark.bean.Page; import benchmark.bean.User; import benchmark.pool.LockObjectPool; import benchmark.service.UserServiceServerImpl; public class UserServiceThriftClientImpl implements benchmark.service.UserService, Closeable { private final String host = "benchmark-server"; private final int port = 8080; private final LockObjectPool clientPool = // new LockObjectPool<>(32, () -> new ThriftUserServiceClient(host, port)); @Override public void close() throws IOException { clientPool.close(); } @Override public boolean existUser(String email) { ThriftUserServiceClient thriftUserServiceClient = clientPool.borrow(); try { return thriftUserServiceClient.client.userExist(email); } catch (Throwable e) { throw new RuntimeException(e); } finally { clientPool.release(thriftUserServiceClient); } } @Override public boolean createUser(User user) { benchmark.rpc.thrift.User thriftUser = Converter.toThrift(user); ThriftUserServiceClient thriftUserServiceClient = clientPool.borrow(); try { return thriftUserServiceClient.client.createUser(thriftUser); } catch (Throwable e) { throw new RuntimeException(e); } finally { clientPool.release(thriftUserServiceClient); } } @Override public User getUser(long id) { ThriftUserServiceClient thriftUserServiceClient = clientPool.borrow(); try { benchmark.rpc.thrift.User thriftUser = thriftUserServiceClient.client.getUser(id); User user = Converter.toRaw(thriftUser); return user; } catch (Throwable e) { throw new RuntimeException(e); } finally { clientPool.release(thriftUserServiceClient); } } @Override public Page listUser(int pageNo) { ThriftUserServiceClient thriftUserServiceClient = clientPool.borrow(); try { UserPage userPage = thriftUserServiceClient.client.listUser(pageNo); Page page = new Page<>(); page.setPageNo(userPage.getPageNo()); page.setTotal(userPage.getTotal()); List userList = new ArrayList<>(userPage.getResult().size()); for (benchmark.rpc.thrift.User thriftUser : userPage.getResult()) { User user = Converter.toRaw(thriftUser); userList.add(user); } page.setResult(userList); return page; } catch (Throwable e) { throw new RuntimeException(e); } finally { clientPool.release(thriftUserServiceClient); } } public static void main(String[] args) throws IOException { try (UserServiceThriftClientImpl userService = new UserServiceThriftClientImpl()) { System.out.println(userService.existUser("12345")); System.out.println(userService.createUser(new UserServiceServerImpl().getUser(1))); System.out.println(userService.getUser(5)); System.out.println(userService.listUser(100)); } } } ================================================ FILE: thrift-client/src/main/resources/logback.xml ================================================ %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n logs/benchmark-rpc-client.log logs/benchmark-rpc-client.%d{yyyy-MM-dd}.log.gz %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n ================================================ FILE: thrift-client/src/main/thrift/UserService.thrift ================================================ namespace java benchmark.rpc.thrift struct User { 1: i64 id, 2: string name, 3: i32 sex, 4: i32 birthday, 5: string email, 6: string mobile, 7: string address, 8: string icon, 9: list permissions, 10: i32 status, 11: i64 createTime, 12: i64 updateTime, } struct UserPage { 1: i32 pageNo, 2: i32 total, 3: list result, } service UserService { bool userExist(1: string email), bool createUser(1: User user), User getUser(1: i64 id), UserPage listUser(1: i32 pageNo) } ================================================ FILE: thrift-server/.gitignore ================================================ /.apt_generated_tests/ ================================================ FILE: thrift-server/pom.xml ================================================ 4.0.0 benchmark.rpc thrift-server round-5 jar thrift-server http://maven.apache.org 11 11 UTF-8 round-5 0.12.0 benchmark.rpc benchmark-base ${version.benchmark-base} org.apache.thrift libthrift ${version.thrift} junit junit 4.12 test org.apache.maven.plugins maven-compiler-plugin 3.8.0 ${maven.compiler.source} ${maven.compiler.target} UTF-8 org.apache.maven.plugins maven-resources-plugin 3.1.0 UTF-8 maven-assembly-plugin 3.1.0 jar-with-dependencies benchmark.rpc.Server make-assembly package single src/main/resources src/main/thrift ================================================ FILE: thrift-server/src/main/java/benchmark/rpc/Server.java ================================================ package benchmark.rpc; import java.net.InetSocketAddress; import org.apache.thrift.protocol.TBinaryProtocol; import org.apache.thrift.server.TServer; import org.apache.thrift.server.TThreadedSelectorServer; import org.apache.thrift.transport.TNonblockingServerSocket; import org.apache.thrift.transport.TNonblockingServerTransport; import org.apache.thrift.transport.TTransportException; import benchmark.rpc.thrift.UserService; import benchmark.rpc.thrift.UserService.Iface; import benchmark.rpc.thrift.UserServiceThriftServerImpl; public class Server { public static void main(String[] args) throws TTransportException { InetSocketAddress serverAddress = new InetSocketAddress("benchmark-server", 8080); TNonblockingServerTransport serverSocket = new TNonblockingServerSocket(serverAddress); TThreadedSelectorServer.Args serverParams = new TThreadedSelectorServer.Args(serverSocket); serverParams.protocolFactory(new TBinaryProtocol.Factory()); serverParams.processor(new UserService.Processor(new UserServiceThriftServerImpl())); TServer server = new TThreadedSelectorServer(serverParams); server.serve(); } } ================================================ FILE: thrift-server/src/main/java/benchmark/rpc/thrift/Converter.java ================================================ package benchmark.rpc.thrift; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.ZoneOffset; public class Converter { public static benchmark.rpc.thrift.User toThrift(benchmark.bean.User user) { benchmark.rpc.thrift.User thriftUser = new benchmark.rpc.thrift.User(); thriftUser.setId(user.getId()); thriftUser.setName(user.getName()); thriftUser.setSex(user.getSex()); thriftUser.setBirthday((int) (user.getBirthday().toEpochDay())); thriftUser.setEmail(user.getEmail()); thriftUser.setMobile(user.getMobile()); thriftUser.setAddress(user.getAddress()); thriftUser.setIcon(user.getIcon()); thriftUser.setPermissions(user.getPermissions()); thriftUser.setStatus(user.getStatus()); thriftUser.setCreateTime(user.getCreateTime().toEpochSecond(ZoneOffset.UTC)); thriftUser.setUpdateTime(user.getUpdateTime().toEpochSecond(ZoneOffset.UTC)); return thriftUser; } public static benchmark.bean.User toRaw(benchmark.rpc.thrift.User user) { benchmark.bean.User rawUser = new benchmark.bean.User(); rawUser.setId(user.getId()); rawUser.setName(user.getName()); rawUser.setSex(user.getSex()); rawUser.setBirthday(LocalDate.ofEpochDay(user.getBirthday())); rawUser.setEmail(user.getEmail()); rawUser.setMobile(user.getMobile()); rawUser.setAddress(user.getAddress()); rawUser.setIcon(user.getIcon()); rawUser.setPermissions(user.getPermissions()); rawUser.setStatus(user.getStatus()); rawUser.setCreateTime(LocalDateTime.ofEpochSecond(user.getCreateTime(), 0, ZoneOffset.UTC)); rawUser.setUpdateTime(LocalDateTime.ofEpochSecond(user.getUpdateTime(), 0, ZoneOffset.UTC)); return rawUser; } } ================================================ FILE: thrift-server/src/main/java/benchmark/rpc/thrift/User.java ================================================ /** * Autogenerated by Thrift Compiler (0.10.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated */ package benchmark.rpc.thrift; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) @javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.10.0)", date = "2018-01-02") public class User implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("User"); private static final org.apache.thrift.protocol.TField ID_FIELD_DESC = new org.apache.thrift.protocol.TField("id", org.apache.thrift.protocol.TType.I64, (short)1); private static final org.apache.thrift.protocol.TField NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("name", org.apache.thrift.protocol.TType.STRING, (short)2); private static final org.apache.thrift.protocol.TField SEX_FIELD_DESC = new org.apache.thrift.protocol.TField("sex", org.apache.thrift.protocol.TType.I32, (short)3); private static final org.apache.thrift.protocol.TField BIRTHDAY_FIELD_DESC = new org.apache.thrift.protocol.TField("birthday", org.apache.thrift.protocol.TType.I32, (short)4); private static final org.apache.thrift.protocol.TField EMAIL_FIELD_DESC = new org.apache.thrift.protocol.TField("email", org.apache.thrift.protocol.TType.STRING, (short)5); private static final org.apache.thrift.protocol.TField MOBILE_FIELD_DESC = new org.apache.thrift.protocol.TField("mobile", org.apache.thrift.protocol.TType.STRING, (short)6); private static final org.apache.thrift.protocol.TField ADDRESS_FIELD_DESC = new org.apache.thrift.protocol.TField("address", org.apache.thrift.protocol.TType.STRING, (short)7); private static final org.apache.thrift.protocol.TField ICON_FIELD_DESC = new org.apache.thrift.protocol.TField("icon", org.apache.thrift.protocol.TType.STRING, (short)8); private static final org.apache.thrift.protocol.TField PERMISSIONS_FIELD_DESC = new org.apache.thrift.protocol.TField("permissions", org.apache.thrift.protocol.TType.LIST, (short)9); private static final org.apache.thrift.protocol.TField STATUS_FIELD_DESC = new org.apache.thrift.protocol.TField("status", org.apache.thrift.protocol.TType.I32, (short)10); private static final org.apache.thrift.protocol.TField CREATE_TIME_FIELD_DESC = new org.apache.thrift.protocol.TField("createTime", org.apache.thrift.protocol.TType.I64, (short)11); private static final org.apache.thrift.protocol.TField UPDATE_TIME_FIELD_DESC = new org.apache.thrift.protocol.TField("updateTime", org.apache.thrift.protocol.TType.I64, (short)12); private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new UserStandardSchemeFactory(); private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new UserTupleSchemeFactory(); public long id; // required public java.lang.String name; // required public int sex; // required public int birthday; // required public java.lang.String email; // required public java.lang.String mobile; // required public java.lang.String address; // required public java.lang.String icon; // required public java.util.List permissions; // required public int status; // required public long createTime; // required public long updateTime; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { ID((short)1, "id"), NAME((short)2, "name"), SEX((short)3, "sex"), BIRTHDAY((short)4, "birthday"), EMAIL((short)5, "email"), MOBILE((short)6, "mobile"), ADDRESS((short)7, "address"), ICON((short)8, "icon"), PERMISSIONS((short)9, "permissions"), STATUS((short)10, "status"), CREATE_TIME((short)11, "createTime"), UPDATE_TIME((short)12, "updateTime"); private static final java.util.Map byName = new java.util.HashMap(); static { for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 1: // ID return ID; case 2: // NAME return NAME; case 3: // SEX return SEX; case 4: // BIRTHDAY return BIRTHDAY; case 5: // EMAIL return EMAIL; case 6: // MOBILE return MOBILE; case 7: // ADDRESS return ADDRESS; case 8: // ICON return ICON; case 9: // PERMISSIONS return PERMISSIONS; case 10: // STATUS return STATUS; case 11: // CREATE_TIME return CREATE_TIME; case 12: // UPDATE_TIME return UPDATE_TIME; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(java.lang.String name) { return byName.get(name); } private final short _thriftId; private final java.lang.String _fieldName; _Fields(short thriftId, java.lang.String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public java.lang.String getFieldName() { return _fieldName; } } // isset id assignments private static final int __ID_ISSET_ID = 0; private static final int __SEX_ISSET_ID = 1; private static final int __BIRTHDAY_ISSET_ID = 2; private static final int __STATUS_ISSET_ID = 3; private static final int __CREATETIME_ISSET_ID = 4; private static final int __UPDATETIME_ISSET_ID = 5; private byte __isset_bitfield = 0; public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.ID, new org.apache.thrift.meta_data.FieldMetaData("id", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))); tmpMap.put(_Fields.NAME, new org.apache.thrift.meta_data.FieldMetaData("name", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); tmpMap.put(_Fields.SEX, new org.apache.thrift.meta_data.FieldMetaData("sex", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); tmpMap.put(_Fields.BIRTHDAY, new org.apache.thrift.meta_data.FieldMetaData("birthday", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); tmpMap.put(_Fields.EMAIL, new org.apache.thrift.meta_data.FieldMetaData("email", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); tmpMap.put(_Fields.MOBILE, new org.apache.thrift.meta_data.FieldMetaData("mobile", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); tmpMap.put(_Fields.ADDRESS, new org.apache.thrift.meta_data.FieldMetaData("address", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); tmpMap.put(_Fields.ICON, new org.apache.thrift.meta_data.FieldMetaData("icon", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); tmpMap.put(_Fields.PERMISSIONS, new org.apache.thrift.meta_data.FieldMetaData("permissions", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)))); tmpMap.put(_Fields.STATUS, new org.apache.thrift.meta_data.FieldMetaData("status", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); tmpMap.put(_Fields.CREATE_TIME, new org.apache.thrift.meta_data.FieldMetaData("createTime", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))); tmpMap.put(_Fields.UPDATE_TIME, new org.apache.thrift.meta_data.FieldMetaData("updateTime", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(User.class, metaDataMap); } public User() { } public User( long id, java.lang.String name, int sex, int birthday, java.lang.String email, java.lang.String mobile, java.lang.String address, java.lang.String icon, java.util.List permissions, int status, long createTime, long updateTime) { this(); this.id = id; setIdIsSet(true); this.name = name; this.sex = sex; setSexIsSet(true); this.birthday = birthday; setBirthdayIsSet(true); this.email = email; this.mobile = mobile; this.address = address; this.icon = icon; this.permissions = permissions; this.status = status; setStatusIsSet(true); this.createTime = createTime; setCreateTimeIsSet(true); this.updateTime = updateTime; setUpdateTimeIsSet(true); } /** * Performs a deep copy on other. */ public User(User other) { __isset_bitfield = other.__isset_bitfield; this.id = other.id; if (other.isSetName()) { this.name = other.name; } this.sex = other.sex; this.birthday = other.birthday; if (other.isSetEmail()) { this.email = other.email; } if (other.isSetMobile()) { this.mobile = other.mobile; } if (other.isSetAddress()) { this.address = other.address; } if (other.isSetIcon()) { this.icon = other.icon; } if (other.isSetPermissions()) { java.util.List __this__permissions = new java.util.ArrayList(other.permissions); this.permissions = __this__permissions; } this.status = other.status; this.createTime = other.createTime; this.updateTime = other.updateTime; } public User deepCopy() { return new User(this); } @Override public void clear() { setIdIsSet(false); this.id = 0; this.name = null; setSexIsSet(false); this.sex = 0; setBirthdayIsSet(false); this.birthday = 0; this.email = null; this.mobile = null; this.address = null; this.icon = null; this.permissions = null; setStatusIsSet(false); this.status = 0; setCreateTimeIsSet(false); this.createTime = 0; setUpdateTimeIsSet(false); this.updateTime = 0; } public long getId() { return this.id; } public User setId(long id) { this.id = id; setIdIsSet(true); return this; } public void unsetId() { __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __ID_ISSET_ID); } /** Returns true if field id is set (has been assigned a value) and false otherwise */ public boolean isSetId() { return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __ID_ISSET_ID); } public void setIdIsSet(boolean value) { __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __ID_ISSET_ID, value); } public java.lang.String getName() { return this.name; } public User setName(java.lang.String name) { this.name = name; return this; } public void unsetName() { this.name = null; } /** Returns true if field name is set (has been assigned a value) and false otherwise */ public boolean isSetName() { return this.name != null; } public void setNameIsSet(boolean value) { if (!value) { this.name = null; } } public int getSex() { return this.sex; } public User setSex(int sex) { this.sex = sex; setSexIsSet(true); return this; } public void unsetSex() { __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __SEX_ISSET_ID); } /** Returns true if field sex is set (has been assigned a value) and false otherwise */ public boolean isSetSex() { return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __SEX_ISSET_ID); } public void setSexIsSet(boolean value) { __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __SEX_ISSET_ID, value); } public int getBirthday() { return this.birthday; } public User setBirthday(int birthday) { this.birthday = birthday; setBirthdayIsSet(true); return this; } public void unsetBirthday() { __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __BIRTHDAY_ISSET_ID); } /** Returns true if field birthday is set (has been assigned a value) and false otherwise */ public boolean isSetBirthday() { return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __BIRTHDAY_ISSET_ID); } public void setBirthdayIsSet(boolean value) { __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __BIRTHDAY_ISSET_ID, value); } public java.lang.String getEmail() { return this.email; } public User setEmail(java.lang.String email) { this.email = email; return this; } public void unsetEmail() { this.email = null; } /** Returns true if field email is set (has been assigned a value) and false otherwise */ public boolean isSetEmail() { return this.email != null; } public void setEmailIsSet(boolean value) { if (!value) { this.email = null; } } public java.lang.String getMobile() { return this.mobile; } public User setMobile(java.lang.String mobile) { this.mobile = mobile; return this; } public void unsetMobile() { this.mobile = null; } /** Returns true if field mobile is set (has been assigned a value) and false otherwise */ public boolean isSetMobile() { return this.mobile != null; } public void setMobileIsSet(boolean value) { if (!value) { this.mobile = null; } } public java.lang.String getAddress() { return this.address; } public User setAddress(java.lang.String address) { this.address = address; return this; } public void unsetAddress() { this.address = null; } /** Returns true if field address is set (has been assigned a value) and false otherwise */ public boolean isSetAddress() { return this.address != null; } public void setAddressIsSet(boolean value) { if (!value) { this.address = null; } } public java.lang.String getIcon() { return this.icon; } public User setIcon(java.lang.String icon) { this.icon = icon; return this; } public void unsetIcon() { this.icon = null; } /** Returns true if field icon is set (has been assigned a value) and false otherwise */ public boolean isSetIcon() { return this.icon != null; } public void setIconIsSet(boolean value) { if (!value) { this.icon = null; } } public int getPermissionsSize() { return (this.permissions == null) ? 0 : this.permissions.size(); } public java.util.Iterator getPermissionsIterator() { return (this.permissions == null) ? null : this.permissions.iterator(); } public void addToPermissions(int elem) { if (this.permissions == null) { this.permissions = new java.util.ArrayList(); } this.permissions.add(elem); } public java.util.List getPermissions() { return this.permissions; } public User setPermissions(java.util.List permissions) { this.permissions = permissions; return this; } public void unsetPermissions() { this.permissions = null; } /** Returns true if field permissions is set (has been assigned a value) and false otherwise */ public boolean isSetPermissions() { return this.permissions != null; } public void setPermissionsIsSet(boolean value) { if (!value) { this.permissions = null; } } public int getStatus() { return this.status; } public User setStatus(int status) { this.status = status; setStatusIsSet(true); return this; } public void unsetStatus() { __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __STATUS_ISSET_ID); } /** Returns true if field status is set (has been assigned a value) and false otherwise */ public boolean isSetStatus() { return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __STATUS_ISSET_ID); } public void setStatusIsSet(boolean value) { __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __STATUS_ISSET_ID, value); } public long getCreateTime() { return this.createTime; } public User setCreateTime(long createTime) { this.createTime = createTime; setCreateTimeIsSet(true); return this; } public void unsetCreateTime() { __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __CREATETIME_ISSET_ID); } /** Returns true if field createTime is set (has been assigned a value) and false otherwise */ public boolean isSetCreateTime() { return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __CREATETIME_ISSET_ID); } public void setCreateTimeIsSet(boolean value) { __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __CREATETIME_ISSET_ID, value); } public long getUpdateTime() { return this.updateTime; } public User setUpdateTime(long updateTime) { this.updateTime = updateTime; setUpdateTimeIsSet(true); return this; } public void unsetUpdateTime() { __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __UPDATETIME_ISSET_ID); } /** Returns true if field updateTime is set (has been assigned a value) and false otherwise */ public boolean isSetUpdateTime() { return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __UPDATETIME_ISSET_ID); } public void setUpdateTimeIsSet(boolean value) { __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __UPDATETIME_ISSET_ID, value); } public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case ID: if (value == null) { unsetId(); } else { setId((java.lang.Long)value); } break; case NAME: if (value == null) { unsetName(); } else { setName((java.lang.String)value); } break; case SEX: if (value == null) { unsetSex(); } else { setSex((java.lang.Integer)value); } break; case BIRTHDAY: if (value == null) { unsetBirthday(); } else { setBirthday((java.lang.Integer)value); } break; case EMAIL: if (value == null) { unsetEmail(); } else { setEmail((java.lang.String)value); } break; case MOBILE: if (value == null) { unsetMobile(); } else { setMobile((java.lang.String)value); } break; case ADDRESS: if (value == null) { unsetAddress(); } else { setAddress((java.lang.String)value); } break; case ICON: if (value == null) { unsetIcon(); } else { setIcon((java.lang.String)value); } break; case PERMISSIONS: if (value == null) { unsetPermissions(); } else { setPermissions((java.util.List)value); } break; case STATUS: if (value == null) { unsetStatus(); } else { setStatus((java.lang.Integer)value); } break; case CREATE_TIME: if (value == null) { unsetCreateTime(); } else { setCreateTime((java.lang.Long)value); } break; case UPDATE_TIME: if (value == null) { unsetUpdateTime(); } else { setUpdateTime((java.lang.Long)value); } break; } } public java.lang.Object getFieldValue(_Fields field) { switch (field) { case ID: return getId(); case NAME: return getName(); case SEX: return getSex(); case BIRTHDAY: return getBirthday(); case EMAIL: return getEmail(); case MOBILE: return getMobile(); case ADDRESS: return getAddress(); case ICON: return getIcon(); case PERMISSIONS: return getPermissions(); case STATUS: return getStatus(); case CREATE_TIME: return getCreateTime(); case UPDATE_TIME: return getUpdateTime(); } throw new java.lang.IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { case ID: return isSetId(); case NAME: return isSetName(); case SEX: return isSetSex(); case BIRTHDAY: return isSetBirthday(); case EMAIL: return isSetEmail(); case MOBILE: return isSetMobile(); case ADDRESS: return isSetAddress(); case ICON: return isSetIcon(); case PERMISSIONS: return isSetPermissions(); case STATUS: return isSetStatus(); case CREATE_TIME: return isSetCreateTime(); case UPDATE_TIME: return isSetUpdateTime(); } throw new java.lang.IllegalStateException(); } @Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof User) return this.equals((User)that); return false; } public boolean equals(User that) { if (that == null) return false; if (this == that) return true; boolean this_present_id = true; boolean that_present_id = true; if (this_present_id || that_present_id) { if (!(this_present_id && that_present_id)) return false; if (this.id != that.id) return false; } boolean this_present_name = true && this.isSetName(); boolean that_present_name = true && that.isSetName(); if (this_present_name || that_present_name) { if (!(this_present_name && that_present_name)) return false; if (!this.name.equals(that.name)) return false; } boolean this_present_sex = true; boolean that_present_sex = true; if (this_present_sex || that_present_sex) { if (!(this_present_sex && that_present_sex)) return false; if (this.sex != that.sex) return false; } boolean this_present_birthday = true; boolean that_present_birthday = true; if (this_present_birthday || that_present_birthday) { if (!(this_present_birthday && that_present_birthday)) return false; if (this.birthday != that.birthday) return false; } boolean this_present_email = true && this.isSetEmail(); boolean that_present_email = true && that.isSetEmail(); if (this_present_email || that_present_email) { if (!(this_present_email && that_present_email)) return false; if (!this.email.equals(that.email)) return false; } boolean this_present_mobile = true && this.isSetMobile(); boolean that_present_mobile = true && that.isSetMobile(); if (this_present_mobile || that_present_mobile) { if (!(this_present_mobile && that_present_mobile)) return false; if (!this.mobile.equals(that.mobile)) return false; } boolean this_present_address = true && this.isSetAddress(); boolean that_present_address = true && that.isSetAddress(); if (this_present_address || that_present_address) { if (!(this_present_address && that_present_address)) return false; if (!this.address.equals(that.address)) return false; } boolean this_present_icon = true && this.isSetIcon(); boolean that_present_icon = true && that.isSetIcon(); if (this_present_icon || that_present_icon) { if (!(this_present_icon && that_present_icon)) return false; if (!this.icon.equals(that.icon)) return false; } boolean this_present_permissions = true && this.isSetPermissions(); boolean that_present_permissions = true && that.isSetPermissions(); if (this_present_permissions || that_present_permissions) { if (!(this_present_permissions && that_present_permissions)) return false; if (!this.permissions.equals(that.permissions)) return false; } boolean this_present_status = true; boolean that_present_status = true; if (this_present_status || that_present_status) { if (!(this_present_status && that_present_status)) return false; if (this.status != that.status) return false; } boolean this_present_createTime = true; boolean that_present_createTime = true; if (this_present_createTime || that_present_createTime) { if (!(this_present_createTime && that_present_createTime)) return false; if (this.createTime != that.createTime) return false; } boolean this_present_updateTime = true; boolean that_present_updateTime = true; if (this_present_updateTime || that_present_updateTime) { if (!(this_present_updateTime && that_present_updateTime)) return false; if (this.updateTime != that.updateTime) return false; } return true; } @Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(id); hashCode = hashCode * 8191 + ((isSetName()) ? 131071 : 524287); if (isSetName()) hashCode = hashCode * 8191 + name.hashCode(); hashCode = hashCode * 8191 + sex; hashCode = hashCode * 8191 + birthday; hashCode = hashCode * 8191 + ((isSetEmail()) ? 131071 : 524287); if (isSetEmail()) hashCode = hashCode * 8191 + email.hashCode(); hashCode = hashCode * 8191 + ((isSetMobile()) ? 131071 : 524287); if (isSetMobile()) hashCode = hashCode * 8191 + mobile.hashCode(); hashCode = hashCode * 8191 + ((isSetAddress()) ? 131071 : 524287); if (isSetAddress()) hashCode = hashCode * 8191 + address.hashCode(); hashCode = hashCode * 8191 + ((isSetIcon()) ? 131071 : 524287); if (isSetIcon()) hashCode = hashCode * 8191 + icon.hashCode(); hashCode = hashCode * 8191 + ((isSetPermissions()) ? 131071 : 524287); if (isSetPermissions()) hashCode = hashCode * 8191 + permissions.hashCode(); hashCode = hashCode * 8191 + status; hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(createTime); hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(updateTime); return hashCode; } @Override public int compareTo(User other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = java.lang.Boolean.valueOf(isSetId()).compareTo(other.isSetId()); if (lastComparison != 0) { return lastComparison; } if (isSetId()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.id, other.id); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetName()).compareTo(other.isSetName()); if (lastComparison != 0) { return lastComparison; } if (isSetName()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.name, other.name); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetSex()).compareTo(other.isSetSex()); if (lastComparison != 0) { return lastComparison; } if (isSetSex()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.sex, other.sex); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetBirthday()).compareTo(other.isSetBirthday()); if (lastComparison != 0) { return lastComparison; } if (isSetBirthday()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.birthday, other.birthday); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetEmail()).compareTo(other.isSetEmail()); if (lastComparison != 0) { return lastComparison; } if (isSetEmail()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.email, other.email); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetMobile()).compareTo(other.isSetMobile()); if (lastComparison != 0) { return lastComparison; } if (isSetMobile()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.mobile, other.mobile); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetAddress()).compareTo(other.isSetAddress()); if (lastComparison != 0) { return lastComparison; } if (isSetAddress()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.address, other.address); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetIcon()).compareTo(other.isSetIcon()); if (lastComparison != 0) { return lastComparison; } if (isSetIcon()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.icon, other.icon); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetPermissions()).compareTo(other.isSetPermissions()); if (lastComparison != 0) { return lastComparison; } if (isSetPermissions()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.permissions, other.permissions); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetStatus()).compareTo(other.isSetStatus()); if (lastComparison != 0) { return lastComparison; } if (isSetStatus()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.status, other.status); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetCreateTime()).compareTo(other.isSetCreateTime()); if (lastComparison != 0) { return lastComparison; } if (isSetCreateTime()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.createTime, other.createTime); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetUpdateTime()).compareTo(other.isSetUpdateTime()); if (lastComparison != 0) { return lastComparison; } if (isSetUpdateTime()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.updateTime, other.updateTime); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { scheme(iprot).read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { scheme(oprot).write(oprot, this); } @Override public java.lang.String toString() { java.lang.StringBuilder sb = new java.lang.StringBuilder("User("); boolean first = true; sb.append("id:"); sb.append(this.id); first = false; if (!first) sb.append(", "); sb.append("name:"); if (this.name == null) { sb.append("null"); } else { sb.append(this.name); } first = false; if (!first) sb.append(", "); sb.append("sex:"); sb.append(this.sex); first = false; if (!first) sb.append(", "); sb.append("birthday:"); sb.append(this.birthday); first = false; if (!first) sb.append(", "); sb.append("email:"); if (this.email == null) { sb.append("null"); } else { sb.append(this.email); } first = false; if (!first) sb.append(", "); sb.append("mobile:"); if (this.mobile == null) { sb.append("null"); } else { sb.append(this.mobile); } first = false; if (!first) sb.append(", "); sb.append("address:"); if (this.address == null) { sb.append("null"); } else { sb.append(this.address); } first = false; if (!first) sb.append(", "); sb.append("icon:"); if (this.icon == null) { sb.append("null"); } else { sb.append(this.icon); } first = false; if (!first) sb.append(", "); sb.append("permissions:"); if (this.permissions == null) { sb.append("null"); } else { sb.append(this.permissions); } first = false; if (!first) sb.append(", "); sb.append("status:"); sb.append(this.status); first = false; if (!first) sb.append(", "); sb.append("createTime:"); sb.append(this.createTime); first = false; if (!first) sb.append(", "); sb.append("updateTime:"); sb.append(this.updateTime); first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields // check for sub-struct validity } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { try { // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. __isset_bitfield = 0; read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class UserStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public UserStandardScheme getScheme() { return new UserStandardScheme(); } } private static class UserStandardScheme extends org.apache.thrift.scheme.StandardScheme { public void read(org.apache.thrift.protocol.TProtocol iprot, User struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 1: // ID if (schemeField.type == org.apache.thrift.protocol.TType.I64) { struct.id = iprot.readI64(); struct.setIdIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 2: // NAME if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.name = iprot.readString(); struct.setNameIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 3: // SEX if (schemeField.type == org.apache.thrift.protocol.TType.I32) { struct.sex = iprot.readI32(); struct.setSexIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 4: // BIRTHDAY if (schemeField.type == org.apache.thrift.protocol.TType.I32) { struct.birthday = iprot.readI32(); struct.setBirthdayIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 5: // EMAIL if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.email = iprot.readString(); struct.setEmailIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 6: // MOBILE if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.mobile = iprot.readString(); struct.setMobileIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 7: // ADDRESS if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.address = iprot.readString(); struct.setAddressIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 8: // ICON if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.icon = iprot.readString(); struct.setIconIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 9: // PERMISSIONS if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { org.apache.thrift.protocol.TList _list0 = iprot.readListBegin(); struct.permissions = new java.util.ArrayList(_list0.size); int _elem1; for (int _i2 = 0; _i2 < _list0.size; ++_i2) { _elem1 = iprot.readI32(); struct.permissions.add(_elem1); } iprot.readListEnd(); } struct.setPermissionsIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 10: // STATUS if (schemeField.type == org.apache.thrift.protocol.TType.I32) { struct.status = iprot.readI32(); struct.setStatusIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 11: // CREATE_TIME if (schemeField.type == org.apache.thrift.protocol.TType.I64) { struct.createTime = iprot.readI64(); struct.setCreateTimeIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 12: // UPDATE_TIME if (schemeField.type == org.apache.thrift.protocol.TType.I64) { struct.updateTime = iprot.readI64(); struct.setUpdateTimeIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, User struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); oprot.writeFieldBegin(ID_FIELD_DESC); oprot.writeI64(struct.id); oprot.writeFieldEnd(); if (struct.name != null) { oprot.writeFieldBegin(NAME_FIELD_DESC); oprot.writeString(struct.name); oprot.writeFieldEnd(); } oprot.writeFieldBegin(SEX_FIELD_DESC); oprot.writeI32(struct.sex); oprot.writeFieldEnd(); oprot.writeFieldBegin(BIRTHDAY_FIELD_DESC); oprot.writeI32(struct.birthday); oprot.writeFieldEnd(); if (struct.email != null) { oprot.writeFieldBegin(EMAIL_FIELD_DESC); oprot.writeString(struct.email); oprot.writeFieldEnd(); } if (struct.mobile != null) { oprot.writeFieldBegin(MOBILE_FIELD_DESC); oprot.writeString(struct.mobile); oprot.writeFieldEnd(); } if (struct.address != null) { oprot.writeFieldBegin(ADDRESS_FIELD_DESC); oprot.writeString(struct.address); oprot.writeFieldEnd(); } if (struct.icon != null) { oprot.writeFieldBegin(ICON_FIELD_DESC); oprot.writeString(struct.icon); oprot.writeFieldEnd(); } if (struct.permissions != null) { oprot.writeFieldBegin(PERMISSIONS_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, struct.permissions.size())); for (int _iter3 : struct.permissions) { oprot.writeI32(_iter3); } oprot.writeListEnd(); } oprot.writeFieldEnd(); } oprot.writeFieldBegin(STATUS_FIELD_DESC); oprot.writeI32(struct.status); oprot.writeFieldEnd(); oprot.writeFieldBegin(CREATE_TIME_FIELD_DESC); oprot.writeI64(struct.createTime); oprot.writeFieldEnd(); oprot.writeFieldBegin(UPDATE_TIME_FIELD_DESC); oprot.writeI64(struct.updateTime); oprot.writeFieldEnd(); oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class UserTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public UserTupleScheme getScheme() { return new UserTupleScheme(); } } private static class UserTupleScheme extends org.apache.thrift.scheme.TupleScheme { @Override public void write(org.apache.thrift.protocol.TProtocol prot, User struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet optionals = new java.util.BitSet(); if (struct.isSetId()) { optionals.set(0); } if (struct.isSetName()) { optionals.set(1); } if (struct.isSetSex()) { optionals.set(2); } if (struct.isSetBirthday()) { optionals.set(3); } if (struct.isSetEmail()) { optionals.set(4); } if (struct.isSetMobile()) { optionals.set(5); } if (struct.isSetAddress()) { optionals.set(6); } if (struct.isSetIcon()) { optionals.set(7); } if (struct.isSetPermissions()) { optionals.set(8); } if (struct.isSetStatus()) { optionals.set(9); } if (struct.isSetCreateTime()) { optionals.set(10); } if (struct.isSetUpdateTime()) { optionals.set(11); } oprot.writeBitSet(optionals, 12); if (struct.isSetId()) { oprot.writeI64(struct.id); } if (struct.isSetName()) { oprot.writeString(struct.name); } if (struct.isSetSex()) { oprot.writeI32(struct.sex); } if (struct.isSetBirthday()) { oprot.writeI32(struct.birthday); } if (struct.isSetEmail()) { oprot.writeString(struct.email); } if (struct.isSetMobile()) { oprot.writeString(struct.mobile); } if (struct.isSetAddress()) { oprot.writeString(struct.address); } if (struct.isSetIcon()) { oprot.writeString(struct.icon); } if (struct.isSetPermissions()) { { oprot.writeI32(struct.permissions.size()); for (int _iter4 : struct.permissions) { oprot.writeI32(_iter4); } } } if (struct.isSetStatus()) { oprot.writeI32(struct.status); } if (struct.isSetCreateTime()) { oprot.writeI64(struct.createTime); } if (struct.isSetUpdateTime()) { oprot.writeI64(struct.updateTime); } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, User struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet incoming = iprot.readBitSet(12); if (incoming.get(0)) { struct.id = iprot.readI64(); struct.setIdIsSet(true); } if (incoming.get(1)) { struct.name = iprot.readString(); struct.setNameIsSet(true); } if (incoming.get(2)) { struct.sex = iprot.readI32(); struct.setSexIsSet(true); } if (incoming.get(3)) { struct.birthday = iprot.readI32(); struct.setBirthdayIsSet(true); } if (incoming.get(4)) { struct.email = iprot.readString(); struct.setEmailIsSet(true); } if (incoming.get(5)) { struct.mobile = iprot.readString(); struct.setMobileIsSet(true); } if (incoming.get(6)) { struct.address = iprot.readString(); struct.setAddressIsSet(true); } if (incoming.get(7)) { struct.icon = iprot.readString(); struct.setIconIsSet(true); } if (incoming.get(8)) { { org.apache.thrift.protocol.TList _list5 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); struct.permissions = new java.util.ArrayList(_list5.size); int _elem6; for (int _i7 = 0; _i7 < _list5.size; ++_i7) { _elem6 = iprot.readI32(); struct.permissions.add(_elem6); } } struct.setPermissionsIsSet(true); } if (incoming.get(9)) { struct.status = iprot.readI32(); struct.setStatusIsSet(true); } if (incoming.get(10)) { struct.createTime = iprot.readI64(); struct.setCreateTimeIsSet(true); } if (incoming.get(11)) { struct.updateTime = iprot.readI64(); struct.setUpdateTimeIsSet(true); } } } private static S scheme(org.apache.thrift.protocol.TProtocol proto) { return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); } } ================================================ FILE: thrift-server/src/main/java/benchmark/rpc/thrift/UserPage.java ================================================ /** * Autogenerated by Thrift Compiler (0.10.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated */ package benchmark.rpc.thrift; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) @javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.10.0)", date = "2018-01-02") public class UserPage implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("UserPage"); private static final org.apache.thrift.protocol.TField PAGE_NO_FIELD_DESC = new org.apache.thrift.protocol.TField("pageNo", org.apache.thrift.protocol.TType.I32, (short)1); private static final org.apache.thrift.protocol.TField TOTAL_FIELD_DESC = new org.apache.thrift.protocol.TField("total", org.apache.thrift.protocol.TType.I32, (short)2); private static final org.apache.thrift.protocol.TField RESULT_FIELD_DESC = new org.apache.thrift.protocol.TField("result", org.apache.thrift.protocol.TType.LIST, (short)3); private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new UserPageStandardSchemeFactory(); private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new UserPageTupleSchemeFactory(); public int pageNo; // required public int total; // required public java.util.List result; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { PAGE_NO((short)1, "pageNo"), TOTAL((short)2, "total"), RESULT((short)3, "result"); private static final java.util.Map byName = new java.util.HashMap(); static { for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 1: // PAGE_NO return PAGE_NO; case 2: // TOTAL return TOTAL; case 3: // RESULT return RESULT; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(java.lang.String name) { return byName.get(name); } private final short _thriftId; private final java.lang.String _fieldName; _Fields(short thriftId, java.lang.String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public java.lang.String getFieldName() { return _fieldName; } } // isset id assignments private static final int __PAGENO_ISSET_ID = 0; private static final int __TOTAL_ISSET_ID = 1; private byte __isset_bitfield = 0; public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.PAGE_NO, new org.apache.thrift.meta_data.FieldMetaData("pageNo", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); tmpMap.put(_Fields.TOTAL, new org.apache.thrift.meta_data.FieldMetaData("total", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); tmpMap.put(_Fields.RESULT, new org.apache.thrift.meta_data.FieldMetaData("result", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, User.class)))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(UserPage.class, metaDataMap); } public UserPage() { } public UserPage( int pageNo, int total, java.util.List result) { this(); this.pageNo = pageNo; setPageNoIsSet(true); this.total = total; setTotalIsSet(true); this.result = result; } /** * Performs a deep copy on other. */ public UserPage(UserPage other) { __isset_bitfield = other.__isset_bitfield; this.pageNo = other.pageNo; this.total = other.total; if (other.isSetResult()) { java.util.List __this__result = new java.util.ArrayList(other.result.size()); for (User other_element : other.result) { __this__result.add(new User(other_element)); } this.result = __this__result; } } public UserPage deepCopy() { return new UserPage(this); } @Override public void clear() { setPageNoIsSet(false); this.pageNo = 0; setTotalIsSet(false); this.total = 0; this.result = null; } public int getPageNo() { return this.pageNo; } public UserPage setPageNo(int pageNo) { this.pageNo = pageNo; setPageNoIsSet(true); return this; } public void unsetPageNo() { __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __PAGENO_ISSET_ID); } /** Returns true if field pageNo is set (has been assigned a value) and false otherwise */ public boolean isSetPageNo() { return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __PAGENO_ISSET_ID); } public void setPageNoIsSet(boolean value) { __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __PAGENO_ISSET_ID, value); } public int getTotal() { return this.total; } public UserPage setTotal(int total) { this.total = total; setTotalIsSet(true); return this; } public void unsetTotal() { __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __TOTAL_ISSET_ID); } /** Returns true if field total is set (has been assigned a value) and false otherwise */ public boolean isSetTotal() { return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __TOTAL_ISSET_ID); } public void setTotalIsSet(boolean value) { __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __TOTAL_ISSET_ID, value); } public int getResultSize() { return (this.result == null) ? 0 : this.result.size(); } public java.util.Iterator getResultIterator() { return (this.result == null) ? null : this.result.iterator(); } public void addToResult(User elem) { if (this.result == null) { this.result = new java.util.ArrayList(); } this.result.add(elem); } public java.util.List getResult() { return this.result; } public UserPage setResult(java.util.List result) { this.result = result; return this; } public void unsetResult() { this.result = null; } /** Returns true if field result is set (has been assigned a value) and false otherwise */ public boolean isSetResult() { return this.result != null; } public void setResultIsSet(boolean value) { if (!value) { this.result = null; } } public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case PAGE_NO: if (value == null) { unsetPageNo(); } else { setPageNo((java.lang.Integer)value); } break; case TOTAL: if (value == null) { unsetTotal(); } else { setTotal((java.lang.Integer)value); } break; case RESULT: if (value == null) { unsetResult(); } else { setResult((java.util.List)value); } break; } } public java.lang.Object getFieldValue(_Fields field) { switch (field) { case PAGE_NO: return getPageNo(); case TOTAL: return getTotal(); case RESULT: return getResult(); } throw new java.lang.IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { case PAGE_NO: return isSetPageNo(); case TOTAL: return isSetTotal(); case RESULT: return isSetResult(); } throw new java.lang.IllegalStateException(); } @Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof UserPage) return this.equals((UserPage)that); return false; } public boolean equals(UserPage that) { if (that == null) return false; if (this == that) return true; boolean this_present_pageNo = true; boolean that_present_pageNo = true; if (this_present_pageNo || that_present_pageNo) { if (!(this_present_pageNo && that_present_pageNo)) return false; if (this.pageNo != that.pageNo) return false; } boolean this_present_total = true; boolean that_present_total = true; if (this_present_total || that_present_total) { if (!(this_present_total && that_present_total)) return false; if (this.total != that.total) return false; } boolean this_present_result = true && this.isSetResult(); boolean that_present_result = true && that.isSetResult(); if (this_present_result || that_present_result) { if (!(this_present_result && that_present_result)) return false; if (!this.result.equals(that.result)) return false; } return true; } @Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + pageNo; hashCode = hashCode * 8191 + total; hashCode = hashCode * 8191 + ((isSetResult()) ? 131071 : 524287); if (isSetResult()) hashCode = hashCode * 8191 + result.hashCode(); return hashCode; } @Override public int compareTo(UserPage other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = java.lang.Boolean.valueOf(isSetPageNo()).compareTo(other.isSetPageNo()); if (lastComparison != 0) { return lastComparison; } if (isSetPageNo()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.pageNo, other.pageNo); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetTotal()).compareTo(other.isSetTotal()); if (lastComparison != 0) { return lastComparison; } if (isSetTotal()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.total, other.total); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetResult()).compareTo(other.isSetResult()); if (lastComparison != 0) { return lastComparison; } if (isSetResult()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.result, other.result); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { scheme(iprot).read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { scheme(oprot).write(oprot, this); } @Override public java.lang.String toString() { java.lang.StringBuilder sb = new java.lang.StringBuilder("UserPage("); boolean first = true; sb.append("pageNo:"); sb.append(this.pageNo); first = false; if (!first) sb.append(", "); sb.append("total:"); sb.append(this.total); first = false; if (!first) sb.append(", "); sb.append("result:"); if (this.result == null) { sb.append("null"); } else { sb.append(this.result); } first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields // check for sub-struct validity } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { try { // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. __isset_bitfield = 0; read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class UserPageStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public UserPageStandardScheme getScheme() { return new UserPageStandardScheme(); } } private static class UserPageStandardScheme extends org.apache.thrift.scheme.StandardScheme { public void read(org.apache.thrift.protocol.TProtocol iprot, UserPage struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 1: // PAGE_NO if (schemeField.type == org.apache.thrift.protocol.TType.I32) { struct.pageNo = iprot.readI32(); struct.setPageNoIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 2: // TOTAL if (schemeField.type == org.apache.thrift.protocol.TType.I32) { struct.total = iprot.readI32(); struct.setTotalIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 3: // RESULT if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { org.apache.thrift.protocol.TList _list8 = iprot.readListBegin(); struct.result = new java.util.ArrayList(_list8.size); User _elem9; for (int _i10 = 0; _i10 < _list8.size; ++_i10) { _elem9 = new User(); _elem9.read(iprot); struct.result.add(_elem9); } iprot.readListEnd(); } struct.setResultIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, UserPage struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); oprot.writeFieldBegin(PAGE_NO_FIELD_DESC); oprot.writeI32(struct.pageNo); oprot.writeFieldEnd(); oprot.writeFieldBegin(TOTAL_FIELD_DESC); oprot.writeI32(struct.total); oprot.writeFieldEnd(); if (struct.result != null) { oprot.writeFieldBegin(RESULT_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.result.size())); for (User _iter11 : struct.result) { _iter11.write(oprot); } oprot.writeListEnd(); } oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class UserPageTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public UserPageTupleScheme getScheme() { return new UserPageTupleScheme(); } } private static class UserPageTupleScheme extends org.apache.thrift.scheme.TupleScheme { @Override public void write(org.apache.thrift.protocol.TProtocol prot, UserPage struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet optionals = new java.util.BitSet(); if (struct.isSetPageNo()) { optionals.set(0); } if (struct.isSetTotal()) { optionals.set(1); } if (struct.isSetResult()) { optionals.set(2); } oprot.writeBitSet(optionals, 3); if (struct.isSetPageNo()) { oprot.writeI32(struct.pageNo); } if (struct.isSetTotal()) { oprot.writeI32(struct.total); } if (struct.isSetResult()) { { oprot.writeI32(struct.result.size()); for (User _iter12 : struct.result) { _iter12.write(oprot); } } } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, UserPage struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet incoming = iprot.readBitSet(3); if (incoming.get(0)) { struct.pageNo = iprot.readI32(); struct.setPageNoIsSet(true); } if (incoming.get(1)) { struct.total = iprot.readI32(); struct.setTotalIsSet(true); } if (incoming.get(2)) { { org.apache.thrift.protocol.TList _list13 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); struct.result = new java.util.ArrayList(_list13.size); User _elem14; for (int _i15 = 0; _i15 < _list13.size; ++_i15) { _elem14 = new User(); _elem14.read(iprot); struct.result.add(_elem14); } } struct.setResultIsSet(true); } } } private static S scheme(org.apache.thrift.protocol.TProtocol proto) { return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); } } ================================================ FILE: thrift-server/src/main/java/benchmark/rpc/thrift/UserService.java ================================================ /** * Autogenerated by Thrift Compiler (0.10.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated */ package benchmark.rpc.thrift; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) @javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.10.0)", date = "2018-01-02") public class UserService { public interface Iface { public boolean userExist(java.lang.String email) throws org.apache.thrift.TException; public boolean createUser(User user) throws org.apache.thrift.TException; public User getUser(long id) throws org.apache.thrift.TException; public UserPage listUser(int pageNo) throws org.apache.thrift.TException; } public interface AsyncIface { public void userExist(java.lang.String email, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; public void createUser(User user, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; public void getUser(long id, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; public void listUser(int pageNo, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; } public static class Client extends org.apache.thrift.TServiceClient implements Iface { public static class Factory implements org.apache.thrift.TServiceClientFactory { public Factory() {} public Client getClient(org.apache.thrift.protocol.TProtocol prot) { return new Client(prot); } public Client getClient(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) { return new Client(iprot, oprot); } } public Client(org.apache.thrift.protocol.TProtocol prot) { super(prot, prot); } public Client(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) { super(iprot, oprot); } public boolean userExist(java.lang.String email) throws org.apache.thrift.TException { send_userExist(email); return recv_userExist(); } public void send_userExist(java.lang.String email) throws org.apache.thrift.TException { userExist_args args = new userExist_args(); args.setEmail(email); sendBase("userExist", args); } public boolean recv_userExist() throws org.apache.thrift.TException { userExist_result result = new userExist_result(); receiveBase(result, "userExist"); if (result.isSetSuccess()) { return result.success; } throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "userExist failed: unknown result"); } public boolean createUser(User user) throws org.apache.thrift.TException { send_createUser(user); return recv_createUser(); } public void send_createUser(User user) throws org.apache.thrift.TException { createUser_args args = new createUser_args(); args.setUser(user); sendBase("createUser", args); } public boolean recv_createUser() throws org.apache.thrift.TException { createUser_result result = new createUser_result(); receiveBase(result, "createUser"); if (result.isSetSuccess()) { return result.success; } throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "createUser failed: unknown result"); } public User getUser(long id) throws org.apache.thrift.TException { send_getUser(id); return recv_getUser(); } public void send_getUser(long id) throws org.apache.thrift.TException { getUser_args args = new getUser_args(); args.setId(id); sendBase("getUser", args); } public User recv_getUser() throws org.apache.thrift.TException { getUser_result result = new getUser_result(); receiveBase(result, "getUser"); if (result.isSetSuccess()) { return result.success; } throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getUser failed: unknown result"); } public UserPage listUser(int pageNo) throws org.apache.thrift.TException { send_listUser(pageNo); return recv_listUser(); } public void send_listUser(int pageNo) throws org.apache.thrift.TException { listUser_args args = new listUser_args(); args.setPageNo(pageNo); sendBase("listUser", args); } public UserPage recv_listUser() throws org.apache.thrift.TException { listUser_result result = new listUser_result(); receiveBase(result, "listUser"); if (result.isSetSuccess()) { return result.success; } throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "listUser failed: unknown result"); } } public static class AsyncClient extends org.apache.thrift.async.TAsyncClient implements AsyncIface { public static class Factory implements org.apache.thrift.async.TAsyncClientFactory { private org.apache.thrift.async.TAsyncClientManager clientManager; private org.apache.thrift.protocol.TProtocolFactory protocolFactory; public Factory(org.apache.thrift.async.TAsyncClientManager clientManager, org.apache.thrift.protocol.TProtocolFactory protocolFactory) { this.clientManager = clientManager; this.protocolFactory = protocolFactory; } public AsyncClient getAsyncClient(org.apache.thrift.transport.TNonblockingTransport transport) { return new AsyncClient(protocolFactory, clientManager, transport); } } public AsyncClient(org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.async.TAsyncClientManager clientManager, org.apache.thrift.transport.TNonblockingTransport transport) { super(protocolFactory, clientManager, transport); } public void userExist(java.lang.String email, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { checkReady(); userExist_call method_call = new userExist_call(email, resultHandler, this, ___protocolFactory, ___transport); this.___currentMethod = method_call; ___manager.call(method_call); } public static class userExist_call extends org.apache.thrift.async.TAsyncMethodCall { private java.lang.String email; public userExist_call(java.lang.String email, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { super(client, protocolFactory, transport, resultHandler, false); this.email = email; } public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("userExist", org.apache.thrift.protocol.TMessageType.CALL, 0)); userExist_args args = new userExist_args(); args.setEmail(email); args.write(prot); prot.writeMessageEnd(); } public java.lang.Boolean getResult() throws org.apache.thrift.TException { if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { throw new java.lang.IllegalStateException("Method call not finished!"); } org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); return (new Client(prot)).recv_userExist(); } } public void createUser(User user, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { checkReady(); createUser_call method_call = new createUser_call(user, resultHandler, this, ___protocolFactory, ___transport); this.___currentMethod = method_call; ___manager.call(method_call); } public static class createUser_call extends org.apache.thrift.async.TAsyncMethodCall { private User user; public createUser_call(User user, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { super(client, protocolFactory, transport, resultHandler, false); this.user = user; } public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("createUser", org.apache.thrift.protocol.TMessageType.CALL, 0)); createUser_args args = new createUser_args(); args.setUser(user); args.write(prot); prot.writeMessageEnd(); } public java.lang.Boolean getResult() throws org.apache.thrift.TException { if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { throw new java.lang.IllegalStateException("Method call not finished!"); } org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); return (new Client(prot)).recv_createUser(); } } public void getUser(long id, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { checkReady(); getUser_call method_call = new getUser_call(id, resultHandler, this, ___protocolFactory, ___transport); this.___currentMethod = method_call; ___manager.call(method_call); } public static class getUser_call extends org.apache.thrift.async.TAsyncMethodCall { private long id; public getUser_call(long id, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { super(client, protocolFactory, transport, resultHandler, false); this.id = id; } public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("getUser", org.apache.thrift.protocol.TMessageType.CALL, 0)); getUser_args args = new getUser_args(); args.setId(id); args.write(prot); prot.writeMessageEnd(); } public User getResult() throws org.apache.thrift.TException { if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { throw new java.lang.IllegalStateException("Method call not finished!"); } org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); return (new Client(prot)).recv_getUser(); } } public void listUser(int pageNo, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { checkReady(); listUser_call method_call = new listUser_call(pageNo, resultHandler, this, ___protocolFactory, ___transport); this.___currentMethod = method_call; ___manager.call(method_call); } public static class listUser_call extends org.apache.thrift.async.TAsyncMethodCall { private int pageNo; public listUser_call(int pageNo, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { super(client, protocolFactory, transport, resultHandler, false); this.pageNo = pageNo; } public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("listUser", org.apache.thrift.protocol.TMessageType.CALL, 0)); listUser_args args = new listUser_args(); args.setPageNo(pageNo); args.write(prot); prot.writeMessageEnd(); } public UserPage getResult() throws org.apache.thrift.TException { if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { throw new java.lang.IllegalStateException("Method call not finished!"); } org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); return (new Client(prot)).recv_listUser(); } } } public static class Processor extends org.apache.thrift.TBaseProcessor implements org.apache.thrift.TProcessor { private static final org.slf4j.Logger _LOGGER = org.slf4j.LoggerFactory.getLogger(Processor.class.getName()); public Processor(I iface) { super(iface, getProcessMap(new java.util.HashMap>())); } protected Processor(I iface, java.util.Map> processMap) { super(iface, getProcessMap(processMap)); } private static java.util.Map> getProcessMap(java.util.Map> processMap) { processMap.put("userExist", new userExist()); processMap.put("createUser", new createUser()); processMap.put("getUser", new getUser()); processMap.put("listUser", new listUser()); return processMap; } public static class userExist extends org.apache.thrift.ProcessFunction { public userExist() { super("userExist"); } public userExist_args getEmptyArgsInstance() { return new userExist_args(); } protected boolean isOneway() { return false; } public userExist_result getResult(I iface, userExist_args args) throws org.apache.thrift.TException { userExist_result result = new userExist_result(); result.success = iface.userExist(args.email); result.setSuccessIsSet(true); return result; } } public static class createUser extends org.apache.thrift.ProcessFunction { public createUser() { super("createUser"); } public createUser_args getEmptyArgsInstance() { return new createUser_args(); } protected boolean isOneway() { return false; } public createUser_result getResult(I iface, createUser_args args) throws org.apache.thrift.TException { createUser_result result = new createUser_result(); result.success = iface.createUser(args.user); result.setSuccessIsSet(true); return result; } } public static class getUser extends org.apache.thrift.ProcessFunction { public getUser() { super("getUser"); } public getUser_args getEmptyArgsInstance() { return new getUser_args(); } protected boolean isOneway() { return false; } public getUser_result getResult(I iface, getUser_args args) throws org.apache.thrift.TException { getUser_result result = new getUser_result(); result.success = iface.getUser(args.id); return result; } } public static class listUser extends org.apache.thrift.ProcessFunction { public listUser() { super("listUser"); } public listUser_args getEmptyArgsInstance() { return new listUser_args(); } protected boolean isOneway() { return false; } public listUser_result getResult(I iface, listUser_args args) throws org.apache.thrift.TException { listUser_result result = new listUser_result(); result.success = iface.listUser(args.pageNo); return result; } } } public static class AsyncProcessor extends org.apache.thrift.TBaseAsyncProcessor { private static final org.slf4j.Logger _LOGGER = org.slf4j.LoggerFactory.getLogger(AsyncProcessor.class.getName()); public AsyncProcessor(I iface) { super(iface, getProcessMap(new java.util.HashMap>())); } protected AsyncProcessor(I iface, java.util.Map> processMap) { super(iface, getProcessMap(processMap)); } private static java.util.Map> getProcessMap(java.util.Map> processMap) { processMap.put("userExist", new userExist()); processMap.put("createUser", new createUser()); processMap.put("getUser", new getUser()); processMap.put("listUser", new listUser()); return processMap; } public static class userExist extends org.apache.thrift.AsyncProcessFunction { public userExist() { super("userExist"); } public userExist_args getEmptyArgsInstance() { return new userExist_args(); } public org.apache.thrift.async.AsyncMethodCallback getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) { final org.apache.thrift.AsyncProcessFunction fcall = this; return new org.apache.thrift.async.AsyncMethodCallback() { public void onComplete(java.lang.Boolean o) { userExist_result result = new userExist_result(); result.success = o; result.setSuccessIsSet(true); try { fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); } catch (org.apache.thrift.transport.TTransportException e) { _LOGGER.error("TTransportException writing to internal frame buffer", e); fb.close(); } catch (java.lang.Exception e) { _LOGGER.error("Exception writing to internal frame buffer", e); onError(e); } } public void onError(java.lang.Exception e) { byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; org.apache.thrift.TSerializable msg; userExist_result result = new userExist_result(); if (e instanceof org.apache.thrift.transport.TTransportException) { _LOGGER.error("TTransportException inside handler", e); fb.close(); return; } else if (e instanceof org.apache.thrift.TApplicationException) { _LOGGER.error("TApplicationException inside handler", e); msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; msg = (org.apache.thrift.TApplicationException)e; } else { _LOGGER.error("Exception inside handler", e); msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); } try { fcall.sendResponse(fb,msg,msgType,seqid); } catch (java.lang.Exception ex) { _LOGGER.error("Exception writing to internal frame buffer", ex); fb.close(); } } }; } protected boolean isOneway() { return false; } public void start(I iface, userExist_args args, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { iface.userExist(args.email,resultHandler); } } public static class createUser extends org.apache.thrift.AsyncProcessFunction { public createUser() { super("createUser"); } public createUser_args getEmptyArgsInstance() { return new createUser_args(); } public org.apache.thrift.async.AsyncMethodCallback getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) { final org.apache.thrift.AsyncProcessFunction fcall = this; return new org.apache.thrift.async.AsyncMethodCallback() { public void onComplete(java.lang.Boolean o) { createUser_result result = new createUser_result(); result.success = o; result.setSuccessIsSet(true); try { fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); } catch (org.apache.thrift.transport.TTransportException e) { _LOGGER.error("TTransportException writing to internal frame buffer", e); fb.close(); } catch (java.lang.Exception e) { _LOGGER.error("Exception writing to internal frame buffer", e); onError(e); } } public void onError(java.lang.Exception e) { byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; org.apache.thrift.TSerializable msg; createUser_result result = new createUser_result(); if (e instanceof org.apache.thrift.transport.TTransportException) { _LOGGER.error("TTransportException inside handler", e); fb.close(); return; } else if (e instanceof org.apache.thrift.TApplicationException) { _LOGGER.error("TApplicationException inside handler", e); msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; msg = (org.apache.thrift.TApplicationException)e; } else { _LOGGER.error("Exception inside handler", e); msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); } try { fcall.sendResponse(fb,msg,msgType,seqid); } catch (java.lang.Exception ex) { _LOGGER.error("Exception writing to internal frame buffer", ex); fb.close(); } } }; } protected boolean isOneway() { return false; } public void start(I iface, createUser_args args, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { iface.createUser(args.user,resultHandler); } } public static class getUser extends org.apache.thrift.AsyncProcessFunction { public getUser() { super("getUser"); } public getUser_args getEmptyArgsInstance() { return new getUser_args(); } public org.apache.thrift.async.AsyncMethodCallback getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) { final org.apache.thrift.AsyncProcessFunction fcall = this; return new org.apache.thrift.async.AsyncMethodCallback() { public void onComplete(User o) { getUser_result result = new getUser_result(); result.success = o; try { fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); } catch (org.apache.thrift.transport.TTransportException e) { _LOGGER.error("TTransportException writing to internal frame buffer", e); fb.close(); } catch (java.lang.Exception e) { _LOGGER.error("Exception writing to internal frame buffer", e); onError(e); } } public void onError(java.lang.Exception e) { byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; org.apache.thrift.TSerializable msg; getUser_result result = new getUser_result(); if (e instanceof org.apache.thrift.transport.TTransportException) { _LOGGER.error("TTransportException inside handler", e); fb.close(); return; } else if (e instanceof org.apache.thrift.TApplicationException) { _LOGGER.error("TApplicationException inside handler", e); msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; msg = (org.apache.thrift.TApplicationException)e; } else { _LOGGER.error("Exception inside handler", e); msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); } try { fcall.sendResponse(fb,msg,msgType,seqid); } catch (java.lang.Exception ex) { _LOGGER.error("Exception writing to internal frame buffer", ex); fb.close(); } } }; } protected boolean isOneway() { return false; } public void start(I iface, getUser_args args, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { iface.getUser(args.id,resultHandler); } } public static class listUser extends org.apache.thrift.AsyncProcessFunction { public listUser() { super("listUser"); } public listUser_args getEmptyArgsInstance() { return new listUser_args(); } public org.apache.thrift.async.AsyncMethodCallback getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) { final org.apache.thrift.AsyncProcessFunction fcall = this; return new org.apache.thrift.async.AsyncMethodCallback() { public void onComplete(UserPage o) { listUser_result result = new listUser_result(); result.success = o; try { fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); } catch (org.apache.thrift.transport.TTransportException e) { _LOGGER.error("TTransportException writing to internal frame buffer", e); fb.close(); } catch (java.lang.Exception e) { _LOGGER.error("Exception writing to internal frame buffer", e); onError(e); } } public void onError(java.lang.Exception e) { byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; org.apache.thrift.TSerializable msg; listUser_result result = new listUser_result(); if (e instanceof org.apache.thrift.transport.TTransportException) { _LOGGER.error("TTransportException inside handler", e); fb.close(); return; } else if (e instanceof org.apache.thrift.TApplicationException) { _LOGGER.error("TApplicationException inside handler", e); msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; msg = (org.apache.thrift.TApplicationException)e; } else { _LOGGER.error("Exception inside handler", e); msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); } try { fcall.sendResponse(fb,msg,msgType,seqid); } catch (java.lang.Exception ex) { _LOGGER.error("Exception writing to internal frame buffer", ex); fb.close(); } } }; } protected boolean isOneway() { return false; } public void start(I iface, listUser_args args, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { iface.listUser(args.pageNo,resultHandler); } } } public static class userExist_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("userExist_args"); private static final org.apache.thrift.protocol.TField EMAIL_FIELD_DESC = new org.apache.thrift.protocol.TField("email", org.apache.thrift.protocol.TType.STRING, (short)1); private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new userExist_argsStandardSchemeFactory(); private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new userExist_argsTupleSchemeFactory(); public java.lang.String email; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { EMAIL((short)1, "email"); private static final java.util.Map byName = new java.util.HashMap(); static { for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 1: // EMAIL return EMAIL; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(java.lang.String name) { return byName.get(name); } private final short _thriftId; private final java.lang.String _fieldName; _Fields(short thriftId, java.lang.String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public java.lang.String getFieldName() { return _fieldName; } } // isset id assignments public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.EMAIL, new org.apache.thrift.meta_data.FieldMetaData("email", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(userExist_args.class, metaDataMap); } public userExist_args() { } public userExist_args( java.lang.String email) { this(); this.email = email; } /** * Performs a deep copy on other. */ public userExist_args(userExist_args other) { if (other.isSetEmail()) { this.email = other.email; } } public userExist_args deepCopy() { return new userExist_args(this); } @Override public void clear() { this.email = null; } public java.lang.String getEmail() { return this.email; } public userExist_args setEmail(java.lang.String email) { this.email = email; return this; } public void unsetEmail() { this.email = null; } /** Returns true if field email is set (has been assigned a value) and false otherwise */ public boolean isSetEmail() { return this.email != null; } public void setEmailIsSet(boolean value) { if (!value) { this.email = null; } } public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case EMAIL: if (value == null) { unsetEmail(); } else { setEmail((java.lang.String)value); } break; } } public java.lang.Object getFieldValue(_Fields field) { switch (field) { case EMAIL: return getEmail(); } throw new java.lang.IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { case EMAIL: return isSetEmail(); } throw new java.lang.IllegalStateException(); } @Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof userExist_args) return this.equals((userExist_args)that); return false; } public boolean equals(userExist_args that) { if (that == null) return false; if (this == that) return true; boolean this_present_email = true && this.isSetEmail(); boolean that_present_email = true && that.isSetEmail(); if (this_present_email || that_present_email) { if (!(this_present_email && that_present_email)) return false; if (!this.email.equals(that.email)) return false; } return true; } @Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + ((isSetEmail()) ? 131071 : 524287); if (isSetEmail()) hashCode = hashCode * 8191 + email.hashCode(); return hashCode; } @Override public int compareTo(userExist_args other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = java.lang.Boolean.valueOf(isSetEmail()).compareTo(other.isSetEmail()); if (lastComparison != 0) { return lastComparison; } if (isSetEmail()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.email, other.email); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { scheme(iprot).read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { scheme(oprot).write(oprot, this); } @Override public java.lang.String toString() { java.lang.StringBuilder sb = new java.lang.StringBuilder("userExist_args("); boolean first = true; sb.append("email:"); if (this.email == null) { sb.append("null"); } else { sb.append(this.email); } first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields // check for sub-struct validity } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { try { read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class userExist_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public userExist_argsStandardScheme getScheme() { return new userExist_argsStandardScheme(); } } private static class userExist_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme { public void read(org.apache.thrift.protocol.TProtocol iprot, userExist_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 1: // EMAIL if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.email = iprot.readString(); struct.setEmailIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, userExist_args struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.email != null) { oprot.writeFieldBegin(EMAIL_FIELD_DESC); oprot.writeString(struct.email); oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class userExist_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public userExist_argsTupleScheme getScheme() { return new userExist_argsTupleScheme(); } } private static class userExist_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme { @Override public void write(org.apache.thrift.protocol.TProtocol prot, userExist_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet optionals = new java.util.BitSet(); if (struct.isSetEmail()) { optionals.set(0); } oprot.writeBitSet(optionals, 1); if (struct.isSetEmail()) { oprot.writeString(struct.email); } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, userExist_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { struct.email = iprot.readString(); struct.setEmailIsSet(true); } } } private static S scheme(org.apache.thrift.protocol.TProtocol proto) { return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); } } public static class userExist_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("userExist_result"); private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.BOOL, (short)0); private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new userExist_resultStandardSchemeFactory(); private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new userExist_resultTupleSchemeFactory(); public boolean success; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { SUCCESS((short)0, "success"); private static final java.util.Map byName = new java.util.HashMap(); static { for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 0: // SUCCESS return SUCCESS; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(java.lang.String name) { return byName.get(name); } private final short _thriftId; private final java.lang.String _fieldName; _Fields(short thriftId, java.lang.String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public java.lang.String getFieldName() { return _fieldName; } } // isset id assignments private static final int __SUCCESS_ISSET_ID = 0; private byte __isset_bitfield = 0; public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(userExist_result.class, metaDataMap); } public userExist_result() { } public userExist_result( boolean success) { this(); this.success = success; setSuccessIsSet(true); } /** * Performs a deep copy on other. */ public userExist_result(userExist_result other) { __isset_bitfield = other.__isset_bitfield; this.success = other.success; } public userExist_result deepCopy() { return new userExist_result(this); } @Override public void clear() { setSuccessIsSet(false); this.success = false; } public boolean isSuccess() { return this.success; } public userExist_result setSuccess(boolean success) { this.success = success; setSuccessIsSet(true); return this; } public void unsetSuccess() { __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __SUCCESS_ISSET_ID); } /** Returns true if field success is set (has been assigned a value) and false otherwise */ public boolean isSetSuccess() { return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __SUCCESS_ISSET_ID); } public void setSuccessIsSet(boolean value) { __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __SUCCESS_ISSET_ID, value); } public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case SUCCESS: if (value == null) { unsetSuccess(); } else { setSuccess((java.lang.Boolean)value); } break; } } public java.lang.Object getFieldValue(_Fields field) { switch (field) { case SUCCESS: return isSuccess(); } throw new java.lang.IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { case SUCCESS: return isSetSuccess(); } throw new java.lang.IllegalStateException(); } @Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof userExist_result) return this.equals((userExist_result)that); return false; } public boolean equals(userExist_result that) { if (that == null) return false; if (this == that) return true; boolean this_present_success = true; boolean that_present_success = true; if (this_present_success || that_present_success) { if (!(this_present_success && that_present_success)) return false; if (this.success != that.success) return false; } return true; } @Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + ((success) ? 131071 : 524287); return hashCode; } @Override public int compareTo(userExist_result other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = java.lang.Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess()); if (lastComparison != 0) { return lastComparison; } if (isSetSuccess()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { scheme(iprot).read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { scheme(oprot).write(oprot, this); } @Override public java.lang.String toString() { java.lang.StringBuilder sb = new java.lang.StringBuilder("userExist_result("); boolean first = true; sb.append("success:"); sb.append(this.success); first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields // check for sub-struct validity } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { try { // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. __isset_bitfield = 0; read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class userExist_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public userExist_resultStandardScheme getScheme() { return new userExist_resultStandardScheme(); } } private static class userExist_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme { public void read(org.apache.thrift.protocol.TProtocol iprot, userExist_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 0: // SUCCESS if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) { struct.success = iprot.readBool(); struct.setSuccessIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, userExist_result struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.isSetSuccess()) { oprot.writeFieldBegin(SUCCESS_FIELD_DESC); oprot.writeBool(struct.success); oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class userExist_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public userExist_resultTupleScheme getScheme() { return new userExist_resultTupleScheme(); } } private static class userExist_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme { @Override public void write(org.apache.thrift.protocol.TProtocol prot, userExist_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet optionals = new java.util.BitSet(); if (struct.isSetSuccess()) { optionals.set(0); } oprot.writeBitSet(optionals, 1); if (struct.isSetSuccess()) { oprot.writeBool(struct.success); } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, userExist_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { struct.success = iprot.readBool(); struct.setSuccessIsSet(true); } } } private static S scheme(org.apache.thrift.protocol.TProtocol proto) { return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); } } public static class createUser_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("createUser_args"); private static final org.apache.thrift.protocol.TField USER_FIELD_DESC = new org.apache.thrift.protocol.TField("user", org.apache.thrift.protocol.TType.STRUCT, (short)1); private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new createUser_argsStandardSchemeFactory(); private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new createUser_argsTupleSchemeFactory(); public User user; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { USER((short)1, "user"); private static final java.util.Map byName = new java.util.HashMap(); static { for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 1: // USER return USER; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(java.lang.String name) { return byName.get(name); } private final short _thriftId; private final java.lang.String _fieldName; _Fields(short thriftId, java.lang.String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public java.lang.String getFieldName() { return _fieldName; } } // isset id assignments public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.USER, new org.apache.thrift.meta_data.FieldMetaData("user", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, User.class))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(createUser_args.class, metaDataMap); } public createUser_args() { } public createUser_args( User user) { this(); this.user = user; } /** * Performs a deep copy on other. */ public createUser_args(createUser_args other) { if (other.isSetUser()) { this.user = new User(other.user); } } public createUser_args deepCopy() { return new createUser_args(this); } @Override public void clear() { this.user = null; } public User getUser() { return this.user; } public createUser_args setUser(User user) { this.user = user; return this; } public void unsetUser() { this.user = null; } /** Returns true if field user is set (has been assigned a value) and false otherwise */ public boolean isSetUser() { return this.user != null; } public void setUserIsSet(boolean value) { if (!value) { this.user = null; } } public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case USER: if (value == null) { unsetUser(); } else { setUser((User)value); } break; } } public java.lang.Object getFieldValue(_Fields field) { switch (field) { case USER: return getUser(); } throw new java.lang.IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { case USER: return isSetUser(); } throw new java.lang.IllegalStateException(); } @Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof createUser_args) return this.equals((createUser_args)that); return false; } public boolean equals(createUser_args that) { if (that == null) return false; if (this == that) return true; boolean this_present_user = true && this.isSetUser(); boolean that_present_user = true && that.isSetUser(); if (this_present_user || that_present_user) { if (!(this_present_user && that_present_user)) return false; if (!this.user.equals(that.user)) return false; } return true; } @Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + ((isSetUser()) ? 131071 : 524287); if (isSetUser()) hashCode = hashCode * 8191 + user.hashCode(); return hashCode; } @Override public int compareTo(createUser_args other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = java.lang.Boolean.valueOf(isSetUser()).compareTo(other.isSetUser()); if (lastComparison != 0) { return lastComparison; } if (isSetUser()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.user, other.user); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { scheme(iprot).read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { scheme(oprot).write(oprot, this); } @Override public java.lang.String toString() { java.lang.StringBuilder sb = new java.lang.StringBuilder("createUser_args("); boolean first = true; sb.append("user:"); if (this.user == null) { sb.append("null"); } else { sb.append(this.user); } first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields // check for sub-struct validity if (user != null) { user.validate(); } } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { try { read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class createUser_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public createUser_argsStandardScheme getScheme() { return new createUser_argsStandardScheme(); } } private static class createUser_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme { public void read(org.apache.thrift.protocol.TProtocol iprot, createUser_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 1: // USER if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { struct.user = new User(); struct.user.read(iprot); struct.setUserIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, createUser_args struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.user != null) { oprot.writeFieldBegin(USER_FIELD_DESC); struct.user.write(oprot); oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class createUser_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public createUser_argsTupleScheme getScheme() { return new createUser_argsTupleScheme(); } } private static class createUser_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme { @Override public void write(org.apache.thrift.protocol.TProtocol prot, createUser_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet optionals = new java.util.BitSet(); if (struct.isSetUser()) { optionals.set(0); } oprot.writeBitSet(optionals, 1); if (struct.isSetUser()) { struct.user.write(oprot); } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, createUser_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { struct.user = new User(); struct.user.read(iprot); struct.setUserIsSet(true); } } } private static S scheme(org.apache.thrift.protocol.TProtocol proto) { return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); } } public static class createUser_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("createUser_result"); private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.BOOL, (short)0); private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new createUser_resultStandardSchemeFactory(); private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new createUser_resultTupleSchemeFactory(); public boolean success; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { SUCCESS((short)0, "success"); private static final java.util.Map byName = new java.util.HashMap(); static { for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 0: // SUCCESS return SUCCESS; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(java.lang.String name) { return byName.get(name); } private final short _thriftId; private final java.lang.String _fieldName; _Fields(short thriftId, java.lang.String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public java.lang.String getFieldName() { return _fieldName; } } // isset id assignments private static final int __SUCCESS_ISSET_ID = 0; private byte __isset_bitfield = 0; public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(createUser_result.class, metaDataMap); } public createUser_result() { } public createUser_result( boolean success) { this(); this.success = success; setSuccessIsSet(true); } /** * Performs a deep copy on other. */ public createUser_result(createUser_result other) { __isset_bitfield = other.__isset_bitfield; this.success = other.success; } public createUser_result deepCopy() { return new createUser_result(this); } @Override public void clear() { setSuccessIsSet(false); this.success = false; } public boolean isSuccess() { return this.success; } public createUser_result setSuccess(boolean success) { this.success = success; setSuccessIsSet(true); return this; } public void unsetSuccess() { __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __SUCCESS_ISSET_ID); } /** Returns true if field success is set (has been assigned a value) and false otherwise */ public boolean isSetSuccess() { return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __SUCCESS_ISSET_ID); } public void setSuccessIsSet(boolean value) { __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __SUCCESS_ISSET_ID, value); } public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case SUCCESS: if (value == null) { unsetSuccess(); } else { setSuccess((java.lang.Boolean)value); } break; } } public java.lang.Object getFieldValue(_Fields field) { switch (field) { case SUCCESS: return isSuccess(); } throw new java.lang.IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { case SUCCESS: return isSetSuccess(); } throw new java.lang.IllegalStateException(); } @Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof createUser_result) return this.equals((createUser_result)that); return false; } public boolean equals(createUser_result that) { if (that == null) return false; if (this == that) return true; boolean this_present_success = true; boolean that_present_success = true; if (this_present_success || that_present_success) { if (!(this_present_success && that_present_success)) return false; if (this.success != that.success) return false; } return true; } @Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + ((success) ? 131071 : 524287); return hashCode; } @Override public int compareTo(createUser_result other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = java.lang.Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess()); if (lastComparison != 0) { return lastComparison; } if (isSetSuccess()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { scheme(iprot).read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { scheme(oprot).write(oprot, this); } @Override public java.lang.String toString() { java.lang.StringBuilder sb = new java.lang.StringBuilder("createUser_result("); boolean first = true; sb.append("success:"); sb.append(this.success); first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields // check for sub-struct validity } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { try { // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. __isset_bitfield = 0; read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class createUser_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public createUser_resultStandardScheme getScheme() { return new createUser_resultStandardScheme(); } } private static class createUser_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme { public void read(org.apache.thrift.protocol.TProtocol iprot, createUser_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 0: // SUCCESS if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) { struct.success = iprot.readBool(); struct.setSuccessIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, createUser_result struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.isSetSuccess()) { oprot.writeFieldBegin(SUCCESS_FIELD_DESC); oprot.writeBool(struct.success); oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class createUser_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public createUser_resultTupleScheme getScheme() { return new createUser_resultTupleScheme(); } } private static class createUser_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme { @Override public void write(org.apache.thrift.protocol.TProtocol prot, createUser_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet optionals = new java.util.BitSet(); if (struct.isSetSuccess()) { optionals.set(0); } oprot.writeBitSet(optionals, 1); if (struct.isSetSuccess()) { oprot.writeBool(struct.success); } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, createUser_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { struct.success = iprot.readBool(); struct.setSuccessIsSet(true); } } } private static S scheme(org.apache.thrift.protocol.TProtocol proto) { return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); } } public static class getUser_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getUser_args"); private static final org.apache.thrift.protocol.TField ID_FIELD_DESC = new org.apache.thrift.protocol.TField("id", org.apache.thrift.protocol.TType.I64, (short)1); private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new getUser_argsStandardSchemeFactory(); private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new getUser_argsTupleSchemeFactory(); public long id; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { ID((short)1, "id"); private static final java.util.Map byName = new java.util.HashMap(); static { for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 1: // ID return ID; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(java.lang.String name) { return byName.get(name); } private final short _thriftId; private final java.lang.String _fieldName; _Fields(short thriftId, java.lang.String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public java.lang.String getFieldName() { return _fieldName; } } // isset id assignments private static final int __ID_ISSET_ID = 0; private byte __isset_bitfield = 0; public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.ID, new org.apache.thrift.meta_data.FieldMetaData("id", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getUser_args.class, metaDataMap); } public getUser_args() { } public getUser_args( long id) { this(); this.id = id; setIdIsSet(true); } /** * Performs a deep copy on other. */ public getUser_args(getUser_args other) { __isset_bitfield = other.__isset_bitfield; this.id = other.id; } public getUser_args deepCopy() { return new getUser_args(this); } @Override public void clear() { setIdIsSet(false); this.id = 0; } public long getId() { return this.id; } public getUser_args setId(long id) { this.id = id; setIdIsSet(true); return this; } public void unsetId() { __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __ID_ISSET_ID); } /** Returns true if field id is set (has been assigned a value) and false otherwise */ public boolean isSetId() { return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __ID_ISSET_ID); } public void setIdIsSet(boolean value) { __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __ID_ISSET_ID, value); } public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case ID: if (value == null) { unsetId(); } else { setId((java.lang.Long)value); } break; } } public java.lang.Object getFieldValue(_Fields field) { switch (field) { case ID: return getId(); } throw new java.lang.IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { case ID: return isSetId(); } throw new java.lang.IllegalStateException(); } @Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof getUser_args) return this.equals((getUser_args)that); return false; } public boolean equals(getUser_args that) { if (that == null) return false; if (this == that) return true; boolean this_present_id = true; boolean that_present_id = true; if (this_present_id || that_present_id) { if (!(this_present_id && that_present_id)) return false; if (this.id != that.id) return false; } return true; } @Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(id); return hashCode; } @Override public int compareTo(getUser_args other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = java.lang.Boolean.valueOf(isSetId()).compareTo(other.isSetId()); if (lastComparison != 0) { return lastComparison; } if (isSetId()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.id, other.id); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { scheme(iprot).read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { scheme(oprot).write(oprot, this); } @Override public java.lang.String toString() { java.lang.StringBuilder sb = new java.lang.StringBuilder("getUser_args("); boolean first = true; sb.append("id:"); sb.append(this.id); first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields // check for sub-struct validity } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { try { // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. __isset_bitfield = 0; read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class getUser_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public getUser_argsStandardScheme getScheme() { return new getUser_argsStandardScheme(); } } private static class getUser_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme { public void read(org.apache.thrift.protocol.TProtocol iprot, getUser_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 1: // ID if (schemeField.type == org.apache.thrift.protocol.TType.I64) { struct.id = iprot.readI64(); struct.setIdIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, getUser_args struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); oprot.writeFieldBegin(ID_FIELD_DESC); oprot.writeI64(struct.id); oprot.writeFieldEnd(); oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class getUser_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public getUser_argsTupleScheme getScheme() { return new getUser_argsTupleScheme(); } } private static class getUser_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme { @Override public void write(org.apache.thrift.protocol.TProtocol prot, getUser_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet optionals = new java.util.BitSet(); if (struct.isSetId()) { optionals.set(0); } oprot.writeBitSet(optionals, 1); if (struct.isSetId()) { oprot.writeI64(struct.id); } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, getUser_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { struct.id = iprot.readI64(); struct.setIdIsSet(true); } } } private static S scheme(org.apache.thrift.protocol.TProtocol proto) { return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); } } public static class getUser_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getUser_result"); private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRUCT, (short)0); private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new getUser_resultStandardSchemeFactory(); private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new getUser_resultTupleSchemeFactory(); public User success; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { SUCCESS((short)0, "success"); private static final java.util.Map byName = new java.util.HashMap(); static { for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 0: // SUCCESS return SUCCESS; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(java.lang.String name) { return byName.get(name); } private final short _thriftId; private final java.lang.String _fieldName; _Fields(short thriftId, java.lang.String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public java.lang.String getFieldName() { return _fieldName; } } // isset id assignments public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, User.class))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getUser_result.class, metaDataMap); } public getUser_result() { } public getUser_result( User success) { this(); this.success = success; } /** * Performs a deep copy on other. */ public getUser_result(getUser_result other) { if (other.isSetSuccess()) { this.success = new User(other.success); } } public getUser_result deepCopy() { return new getUser_result(this); } @Override public void clear() { this.success = null; } public User getSuccess() { return this.success; } public getUser_result setSuccess(User success) { this.success = success; return this; } public void unsetSuccess() { this.success = null; } /** Returns true if field success is set (has been assigned a value) and false otherwise */ public boolean isSetSuccess() { return this.success != null; } public void setSuccessIsSet(boolean value) { if (!value) { this.success = null; } } public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case SUCCESS: if (value == null) { unsetSuccess(); } else { setSuccess((User)value); } break; } } public java.lang.Object getFieldValue(_Fields field) { switch (field) { case SUCCESS: return getSuccess(); } throw new java.lang.IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { case SUCCESS: return isSetSuccess(); } throw new java.lang.IllegalStateException(); } @Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof getUser_result) return this.equals((getUser_result)that); return false; } public boolean equals(getUser_result that) { if (that == null) return false; if (this == that) return true; boolean this_present_success = true && this.isSetSuccess(); boolean that_present_success = true && that.isSetSuccess(); if (this_present_success || that_present_success) { if (!(this_present_success && that_present_success)) return false; if (!this.success.equals(that.success)) return false; } return true; } @Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + ((isSetSuccess()) ? 131071 : 524287); if (isSetSuccess()) hashCode = hashCode * 8191 + success.hashCode(); return hashCode; } @Override public int compareTo(getUser_result other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = java.lang.Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess()); if (lastComparison != 0) { return lastComparison; } if (isSetSuccess()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { scheme(iprot).read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { scheme(oprot).write(oprot, this); } @Override public java.lang.String toString() { java.lang.StringBuilder sb = new java.lang.StringBuilder("getUser_result("); boolean first = true; sb.append("success:"); if (this.success == null) { sb.append("null"); } else { sb.append(this.success); } first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields // check for sub-struct validity if (success != null) { success.validate(); } } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { try { read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class getUser_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public getUser_resultStandardScheme getScheme() { return new getUser_resultStandardScheme(); } } private static class getUser_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme { public void read(org.apache.thrift.protocol.TProtocol iprot, getUser_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 0: // SUCCESS if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { struct.success = new User(); struct.success.read(iprot); struct.setSuccessIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, getUser_result struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.success != null) { oprot.writeFieldBegin(SUCCESS_FIELD_DESC); struct.success.write(oprot); oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class getUser_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public getUser_resultTupleScheme getScheme() { return new getUser_resultTupleScheme(); } } private static class getUser_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme { @Override public void write(org.apache.thrift.protocol.TProtocol prot, getUser_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet optionals = new java.util.BitSet(); if (struct.isSetSuccess()) { optionals.set(0); } oprot.writeBitSet(optionals, 1); if (struct.isSetSuccess()) { struct.success.write(oprot); } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, getUser_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { struct.success = new User(); struct.success.read(iprot); struct.setSuccessIsSet(true); } } } private static S scheme(org.apache.thrift.protocol.TProtocol proto) { return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); } } public static class listUser_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("listUser_args"); private static final org.apache.thrift.protocol.TField PAGE_NO_FIELD_DESC = new org.apache.thrift.protocol.TField("pageNo", org.apache.thrift.protocol.TType.I32, (short)1); private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new listUser_argsStandardSchemeFactory(); private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new listUser_argsTupleSchemeFactory(); public int pageNo; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { PAGE_NO((short)1, "pageNo"); private static final java.util.Map byName = new java.util.HashMap(); static { for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 1: // PAGE_NO return PAGE_NO; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(java.lang.String name) { return byName.get(name); } private final short _thriftId; private final java.lang.String _fieldName; _Fields(short thriftId, java.lang.String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public java.lang.String getFieldName() { return _fieldName; } } // isset id assignments private static final int __PAGENO_ISSET_ID = 0; private byte __isset_bitfield = 0; public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.PAGE_NO, new org.apache.thrift.meta_data.FieldMetaData("pageNo", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(listUser_args.class, metaDataMap); } public listUser_args() { } public listUser_args( int pageNo) { this(); this.pageNo = pageNo; setPageNoIsSet(true); } /** * Performs a deep copy on other. */ public listUser_args(listUser_args other) { __isset_bitfield = other.__isset_bitfield; this.pageNo = other.pageNo; } public listUser_args deepCopy() { return new listUser_args(this); } @Override public void clear() { setPageNoIsSet(false); this.pageNo = 0; } public int getPageNo() { return this.pageNo; } public listUser_args setPageNo(int pageNo) { this.pageNo = pageNo; setPageNoIsSet(true); return this; } public void unsetPageNo() { __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __PAGENO_ISSET_ID); } /** Returns true if field pageNo is set (has been assigned a value) and false otherwise */ public boolean isSetPageNo() { return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __PAGENO_ISSET_ID); } public void setPageNoIsSet(boolean value) { __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __PAGENO_ISSET_ID, value); } public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case PAGE_NO: if (value == null) { unsetPageNo(); } else { setPageNo((java.lang.Integer)value); } break; } } public java.lang.Object getFieldValue(_Fields field) { switch (field) { case PAGE_NO: return getPageNo(); } throw new java.lang.IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { case PAGE_NO: return isSetPageNo(); } throw new java.lang.IllegalStateException(); } @Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof listUser_args) return this.equals((listUser_args)that); return false; } public boolean equals(listUser_args that) { if (that == null) return false; if (this == that) return true; boolean this_present_pageNo = true; boolean that_present_pageNo = true; if (this_present_pageNo || that_present_pageNo) { if (!(this_present_pageNo && that_present_pageNo)) return false; if (this.pageNo != that.pageNo) return false; } return true; } @Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + pageNo; return hashCode; } @Override public int compareTo(listUser_args other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = java.lang.Boolean.valueOf(isSetPageNo()).compareTo(other.isSetPageNo()); if (lastComparison != 0) { return lastComparison; } if (isSetPageNo()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.pageNo, other.pageNo); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { scheme(iprot).read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { scheme(oprot).write(oprot, this); } @Override public java.lang.String toString() { java.lang.StringBuilder sb = new java.lang.StringBuilder("listUser_args("); boolean first = true; sb.append("pageNo:"); sb.append(this.pageNo); first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields // check for sub-struct validity } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { try { // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. __isset_bitfield = 0; read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class listUser_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public listUser_argsStandardScheme getScheme() { return new listUser_argsStandardScheme(); } } private static class listUser_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme { public void read(org.apache.thrift.protocol.TProtocol iprot, listUser_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 1: // PAGE_NO if (schemeField.type == org.apache.thrift.protocol.TType.I32) { struct.pageNo = iprot.readI32(); struct.setPageNoIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, listUser_args struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); oprot.writeFieldBegin(PAGE_NO_FIELD_DESC); oprot.writeI32(struct.pageNo); oprot.writeFieldEnd(); oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class listUser_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public listUser_argsTupleScheme getScheme() { return new listUser_argsTupleScheme(); } } private static class listUser_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme { @Override public void write(org.apache.thrift.protocol.TProtocol prot, listUser_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet optionals = new java.util.BitSet(); if (struct.isSetPageNo()) { optionals.set(0); } oprot.writeBitSet(optionals, 1); if (struct.isSetPageNo()) { oprot.writeI32(struct.pageNo); } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, listUser_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { struct.pageNo = iprot.readI32(); struct.setPageNoIsSet(true); } } } private static S scheme(org.apache.thrift.protocol.TProtocol proto) { return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); } } public static class listUser_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("listUser_result"); private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRUCT, (short)0); private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new listUser_resultStandardSchemeFactory(); private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new listUser_resultTupleSchemeFactory(); public UserPage success; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { SUCCESS((short)0, "success"); private static final java.util.Map byName = new java.util.HashMap(); static { for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 0: // SUCCESS return SUCCESS; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(java.lang.String name) { return byName.get(name); } private final short _thriftId; private final java.lang.String _fieldName; _Fields(short thriftId, java.lang.String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public java.lang.String getFieldName() { return _fieldName; } } // isset id assignments public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, UserPage.class))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(listUser_result.class, metaDataMap); } public listUser_result() { } public listUser_result( UserPage success) { this(); this.success = success; } /** * Performs a deep copy on other. */ public listUser_result(listUser_result other) { if (other.isSetSuccess()) { this.success = new UserPage(other.success); } } public listUser_result deepCopy() { return new listUser_result(this); } @Override public void clear() { this.success = null; } public UserPage getSuccess() { return this.success; } public listUser_result setSuccess(UserPage success) { this.success = success; return this; } public void unsetSuccess() { this.success = null; } /** Returns true if field success is set (has been assigned a value) and false otherwise */ public boolean isSetSuccess() { return this.success != null; } public void setSuccessIsSet(boolean value) { if (!value) { this.success = null; } } public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case SUCCESS: if (value == null) { unsetSuccess(); } else { setSuccess((UserPage)value); } break; } } public java.lang.Object getFieldValue(_Fields field) { switch (field) { case SUCCESS: return getSuccess(); } throw new java.lang.IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { case SUCCESS: return isSetSuccess(); } throw new java.lang.IllegalStateException(); } @Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof listUser_result) return this.equals((listUser_result)that); return false; } public boolean equals(listUser_result that) { if (that == null) return false; if (this == that) return true; boolean this_present_success = true && this.isSetSuccess(); boolean that_present_success = true && that.isSetSuccess(); if (this_present_success || that_present_success) { if (!(this_present_success && that_present_success)) return false; if (!this.success.equals(that.success)) return false; } return true; } @Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + ((isSetSuccess()) ? 131071 : 524287); if (isSetSuccess()) hashCode = hashCode * 8191 + success.hashCode(); return hashCode; } @Override public int compareTo(listUser_result other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = java.lang.Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess()); if (lastComparison != 0) { return lastComparison; } if (isSetSuccess()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { scheme(iprot).read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { scheme(oprot).write(oprot, this); } @Override public java.lang.String toString() { java.lang.StringBuilder sb = new java.lang.StringBuilder("listUser_result("); boolean first = true; sb.append("success:"); if (this.success == null) { sb.append("null"); } else { sb.append(this.success); } first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields // check for sub-struct validity if (success != null) { success.validate(); } } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { try { read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class listUser_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public listUser_resultStandardScheme getScheme() { return new listUser_resultStandardScheme(); } } private static class listUser_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme { public void read(org.apache.thrift.protocol.TProtocol iprot, listUser_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 0: // SUCCESS if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { struct.success = new UserPage(); struct.success.read(iprot); struct.setSuccessIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, listUser_result struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.success != null) { oprot.writeFieldBegin(SUCCESS_FIELD_DESC); struct.success.write(oprot); oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class listUser_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public listUser_resultTupleScheme getScheme() { return new listUser_resultTupleScheme(); } } private static class listUser_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme { @Override public void write(org.apache.thrift.protocol.TProtocol prot, listUser_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet optionals = new java.util.BitSet(); if (struct.isSetSuccess()) { optionals.set(0); } oprot.writeBitSet(optionals, 1); if (struct.isSetSuccess()) { struct.success.write(oprot); } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, listUser_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { struct.success = new UserPage(); struct.success.read(iprot); struct.setSuccessIsSet(true); } } } private static S scheme(org.apache.thrift.protocol.TProtocol proto) { return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); } } } ================================================ FILE: thrift-server/src/main/java/benchmark/rpc/thrift/UserServiceThriftServerImpl.java ================================================ package benchmark.rpc.thrift; import java.util.ArrayList; import java.util.List; import org.apache.thrift.TException; import benchmark.bean.Page; import benchmark.service.UserServiceServerImpl; public class UserServiceThriftServerImpl implements UserService.Iface { private final benchmark.service.UserService userService = new UserServiceServerImpl(); @Override public boolean userExist(String email) throws TException { return userService.existUser(email); } @Override public boolean createUser(User user) throws TException { benchmark.bean.User rawUser = Converter.toRaw(user); return userService.createUser(rawUser); } @Override public User getUser(long id) throws TException { benchmark.bean.User rawUser = userService.getUser(id); User user = Converter.toThrift(rawUser); return user; } @Override public UserPage listUser(int pageNo) throws TException { Page page = userService.listUser(pageNo); List userList = new ArrayList<>(); for (benchmark.bean.User rawUser : page.getResult()) { User user = Converter.toThrift(rawUser); userList.add(user); } UserPage userPage = new UserPage(); userPage.setPageNo(page.getPageNo()); userPage.setTotal(page.getTotal()); userPage.setResult(userList); return userPage; } } ================================================ FILE: thrift-server/src/main/thrift/UserService.thrift ================================================ namespace java benchmark.rpc.thrift struct User { 1: i64 id, 2: string name, 3: i32 sex, 4: i32 birthday, 5: string email, 6: string mobile, 7: string address, 8: string icon, 9: list permissions, 10: i32 status, 11: i64 createTime, 12: i64 updateTime, } struct UserPage { 1: i32 pageNo, 2: i32 total, 3: list result, } service UserService { bool userExist(1: string email), bool createUser(1: User user), User getUser(1: i64 id), UserPage listUser(1: i32 pageNo) } ================================================ FILE: thrift-server/src/main/thrift/gen-java/benchmark/rpc/thrift/User.java ================================================ /** * Autogenerated by Thrift Compiler (0.10.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated */ package benchmark.rpc.thrift; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) @javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.10.0)", date = "2018-01-02") public class User implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("User"); private static final org.apache.thrift.protocol.TField ID_FIELD_DESC = new org.apache.thrift.protocol.TField("id", org.apache.thrift.protocol.TType.I64, (short)1); private static final org.apache.thrift.protocol.TField NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("name", org.apache.thrift.protocol.TType.STRING, (short)2); private static final org.apache.thrift.protocol.TField SEX_FIELD_DESC = new org.apache.thrift.protocol.TField("sex", org.apache.thrift.protocol.TType.I32, (short)3); private static final org.apache.thrift.protocol.TField BIRTHDAY_FIELD_DESC = new org.apache.thrift.protocol.TField("birthday", org.apache.thrift.protocol.TType.I32, (short)4); private static final org.apache.thrift.protocol.TField EMAIL_FIELD_DESC = new org.apache.thrift.protocol.TField("email", org.apache.thrift.protocol.TType.STRING, (short)5); private static final org.apache.thrift.protocol.TField MOBILE_FIELD_DESC = new org.apache.thrift.protocol.TField("mobile", org.apache.thrift.protocol.TType.STRING, (short)6); private static final org.apache.thrift.protocol.TField ADDRESS_FIELD_DESC = new org.apache.thrift.protocol.TField("address", org.apache.thrift.protocol.TType.STRING, (short)7); private static final org.apache.thrift.protocol.TField ICON_FIELD_DESC = new org.apache.thrift.protocol.TField("icon", org.apache.thrift.protocol.TType.STRING, (short)8); private static final org.apache.thrift.protocol.TField PERMISSIONS_FIELD_DESC = new org.apache.thrift.protocol.TField("permissions", org.apache.thrift.protocol.TType.LIST, (short)9); private static final org.apache.thrift.protocol.TField STATUS_FIELD_DESC = new org.apache.thrift.protocol.TField("status", org.apache.thrift.protocol.TType.I32, (short)10); private static final org.apache.thrift.protocol.TField CREATE_TIME_FIELD_DESC = new org.apache.thrift.protocol.TField("createTime", org.apache.thrift.protocol.TType.I64, (short)11); private static final org.apache.thrift.protocol.TField UPDATE_TIME_FIELD_DESC = new org.apache.thrift.protocol.TField("updateTime", org.apache.thrift.protocol.TType.I64, (short)12); private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new UserStandardSchemeFactory(); private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new UserTupleSchemeFactory(); public long id; // required public java.lang.String name; // required public int sex; // required public int birthday; // required public java.lang.String email; // required public java.lang.String mobile; // required public java.lang.String address; // required public java.lang.String icon; // required public java.util.List permissions; // required public int status; // required public long createTime; // required public long updateTime; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { ID((short)1, "id"), NAME((short)2, "name"), SEX((short)3, "sex"), BIRTHDAY((short)4, "birthday"), EMAIL((short)5, "email"), MOBILE((short)6, "mobile"), ADDRESS((short)7, "address"), ICON((short)8, "icon"), PERMISSIONS((short)9, "permissions"), STATUS((short)10, "status"), CREATE_TIME((short)11, "createTime"), UPDATE_TIME((short)12, "updateTime"); private static final java.util.Map byName = new java.util.HashMap(); static { for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 1: // ID return ID; case 2: // NAME return NAME; case 3: // SEX return SEX; case 4: // BIRTHDAY return BIRTHDAY; case 5: // EMAIL return EMAIL; case 6: // MOBILE return MOBILE; case 7: // ADDRESS return ADDRESS; case 8: // ICON return ICON; case 9: // PERMISSIONS return PERMISSIONS; case 10: // STATUS return STATUS; case 11: // CREATE_TIME return CREATE_TIME; case 12: // UPDATE_TIME return UPDATE_TIME; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(java.lang.String name) { return byName.get(name); } private final short _thriftId; private final java.lang.String _fieldName; _Fields(short thriftId, java.lang.String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public java.lang.String getFieldName() { return _fieldName; } } // isset id assignments private static final int __ID_ISSET_ID = 0; private static final int __SEX_ISSET_ID = 1; private static final int __BIRTHDAY_ISSET_ID = 2; private static final int __STATUS_ISSET_ID = 3; private static final int __CREATETIME_ISSET_ID = 4; private static final int __UPDATETIME_ISSET_ID = 5; private byte __isset_bitfield = 0; public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.ID, new org.apache.thrift.meta_data.FieldMetaData("id", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))); tmpMap.put(_Fields.NAME, new org.apache.thrift.meta_data.FieldMetaData("name", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); tmpMap.put(_Fields.SEX, new org.apache.thrift.meta_data.FieldMetaData("sex", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); tmpMap.put(_Fields.BIRTHDAY, new org.apache.thrift.meta_data.FieldMetaData("birthday", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); tmpMap.put(_Fields.EMAIL, new org.apache.thrift.meta_data.FieldMetaData("email", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); tmpMap.put(_Fields.MOBILE, new org.apache.thrift.meta_data.FieldMetaData("mobile", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); tmpMap.put(_Fields.ADDRESS, new org.apache.thrift.meta_data.FieldMetaData("address", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); tmpMap.put(_Fields.ICON, new org.apache.thrift.meta_data.FieldMetaData("icon", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); tmpMap.put(_Fields.PERMISSIONS, new org.apache.thrift.meta_data.FieldMetaData("permissions", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)))); tmpMap.put(_Fields.STATUS, new org.apache.thrift.meta_data.FieldMetaData("status", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); tmpMap.put(_Fields.CREATE_TIME, new org.apache.thrift.meta_data.FieldMetaData("createTime", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))); tmpMap.put(_Fields.UPDATE_TIME, new org.apache.thrift.meta_data.FieldMetaData("updateTime", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(User.class, metaDataMap); } public User() { } public User( long id, java.lang.String name, int sex, int birthday, java.lang.String email, java.lang.String mobile, java.lang.String address, java.lang.String icon, java.util.List permissions, int status, long createTime, long updateTime) { this(); this.id = id; setIdIsSet(true); this.name = name; this.sex = sex; setSexIsSet(true); this.birthday = birthday; setBirthdayIsSet(true); this.email = email; this.mobile = mobile; this.address = address; this.icon = icon; this.permissions = permissions; this.status = status; setStatusIsSet(true); this.createTime = createTime; setCreateTimeIsSet(true); this.updateTime = updateTime; setUpdateTimeIsSet(true); } /** * Performs a deep copy on other. */ public User(User other) { __isset_bitfield = other.__isset_bitfield; this.id = other.id; if (other.isSetName()) { this.name = other.name; } this.sex = other.sex; this.birthday = other.birthday; if (other.isSetEmail()) { this.email = other.email; } if (other.isSetMobile()) { this.mobile = other.mobile; } if (other.isSetAddress()) { this.address = other.address; } if (other.isSetIcon()) { this.icon = other.icon; } if (other.isSetPermissions()) { java.util.List __this__permissions = new java.util.ArrayList(other.permissions); this.permissions = __this__permissions; } this.status = other.status; this.createTime = other.createTime; this.updateTime = other.updateTime; } public User deepCopy() { return new User(this); } @Override public void clear() { setIdIsSet(false); this.id = 0; this.name = null; setSexIsSet(false); this.sex = 0; setBirthdayIsSet(false); this.birthday = 0; this.email = null; this.mobile = null; this.address = null; this.icon = null; this.permissions = null; setStatusIsSet(false); this.status = 0; setCreateTimeIsSet(false); this.createTime = 0; setUpdateTimeIsSet(false); this.updateTime = 0; } public long getId() { return this.id; } public User setId(long id) { this.id = id; setIdIsSet(true); return this; } public void unsetId() { __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __ID_ISSET_ID); } /** Returns true if field id is set (has been assigned a value) and false otherwise */ public boolean isSetId() { return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __ID_ISSET_ID); } public void setIdIsSet(boolean value) { __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __ID_ISSET_ID, value); } public java.lang.String getName() { return this.name; } public User setName(java.lang.String name) { this.name = name; return this; } public void unsetName() { this.name = null; } /** Returns true if field name is set (has been assigned a value) and false otherwise */ public boolean isSetName() { return this.name != null; } public void setNameIsSet(boolean value) { if (!value) { this.name = null; } } public int getSex() { return this.sex; } public User setSex(int sex) { this.sex = sex; setSexIsSet(true); return this; } public void unsetSex() { __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __SEX_ISSET_ID); } /** Returns true if field sex is set (has been assigned a value) and false otherwise */ public boolean isSetSex() { return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __SEX_ISSET_ID); } public void setSexIsSet(boolean value) { __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __SEX_ISSET_ID, value); } public int getBirthday() { return this.birthday; } public User setBirthday(int birthday) { this.birthday = birthday; setBirthdayIsSet(true); return this; } public void unsetBirthday() { __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __BIRTHDAY_ISSET_ID); } /** Returns true if field birthday is set (has been assigned a value) and false otherwise */ public boolean isSetBirthday() { return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __BIRTHDAY_ISSET_ID); } public void setBirthdayIsSet(boolean value) { __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __BIRTHDAY_ISSET_ID, value); } public java.lang.String getEmail() { return this.email; } public User setEmail(java.lang.String email) { this.email = email; return this; } public void unsetEmail() { this.email = null; } /** Returns true if field email is set (has been assigned a value) and false otherwise */ public boolean isSetEmail() { return this.email != null; } public void setEmailIsSet(boolean value) { if (!value) { this.email = null; } } public java.lang.String getMobile() { return this.mobile; } public User setMobile(java.lang.String mobile) { this.mobile = mobile; return this; } public void unsetMobile() { this.mobile = null; } /** Returns true if field mobile is set (has been assigned a value) and false otherwise */ public boolean isSetMobile() { return this.mobile != null; } public void setMobileIsSet(boolean value) { if (!value) { this.mobile = null; } } public java.lang.String getAddress() { return this.address; } public User setAddress(java.lang.String address) { this.address = address; return this; } public void unsetAddress() { this.address = null; } /** Returns true if field address is set (has been assigned a value) and false otherwise */ public boolean isSetAddress() { return this.address != null; } public void setAddressIsSet(boolean value) { if (!value) { this.address = null; } } public java.lang.String getIcon() { return this.icon; } public User setIcon(java.lang.String icon) { this.icon = icon; return this; } public void unsetIcon() { this.icon = null; } /** Returns true if field icon is set (has been assigned a value) and false otherwise */ public boolean isSetIcon() { return this.icon != null; } public void setIconIsSet(boolean value) { if (!value) { this.icon = null; } } public int getPermissionsSize() { return (this.permissions == null) ? 0 : this.permissions.size(); } public java.util.Iterator getPermissionsIterator() { return (this.permissions == null) ? null : this.permissions.iterator(); } public void addToPermissions(int elem) { if (this.permissions == null) { this.permissions = new java.util.ArrayList(); } this.permissions.add(elem); } public java.util.List getPermissions() { return this.permissions; } public User setPermissions(java.util.List permissions) { this.permissions = permissions; return this; } public void unsetPermissions() { this.permissions = null; } /** Returns true if field permissions is set (has been assigned a value) and false otherwise */ public boolean isSetPermissions() { return this.permissions != null; } public void setPermissionsIsSet(boolean value) { if (!value) { this.permissions = null; } } public int getStatus() { return this.status; } public User setStatus(int status) { this.status = status; setStatusIsSet(true); return this; } public void unsetStatus() { __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __STATUS_ISSET_ID); } /** Returns true if field status is set (has been assigned a value) and false otherwise */ public boolean isSetStatus() { return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __STATUS_ISSET_ID); } public void setStatusIsSet(boolean value) { __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __STATUS_ISSET_ID, value); } public long getCreateTime() { return this.createTime; } public User setCreateTime(long createTime) { this.createTime = createTime; setCreateTimeIsSet(true); return this; } public void unsetCreateTime() { __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __CREATETIME_ISSET_ID); } /** Returns true if field createTime is set (has been assigned a value) and false otherwise */ public boolean isSetCreateTime() { return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __CREATETIME_ISSET_ID); } public void setCreateTimeIsSet(boolean value) { __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __CREATETIME_ISSET_ID, value); } public long getUpdateTime() { return this.updateTime; } public User setUpdateTime(long updateTime) { this.updateTime = updateTime; setUpdateTimeIsSet(true); return this; } public void unsetUpdateTime() { __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __UPDATETIME_ISSET_ID); } /** Returns true if field updateTime is set (has been assigned a value) and false otherwise */ public boolean isSetUpdateTime() { return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __UPDATETIME_ISSET_ID); } public void setUpdateTimeIsSet(boolean value) { __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __UPDATETIME_ISSET_ID, value); } public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case ID: if (value == null) { unsetId(); } else { setId((java.lang.Long)value); } break; case NAME: if (value == null) { unsetName(); } else { setName((java.lang.String)value); } break; case SEX: if (value == null) { unsetSex(); } else { setSex((java.lang.Integer)value); } break; case BIRTHDAY: if (value == null) { unsetBirthday(); } else { setBirthday((java.lang.Integer)value); } break; case EMAIL: if (value == null) { unsetEmail(); } else { setEmail((java.lang.String)value); } break; case MOBILE: if (value == null) { unsetMobile(); } else { setMobile((java.lang.String)value); } break; case ADDRESS: if (value == null) { unsetAddress(); } else { setAddress((java.lang.String)value); } break; case ICON: if (value == null) { unsetIcon(); } else { setIcon((java.lang.String)value); } break; case PERMISSIONS: if (value == null) { unsetPermissions(); } else { setPermissions((java.util.List)value); } break; case STATUS: if (value == null) { unsetStatus(); } else { setStatus((java.lang.Integer)value); } break; case CREATE_TIME: if (value == null) { unsetCreateTime(); } else { setCreateTime((java.lang.Long)value); } break; case UPDATE_TIME: if (value == null) { unsetUpdateTime(); } else { setUpdateTime((java.lang.Long)value); } break; } } public java.lang.Object getFieldValue(_Fields field) { switch (field) { case ID: return getId(); case NAME: return getName(); case SEX: return getSex(); case BIRTHDAY: return getBirthday(); case EMAIL: return getEmail(); case MOBILE: return getMobile(); case ADDRESS: return getAddress(); case ICON: return getIcon(); case PERMISSIONS: return getPermissions(); case STATUS: return getStatus(); case CREATE_TIME: return getCreateTime(); case UPDATE_TIME: return getUpdateTime(); } throw new java.lang.IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { case ID: return isSetId(); case NAME: return isSetName(); case SEX: return isSetSex(); case BIRTHDAY: return isSetBirthday(); case EMAIL: return isSetEmail(); case MOBILE: return isSetMobile(); case ADDRESS: return isSetAddress(); case ICON: return isSetIcon(); case PERMISSIONS: return isSetPermissions(); case STATUS: return isSetStatus(); case CREATE_TIME: return isSetCreateTime(); case UPDATE_TIME: return isSetUpdateTime(); } throw new java.lang.IllegalStateException(); } @Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof User) return this.equals((User)that); return false; } public boolean equals(User that) { if (that == null) return false; if (this == that) return true; boolean this_present_id = true; boolean that_present_id = true; if (this_present_id || that_present_id) { if (!(this_present_id && that_present_id)) return false; if (this.id != that.id) return false; } boolean this_present_name = true && this.isSetName(); boolean that_present_name = true && that.isSetName(); if (this_present_name || that_present_name) { if (!(this_present_name && that_present_name)) return false; if (!this.name.equals(that.name)) return false; } boolean this_present_sex = true; boolean that_present_sex = true; if (this_present_sex || that_present_sex) { if (!(this_present_sex && that_present_sex)) return false; if (this.sex != that.sex) return false; } boolean this_present_birthday = true; boolean that_present_birthday = true; if (this_present_birthday || that_present_birthday) { if (!(this_present_birthday && that_present_birthday)) return false; if (this.birthday != that.birthday) return false; } boolean this_present_email = true && this.isSetEmail(); boolean that_present_email = true && that.isSetEmail(); if (this_present_email || that_present_email) { if (!(this_present_email && that_present_email)) return false; if (!this.email.equals(that.email)) return false; } boolean this_present_mobile = true && this.isSetMobile(); boolean that_present_mobile = true && that.isSetMobile(); if (this_present_mobile || that_present_mobile) { if (!(this_present_mobile && that_present_mobile)) return false; if (!this.mobile.equals(that.mobile)) return false; } boolean this_present_address = true && this.isSetAddress(); boolean that_present_address = true && that.isSetAddress(); if (this_present_address || that_present_address) { if (!(this_present_address && that_present_address)) return false; if (!this.address.equals(that.address)) return false; } boolean this_present_icon = true && this.isSetIcon(); boolean that_present_icon = true && that.isSetIcon(); if (this_present_icon || that_present_icon) { if (!(this_present_icon && that_present_icon)) return false; if (!this.icon.equals(that.icon)) return false; } boolean this_present_permissions = true && this.isSetPermissions(); boolean that_present_permissions = true && that.isSetPermissions(); if (this_present_permissions || that_present_permissions) { if (!(this_present_permissions && that_present_permissions)) return false; if (!this.permissions.equals(that.permissions)) return false; } boolean this_present_status = true; boolean that_present_status = true; if (this_present_status || that_present_status) { if (!(this_present_status && that_present_status)) return false; if (this.status != that.status) return false; } boolean this_present_createTime = true; boolean that_present_createTime = true; if (this_present_createTime || that_present_createTime) { if (!(this_present_createTime && that_present_createTime)) return false; if (this.createTime != that.createTime) return false; } boolean this_present_updateTime = true; boolean that_present_updateTime = true; if (this_present_updateTime || that_present_updateTime) { if (!(this_present_updateTime && that_present_updateTime)) return false; if (this.updateTime != that.updateTime) return false; } return true; } @Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(id); hashCode = hashCode * 8191 + ((isSetName()) ? 131071 : 524287); if (isSetName()) hashCode = hashCode * 8191 + name.hashCode(); hashCode = hashCode * 8191 + sex; hashCode = hashCode * 8191 + birthday; hashCode = hashCode * 8191 + ((isSetEmail()) ? 131071 : 524287); if (isSetEmail()) hashCode = hashCode * 8191 + email.hashCode(); hashCode = hashCode * 8191 + ((isSetMobile()) ? 131071 : 524287); if (isSetMobile()) hashCode = hashCode * 8191 + mobile.hashCode(); hashCode = hashCode * 8191 + ((isSetAddress()) ? 131071 : 524287); if (isSetAddress()) hashCode = hashCode * 8191 + address.hashCode(); hashCode = hashCode * 8191 + ((isSetIcon()) ? 131071 : 524287); if (isSetIcon()) hashCode = hashCode * 8191 + icon.hashCode(); hashCode = hashCode * 8191 + ((isSetPermissions()) ? 131071 : 524287); if (isSetPermissions()) hashCode = hashCode * 8191 + permissions.hashCode(); hashCode = hashCode * 8191 + status; hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(createTime); hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(updateTime); return hashCode; } @Override public int compareTo(User other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = java.lang.Boolean.valueOf(isSetId()).compareTo(other.isSetId()); if (lastComparison != 0) { return lastComparison; } if (isSetId()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.id, other.id); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetName()).compareTo(other.isSetName()); if (lastComparison != 0) { return lastComparison; } if (isSetName()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.name, other.name); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetSex()).compareTo(other.isSetSex()); if (lastComparison != 0) { return lastComparison; } if (isSetSex()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.sex, other.sex); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetBirthday()).compareTo(other.isSetBirthday()); if (lastComparison != 0) { return lastComparison; } if (isSetBirthday()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.birthday, other.birthday); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetEmail()).compareTo(other.isSetEmail()); if (lastComparison != 0) { return lastComparison; } if (isSetEmail()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.email, other.email); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetMobile()).compareTo(other.isSetMobile()); if (lastComparison != 0) { return lastComparison; } if (isSetMobile()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.mobile, other.mobile); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetAddress()).compareTo(other.isSetAddress()); if (lastComparison != 0) { return lastComparison; } if (isSetAddress()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.address, other.address); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetIcon()).compareTo(other.isSetIcon()); if (lastComparison != 0) { return lastComparison; } if (isSetIcon()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.icon, other.icon); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetPermissions()).compareTo(other.isSetPermissions()); if (lastComparison != 0) { return lastComparison; } if (isSetPermissions()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.permissions, other.permissions); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetStatus()).compareTo(other.isSetStatus()); if (lastComparison != 0) { return lastComparison; } if (isSetStatus()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.status, other.status); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetCreateTime()).compareTo(other.isSetCreateTime()); if (lastComparison != 0) { return lastComparison; } if (isSetCreateTime()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.createTime, other.createTime); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetUpdateTime()).compareTo(other.isSetUpdateTime()); if (lastComparison != 0) { return lastComparison; } if (isSetUpdateTime()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.updateTime, other.updateTime); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { scheme(iprot).read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { scheme(oprot).write(oprot, this); } @Override public java.lang.String toString() { java.lang.StringBuilder sb = new java.lang.StringBuilder("User("); boolean first = true; sb.append("id:"); sb.append(this.id); first = false; if (!first) sb.append(", "); sb.append("name:"); if (this.name == null) { sb.append("null"); } else { sb.append(this.name); } first = false; if (!first) sb.append(", "); sb.append("sex:"); sb.append(this.sex); first = false; if (!first) sb.append(", "); sb.append("birthday:"); sb.append(this.birthday); first = false; if (!first) sb.append(", "); sb.append("email:"); if (this.email == null) { sb.append("null"); } else { sb.append(this.email); } first = false; if (!first) sb.append(", "); sb.append("mobile:"); if (this.mobile == null) { sb.append("null"); } else { sb.append(this.mobile); } first = false; if (!first) sb.append(", "); sb.append("address:"); if (this.address == null) { sb.append("null"); } else { sb.append(this.address); } first = false; if (!first) sb.append(", "); sb.append("icon:"); if (this.icon == null) { sb.append("null"); } else { sb.append(this.icon); } first = false; if (!first) sb.append(", "); sb.append("permissions:"); if (this.permissions == null) { sb.append("null"); } else { sb.append(this.permissions); } first = false; if (!first) sb.append(", "); sb.append("status:"); sb.append(this.status); first = false; if (!first) sb.append(", "); sb.append("createTime:"); sb.append(this.createTime); first = false; if (!first) sb.append(", "); sb.append("updateTime:"); sb.append(this.updateTime); first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields // check for sub-struct validity } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { try { // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. __isset_bitfield = 0; read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class UserStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public UserStandardScheme getScheme() { return new UserStandardScheme(); } } private static class UserStandardScheme extends org.apache.thrift.scheme.StandardScheme { public void read(org.apache.thrift.protocol.TProtocol iprot, User struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 1: // ID if (schemeField.type == org.apache.thrift.protocol.TType.I64) { struct.id = iprot.readI64(); struct.setIdIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 2: // NAME if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.name = iprot.readString(); struct.setNameIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 3: // SEX if (schemeField.type == org.apache.thrift.protocol.TType.I32) { struct.sex = iprot.readI32(); struct.setSexIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 4: // BIRTHDAY if (schemeField.type == org.apache.thrift.protocol.TType.I32) { struct.birthday = iprot.readI32(); struct.setBirthdayIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 5: // EMAIL if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.email = iprot.readString(); struct.setEmailIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 6: // MOBILE if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.mobile = iprot.readString(); struct.setMobileIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 7: // ADDRESS if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.address = iprot.readString(); struct.setAddressIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 8: // ICON if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.icon = iprot.readString(); struct.setIconIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 9: // PERMISSIONS if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { org.apache.thrift.protocol.TList _list0 = iprot.readListBegin(); struct.permissions = new java.util.ArrayList(_list0.size); int _elem1; for (int _i2 = 0; _i2 < _list0.size; ++_i2) { _elem1 = iprot.readI32(); struct.permissions.add(_elem1); } iprot.readListEnd(); } struct.setPermissionsIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 10: // STATUS if (schemeField.type == org.apache.thrift.protocol.TType.I32) { struct.status = iprot.readI32(); struct.setStatusIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 11: // CREATE_TIME if (schemeField.type == org.apache.thrift.protocol.TType.I64) { struct.createTime = iprot.readI64(); struct.setCreateTimeIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 12: // UPDATE_TIME if (schemeField.type == org.apache.thrift.protocol.TType.I64) { struct.updateTime = iprot.readI64(); struct.setUpdateTimeIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, User struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); oprot.writeFieldBegin(ID_FIELD_DESC); oprot.writeI64(struct.id); oprot.writeFieldEnd(); if (struct.name != null) { oprot.writeFieldBegin(NAME_FIELD_DESC); oprot.writeString(struct.name); oprot.writeFieldEnd(); } oprot.writeFieldBegin(SEX_FIELD_DESC); oprot.writeI32(struct.sex); oprot.writeFieldEnd(); oprot.writeFieldBegin(BIRTHDAY_FIELD_DESC); oprot.writeI32(struct.birthday); oprot.writeFieldEnd(); if (struct.email != null) { oprot.writeFieldBegin(EMAIL_FIELD_DESC); oprot.writeString(struct.email); oprot.writeFieldEnd(); } if (struct.mobile != null) { oprot.writeFieldBegin(MOBILE_FIELD_DESC); oprot.writeString(struct.mobile); oprot.writeFieldEnd(); } if (struct.address != null) { oprot.writeFieldBegin(ADDRESS_FIELD_DESC); oprot.writeString(struct.address); oprot.writeFieldEnd(); } if (struct.icon != null) { oprot.writeFieldBegin(ICON_FIELD_DESC); oprot.writeString(struct.icon); oprot.writeFieldEnd(); } if (struct.permissions != null) { oprot.writeFieldBegin(PERMISSIONS_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, struct.permissions.size())); for (int _iter3 : struct.permissions) { oprot.writeI32(_iter3); } oprot.writeListEnd(); } oprot.writeFieldEnd(); } oprot.writeFieldBegin(STATUS_FIELD_DESC); oprot.writeI32(struct.status); oprot.writeFieldEnd(); oprot.writeFieldBegin(CREATE_TIME_FIELD_DESC); oprot.writeI64(struct.createTime); oprot.writeFieldEnd(); oprot.writeFieldBegin(UPDATE_TIME_FIELD_DESC); oprot.writeI64(struct.updateTime); oprot.writeFieldEnd(); oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class UserTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public UserTupleScheme getScheme() { return new UserTupleScheme(); } } private static class UserTupleScheme extends org.apache.thrift.scheme.TupleScheme { @Override public void write(org.apache.thrift.protocol.TProtocol prot, User struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet optionals = new java.util.BitSet(); if (struct.isSetId()) { optionals.set(0); } if (struct.isSetName()) { optionals.set(1); } if (struct.isSetSex()) { optionals.set(2); } if (struct.isSetBirthday()) { optionals.set(3); } if (struct.isSetEmail()) { optionals.set(4); } if (struct.isSetMobile()) { optionals.set(5); } if (struct.isSetAddress()) { optionals.set(6); } if (struct.isSetIcon()) { optionals.set(7); } if (struct.isSetPermissions()) { optionals.set(8); } if (struct.isSetStatus()) { optionals.set(9); } if (struct.isSetCreateTime()) { optionals.set(10); } if (struct.isSetUpdateTime()) { optionals.set(11); } oprot.writeBitSet(optionals, 12); if (struct.isSetId()) { oprot.writeI64(struct.id); } if (struct.isSetName()) { oprot.writeString(struct.name); } if (struct.isSetSex()) { oprot.writeI32(struct.sex); } if (struct.isSetBirthday()) { oprot.writeI32(struct.birthday); } if (struct.isSetEmail()) { oprot.writeString(struct.email); } if (struct.isSetMobile()) { oprot.writeString(struct.mobile); } if (struct.isSetAddress()) { oprot.writeString(struct.address); } if (struct.isSetIcon()) { oprot.writeString(struct.icon); } if (struct.isSetPermissions()) { { oprot.writeI32(struct.permissions.size()); for (int _iter4 : struct.permissions) { oprot.writeI32(_iter4); } } } if (struct.isSetStatus()) { oprot.writeI32(struct.status); } if (struct.isSetCreateTime()) { oprot.writeI64(struct.createTime); } if (struct.isSetUpdateTime()) { oprot.writeI64(struct.updateTime); } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, User struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet incoming = iprot.readBitSet(12); if (incoming.get(0)) { struct.id = iprot.readI64(); struct.setIdIsSet(true); } if (incoming.get(1)) { struct.name = iprot.readString(); struct.setNameIsSet(true); } if (incoming.get(2)) { struct.sex = iprot.readI32(); struct.setSexIsSet(true); } if (incoming.get(3)) { struct.birthday = iprot.readI32(); struct.setBirthdayIsSet(true); } if (incoming.get(4)) { struct.email = iprot.readString(); struct.setEmailIsSet(true); } if (incoming.get(5)) { struct.mobile = iprot.readString(); struct.setMobileIsSet(true); } if (incoming.get(6)) { struct.address = iprot.readString(); struct.setAddressIsSet(true); } if (incoming.get(7)) { struct.icon = iprot.readString(); struct.setIconIsSet(true); } if (incoming.get(8)) { { org.apache.thrift.protocol.TList _list5 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); struct.permissions = new java.util.ArrayList(_list5.size); int _elem6; for (int _i7 = 0; _i7 < _list5.size; ++_i7) { _elem6 = iprot.readI32(); struct.permissions.add(_elem6); } } struct.setPermissionsIsSet(true); } if (incoming.get(9)) { struct.status = iprot.readI32(); struct.setStatusIsSet(true); } if (incoming.get(10)) { struct.createTime = iprot.readI64(); struct.setCreateTimeIsSet(true); } if (incoming.get(11)) { struct.updateTime = iprot.readI64(); struct.setUpdateTimeIsSet(true); } } } private static S scheme(org.apache.thrift.protocol.TProtocol proto) { return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); } } ================================================ FILE: thrift-server/src/main/thrift/gen-java/benchmark/rpc/thrift/UserPage.java ================================================ /** * Autogenerated by Thrift Compiler (0.10.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated */ package benchmark.rpc.thrift; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) @javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.10.0)", date = "2018-01-02") public class UserPage implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("UserPage"); private static final org.apache.thrift.protocol.TField PAGE_NO_FIELD_DESC = new org.apache.thrift.protocol.TField("pageNo", org.apache.thrift.protocol.TType.I32, (short)1); private static final org.apache.thrift.protocol.TField TOTAL_FIELD_DESC = new org.apache.thrift.protocol.TField("total", org.apache.thrift.protocol.TType.I32, (short)2); private static final org.apache.thrift.protocol.TField RESULT_FIELD_DESC = new org.apache.thrift.protocol.TField("result", org.apache.thrift.protocol.TType.LIST, (short)3); private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new UserPageStandardSchemeFactory(); private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new UserPageTupleSchemeFactory(); public int pageNo; // required public int total; // required public java.util.List result; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { PAGE_NO((short)1, "pageNo"), TOTAL((short)2, "total"), RESULT((short)3, "result"); private static final java.util.Map byName = new java.util.HashMap(); static { for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 1: // PAGE_NO return PAGE_NO; case 2: // TOTAL return TOTAL; case 3: // RESULT return RESULT; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(java.lang.String name) { return byName.get(name); } private final short _thriftId; private final java.lang.String _fieldName; _Fields(short thriftId, java.lang.String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public java.lang.String getFieldName() { return _fieldName; } } // isset id assignments private static final int __PAGENO_ISSET_ID = 0; private static final int __TOTAL_ISSET_ID = 1; private byte __isset_bitfield = 0; public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.PAGE_NO, new org.apache.thrift.meta_data.FieldMetaData("pageNo", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); tmpMap.put(_Fields.TOTAL, new org.apache.thrift.meta_data.FieldMetaData("total", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); tmpMap.put(_Fields.RESULT, new org.apache.thrift.meta_data.FieldMetaData("result", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, User.class)))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(UserPage.class, metaDataMap); } public UserPage() { } public UserPage( int pageNo, int total, java.util.List result) { this(); this.pageNo = pageNo; setPageNoIsSet(true); this.total = total; setTotalIsSet(true); this.result = result; } /** * Performs a deep copy on other. */ public UserPage(UserPage other) { __isset_bitfield = other.__isset_bitfield; this.pageNo = other.pageNo; this.total = other.total; if (other.isSetResult()) { java.util.List __this__result = new java.util.ArrayList(other.result.size()); for (User other_element : other.result) { __this__result.add(new User(other_element)); } this.result = __this__result; } } public UserPage deepCopy() { return new UserPage(this); } @Override public void clear() { setPageNoIsSet(false); this.pageNo = 0; setTotalIsSet(false); this.total = 0; this.result = null; } public int getPageNo() { return this.pageNo; } public UserPage setPageNo(int pageNo) { this.pageNo = pageNo; setPageNoIsSet(true); return this; } public void unsetPageNo() { __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __PAGENO_ISSET_ID); } /** Returns true if field pageNo is set (has been assigned a value) and false otherwise */ public boolean isSetPageNo() { return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __PAGENO_ISSET_ID); } public void setPageNoIsSet(boolean value) { __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __PAGENO_ISSET_ID, value); } public int getTotal() { return this.total; } public UserPage setTotal(int total) { this.total = total; setTotalIsSet(true); return this; } public void unsetTotal() { __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __TOTAL_ISSET_ID); } /** Returns true if field total is set (has been assigned a value) and false otherwise */ public boolean isSetTotal() { return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __TOTAL_ISSET_ID); } public void setTotalIsSet(boolean value) { __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __TOTAL_ISSET_ID, value); } public int getResultSize() { return (this.result == null) ? 0 : this.result.size(); } public java.util.Iterator getResultIterator() { return (this.result == null) ? null : this.result.iterator(); } public void addToResult(User elem) { if (this.result == null) { this.result = new java.util.ArrayList(); } this.result.add(elem); } public java.util.List getResult() { return this.result; } public UserPage setResult(java.util.List result) { this.result = result; return this; } public void unsetResult() { this.result = null; } /** Returns true if field result is set (has been assigned a value) and false otherwise */ public boolean isSetResult() { return this.result != null; } public void setResultIsSet(boolean value) { if (!value) { this.result = null; } } public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case PAGE_NO: if (value == null) { unsetPageNo(); } else { setPageNo((java.lang.Integer)value); } break; case TOTAL: if (value == null) { unsetTotal(); } else { setTotal((java.lang.Integer)value); } break; case RESULT: if (value == null) { unsetResult(); } else { setResult((java.util.List)value); } break; } } public java.lang.Object getFieldValue(_Fields field) { switch (field) { case PAGE_NO: return getPageNo(); case TOTAL: return getTotal(); case RESULT: return getResult(); } throw new java.lang.IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { case PAGE_NO: return isSetPageNo(); case TOTAL: return isSetTotal(); case RESULT: return isSetResult(); } throw new java.lang.IllegalStateException(); } @Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof UserPage) return this.equals((UserPage)that); return false; } public boolean equals(UserPage that) { if (that == null) return false; if (this == that) return true; boolean this_present_pageNo = true; boolean that_present_pageNo = true; if (this_present_pageNo || that_present_pageNo) { if (!(this_present_pageNo && that_present_pageNo)) return false; if (this.pageNo != that.pageNo) return false; } boolean this_present_total = true; boolean that_present_total = true; if (this_present_total || that_present_total) { if (!(this_present_total && that_present_total)) return false; if (this.total != that.total) return false; } boolean this_present_result = true && this.isSetResult(); boolean that_present_result = true && that.isSetResult(); if (this_present_result || that_present_result) { if (!(this_present_result && that_present_result)) return false; if (!this.result.equals(that.result)) return false; } return true; } @Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + pageNo; hashCode = hashCode * 8191 + total; hashCode = hashCode * 8191 + ((isSetResult()) ? 131071 : 524287); if (isSetResult()) hashCode = hashCode * 8191 + result.hashCode(); return hashCode; } @Override public int compareTo(UserPage other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = java.lang.Boolean.valueOf(isSetPageNo()).compareTo(other.isSetPageNo()); if (lastComparison != 0) { return lastComparison; } if (isSetPageNo()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.pageNo, other.pageNo); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetTotal()).compareTo(other.isSetTotal()); if (lastComparison != 0) { return lastComparison; } if (isSetTotal()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.total, other.total); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetResult()).compareTo(other.isSetResult()); if (lastComparison != 0) { return lastComparison; } if (isSetResult()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.result, other.result); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { scheme(iprot).read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { scheme(oprot).write(oprot, this); } @Override public java.lang.String toString() { java.lang.StringBuilder sb = new java.lang.StringBuilder("UserPage("); boolean first = true; sb.append("pageNo:"); sb.append(this.pageNo); first = false; if (!first) sb.append(", "); sb.append("total:"); sb.append(this.total); first = false; if (!first) sb.append(", "); sb.append("result:"); if (this.result == null) { sb.append("null"); } else { sb.append(this.result); } first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields // check for sub-struct validity } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { try { // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. __isset_bitfield = 0; read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class UserPageStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public UserPageStandardScheme getScheme() { return new UserPageStandardScheme(); } } private static class UserPageStandardScheme extends org.apache.thrift.scheme.StandardScheme { public void read(org.apache.thrift.protocol.TProtocol iprot, UserPage struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 1: // PAGE_NO if (schemeField.type == org.apache.thrift.protocol.TType.I32) { struct.pageNo = iprot.readI32(); struct.setPageNoIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 2: // TOTAL if (schemeField.type == org.apache.thrift.protocol.TType.I32) { struct.total = iprot.readI32(); struct.setTotalIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 3: // RESULT if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { org.apache.thrift.protocol.TList _list8 = iprot.readListBegin(); struct.result = new java.util.ArrayList(_list8.size); User _elem9; for (int _i10 = 0; _i10 < _list8.size; ++_i10) { _elem9 = new User(); _elem9.read(iprot); struct.result.add(_elem9); } iprot.readListEnd(); } struct.setResultIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, UserPage struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); oprot.writeFieldBegin(PAGE_NO_FIELD_DESC); oprot.writeI32(struct.pageNo); oprot.writeFieldEnd(); oprot.writeFieldBegin(TOTAL_FIELD_DESC); oprot.writeI32(struct.total); oprot.writeFieldEnd(); if (struct.result != null) { oprot.writeFieldBegin(RESULT_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.result.size())); for (User _iter11 : struct.result) { _iter11.write(oprot); } oprot.writeListEnd(); } oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class UserPageTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public UserPageTupleScheme getScheme() { return new UserPageTupleScheme(); } } private static class UserPageTupleScheme extends org.apache.thrift.scheme.TupleScheme { @Override public void write(org.apache.thrift.protocol.TProtocol prot, UserPage struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet optionals = new java.util.BitSet(); if (struct.isSetPageNo()) { optionals.set(0); } if (struct.isSetTotal()) { optionals.set(1); } if (struct.isSetResult()) { optionals.set(2); } oprot.writeBitSet(optionals, 3); if (struct.isSetPageNo()) { oprot.writeI32(struct.pageNo); } if (struct.isSetTotal()) { oprot.writeI32(struct.total); } if (struct.isSetResult()) { { oprot.writeI32(struct.result.size()); for (User _iter12 : struct.result) { _iter12.write(oprot); } } } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, UserPage struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet incoming = iprot.readBitSet(3); if (incoming.get(0)) { struct.pageNo = iprot.readI32(); struct.setPageNoIsSet(true); } if (incoming.get(1)) { struct.total = iprot.readI32(); struct.setTotalIsSet(true); } if (incoming.get(2)) { { org.apache.thrift.protocol.TList _list13 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); struct.result = new java.util.ArrayList(_list13.size); User _elem14; for (int _i15 = 0; _i15 < _list13.size; ++_i15) { _elem14 = new User(); _elem14.read(iprot); struct.result.add(_elem14); } } struct.setResultIsSet(true); } } } private static S scheme(org.apache.thrift.protocol.TProtocol proto) { return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); } } ================================================ FILE: thrift-server/src/main/thrift/gen-java/benchmark/rpc/thrift/UserService.java ================================================ /** * Autogenerated by Thrift Compiler (0.10.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated */ package benchmark.rpc.thrift; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) @javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.10.0)", date = "2018-01-02") public class UserService { public interface Iface { public boolean userExist(java.lang.String email) throws org.apache.thrift.TException; public boolean createUser(User user) throws org.apache.thrift.TException; public User getUser(long id) throws org.apache.thrift.TException; public UserPage listUser(int pageNo) throws org.apache.thrift.TException; } public interface AsyncIface { public void userExist(java.lang.String email, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; public void createUser(User user, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; public void getUser(long id, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; public void listUser(int pageNo, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; } public static class Client extends org.apache.thrift.TServiceClient implements Iface { public static class Factory implements org.apache.thrift.TServiceClientFactory { public Factory() {} public Client getClient(org.apache.thrift.protocol.TProtocol prot) { return new Client(prot); } public Client getClient(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) { return new Client(iprot, oprot); } } public Client(org.apache.thrift.protocol.TProtocol prot) { super(prot, prot); } public Client(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) { super(iprot, oprot); } public boolean userExist(java.lang.String email) throws org.apache.thrift.TException { send_userExist(email); return recv_userExist(); } public void send_userExist(java.lang.String email) throws org.apache.thrift.TException { userExist_args args = new userExist_args(); args.setEmail(email); sendBase("userExist", args); } public boolean recv_userExist() throws org.apache.thrift.TException { userExist_result result = new userExist_result(); receiveBase(result, "userExist"); if (result.isSetSuccess()) { return result.success; } throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "userExist failed: unknown result"); } public boolean createUser(User user) throws org.apache.thrift.TException { send_createUser(user); return recv_createUser(); } public void send_createUser(User user) throws org.apache.thrift.TException { createUser_args args = new createUser_args(); args.setUser(user); sendBase("createUser", args); } public boolean recv_createUser() throws org.apache.thrift.TException { createUser_result result = new createUser_result(); receiveBase(result, "createUser"); if (result.isSetSuccess()) { return result.success; } throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "createUser failed: unknown result"); } public User getUser(long id) throws org.apache.thrift.TException { send_getUser(id); return recv_getUser(); } public void send_getUser(long id) throws org.apache.thrift.TException { getUser_args args = new getUser_args(); args.setId(id); sendBase("getUser", args); } public User recv_getUser() throws org.apache.thrift.TException { getUser_result result = new getUser_result(); receiveBase(result, "getUser"); if (result.isSetSuccess()) { return result.success; } throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getUser failed: unknown result"); } public UserPage listUser(int pageNo) throws org.apache.thrift.TException { send_listUser(pageNo); return recv_listUser(); } public void send_listUser(int pageNo) throws org.apache.thrift.TException { listUser_args args = new listUser_args(); args.setPageNo(pageNo); sendBase("listUser", args); } public UserPage recv_listUser() throws org.apache.thrift.TException { listUser_result result = new listUser_result(); receiveBase(result, "listUser"); if (result.isSetSuccess()) { return result.success; } throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "listUser failed: unknown result"); } } public static class AsyncClient extends org.apache.thrift.async.TAsyncClient implements AsyncIface { public static class Factory implements org.apache.thrift.async.TAsyncClientFactory { private org.apache.thrift.async.TAsyncClientManager clientManager; private org.apache.thrift.protocol.TProtocolFactory protocolFactory; public Factory(org.apache.thrift.async.TAsyncClientManager clientManager, org.apache.thrift.protocol.TProtocolFactory protocolFactory) { this.clientManager = clientManager; this.protocolFactory = protocolFactory; } public AsyncClient getAsyncClient(org.apache.thrift.transport.TNonblockingTransport transport) { return new AsyncClient(protocolFactory, clientManager, transport); } } public AsyncClient(org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.async.TAsyncClientManager clientManager, org.apache.thrift.transport.TNonblockingTransport transport) { super(protocolFactory, clientManager, transport); } public void userExist(java.lang.String email, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { checkReady(); userExist_call method_call = new userExist_call(email, resultHandler, this, ___protocolFactory, ___transport); this.___currentMethod = method_call; ___manager.call(method_call); } public static class userExist_call extends org.apache.thrift.async.TAsyncMethodCall { private java.lang.String email; public userExist_call(java.lang.String email, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { super(client, protocolFactory, transport, resultHandler, false); this.email = email; } public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("userExist", org.apache.thrift.protocol.TMessageType.CALL, 0)); userExist_args args = new userExist_args(); args.setEmail(email); args.write(prot); prot.writeMessageEnd(); } public java.lang.Boolean getResult() throws org.apache.thrift.TException { if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { throw new java.lang.IllegalStateException("Method call not finished!"); } org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); return (new Client(prot)).recv_userExist(); } } public void createUser(User user, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { checkReady(); createUser_call method_call = new createUser_call(user, resultHandler, this, ___protocolFactory, ___transport); this.___currentMethod = method_call; ___manager.call(method_call); } public static class createUser_call extends org.apache.thrift.async.TAsyncMethodCall { private User user; public createUser_call(User user, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { super(client, protocolFactory, transport, resultHandler, false); this.user = user; } public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("createUser", org.apache.thrift.protocol.TMessageType.CALL, 0)); createUser_args args = new createUser_args(); args.setUser(user); args.write(prot); prot.writeMessageEnd(); } public java.lang.Boolean getResult() throws org.apache.thrift.TException { if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { throw new java.lang.IllegalStateException("Method call not finished!"); } org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); return (new Client(prot)).recv_createUser(); } } public void getUser(long id, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { checkReady(); getUser_call method_call = new getUser_call(id, resultHandler, this, ___protocolFactory, ___transport); this.___currentMethod = method_call; ___manager.call(method_call); } public static class getUser_call extends org.apache.thrift.async.TAsyncMethodCall { private long id; public getUser_call(long id, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { super(client, protocolFactory, transport, resultHandler, false); this.id = id; } public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("getUser", org.apache.thrift.protocol.TMessageType.CALL, 0)); getUser_args args = new getUser_args(); args.setId(id); args.write(prot); prot.writeMessageEnd(); } public User getResult() throws org.apache.thrift.TException { if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { throw new java.lang.IllegalStateException("Method call not finished!"); } org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); return (new Client(prot)).recv_getUser(); } } public void listUser(int pageNo, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { checkReady(); listUser_call method_call = new listUser_call(pageNo, resultHandler, this, ___protocolFactory, ___transport); this.___currentMethod = method_call; ___manager.call(method_call); } public static class listUser_call extends org.apache.thrift.async.TAsyncMethodCall { private int pageNo; public listUser_call(int pageNo, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { super(client, protocolFactory, transport, resultHandler, false); this.pageNo = pageNo; } public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("listUser", org.apache.thrift.protocol.TMessageType.CALL, 0)); listUser_args args = new listUser_args(); args.setPageNo(pageNo); args.write(prot); prot.writeMessageEnd(); } public UserPage getResult() throws org.apache.thrift.TException { if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { throw new java.lang.IllegalStateException("Method call not finished!"); } org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); return (new Client(prot)).recv_listUser(); } } } public static class Processor extends org.apache.thrift.TBaseProcessor implements org.apache.thrift.TProcessor { private static final org.slf4j.Logger _LOGGER = org.slf4j.LoggerFactory.getLogger(Processor.class.getName()); public Processor(I iface) { super(iface, getProcessMap(new java.util.HashMap>())); } protected Processor(I iface, java.util.Map> processMap) { super(iface, getProcessMap(processMap)); } private static java.util.Map> getProcessMap(java.util.Map> processMap) { processMap.put("userExist", new userExist()); processMap.put("createUser", new createUser()); processMap.put("getUser", new getUser()); processMap.put("listUser", new listUser()); return processMap; } public static class userExist extends org.apache.thrift.ProcessFunction { public userExist() { super("userExist"); } public userExist_args getEmptyArgsInstance() { return new userExist_args(); } protected boolean isOneway() { return false; } public userExist_result getResult(I iface, userExist_args args) throws org.apache.thrift.TException { userExist_result result = new userExist_result(); result.success = iface.userExist(args.email); result.setSuccessIsSet(true); return result; } } public static class createUser extends org.apache.thrift.ProcessFunction { public createUser() { super("createUser"); } public createUser_args getEmptyArgsInstance() { return new createUser_args(); } protected boolean isOneway() { return false; } public createUser_result getResult(I iface, createUser_args args) throws org.apache.thrift.TException { createUser_result result = new createUser_result(); result.success = iface.createUser(args.user); result.setSuccessIsSet(true); return result; } } public static class getUser extends org.apache.thrift.ProcessFunction { public getUser() { super("getUser"); } public getUser_args getEmptyArgsInstance() { return new getUser_args(); } protected boolean isOneway() { return false; } public getUser_result getResult(I iface, getUser_args args) throws org.apache.thrift.TException { getUser_result result = new getUser_result(); result.success = iface.getUser(args.id); return result; } } public static class listUser extends org.apache.thrift.ProcessFunction { public listUser() { super("listUser"); } public listUser_args getEmptyArgsInstance() { return new listUser_args(); } protected boolean isOneway() { return false; } public listUser_result getResult(I iface, listUser_args args) throws org.apache.thrift.TException { listUser_result result = new listUser_result(); result.success = iface.listUser(args.pageNo); return result; } } } public static class AsyncProcessor extends org.apache.thrift.TBaseAsyncProcessor { private static final org.slf4j.Logger _LOGGER = org.slf4j.LoggerFactory.getLogger(AsyncProcessor.class.getName()); public AsyncProcessor(I iface) { super(iface, getProcessMap(new java.util.HashMap>())); } protected AsyncProcessor(I iface, java.util.Map> processMap) { super(iface, getProcessMap(processMap)); } private static java.util.Map> getProcessMap(java.util.Map> processMap) { processMap.put("userExist", new userExist()); processMap.put("createUser", new createUser()); processMap.put("getUser", new getUser()); processMap.put("listUser", new listUser()); return processMap; } public static class userExist extends org.apache.thrift.AsyncProcessFunction { public userExist() { super("userExist"); } public userExist_args getEmptyArgsInstance() { return new userExist_args(); } public org.apache.thrift.async.AsyncMethodCallback getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) { final org.apache.thrift.AsyncProcessFunction fcall = this; return new org.apache.thrift.async.AsyncMethodCallback() { public void onComplete(java.lang.Boolean o) { userExist_result result = new userExist_result(); result.success = o; result.setSuccessIsSet(true); try { fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); } catch (org.apache.thrift.transport.TTransportException e) { _LOGGER.error("TTransportException writing to internal frame buffer", e); fb.close(); } catch (java.lang.Exception e) { _LOGGER.error("Exception writing to internal frame buffer", e); onError(e); } } public void onError(java.lang.Exception e) { byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; org.apache.thrift.TSerializable msg; userExist_result result = new userExist_result(); if (e instanceof org.apache.thrift.transport.TTransportException) { _LOGGER.error("TTransportException inside handler", e); fb.close(); return; } else if (e instanceof org.apache.thrift.TApplicationException) { _LOGGER.error("TApplicationException inside handler", e); msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; msg = (org.apache.thrift.TApplicationException)e; } else { _LOGGER.error("Exception inside handler", e); msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); } try { fcall.sendResponse(fb,msg,msgType,seqid); } catch (java.lang.Exception ex) { _LOGGER.error("Exception writing to internal frame buffer", ex); fb.close(); } } }; } protected boolean isOneway() { return false; } public void start(I iface, userExist_args args, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { iface.userExist(args.email,resultHandler); } } public static class createUser extends org.apache.thrift.AsyncProcessFunction { public createUser() { super("createUser"); } public createUser_args getEmptyArgsInstance() { return new createUser_args(); } public org.apache.thrift.async.AsyncMethodCallback getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) { final org.apache.thrift.AsyncProcessFunction fcall = this; return new org.apache.thrift.async.AsyncMethodCallback() { public void onComplete(java.lang.Boolean o) { createUser_result result = new createUser_result(); result.success = o; result.setSuccessIsSet(true); try { fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); } catch (org.apache.thrift.transport.TTransportException e) { _LOGGER.error("TTransportException writing to internal frame buffer", e); fb.close(); } catch (java.lang.Exception e) { _LOGGER.error("Exception writing to internal frame buffer", e); onError(e); } } public void onError(java.lang.Exception e) { byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; org.apache.thrift.TSerializable msg; createUser_result result = new createUser_result(); if (e instanceof org.apache.thrift.transport.TTransportException) { _LOGGER.error("TTransportException inside handler", e); fb.close(); return; } else if (e instanceof org.apache.thrift.TApplicationException) { _LOGGER.error("TApplicationException inside handler", e); msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; msg = (org.apache.thrift.TApplicationException)e; } else { _LOGGER.error("Exception inside handler", e); msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); } try { fcall.sendResponse(fb,msg,msgType,seqid); } catch (java.lang.Exception ex) { _LOGGER.error("Exception writing to internal frame buffer", ex); fb.close(); } } }; } protected boolean isOneway() { return false; } public void start(I iface, createUser_args args, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { iface.createUser(args.user,resultHandler); } } public static class getUser extends org.apache.thrift.AsyncProcessFunction { public getUser() { super("getUser"); } public getUser_args getEmptyArgsInstance() { return new getUser_args(); } public org.apache.thrift.async.AsyncMethodCallback getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) { final org.apache.thrift.AsyncProcessFunction fcall = this; return new org.apache.thrift.async.AsyncMethodCallback() { public void onComplete(User o) { getUser_result result = new getUser_result(); result.success = o; try { fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); } catch (org.apache.thrift.transport.TTransportException e) { _LOGGER.error("TTransportException writing to internal frame buffer", e); fb.close(); } catch (java.lang.Exception e) { _LOGGER.error("Exception writing to internal frame buffer", e); onError(e); } } public void onError(java.lang.Exception e) { byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; org.apache.thrift.TSerializable msg; getUser_result result = new getUser_result(); if (e instanceof org.apache.thrift.transport.TTransportException) { _LOGGER.error("TTransportException inside handler", e); fb.close(); return; } else if (e instanceof org.apache.thrift.TApplicationException) { _LOGGER.error("TApplicationException inside handler", e); msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; msg = (org.apache.thrift.TApplicationException)e; } else { _LOGGER.error("Exception inside handler", e); msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); } try { fcall.sendResponse(fb,msg,msgType,seqid); } catch (java.lang.Exception ex) { _LOGGER.error("Exception writing to internal frame buffer", ex); fb.close(); } } }; } protected boolean isOneway() { return false; } public void start(I iface, getUser_args args, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { iface.getUser(args.id,resultHandler); } } public static class listUser extends org.apache.thrift.AsyncProcessFunction { public listUser() { super("listUser"); } public listUser_args getEmptyArgsInstance() { return new listUser_args(); } public org.apache.thrift.async.AsyncMethodCallback getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) { final org.apache.thrift.AsyncProcessFunction fcall = this; return new org.apache.thrift.async.AsyncMethodCallback() { public void onComplete(UserPage o) { listUser_result result = new listUser_result(); result.success = o; try { fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); } catch (org.apache.thrift.transport.TTransportException e) { _LOGGER.error("TTransportException writing to internal frame buffer", e); fb.close(); } catch (java.lang.Exception e) { _LOGGER.error("Exception writing to internal frame buffer", e); onError(e); } } public void onError(java.lang.Exception e) { byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; org.apache.thrift.TSerializable msg; listUser_result result = new listUser_result(); if (e instanceof org.apache.thrift.transport.TTransportException) { _LOGGER.error("TTransportException inside handler", e); fb.close(); return; } else if (e instanceof org.apache.thrift.TApplicationException) { _LOGGER.error("TApplicationException inside handler", e); msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; msg = (org.apache.thrift.TApplicationException)e; } else { _LOGGER.error("Exception inside handler", e); msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); } try { fcall.sendResponse(fb,msg,msgType,seqid); } catch (java.lang.Exception ex) { _LOGGER.error("Exception writing to internal frame buffer", ex); fb.close(); } } }; } protected boolean isOneway() { return false; } public void start(I iface, listUser_args args, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { iface.listUser(args.pageNo,resultHandler); } } } public static class userExist_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("userExist_args"); private static final org.apache.thrift.protocol.TField EMAIL_FIELD_DESC = new org.apache.thrift.protocol.TField("email", org.apache.thrift.protocol.TType.STRING, (short)1); private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new userExist_argsStandardSchemeFactory(); private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new userExist_argsTupleSchemeFactory(); public java.lang.String email; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { EMAIL((short)1, "email"); private static final java.util.Map byName = new java.util.HashMap(); static { for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 1: // EMAIL return EMAIL; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(java.lang.String name) { return byName.get(name); } private final short _thriftId; private final java.lang.String _fieldName; _Fields(short thriftId, java.lang.String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public java.lang.String getFieldName() { return _fieldName; } } // isset id assignments public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.EMAIL, new org.apache.thrift.meta_data.FieldMetaData("email", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(userExist_args.class, metaDataMap); } public userExist_args() { } public userExist_args( java.lang.String email) { this(); this.email = email; } /** * Performs a deep copy on other. */ public userExist_args(userExist_args other) { if (other.isSetEmail()) { this.email = other.email; } } public userExist_args deepCopy() { return new userExist_args(this); } @Override public void clear() { this.email = null; } public java.lang.String getEmail() { return this.email; } public userExist_args setEmail(java.lang.String email) { this.email = email; return this; } public void unsetEmail() { this.email = null; } /** Returns true if field email is set (has been assigned a value) and false otherwise */ public boolean isSetEmail() { return this.email != null; } public void setEmailIsSet(boolean value) { if (!value) { this.email = null; } } public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case EMAIL: if (value == null) { unsetEmail(); } else { setEmail((java.lang.String)value); } break; } } public java.lang.Object getFieldValue(_Fields field) { switch (field) { case EMAIL: return getEmail(); } throw new java.lang.IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { case EMAIL: return isSetEmail(); } throw new java.lang.IllegalStateException(); } @Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof userExist_args) return this.equals((userExist_args)that); return false; } public boolean equals(userExist_args that) { if (that == null) return false; if (this == that) return true; boolean this_present_email = true && this.isSetEmail(); boolean that_present_email = true && that.isSetEmail(); if (this_present_email || that_present_email) { if (!(this_present_email && that_present_email)) return false; if (!this.email.equals(that.email)) return false; } return true; } @Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + ((isSetEmail()) ? 131071 : 524287); if (isSetEmail()) hashCode = hashCode * 8191 + email.hashCode(); return hashCode; } @Override public int compareTo(userExist_args other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = java.lang.Boolean.valueOf(isSetEmail()).compareTo(other.isSetEmail()); if (lastComparison != 0) { return lastComparison; } if (isSetEmail()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.email, other.email); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { scheme(iprot).read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { scheme(oprot).write(oprot, this); } @Override public java.lang.String toString() { java.lang.StringBuilder sb = new java.lang.StringBuilder("userExist_args("); boolean first = true; sb.append("email:"); if (this.email == null) { sb.append("null"); } else { sb.append(this.email); } first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields // check for sub-struct validity } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { try { read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class userExist_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public userExist_argsStandardScheme getScheme() { return new userExist_argsStandardScheme(); } } private static class userExist_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme { public void read(org.apache.thrift.protocol.TProtocol iprot, userExist_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 1: // EMAIL if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.email = iprot.readString(); struct.setEmailIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, userExist_args struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.email != null) { oprot.writeFieldBegin(EMAIL_FIELD_DESC); oprot.writeString(struct.email); oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class userExist_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public userExist_argsTupleScheme getScheme() { return new userExist_argsTupleScheme(); } } private static class userExist_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme { @Override public void write(org.apache.thrift.protocol.TProtocol prot, userExist_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet optionals = new java.util.BitSet(); if (struct.isSetEmail()) { optionals.set(0); } oprot.writeBitSet(optionals, 1); if (struct.isSetEmail()) { oprot.writeString(struct.email); } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, userExist_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { struct.email = iprot.readString(); struct.setEmailIsSet(true); } } } private static S scheme(org.apache.thrift.protocol.TProtocol proto) { return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); } } public static class userExist_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("userExist_result"); private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.BOOL, (short)0); private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new userExist_resultStandardSchemeFactory(); private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new userExist_resultTupleSchemeFactory(); public boolean success; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { SUCCESS((short)0, "success"); private static final java.util.Map byName = new java.util.HashMap(); static { for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 0: // SUCCESS return SUCCESS; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(java.lang.String name) { return byName.get(name); } private final short _thriftId; private final java.lang.String _fieldName; _Fields(short thriftId, java.lang.String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public java.lang.String getFieldName() { return _fieldName; } } // isset id assignments private static final int __SUCCESS_ISSET_ID = 0; private byte __isset_bitfield = 0; public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(userExist_result.class, metaDataMap); } public userExist_result() { } public userExist_result( boolean success) { this(); this.success = success; setSuccessIsSet(true); } /** * Performs a deep copy on other. */ public userExist_result(userExist_result other) { __isset_bitfield = other.__isset_bitfield; this.success = other.success; } public userExist_result deepCopy() { return new userExist_result(this); } @Override public void clear() { setSuccessIsSet(false); this.success = false; } public boolean isSuccess() { return this.success; } public userExist_result setSuccess(boolean success) { this.success = success; setSuccessIsSet(true); return this; } public void unsetSuccess() { __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __SUCCESS_ISSET_ID); } /** Returns true if field success is set (has been assigned a value) and false otherwise */ public boolean isSetSuccess() { return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __SUCCESS_ISSET_ID); } public void setSuccessIsSet(boolean value) { __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __SUCCESS_ISSET_ID, value); } public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case SUCCESS: if (value == null) { unsetSuccess(); } else { setSuccess((java.lang.Boolean)value); } break; } } public java.lang.Object getFieldValue(_Fields field) { switch (field) { case SUCCESS: return isSuccess(); } throw new java.lang.IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { case SUCCESS: return isSetSuccess(); } throw new java.lang.IllegalStateException(); } @Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof userExist_result) return this.equals((userExist_result)that); return false; } public boolean equals(userExist_result that) { if (that == null) return false; if (this == that) return true; boolean this_present_success = true; boolean that_present_success = true; if (this_present_success || that_present_success) { if (!(this_present_success && that_present_success)) return false; if (this.success != that.success) return false; } return true; } @Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + ((success) ? 131071 : 524287); return hashCode; } @Override public int compareTo(userExist_result other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = java.lang.Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess()); if (lastComparison != 0) { return lastComparison; } if (isSetSuccess()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { scheme(iprot).read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { scheme(oprot).write(oprot, this); } @Override public java.lang.String toString() { java.lang.StringBuilder sb = new java.lang.StringBuilder("userExist_result("); boolean first = true; sb.append("success:"); sb.append(this.success); first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields // check for sub-struct validity } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { try { // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. __isset_bitfield = 0; read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class userExist_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public userExist_resultStandardScheme getScheme() { return new userExist_resultStandardScheme(); } } private static class userExist_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme { public void read(org.apache.thrift.protocol.TProtocol iprot, userExist_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 0: // SUCCESS if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) { struct.success = iprot.readBool(); struct.setSuccessIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, userExist_result struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.isSetSuccess()) { oprot.writeFieldBegin(SUCCESS_FIELD_DESC); oprot.writeBool(struct.success); oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class userExist_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public userExist_resultTupleScheme getScheme() { return new userExist_resultTupleScheme(); } } private static class userExist_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme { @Override public void write(org.apache.thrift.protocol.TProtocol prot, userExist_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet optionals = new java.util.BitSet(); if (struct.isSetSuccess()) { optionals.set(0); } oprot.writeBitSet(optionals, 1); if (struct.isSetSuccess()) { oprot.writeBool(struct.success); } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, userExist_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { struct.success = iprot.readBool(); struct.setSuccessIsSet(true); } } } private static S scheme(org.apache.thrift.protocol.TProtocol proto) { return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); } } public static class createUser_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("createUser_args"); private static final org.apache.thrift.protocol.TField USER_FIELD_DESC = new org.apache.thrift.protocol.TField("user", org.apache.thrift.protocol.TType.STRUCT, (short)1); private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new createUser_argsStandardSchemeFactory(); private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new createUser_argsTupleSchemeFactory(); public User user; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { USER((short)1, "user"); private static final java.util.Map byName = new java.util.HashMap(); static { for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 1: // USER return USER; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(java.lang.String name) { return byName.get(name); } private final short _thriftId; private final java.lang.String _fieldName; _Fields(short thriftId, java.lang.String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public java.lang.String getFieldName() { return _fieldName; } } // isset id assignments public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.USER, new org.apache.thrift.meta_data.FieldMetaData("user", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, User.class))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(createUser_args.class, metaDataMap); } public createUser_args() { } public createUser_args( User user) { this(); this.user = user; } /** * Performs a deep copy on other. */ public createUser_args(createUser_args other) { if (other.isSetUser()) { this.user = new User(other.user); } } public createUser_args deepCopy() { return new createUser_args(this); } @Override public void clear() { this.user = null; } public User getUser() { return this.user; } public createUser_args setUser(User user) { this.user = user; return this; } public void unsetUser() { this.user = null; } /** Returns true if field user is set (has been assigned a value) and false otherwise */ public boolean isSetUser() { return this.user != null; } public void setUserIsSet(boolean value) { if (!value) { this.user = null; } } public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case USER: if (value == null) { unsetUser(); } else { setUser((User)value); } break; } } public java.lang.Object getFieldValue(_Fields field) { switch (field) { case USER: return getUser(); } throw new java.lang.IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { case USER: return isSetUser(); } throw new java.lang.IllegalStateException(); } @Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof createUser_args) return this.equals((createUser_args)that); return false; } public boolean equals(createUser_args that) { if (that == null) return false; if (this == that) return true; boolean this_present_user = true && this.isSetUser(); boolean that_present_user = true && that.isSetUser(); if (this_present_user || that_present_user) { if (!(this_present_user && that_present_user)) return false; if (!this.user.equals(that.user)) return false; } return true; } @Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + ((isSetUser()) ? 131071 : 524287); if (isSetUser()) hashCode = hashCode * 8191 + user.hashCode(); return hashCode; } @Override public int compareTo(createUser_args other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = java.lang.Boolean.valueOf(isSetUser()).compareTo(other.isSetUser()); if (lastComparison != 0) { return lastComparison; } if (isSetUser()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.user, other.user); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { scheme(iprot).read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { scheme(oprot).write(oprot, this); } @Override public java.lang.String toString() { java.lang.StringBuilder sb = new java.lang.StringBuilder("createUser_args("); boolean first = true; sb.append("user:"); if (this.user == null) { sb.append("null"); } else { sb.append(this.user); } first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields // check for sub-struct validity if (user != null) { user.validate(); } } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { try { read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class createUser_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public createUser_argsStandardScheme getScheme() { return new createUser_argsStandardScheme(); } } private static class createUser_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme { public void read(org.apache.thrift.protocol.TProtocol iprot, createUser_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 1: // USER if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { struct.user = new User(); struct.user.read(iprot); struct.setUserIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, createUser_args struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.user != null) { oprot.writeFieldBegin(USER_FIELD_DESC); struct.user.write(oprot); oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class createUser_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public createUser_argsTupleScheme getScheme() { return new createUser_argsTupleScheme(); } } private static class createUser_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme { @Override public void write(org.apache.thrift.protocol.TProtocol prot, createUser_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet optionals = new java.util.BitSet(); if (struct.isSetUser()) { optionals.set(0); } oprot.writeBitSet(optionals, 1); if (struct.isSetUser()) { struct.user.write(oprot); } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, createUser_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { struct.user = new User(); struct.user.read(iprot); struct.setUserIsSet(true); } } } private static S scheme(org.apache.thrift.protocol.TProtocol proto) { return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); } } public static class createUser_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("createUser_result"); private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.BOOL, (short)0); private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new createUser_resultStandardSchemeFactory(); private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new createUser_resultTupleSchemeFactory(); public boolean success; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { SUCCESS((short)0, "success"); private static final java.util.Map byName = new java.util.HashMap(); static { for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 0: // SUCCESS return SUCCESS; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(java.lang.String name) { return byName.get(name); } private final short _thriftId; private final java.lang.String _fieldName; _Fields(short thriftId, java.lang.String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public java.lang.String getFieldName() { return _fieldName; } } // isset id assignments private static final int __SUCCESS_ISSET_ID = 0; private byte __isset_bitfield = 0; public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(createUser_result.class, metaDataMap); } public createUser_result() { } public createUser_result( boolean success) { this(); this.success = success; setSuccessIsSet(true); } /** * Performs a deep copy on other. */ public createUser_result(createUser_result other) { __isset_bitfield = other.__isset_bitfield; this.success = other.success; } public createUser_result deepCopy() { return new createUser_result(this); } @Override public void clear() { setSuccessIsSet(false); this.success = false; } public boolean isSuccess() { return this.success; } public createUser_result setSuccess(boolean success) { this.success = success; setSuccessIsSet(true); return this; } public void unsetSuccess() { __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __SUCCESS_ISSET_ID); } /** Returns true if field success is set (has been assigned a value) and false otherwise */ public boolean isSetSuccess() { return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __SUCCESS_ISSET_ID); } public void setSuccessIsSet(boolean value) { __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __SUCCESS_ISSET_ID, value); } public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case SUCCESS: if (value == null) { unsetSuccess(); } else { setSuccess((java.lang.Boolean)value); } break; } } public java.lang.Object getFieldValue(_Fields field) { switch (field) { case SUCCESS: return isSuccess(); } throw new java.lang.IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { case SUCCESS: return isSetSuccess(); } throw new java.lang.IllegalStateException(); } @Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof createUser_result) return this.equals((createUser_result)that); return false; } public boolean equals(createUser_result that) { if (that == null) return false; if (this == that) return true; boolean this_present_success = true; boolean that_present_success = true; if (this_present_success || that_present_success) { if (!(this_present_success && that_present_success)) return false; if (this.success != that.success) return false; } return true; } @Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + ((success) ? 131071 : 524287); return hashCode; } @Override public int compareTo(createUser_result other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = java.lang.Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess()); if (lastComparison != 0) { return lastComparison; } if (isSetSuccess()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { scheme(iprot).read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { scheme(oprot).write(oprot, this); } @Override public java.lang.String toString() { java.lang.StringBuilder sb = new java.lang.StringBuilder("createUser_result("); boolean first = true; sb.append("success:"); sb.append(this.success); first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields // check for sub-struct validity } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { try { // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. __isset_bitfield = 0; read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class createUser_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public createUser_resultStandardScheme getScheme() { return new createUser_resultStandardScheme(); } } private static class createUser_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme { public void read(org.apache.thrift.protocol.TProtocol iprot, createUser_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 0: // SUCCESS if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) { struct.success = iprot.readBool(); struct.setSuccessIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, createUser_result struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.isSetSuccess()) { oprot.writeFieldBegin(SUCCESS_FIELD_DESC); oprot.writeBool(struct.success); oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class createUser_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public createUser_resultTupleScheme getScheme() { return new createUser_resultTupleScheme(); } } private static class createUser_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme { @Override public void write(org.apache.thrift.protocol.TProtocol prot, createUser_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet optionals = new java.util.BitSet(); if (struct.isSetSuccess()) { optionals.set(0); } oprot.writeBitSet(optionals, 1); if (struct.isSetSuccess()) { oprot.writeBool(struct.success); } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, createUser_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { struct.success = iprot.readBool(); struct.setSuccessIsSet(true); } } } private static S scheme(org.apache.thrift.protocol.TProtocol proto) { return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); } } public static class getUser_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getUser_args"); private static final org.apache.thrift.protocol.TField ID_FIELD_DESC = new org.apache.thrift.protocol.TField("id", org.apache.thrift.protocol.TType.I64, (short)1); private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new getUser_argsStandardSchemeFactory(); private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new getUser_argsTupleSchemeFactory(); public long id; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { ID((short)1, "id"); private static final java.util.Map byName = new java.util.HashMap(); static { for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 1: // ID return ID; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(java.lang.String name) { return byName.get(name); } private final short _thriftId; private final java.lang.String _fieldName; _Fields(short thriftId, java.lang.String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public java.lang.String getFieldName() { return _fieldName; } } // isset id assignments private static final int __ID_ISSET_ID = 0; private byte __isset_bitfield = 0; public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.ID, new org.apache.thrift.meta_data.FieldMetaData("id", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getUser_args.class, metaDataMap); } public getUser_args() { } public getUser_args( long id) { this(); this.id = id; setIdIsSet(true); } /** * Performs a deep copy on other. */ public getUser_args(getUser_args other) { __isset_bitfield = other.__isset_bitfield; this.id = other.id; } public getUser_args deepCopy() { return new getUser_args(this); } @Override public void clear() { setIdIsSet(false); this.id = 0; } public long getId() { return this.id; } public getUser_args setId(long id) { this.id = id; setIdIsSet(true); return this; } public void unsetId() { __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __ID_ISSET_ID); } /** Returns true if field id is set (has been assigned a value) and false otherwise */ public boolean isSetId() { return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __ID_ISSET_ID); } public void setIdIsSet(boolean value) { __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __ID_ISSET_ID, value); } public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case ID: if (value == null) { unsetId(); } else { setId((java.lang.Long)value); } break; } } public java.lang.Object getFieldValue(_Fields field) { switch (field) { case ID: return getId(); } throw new java.lang.IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { case ID: return isSetId(); } throw new java.lang.IllegalStateException(); } @Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof getUser_args) return this.equals((getUser_args)that); return false; } public boolean equals(getUser_args that) { if (that == null) return false; if (this == that) return true; boolean this_present_id = true; boolean that_present_id = true; if (this_present_id || that_present_id) { if (!(this_present_id && that_present_id)) return false; if (this.id != that.id) return false; } return true; } @Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(id); return hashCode; } @Override public int compareTo(getUser_args other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = java.lang.Boolean.valueOf(isSetId()).compareTo(other.isSetId()); if (lastComparison != 0) { return lastComparison; } if (isSetId()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.id, other.id); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { scheme(iprot).read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { scheme(oprot).write(oprot, this); } @Override public java.lang.String toString() { java.lang.StringBuilder sb = new java.lang.StringBuilder("getUser_args("); boolean first = true; sb.append("id:"); sb.append(this.id); first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields // check for sub-struct validity } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { try { // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. __isset_bitfield = 0; read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class getUser_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public getUser_argsStandardScheme getScheme() { return new getUser_argsStandardScheme(); } } private static class getUser_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme { public void read(org.apache.thrift.protocol.TProtocol iprot, getUser_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 1: // ID if (schemeField.type == org.apache.thrift.protocol.TType.I64) { struct.id = iprot.readI64(); struct.setIdIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, getUser_args struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); oprot.writeFieldBegin(ID_FIELD_DESC); oprot.writeI64(struct.id); oprot.writeFieldEnd(); oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class getUser_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public getUser_argsTupleScheme getScheme() { return new getUser_argsTupleScheme(); } } private static class getUser_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme { @Override public void write(org.apache.thrift.protocol.TProtocol prot, getUser_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet optionals = new java.util.BitSet(); if (struct.isSetId()) { optionals.set(0); } oprot.writeBitSet(optionals, 1); if (struct.isSetId()) { oprot.writeI64(struct.id); } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, getUser_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { struct.id = iprot.readI64(); struct.setIdIsSet(true); } } } private static S scheme(org.apache.thrift.protocol.TProtocol proto) { return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); } } public static class getUser_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getUser_result"); private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRUCT, (short)0); private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new getUser_resultStandardSchemeFactory(); private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new getUser_resultTupleSchemeFactory(); public User success; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { SUCCESS((short)0, "success"); private static final java.util.Map byName = new java.util.HashMap(); static { for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 0: // SUCCESS return SUCCESS; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(java.lang.String name) { return byName.get(name); } private final short _thriftId; private final java.lang.String _fieldName; _Fields(short thriftId, java.lang.String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public java.lang.String getFieldName() { return _fieldName; } } // isset id assignments public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, User.class))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getUser_result.class, metaDataMap); } public getUser_result() { } public getUser_result( User success) { this(); this.success = success; } /** * Performs a deep copy on other. */ public getUser_result(getUser_result other) { if (other.isSetSuccess()) { this.success = new User(other.success); } } public getUser_result deepCopy() { return new getUser_result(this); } @Override public void clear() { this.success = null; } public User getSuccess() { return this.success; } public getUser_result setSuccess(User success) { this.success = success; return this; } public void unsetSuccess() { this.success = null; } /** Returns true if field success is set (has been assigned a value) and false otherwise */ public boolean isSetSuccess() { return this.success != null; } public void setSuccessIsSet(boolean value) { if (!value) { this.success = null; } } public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case SUCCESS: if (value == null) { unsetSuccess(); } else { setSuccess((User)value); } break; } } public java.lang.Object getFieldValue(_Fields field) { switch (field) { case SUCCESS: return getSuccess(); } throw new java.lang.IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { case SUCCESS: return isSetSuccess(); } throw new java.lang.IllegalStateException(); } @Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof getUser_result) return this.equals((getUser_result)that); return false; } public boolean equals(getUser_result that) { if (that == null) return false; if (this == that) return true; boolean this_present_success = true && this.isSetSuccess(); boolean that_present_success = true && that.isSetSuccess(); if (this_present_success || that_present_success) { if (!(this_present_success && that_present_success)) return false; if (!this.success.equals(that.success)) return false; } return true; } @Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + ((isSetSuccess()) ? 131071 : 524287); if (isSetSuccess()) hashCode = hashCode * 8191 + success.hashCode(); return hashCode; } @Override public int compareTo(getUser_result other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = java.lang.Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess()); if (lastComparison != 0) { return lastComparison; } if (isSetSuccess()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { scheme(iprot).read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { scheme(oprot).write(oprot, this); } @Override public java.lang.String toString() { java.lang.StringBuilder sb = new java.lang.StringBuilder("getUser_result("); boolean first = true; sb.append("success:"); if (this.success == null) { sb.append("null"); } else { sb.append(this.success); } first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields // check for sub-struct validity if (success != null) { success.validate(); } } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { try { read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class getUser_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public getUser_resultStandardScheme getScheme() { return new getUser_resultStandardScheme(); } } private static class getUser_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme { public void read(org.apache.thrift.protocol.TProtocol iprot, getUser_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 0: // SUCCESS if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { struct.success = new User(); struct.success.read(iprot); struct.setSuccessIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, getUser_result struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.success != null) { oprot.writeFieldBegin(SUCCESS_FIELD_DESC); struct.success.write(oprot); oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class getUser_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public getUser_resultTupleScheme getScheme() { return new getUser_resultTupleScheme(); } } private static class getUser_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme { @Override public void write(org.apache.thrift.protocol.TProtocol prot, getUser_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet optionals = new java.util.BitSet(); if (struct.isSetSuccess()) { optionals.set(0); } oprot.writeBitSet(optionals, 1); if (struct.isSetSuccess()) { struct.success.write(oprot); } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, getUser_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { struct.success = new User(); struct.success.read(iprot); struct.setSuccessIsSet(true); } } } private static S scheme(org.apache.thrift.protocol.TProtocol proto) { return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); } } public static class listUser_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("listUser_args"); private static final org.apache.thrift.protocol.TField PAGE_NO_FIELD_DESC = new org.apache.thrift.protocol.TField("pageNo", org.apache.thrift.protocol.TType.I32, (short)1); private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new listUser_argsStandardSchemeFactory(); private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new listUser_argsTupleSchemeFactory(); public int pageNo; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { PAGE_NO((short)1, "pageNo"); private static final java.util.Map byName = new java.util.HashMap(); static { for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 1: // PAGE_NO return PAGE_NO; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(java.lang.String name) { return byName.get(name); } private final short _thriftId; private final java.lang.String _fieldName; _Fields(short thriftId, java.lang.String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public java.lang.String getFieldName() { return _fieldName; } } // isset id assignments private static final int __PAGENO_ISSET_ID = 0; private byte __isset_bitfield = 0; public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.PAGE_NO, new org.apache.thrift.meta_data.FieldMetaData("pageNo", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(listUser_args.class, metaDataMap); } public listUser_args() { } public listUser_args( int pageNo) { this(); this.pageNo = pageNo; setPageNoIsSet(true); } /** * Performs a deep copy on other. */ public listUser_args(listUser_args other) { __isset_bitfield = other.__isset_bitfield; this.pageNo = other.pageNo; } public listUser_args deepCopy() { return new listUser_args(this); } @Override public void clear() { setPageNoIsSet(false); this.pageNo = 0; } public int getPageNo() { return this.pageNo; } public listUser_args setPageNo(int pageNo) { this.pageNo = pageNo; setPageNoIsSet(true); return this; } public void unsetPageNo() { __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __PAGENO_ISSET_ID); } /** Returns true if field pageNo is set (has been assigned a value) and false otherwise */ public boolean isSetPageNo() { return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __PAGENO_ISSET_ID); } public void setPageNoIsSet(boolean value) { __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __PAGENO_ISSET_ID, value); } public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case PAGE_NO: if (value == null) { unsetPageNo(); } else { setPageNo((java.lang.Integer)value); } break; } } public java.lang.Object getFieldValue(_Fields field) { switch (field) { case PAGE_NO: return getPageNo(); } throw new java.lang.IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { case PAGE_NO: return isSetPageNo(); } throw new java.lang.IllegalStateException(); } @Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof listUser_args) return this.equals((listUser_args)that); return false; } public boolean equals(listUser_args that) { if (that == null) return false; if (this == that) return true; boolean this_present_pageNo = true; boolean that_present_pageNo = true; if (this_present_pageNo || that_present_pageNo) { if (!(this_present_pageNo && that_present_pageNo)) return false; if (this.pageNo != that.pageNo) return false; } return true; } @Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + pageNo; return hashCode; } @Override public int compareTo(listUser_args other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = java.lang.Boolean.valueOf(isSetPageNo()).compareTo(other.isSetPageNo()); if (lastComparison != 0) { return lastComparison; } if (isSetPageNo()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.pageNo, other.pageNo); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { scheme(iprot).read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { scheme(oprot).write(oprot, this); } @Override public java.lang.String toString() { java.lang.StringBuilder sb = new java.lang.StringBuilder("listUser_args("); boolean first = true; sb.append("pageNo:"); sb.append(this.pageNo); first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields // check for sub-struct validity } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { try { // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. __isset_bitfield = 0; read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class listUser_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public listUser_argsStandardScheme getScheme() { return new listUser_argsStandardScheme(); } } private static class listUser_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme { public void read(org.apache.thrift.protocol.TProtocol iprot, listUser_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 1: // PAGE_NO if (schemeField.type == org.apache.thrift.protocol.TType.I32) { struct.pageNo = iprot.readI32(); struct.setPageNoIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, listUser_args struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); oprot.writeFieldBegin(PAGE_NO_FIELD_DESC); oprot.writeI32(struct.pageNo); oprot.writeFieldEnd(); oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class listUser_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public listUser_argsTupleScheme getScheme() { return new listUser_argsTupleScheme(); } } private static class listUser_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme { @Override public void write(org.apache.thrift.protocol.TProtocol prot, listUser_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet optionals = new java.util.BitSet(); if (struct.isSetPageNo()) { optionals.set(0); } oprot.writeBitSet(optionals, 1); if (struct.isSetPageNo()) { oprot.writeI32(struct.pageNo); } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, listUser_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { struct.pageNo = iprot.readI32(); struct.setPageNoIsSet(true); } } } private static S scheme(org.apache.thrift.protocol.TProtocol proto) { return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); } } public static class listUser_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("listUser_result"); private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRUCT, (short)0); private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new listUser_resultStandardSchemeFactory(); private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new listUser_resultTupleSchemeFactory(); public UserPage success; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { SUCCESS((short)0, "success"); private static final java.util.Map byName = new java.util.HashMap(); static { for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 0: // SUCCESS return SUCCESS; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(java.lang.String name) { return byName.get(name); } private final short _thriftId; private final java.lang.String _fieldName; _Fields(short thriftId, java.lang.String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public java.lang.String getFieldName() { return _fieldName; } } // isset id assignments public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, UserPage.class))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(listUser_result.class, metaDataMap); } public listUser_result() { } public listUser_result( UserPage success) { this(); this.success = success; } /** * Performs a deep copy on other. */ public listUser_result(listUser_result other) { if (other.isSetSuccess()) { this.success = new UserPage(other.success); } } public listUser_result deepCopy() { return new listUser_result(this); } @Override public void clear() { this.success = null; } public UserPage getSuccess() { return this.success; } public listUser_result setSuccess(UserPage success) { this.success = success; return this; } public void unsetSuccess() { this.success = null; } /** Returns true if field success is set (has been assigned a value) and false otherwise */ public boolean isSetSuccess() { return this.success != null; } public void setSuccessIsSet(boolean value) { if (!value) { this.success = null; } } public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case SUCCESS: if (value == null) { unsetSuccess(); } else { setSuccess((UserPage)value); } break; } } public java.lang.Object getFieldValue(_Fields field) { switch (field) { case SUCCESS: return getSuccess(); } throw new java.lang.IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { case SUCCESS: return isSetSuccess(); } throw new java.lang.IllegalStateException(); } @Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof listUser_result) return this.equals((listUser_result)that); return false; } public boolean equals(listUser_result that) { if (that == null) return false; if (this == that) return true; boolean this_present_success = true && this.isSetSuccess(); boolean that_present_success = true && that.isSetSuccess(); if (this_present_success || that_present_success) { if (!(this_present_success && that_present_success)) return false; if (!this.success.equals(that.success)) return false; } return true; } @Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + ((isSetSuccess()) ? 131071 : 524287); if (isSetSuccess()) hashCode = hashCode * 8191 + success.hashCode(); return hashCode; } @Override public int compareTo(listUser_result other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = java.lang.Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess()); if (lastComparison != 0) { return lastComparison; } if (isSetSuccess()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { scheme(iprot).read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { scheme(oprot).write(oprot, this); } @Override public java.lang.String toString() { java.lang.StringBuilder sb = new java.lang.StringBuilder("listUser_result("); boolean first = true; sb.append("success:"); if (this.success == null) { sb.append("null"); } else { sb.append(this.success); } first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields // check for sub-struct validity if (success != null) { success.validate(); } } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { try { read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class listUser_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public listUser_resultStandardScheme getScheme() { return new listUser_resultStandardScheme(); } } private static class listUser_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme { public void read(org.apache.thrift.protocol.TProtocol iprot, listUser_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 0: // SUCCESS if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { struct.success = new UserPage(); struct.success.read(iprot); struct.setSuccessIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, listUser_result struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.success != null) { oprot.writeFieldBegin(SUCCESS_FIELD_DESC); struct.success.write(oprot); oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class listUser_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public listUser_resultTupleScheme getScheme() { return new listUser_resultTupleScheme(); } } private static class listUser_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme { @Override public void write(org.apache.thrift.protocol.TProtocol prot, listUser_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet optionals = new java.util.BitSet(); if (struct.isSetSuccess()) { optionals.set(0); } oprot.writeBitSet(optionals, 1); if (struct.isSetSuccess()) { struct.success.write(oprot); } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, listUser_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { struct.success = new UserPage(); struct.success.read(iprot); struct.setSuccessIsSet(true); } } } private static S scheme(org.apache.thrift.protocol.TProtocol proto) { return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); } } } ================================================ FILE: turbo-rest-client/pom.xml ================================================ 4.0.0 benchmark.rpc turbo-rest-client round-5 jar turbo-rest-client http://maven.apache.org 11 11 UTF-8 round-5 benchmark.rpc benchmark-base ${version.benchmark-base} junit junit 4.12 test org.apache.maven.plugins maven-compiler-plugin 3.8.0 ${maven.compiler.source} ${maven.compiler.target} UTF-8 org.apache.maven.plugins maven-resources-plugin 3.1.0 UTF-8 maven-assembly-plugin 3.1.0 jar-with-dependencies benchmark.rpc.Client make-assembly package single src/main/resources ================================================ FILE: turbo-rest-client/src/main/java/benchmark/rpc/Client.java ================================================ package benchmark.rpc; import java.util.concurrent.TimeUnit; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; import benchmark.bean.Page; import benchmark.bean.User; import benchmark.service.TurboUserServiceJsonHttpClientImpl; import benchmark.service.UserService; @State(Scope.Benchmark) public class Client extends AbstractClient { public static final int CONCURRENCY = 32; private final UserService userService = new TurboUserServiceJsonHttpClientImpl(CONCURRENCY); @Override protected UserService getUserService() { return userService; } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public boolean existUser() throws Exception { return super.existUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public boolean createUser() throws Exception { return super.createUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public User getUser() throws Exception { return super.getUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public Page listUser() throws Exception { return super.listUser(); } public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder()// .include(Client.class.getSimpleName())// .warmupIterations(3)// .warmupTime(TimeValue.seconds(10))// .measurementIterations(3)// .measurementTime(TimeValue.seconds(10))// .threads(CONCURRENCY)// .forks(1)// .build(); new Runner(opt).run(); } } ================================================ FILE: turbo-rest-client/src/main/java/benchmark/service/TurboUserServiceJsonHttpClientImpl.java ================================================ package benchmark.service; import java.nio.charset.StandardCharsets; import org.apache.http.HttpEntity; import org.apache.http.client.entity.EntityBuilder; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.util.EntityUtils; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; import benchmark.bean.Page; import benchmark.bean.User; import benchmark.rpc.util.HttpClientUtils; import benchmark.rpc.util.JsonUtils; /** * only for client * * @author Hank * */ public class TurboUserServiceJsonHttpClientImpl implements UserService { private static final String URL_EXIST_USER = "http://benchmark-server:8080/shop/auth/user/exist?v=2&email="; private static final String URL_CREATE_USER = "http://benchmark-server:8080/shop/auth/user/create?v=2"; private static final String URL_GET_USER = "http://benchmark-server:8080/shop/auth/user/get?v=2&id="; private static final String URL_LIST_USER = "http://benchmark-server:8080/shop/auth/user/list?v=1&pageNo="; private final CloseableHttpClient client; private final ObjectMapper objectMapper = JsonUtils.objectMapper; private final JavaType userPageType = objectMapper.getTypeFactory()// .constructParametricType(Page.class, User.class); public TurboUserServiceJsonHttpClientImpl(int concurrency) { client = HttpClientUtils.createHttpClient(concurrency); } @Override public boolean existUser(String email) { try { String url = URL_EXIST_USER + email; HttpGet request = new HttpGet(url); CloseableHttpResponse response = client.execute(request); String result = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8); return "true".equals(result); } catch (Exception e) { throw new RuntimeException(e); } } @Override public boolean createUser(User user) { try { byte[] bytes = objectMapper.writeValueAsBytes(user); HttpPost request = new HttpPost(URL_CREATE_USER); HttpEntity entity = EntityBuilder.create().setBinary(bytes).build(); request.setEntity(entity); CloseableHttpResponse response = client.execute(request); String result = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8); return "true".equals(result); } catch (Exception e) { throw new RuntimeException(e); } } @Override public User getUser(long id) { try { String url = URL_GET_USER + id; HttpGet request = new HttpGet(url); CloseableHttpResponse response = client.execute(request); byte[] bytes = EntityUtils.toByteArray(response.getEntity()); return objectMapper.readValue(bytes, User.class); } catch (Exception e) { throw new RuntimeException(e); } } @Override public Page listUser(int pageNo) { try { String url = URL_LIST_USER + pageNo; HttpGet request = new HttpGet(url); CloseableHttpResponse response = client.execute(request); byte[] bytes = EntityUtils.toByteArray(response.getEntity()); return objectMapper.readValue(bytes, userPageType); } catch (Exception e) { throw new RuntimeException(e); } } public static void main(String[] args) throws Exception { UserService userService = new UserServiceJsonHttpClientImpl(256); System.out.println(userService.existUser("1236")); System.out.println(userService.getUser(123)); System.out.println(userService.listUser(123)); } } ================================================ FILE: turbo-rest-server/.gitignore ================================================ /.apt_generated_tests/ ================================================ FILE: turbo-rest-server/pom.xml ================================================ 4.0.0 benchmark.rpc turbo-rest-server round-5 jar turbo-rest-server http://maven.apache.org 11 11 UTF-8 round-5 0.0.9 benchmark.rpc benchmark-base ${version.benchmark-base} com.turbo-rpc turbo-rpc ${version.turbo} com.turbo-rpc turbo-protostuff ${version.turbo} junit junit 4.12 test org.apache.maven.plugins maven-compiler-plugin 3.8.0 ${maven.compiler.source} ${maven.compiler.target} UTF-8 -parameters org.apache.maven.plugins maven-resources-plugin 3.1.0 UTF-8 maven-assembly-plugin 3.1.0 jar-with-dependencies benchmark.rpc.Server make-assembly package single src/main/resources ================================================ FILE: turbo-rest-server/src/main/java/benchmark/rpc/Server.java ================================================ package benchmark.rpc; import java.util.Map; import benchmark.rpc.service.TurboUserService; import benchmark.rpc.service.TurboUserServiceServerImpl; import io.netty.util.ResourceLeakDetector; import io.netty.util.ResourceLeakDetector.Level; import rpc.turbo.config.HostPort; import rpc.turbo.server.TurboServer; public class Server { public static void main(String[] args) throws Exception { ResourceLeakDetector.setLevel(Level.DISABLED); try (TurboServer server = new TurboServer("shop", "auth");) { Map, Object> services = Map.of(TurboUserService.class, new TurboUserServiceServerImpl()); server.registerService(services); server.startRestServer(new HostPort("benchmark-server", 8080)); server.waitUntilShutdown(); } } } ================================================ FILE: turbo-rest-server/src/main/java/benchmark/rpc/service/TurboUserService.java ================================================ package benchmark.rpc.service; import java.util.concurrent.CompletableFuture; import benchmark.bean.Page; import benchmark.bean.User; import rpc.turbo.annotation.TurboService; @TurboService(version = "1.0.0", rest = "user") public interface TurboUserService { @TurboService(version = "2.1.2", rest = "exist") public CompletableFuture existUser(String email); @TurboService(version = "2.1.2", rest = "create") public CompletableFuture createUser(User user); @TurboService(version = "2.1.2", rest = "get") public CompletableFuture getUser(long id); @TurboService(version = "1.2.1", rest = "list") public CompletableFuture> listUser(int pageNo); } ================================================ FILE: turbo-rest-server/src/main/java/benchmark/rpc/service/TurboUserServiceServerImpl.java ================================================ package benchmark.rpc.service; import java.time.LocalDate; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.concurrent.CompletableFuture; import benchmark.bean.Page; import benchmark.bean.User; public class TurboUserServiceServerImpl implements TurboUserService { @Override public CompletableFuture existUser(String email) { if (email == null || email.isEmpty()) { return CompletableFuture.completedFuture(Boolean.TRUE); } if (email.charAt(email.length() - 1) < '5') { return CompletableFuture.completedFuture(Boolean.FALSE); } return CompletableFuture.completedFuture(Boolean.TRUE); } @Override public CompletableFuture getUser(long id) { User user = new User(); user.setId(id); user.setName(new String("Doug Lea")); user.setSex(1); user.setBirthday(LocalDate.of(1968, 12, 8)); user.setEmail(new String("dong.lea@gmail.com")); user.setMobile(new String("18612345678")); user.setAddress(new String("北京市 中关村 中关村大街1号 鼎好大厦 1605")); user.setIcon(new String("https://www.baidu.com/img/bd_logo1.png")); user.setStatus(1); user.setCreateTime(LocalDateTime.now()); user.setUpdateTime(user.getCreateTime()); List permissions = new ArrayList( Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 19, 88, 86, 89, 90, 91, 92)); user.setPermissions(permissions); return CompletableFuture.completedFuture(user); } @Override public CompletableFuture> listUser(int pageNo) { List userList = new ArrayList<>(15); for (int i = 0; i < 15; i++) { User user = new User(); user.setId(i); user.setName("Doug Lea" + i); user.setSex(1); user.setBirthday(LocalDate.of(1968, 12, 8)); user.setEmail("dong.lea@gmail.com" + i); user.setMobile("18612345678" + i); user.setAddress("北京市 中关村 中关村大街1号 鼎好大厦 1605" + i); user.setIcon("https://www.baidu.com/img/bd_logo1.png" + i); user.setStatus(1); user.setCreateTime(LocalDateTime.now()); user.setUpdateTime(user.getCreateTime()); List permissions = new ArrayList( Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 19, 88, 86, 89, 90, 91, 92)); user.setPermissions(permissions); userList.add(user); } Page page = new Page<>(); page.setPageNo(pageNo); page.setTotal(1000); page.setResult(userList); return CompletableFuture.completedFuture(page); } @Override public CompletableFuture createUser(User user) { if (user == null) { return CompletableFuture.completedFuture(Boolean.FALSE); } return CompletableFuture.completedFuture(Boolean.TRUE); } } ================================================ FILE: turbo-rest-server/src/main/resources/logback.xml ================================================ %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n logs/benchmark-rpc-client.log logs/benchmark-rpc-client.%d{yyyy-MM-dd}.log.gz %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n ================================================ FILE: turbo-rpc-client/.gitignore ================================================ /.apt_generated_tests/ ================================================ FILE: turbo-rpc-client/pom.xml ================================================ 4.0.0 benchmark.rpc turbo-rpc-client round-5 jar turbo-rpc-client http://maven.apache.org 11 11 UTF-8 round-5 0.0.9 benchmark.rpc benchmark-base ${version.benchmark-base} com.turbo-rpc turbo-rpc ${version.turbo} com.turbo-rpc turbo-kryo ${version.turbo} com.turbo-rpc turbo-protostuff ${version.turbo} junit junit 4.12 test org.apache.maven.plugins maven-compiler-plugin 3.8.0 ${maven.compiler.source} ${maven.compiler.target} UTF-8 -parameters org.apache.maven.plugins maven-resources-plugin 3.1.0 UTF-8 maven-assembly-plugin 3.1.0 jar-with-dependencies benchmark.rpc.Client make-assembly package single src/main/resources ================================================ FILE: turbo-rpc-client/src/main/java/benchmark/rpc/Client.java ================================================ package benchmark.rpc; import java.io.IOException; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; import benchmark.bean.Page; import benchmark.bean.User; import benchmark.rpc.service.TurboUserService; import benchmark.service.UserService; import benchmark.service.UserServiceServerImpl; import io.netty.util.ResourceLeakDetector; import io.netty.util.ResourceLeakDetector.Level; import rpc.turbo.client.TurboClient; @State(Scope.Benchmark) public class Client { public static final int CONCURRENCY = 32; private final AtomicInteger counter = new AtomicInteger(0); private final UserService _serviceUserService = new UserServiceServerImpl(); private final TurboClient client; private final TurboUserService userService; public Client() { ResourceLeakDetector.setLevel(Level.DISABLED); client = new TurboClient("turbo-client.conf"); try { client.register(TurboUserService.class); userService = client.getService(TurboUserService.class); } catch (Exception e) { throw new RuntimeException(e); } } @TearDown public void close() throws IOException { client.close(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) public Boolean existUser() throws Exception { String email = String.valueOf(counter.getAndIncrement()); return userService.existUser(email).join(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) public Boolean createUser() throws Exception { int id = counter.getAndIncrement(); User user = _serviceUserService.getUser(id); return userService.createUser(user).join(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) public User getUser() throws Exception { int id = counter.getAndIncrement(); return userService.getUser(id).join(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) public Page listUser() throws Exception { int pageNo = counter.getAndIncrement(); return userService.listUser(pageNo).join(); } public static void main(String[] args) throws Exception { Options opt = new OptionsBuilder()// .include(Client.class.getSimpleName())// .warmupIterations(3)// .warmupTime(TimeValue.seconds(10))// .measurementIterations(3)// .measurementTime(TimeValue.seconds(10))// .threads(CONCURRENCY)// .forks(1)// .build(); new Runner(opt).run(); } } ================================================ FILE: turbo-rpc-client/src/main/java/benchmark/rpc/service/TurboUserService.java ================================================ package benchmark.rpc.service; import java.util.concurrent.CompletableFuture; import benchmark.bean.Page; import benchmark.bean.User; import rpc.turbo.annotation.TurboService; @TurboService(version = "1.0.0", rest = "user") public interface TurboUserService { @TurboService(version = "2.1.2", rest = "exist") public CompletableFuture existUser(String email); @TurboService(version = "2.1.2", rest = "create") public CompletableFuture createUser(User user); @TurboService(version = "2.1.2", rest = "get") public CompletableFuture getUser(long id); @TurboService(version = "1.2.1", rest = "list") public CompletableFuture> listUser(int pageNo); } ================================================ FILE: turbo-rpc-client/src/main/resources/logback.xml ================================================ %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n logs/benchmark-rpc-client.log logs/benchmark-rpc-client.%d{yyyy-MM-dd}.log.gz %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n ================================================ FILE: turbo-rpc-client/src/main/resources/turbo-client.conf ================================================ #https://github.com/lightbend/config apps = [ { group = "shop" app = "auth" serializer.class = "rpc.turbo.serialization.kryo.KryoSerializer" #app全局超时时间,大于0时会把所有方法的timeout都给覆盖掉,可空 globalTimeout = 0 maxRequestWait = 0 #每个服务器几个连接,默认是1,性能不会太好 connectPerServer = 4 #每个服务器出错上限,达到后会把该服务器相关连接放到zombieMap里面,会有进程定期检查zombieMap,如果能连上就重新放到activeMap里面 serverErrorThreshold = 16 #如果设置的话必须满足connectErrorThreshold * connectonPerServer >= serverErrorThreshold,否则会导致无法进入zombieMap中 #connectErrorThreshold = 16 #负载均衡实现 loadBalanceFactory.class = "rpc.turbo.loadbalance.RoundRobinLoadBalanceFactory" #服务发现 discover { class = "rpc.turbo.discover.DirectConnectDiscover" address = ["benchmark-server:8080"] } } ] ================================================ FILE: turbo-rpc-server/.gitignore ================================================ /.apt_generated_tests/ ================================================ FILE: turbo-rpc-server/pom.xml ================================================ 4.0.0 benchmark.rpc turbo-rpc-server round-5 jar turbo-rpc-server http://maven.apache.org 11 11 UTF-8 round-5 2.1.2.RELEASE 0.0.9 benchmark.rpc benchmark-base ${version.benchmark-base} com.turbo-rpc turbo-rpc ${version.turbo} com.turbo-rpc turbo-kryo ${version.turbo} com.turbo-rpc turbo-protostuff ${version.turbo} com.turbo-rpc turbo-spring-boot-starter ${version.turbo} org.springframework.boot spring-boot-starter ${version.spring-boot} junit junit 4.12 test org.apache.maven.plugins maven-compiler-plugin 3.8.0 ${maven.compiler.source} ${maven.compiler.target} UTF-8 -parameters org.apache.maven.plugins maven-resources-plugin 3.1.0 UTF-8 org.springframework.boot spring-boot-maven-plugin benchmark.rpc.Server repackage src/main/resources ================================================ FILE: turbo-rpc-server/src/main/java/benchmark/rpc/Server.java ================================================ package benchmark.rpc; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import io.netty.util.ResourceLeakDetector; import io.netty.util.ResourceLeakDetector.Level; import rpc.turbo.boot.EnableTurboServer; @SpringBootApplication(scanBasePackages = { "benchmark" }) @EnableTurboServer public class Server { public static void main(String[] args) throws Exception { ResourceLeakDetector.setLevel(Level.DISABLED); SpringApplication.run(Server.class, args); } } ================================================ FILE: turbo-rpc-server/src/main/java/benchmark/rpc/service/TurboUserService.java ================================================ package benchmark.rpc.service; import java.util.concurrent.CompletableFuture; import benchmark.bean.Page; import benchmark.bean.User; import rpc.turbo.annotation.TurboService; @TurboService(version = "1.0.0", rest = "user") public interface TurboUserService { @TurboService(version = "2.1.2", rest = "exist") public CompletableFuture existUser(String email); @TurboService(version = "2.1.2", rest = "create") public CompletableFuture createUser(User user); @TurboService(version = "2.1.2", rest = "get") public CompletableFuture getUser(long id); @TurboService(version = "1.2.1", rest = "list") public CompletableFuture> listUser(int pageNo); } ================================================ FILE: turbo-rpc-server/src/main/java/benchmark/rpc/service/TurboUserServiceServerImpl.java ================================================ package benchmark.rpc.service; import java.time.LocalDate; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.concurrent.CompletableFuture; import org.springframework.stereotype.Component; import benchmark.bean.Page; import benchmark.bean.User; @Component public class TurboUserServiceServerImpl implements TurboUserService { @Override public CompletableFuture existUser(String email) { if (email == null || email.isEmpty()) { return CompletableFuture.completedFuture(Boolean.TRUE); } if (email.charAt(email.length() - 1) < '5') { return CompletableFuture.completedFuture(Boolean.FALSE); } return CompletableFuture.completedFuture(Boolean.TRUE); } @Override public CompletableFuture getUser(long id) { User user = new User(); user.setId(id); user.setName(new String("Doug Lea")); user.setSex(1); user.setBirthday(LocalDate.of(1968, 12, 8)); user.setEmail(new String("dong.lea@gmail.com")); user.setMobile(new String("18612345678")); user.setAddress(new String("北京市 中关村 中关村大街1号 鼎好大厦 1605")); user.setIcon(new String("https://www.baidu.com/img/bd_logo1.png")); user.setStatus(1); user.setCreateTime(LocalDateTime.now()); user.setUpdateTime(user.getCreateTime()); List permissions = new ArrayList( Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 19, 88, 86, 89, 90, 91, 92)); user.setPermissions(permissions); return CompletableFuture.completedFuture(user); } @Override public CompletableFuture> listUser(int pageNo) { List userList = new ArrayList<>(15); for (int i = 0; i < 15; i++) { User user = new User(); user.setId(i); user.setName("Doug Lea" + i); user.setSex(1); user.setBirthday(LocalDate.of(1968, 12, 8)); user.setEmail("dong.lea@gmail.com" + i); user.setMobile("18612345678" + i); user.setAddress("北京市 中关村 中关村大街1号 鼎好大厦 1605" + i); user.setIcon("https://www.baidu.com/img/bd_logo1.png" + i); user.setStatus(1); user.setCreateTime(LocalDateTime.now()); user.setUpdateTime(user.getCreateTime()); List permissions = new ArrayList( Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 19, 88, 86, 89, 90, 91, 92)); user.setPermissions(permissions); userList.add(user); } Page page = new Page<>(); page.setPageNo(pageNo); page.setTotal(1000); page.setResult(userList); return CompletableFuture.completedFuture(page); } @Override public CompletableFuture createUser(User user) { if (user == null) { return CompletableFuture.completedFuture(Boolean.FALSE); } return CompletableFuture.completedFuture(Boolean.TRUE); } } ================================================ FILE: turbo-rpc-server/src/main/resources/logback.xml ================================================ %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n logs/benchmark-rpc-client.log logs/benchmark-rpc-client.%d{yyyy-MM-dd}.log.gz %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n ================================================ FILE: turbo-rpc-server/src/main/resources/turbo-server.conf ================================================ group = shop app = auth #rpc序列化,默认为ProtostuffSerializer,可以修改为自己的实现 #"rpc.turbo.serialization.protostuff.ProtostuffSerializer" #"rpc.turbo.serialization.kryo.KryoSerializer" serializer.class = "rpc.turbo.serialization.kryo.KryoSerializer" #http json转换,默认为JacksonMapper,可以修改为自己的实现 jsonMapper.class = "rpc.turbo.serialization.jackson.JacksonMapper" registers = [ { #Register实现 register.class = "rpc.turbo.registry.DirectConnectRegister" #Register地址 register.address = ["benchmark-server:8086"] #发布协议,RPC或者REST server.protocol = "RPC" #对外服务地址,不同协议不能同一个端口,相同协议不允许出现port相同host不同的情况 server.address = "benchmark-server:8080" #对外服务权重 server.weight = 100 } ] ================================================ FILE: undertow-async-client/.gitignore ================================================ /.apt_generated_tests/ ================================================ FILE: undertow-async-client/pom.xml ================================================ 4.0.0 benchmark.rpc undertow-async-client round-5 jar undertow-async-client http://maven.apache.org 11 11 UTF-8 round-5 benchmark.rpc benchmark-base ${version.benchmark-base} junit junit 4.12 test org.apache.maven.plugins maven-compiler-plugin 3.8.0 ${maven.compiler.source} ${maven.compiler.target} UTF-8 org.apache.maven.plugins maven-resources-plugin 3.1.0 UTF-8 maven-assembly-plugin 3.1.0 jar-with-dependencies benchmark.rpc.Client make-assembly package single src/main/resources ================================================ FILE: undertow-async-client/src/main/java/benchmark/rpc/Client.java ================================================ package benchmark.rpc; import java.util.concurrent.TimeUnit; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; import benchmark.bean.Page; import benchmark.bean.User; import benchmark.service.UserService; import benchmark.service.UserServiceJsonHttpClientImpl; @State(Scope.Benchmark) public class Client extends AbstractClient { public static final int CONCURRENCY = 32; private final UserService userService = new UserServiceJsonHttpClientImpl(CONCURRENCY); @Override protected UserService getUserService() { return userService; } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public boolean existUser() throws Exception { return super.existUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public boolean createUser() throws Exception { return super.createUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public User getUser() throws Exception { return super.getUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public Page listUser() throws Exception { return super.listUser(); } public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder()// .include(Client.class.getSimpleName())// .warmupIterations(3)// .warmupTime(TimeValue.seconds(10))// .measurementIterations(3)// .measurementTime(TimeValue.seconds(10))// .threads(CONCURRENCY)// .forks(1)// .build(); new Runner(opt).run(); } } ================================================ FILE: undertow-async-server/.gitignore ================================================ /.apt_generated_tests/ ================================================ FILE: undertow-async-server/pom.xml ================================================ 4.0.0 benchmark.rpc undertow-async-server round-5 jar undertow-async-server http://maven.apache.org 11 11 UTF-8 round-5 2.0.17.Final benchmark.rpc benchmark-base ${version.benchmark-base} io.undertow undertow-core ${version.undertow} junit junit 4.12 test org.apache.maven.plugins maven-compiler-plugin 3.8.0 ${maven.compiler.source} ${maven.compiler.target} UTF-8 org.apache.maven.plugins maven-resources-plugin 3.1.0 UTF-8 maven-assembly-plugin 3.1.0 jar-with-dependencies benchmark.rpc.Server make-assembly package single src/main/resources ================================================ FILE: undertow-async-server/src/main/java/benchmark/rpc/Server.java ================================================ package benchmark.rpc; import benchmark.rpc.undertow.server.CreateUserHandler; import benchmark.rpc.undertow.server.UserExistHandler; import benchmark.rpc.undertow.server.GetUserHandler; import benchmark.rpc.undertow.server.ListUserHandler; import io.undertow.Undertow; import io.undertow.UndertowOptions; import io.undertow.server.HttpHandler; import io.undertow.server.handlers.PathHandler; public class Server { public static final String host = "benchmark-server"; public static final int port = 8080; public static void main(String[] args) { Undertow.builder()// .addHttpListener(port, host)// .setServerOption(UndertowOptions.ALWAYS_SET_KEEP_ALIVE, false)// .setServerOption(UndertowOptions.ALWAYS_SET_DATE, false)// .setHandler(paths())// .build()// .start(); } private static HttpHandler paths() { return new PathHandler()// .addExactPath("/user-exist", new UserExistHandler())// .addExactPath("/create-user", new CreateUserHandler())// .addExactPath("/get-user", new GetUserHandler())// .addExactPath("/list-user", new ListUserHandler())// ; } } ================================================ FILE: undertow-async-server/src/main/java/benchmark/rpc/undertow/server/CreateUserHandler.java ================================================ package benchmark.rpc.undertow.server; import com.fasterxml.jackson.databind.ObjectMapper; import benchmark.bean.User; import benchmark.rpc.util.JsonUtils; import benchmark.service.UserService; import benchmark.service.UserServiceServerImpl; import io.undertow.async.handler.AsyncHttpHandler; import io.undertow.async.io.PooledByteBufferInputStream; import io.undertow.server.HttpServerExchange; import io.undertow.util.StatusCodes; public class CreateUserHandler extends AsyncHttpHandler { private final ObjectMapper objectMapper = JsonUtils.objectMapper; private final UserService userService = new UserServiceServerImpl(); @Override protected void handleAsyncRequest(HttpServerExchange exchange, PooledByteBufferInputStream content) throws Exception { byte[] bytes = readBytesAndClose(content); User user = objectMapper.readValue(bytes, User.class); userService.createUser(user); send(exchange, StatusCodes.OK, "true"); } } ================================================ FILE: undertow-async-server/src/main/java/benchmark/rpc/undertow/server/GetUserHandler.java ================================================ package benchmark.rpc.undertow.server; import java.util.Deque; import java.util.Map; import com.fasterxml.jackson.databind.ObjectMapper; import benchmark.bean.User; import benchmark.rpc.util.JsonUtils; import benchmark.service.UserService; import benchmark.service.UserServiceServerImpl; import io.undertow.async.handler.AsyncHttpHandler; import io.undertow.async.io.PooledByteBufferInputStream; import io.undertow.async.io.PooledByteBufferOutputStream; import io.undertow.connector.ByteBufferPool; import io.undertow.server.HttpServerExchange; import io.undertow.util.StatusCodes; public class GetUserHandler extends AsyncHttpHandler { private final ObjectMapper objectMapper = JsonUtils.objectMapper; private final UserService userService = new UserServiceServerImpl(); @Override protected void handleAsyncRequest(HttpServerExchange exchange, PooledByteBufferInputStream content) throws Exception { Map> params = exchange.getQueryParameters(); String idStr = params.get("id").getFirst(); long id = Integer.parseInt(idStr); User user = userService.getUser(id); ByteBufferPool pool = exchange.getConnection().getByteBufferPool(); PooledByteBufferOutputStream output = new PooledByteBufferOutputStream(pool); objectMapper.writeValue(output, user); send(exchange, StatusCodes.OK, output); } } ================================================ FILE: undertow-async-server/src/main/java/benchmark/rpc/undertow/server/ListUserHandler.java ================================================ package benchmark.rpc.undertow.server; import java.util.Deque; import java.util.Map; import com.fasterxml.jackson.databind.ObjectMapper; import benchmark.bean.Page; import benchmark.bean.User; import benchmark.rpc.util.JsonUtils; import benchmark.service.UserService; import benchmark.service.UserServiceServerImpl; import io.undertow.async.handler.AsyncHttpHandler; import io.undertow.async.io.PooledByteBufferInputStream; import io.undertow.async.io.PooledByteBufferOutputStream; import io.undertow.connector.ByteBufferPool; import io.undertow.server.HttpServerExchange; import io.undertow.util.StatusCodes; public class ListUserHandler extends AsyncHttpHandler { private final ObjectMapper objectMapper = JsonUtils.objectMapper; private final UserService userService = new UserServiceServerImpl(); @Override protected void handleAsyncRequest(HttpServerExchange exchange, PooledByteBufferInputStream content) throws Exception { Map> params = exchange.getQueryParameters(); String pageNoStr = params.get("pageNo").getFirst(); int pageNo = Integer.parseInt(pageNoStr); Page userList = userService.listUser(pageNo); ByteBufferPool pool = exchange.getConnection().getByteBufferPool(); PooledByteBufferOutputStream output = new PooledByteBufferOutputStream(pool); objectMapper.writeValue(output, userList); send(exchange, StatusCodes.OK, output); } } ================================================ FILE: undertow-async-server/src/main/java/benchmark/rpc/undertow/server/UserExistHandler.java ================================================ package benchmark.rpc.undertow.server; import java.util.Deque; import java.util.Map; import benchmark.service.UserService; import benchmark.service.UserServiceServerImpl; import io.undertow.async.handler.AsyncHttpHandler; import io.undertow.async.io.PooledByteBufferInputStream; import io.undertow.server.HttpServerExchange; import io.undertow.util.StatusCodes; public class UserExistHandler extends AsyncHttpHandler { private final UserService userService = new UserServiceServerImpl(); @Override protected void handleAsyncRequest(HttpServerExchange exchange, PooledByteBufferInputStream content) throws Exception { Map> params = exchange.getQueryParameters(); String email = params.get("email").getFirst(); if (userService.existUser(email)) { send(exchange, StatusCodes.OK, "true"); } else { send(exchange, StatusCodes.OK, "false"); } } } ================================================ FILE: undertow-async-server/src/main/java/io/undertow/async/handler/AsyncHttpHandler.java ================================================ /* * 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 io.undertow.async.handler; import static io.undertow.async.util.UnsafeUtils.unsafe; import static org.xnio.Bits.intBitMask; import java.io.IOException; import java.lang.reflect.Field; import java.nio.ByteBuffer; import java.util.ArrayList; import org.xnio.IoUtils; import org.xnio.channels.StreamSinkChannel; import org.xnio.channels.StreamSourceChannel; import io.undertow.UndertowLogger; import io.undertow.async.io.PooledByteBufferInputStream; import io.undertow.async.io.PooledByteBufferOutputStream; import io.undertow.connector.ByteBufferPool; import io.undertow.connector.PooledByteBuffer; import io.undertow.io.AsyncSenderImpl; import io.undertow.io.Receiver.RequestToLargeException; import io.undertow.io.Sender; import io.undertow.server.Connectors; import io.undertow.server.HttpHandler; import io.undertow.server.HttpServerExchange; import io.undertow.util.Headers; import io.undertow.util.HttpString; import io.undertow.util.Methods; /** * unsafe and only support few versions * * @author hank.whu@gmail.com * */ public abstract class AsyncHttpHandler implements HttpHandler { private static final PooledByteBuffer[] EMPTY_BUFFERS = PooledByteBufferInputStream.EMPTY_BUFFERS; private static final int MASK_RESPONSE_CODE = intBitMask(0, 9); private static final long exchangeResponseChannelFieldOffset; private static final long exchangeStatusCodeFieldOffset; private static final long asyncSenderImplChannelFieldOffset; private static final long asyncSenderImplPooledBuffersFieldOffset; @Override final public void handleRequest(HttpServerExchange exchange) throws Exception { HttpString httpMethod = exchange.getRequestMethod(); if (httpMethod == Methods.GET) { internalAsyncRequest(exchange, null); return; } final String contentLengthString = exchange.getRequestHeaders().getFirst(Headers.CONTENT_LENGTH); final long contentLength; if (contentLengthString != null) { contentLength = Long.parseLong(contentLengthString); if (contentLength > Integer.MAX_VALUE) { throw new RequestToLargeException(); } } else { contentLength = -1; } PooledByteBuffer buffer = exchange.getConnection().getByteBufferPool().allocate(); final ArrayList bufferList; if (contentLength > 0) { int bufferLength = buffer.getBuffer().capacity(); long count = (contentLength + bufferLength - 1) / bufferLength;// ceil div bufferList = new ArrayList<>((int) count); } else { bufferList = new ArrayList<>(8);// usually enough } final StreamSourceChannel channel = exchange.getRequestChannel(); // copy from io.undertow.server.handlers.RequestBufferingHandler try { do { ByteBuffer b = buffer.getBuffer(); int r = channel.read(b); if (r == -1) { // TODO: listener read if (b.position() == 0) { buffer.close(); } else { b.flip(); bufferList.add(buffer); } break; } else if (r == 0) { final PooledByteBuffer finalBuffer = buffer; channel.getReadSetter().set(requestChannel -> { PooledByteBuffer pooledByteBuffer = finalBuffer; try { do { ByteBuffer byteBuffer = pooledByteBuffer.getBuffer(); int readLength = requestChannel.read(byteBuffer); if (readLength == -1) { // TODO: listener read if (byteBuffer.position() == 0) { pooledByteBuffer.close(); } else { byteBuffer.flip(); bufferList.add(pooledByteBuffer); } Connectors.resetRequestChannel(exchange); requestChannel.getReadSetter().set(null); return; } else if (readLength == 0) { return; } else if (!byteBuffer.hasRemaining()) { byteBuffer.flip(); bufferList.add(pooledByteBuffer); pooledByteBuffer = exchange.getConnection().getByteBufferPool().allocate(); } } while (true); } catch (Throwable t) { if (t instanceof IOException) { UndertowLogger.REQUEST_IO_LOGGER.ioException((IOException) t); } else { UndertowLogger.REQUEST_IO_LOGGER.handleUnexpectedFailure(t); } release(bufferList); if (pooledByteBuffer != null && pooledByteBuffer.isOpen()) { IoUtils.safeClose(pooledByteBuffer); } exchange.endExchange(); return; } }); channel.resumeReads(); internalAsyncRequest(exchange, bufferList); return; } else if (!b.hasRemaining()) { b.flip(); bufferList.add(buffer); buffer = exchange.getConnection().getByteBufferPool().allocate(); } } while (true); Connectors.resetRequestChannel(exchange); internalAsyncRequest(exchange, bufferList); } catch (Throwable e) { release(bufferList); if (buffer != null && buffer.isOpen()) { IoUtils.safeClose(buffer); } throw e; } } private void internalAsyncRequest(final HttpServerExchange exchange, ArrayList bufferList) throws Exception { // ensure exchange not end getResponseChannel(exchange).resumeWrites(); PooledByteBuffer[] buffers = EMPTY_BUFFERS; if (bufferList != null && bufferList.size() > 0) { buffers = new PooledByteBuffer[bufferList.size()]; buffers = bufferList.toArray(buffers); } handleAsyncRequest(exchange, new PooledByteBufferInputStream(buffers)); } /** * will be called after get all request data.
* * * @param exchange * * @param content * must close it * * @throws Exception */ protected abstract void handleAsyncRequest(HttpServerExchange exchange, PooledByteBufferInputStream content) throws Exception; protected byte[] readBytesAndClose(PooledByteBufferInputStream content) { try { byte[] bytes = new byte[content.available()]; content.read(bytes); return bytes; } catch (IOException e) { throw new RuntimeException(e); } finally { try {// must close it content.close(); } catch (IOException e) { e.printStackTrace(); } } } /** * response * * @param exchange * @param statusCode * @param msg */ protected final void send(HttpServerExchange exchange, int statusCode, String msg) { ByteBufferPool pool = exchange.getConnection().getByteBufferPool(); PooledByteBufferOutputStream output = new PooledByteBufferOutputStream(pool); try { output.write(msg); } catch (IOException e) { UndertowLogger.REQUEST_IO_LOGGER.ioException(e); } send(exchange, statusCode, output); } /** * response * * @param exchange * @param statusCode * @param output * auto release */ protected final void send(HttpServerExchange exchange, int statusCode, PooledByteBufferOutputStream output) { try { output.flip(); StreamSinkChannel channel = getResponseChannel(exchange); Sender sender = exchange.getResponseSender(); setStatusCode(exchange, statusCode); setResponseChannel(sender, channel); setPooledBuffers(sender, output.getPooledByteBuffers()); sender.send(output.getByteBuffers()); } catch (Throwable t) { UndertowLogger.REQUEST_IO_LOGGER.handleUnexpectedFailure(t); } } /** * return the buffer to the buffer pool * * @param bufferList */ private void release(ArrayList bufferList) { if (bufferList == null || bufferList.size() == 0) { return; } for (int i = 0; i < bufferList.size(); ++i) { IoUtils.safeClose(bufferList.get(i)); } } /** * force get response channel * * @param exchange * @return */ private StreamSinkChannel getResponseChannel(HttpServerExchange exchange) { StreamSinkChannel channel = (StreamSinkChannel) unsafe().getObject(exchange, exchangeResponseChannelFieldOffset); if (channel == null) { channel = exchange.getResponseChannel(); } return channel; } /** * force set status code * * @param exchange * @param statusCode */ private void setStatusCode(HttpServerExchange exchange, int statusCode) { int oldVal = unsafe().getInt(exchange, exchangeStatusCodeFieldOffset); int newVal = oldVal & ~MASK_RESPONSE_CODE | statusCode & MASK_RESPONSE_CODE; unsafe().getAndSetInt(exchange, exchangeStatusCodeFieldOffset, newVal); } /** * force set response channel * * @param sender * @param channel */ private void setResponseChannel(Sender sender, StreamSinkChannel channel) { if (!(sender instanceof AsyncSenderImpl)) { throw new RuntimeException("only support AsyncSenderImpl"); } unsafe().getAndSetObject(sender, asyncSenderImplChannelFieldOffset, channel); } /** * just for async release * * @param sender * @param pooledBuffers * will be released */ private void setPooledBuffers(Sender sender, PooledByteBuffer[] pooledBuffers) { if (!(sender instanceof AsyncSenderImpl)) { throw new RuntimeException("only support AsyncSenderImpl"); } unsafe().getAndSetObject(sender, asyncSenderImplPooledBuffersFieldOffset, pooledBuffers); } static { try { Field field = HttpServerExchange.class.getDeclaredField("responseChannel"); exchangeResponseChannelFieldOffset = unsafe().objectFieldOffset(field); } catch (Throwable e) { throw new RuntimeException("cannot find HttpServerExchange.responseChannel", e); } try { Field field = HttpServerExchange.class.getDeclaredField("state"); exchangeStatusCodeFieldOffset = unsafe().objectFieldOffset(field); } catch (Throwable e) { throw new RuntimeException("cannot find HttpServerExchange.state", e); } try { Field field = AsyncSenderImpl.class.getDeclaredField("channel"); asyncSenderImplChannelFieldOffset = unsafe().objectFieldOffset(field); } catch (Throwable e) { throw new RuntimeException("cannot find AsyncSenderImpl.channel", e); } try { Field field = AsyncSenderImpl.class.getDeclaredField("pooledBuffers"); asyncSenderImplPooledBuffersFieldOffset = unsafe().objectFieldOffset(field); } catch (Throwable e) { throw new RuntimeException("cannot find AsyncSenderImpl.pooledBuffers", e); } } } ================================================ FILE: undertow-async-server/src/main/java/io/undertow/async/io/PooledByteBufferInputStream.java ================================================ /* * 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 io.undertow.async.io; import java.io.IOException; import java.io.InputStream; import java.nio.ByteBuffer; import java.util.Objects; import io.undertow.connector.PooledByteBuffer; /** * * @author hank.whu@gmail.com * */ public final class PooledByteBufferInputStream extends InputStream { public static final PooledByteBuffer[] EMPTY_BUFFERS = new PooledByteBuffer[0]; private PooledByteBuffer[] buffers; private int index = -1; private ByteBuffer current; public PooledByteBufferInputStream(PooledByteBuffer[] buffers) { Objects.requireNonNull(buffers); for (int i = 0; i < buffers.length; i++) { if (!buffers[i].isOpen()) { throw new IllegalAccessError("buffers must all open"); } } this.buffers = buffers; next(); } private void next() { if (buffers.length > ++index) { current = buffers[index].getBuffer(); return; } current = null; } public void flip() { for (int i = 0; i < buffers.length; i++) { buffers[i].getBuffer().flip(); } } @Override public int read() throws IOException { while (current != null && !current.hasRemaining()) { next(); } if (current == null) { return -1; } return current.get() & 0xFF; } @Override public int read(byte[] bytes) throws IOException { return read(bytes, 0, bytes.length); } @Override public int read(byte[] bytes, int off, int len) throws IOException { if (bytes == null) { throw new NullPointerException(); } else if (off < 0 || len < 0 || len > bytes.length - off) { throw new IndexOutOfBoundsException(); } int readLength = 0; while (current != null && len > 0) { while (current != null && !current.hasRemaining()) { next(); } if (current == null) { break; } int currentRead = Math.min(current.remaining(), len); current.get(bytes, off, currentRead); readLength += currentRead; off += currentRead; len -= currentRead; } return readLength == 0 ? -1 : readLength; } @Override public long skip(long n) throws IOException { long remaining = n; while (current != null && remaining > 0) { while (current != null && !current.hasRemaining()) { next(); } if (current == null) { break; } int currentSkip = (int) Math.min(current.remaining(), remaining); current.position(current.position() + currentSkip); remaining -= currentSkip; } return n - remaining; } @Override public int available() throws IOException { int remaining = 0; for (int i = 0; i < buffers.length; i++) { remaining += buffers[i].getBuffer().remaining(); } return remaining; } @Override public void close() throws IOException { if (buffers == null || buffers == EMPTY_BUFFERS) { return; } for (int i = 0; i < buffers.length; i++) { buffers[i].close(); } buffers = EMPTY_BUFFERS; } @Override public synchronized void mark(int readlimit) { throw new UnsupportedOperationException(); } @Override public synchronized void reset() throws IOException { throw new UnsupportedOperationException(); } @Override public boolean markSupported() { return false; } } ================================================ FILE: undertow-async-server/src/main/java/io/undertow/async/io/PooledByteBufferOutputStream.java ================================================ /* * 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 io.undertow.async.io; import java.io.IOException; import java.io.OutputStream; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Objects; import org.xnio.IoUtils; import io.undertow.connector.ByteBufferPool; import io.undertow.connector.PooledByteBuffer; /** * * @author hank.whu@gmail.com * */ public final class PooledByteBufferOutputStream extends OutputStream { private final ByteBufferPool byteBufferPool; private ArrayList pooledList = new ArrayList<>(4); private int index = -1; private ByteBuffer current; public PooledByteBufferOutputStream(ByteBufferPool byteBufferPool) { this.byteBufferPool = byteBufferPool; } public PooledByteBuffer[] getPooledByteBuffers() { PooledByteBuffer[] buffers = new PooledByteBuffer[pooledList.size()]; return pooledList.toArray(buffers); } public ByteBuffer[] getByteBuffers() { ByteBuffer[] buffers = new ByteBuffer[pooledList.size()]; for (int i = 0; i < pooledList.size(); i++) { buffers[i] = pooledList.get(i).getBuffer(); } return buffers; } public void flip() { for (int i = 0; i < pooledList.size(); i++) { PooledByteBuffer pooled = pooledList.get(i); pooled.getBuffer().flip(); } } public void clear() { for (int i = 0; i < pooledList.size(); i++) { PooledByteBuffer pooled = pooledList.get(i); pooled.getBuffer().clear(); } current = null; index = -1; } public void release() { for (int i = 0; i < pooledList.size(); i++) { PooledByteBuffer pooled = pooledList.get(i); IoUtils.safeClose(pooled); } pooledList.clear(); } @Override public void write(final byte[] bytes, int offset, int length) throws IOException { Objects.requireNonNull(bytes, "bytes is null"); if (length <= 0) { return; } if (current == null) { alloc(); } while (length > 0) { if (!current.hasRemaining()) { alloc(); } int writeLength = Math.min(current.remaining(), length); current.put(bytes, offset, writeLength); length -= writeLength; offset += writeLength; } } public void write(String str) throws IOException { write(str.getBytes(StandardCharsets.UTF_8)); } @Override public void write(byte[] bytes) throws IOException { write(bytes, 0, bytes.length); } @Override public void write(int b) throws IOException { if (current == null || !current.hasRemaining()) { alloc(); } current.put((byte) b); } private void alloc() { index++; if (pooledList.size() - 1 > index) { current = pooledList.get(index).getBuffer(); return; } PooledByteBuffer pooled = byteBufferPool.allocate(); current = pooled.getBuffer(); pooledList.add(pooled); } } ================================================ FILE: undertow-async-server/src/main/java/io/undertow/async/util/UnsafeUtils.java ================================================ /* * 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 io.undertow.async.util; import sun.misc.Unsafe; /** * * @author hank.whu@gmail.com * */ public final class UnsafeUtils { final static private Unsafe _unsafe; static { Unsafe tmpUnsafe = null; try { java.lang.reflect.Field field = sun.misc.Unsafe.class.getDeclaredField("theUnsafe"); field.setAccessible(true); tmpUnsafe = (sun.misc.Unsafe) field.get(null); } catch (java.lang.Exception e) { throw new RuntimeException(e); } _unsafe = tmpUnsafe; } public static final Unsafe unsafe() { return _unsafe; } } ================================================ FILE: undertow-async-server/src/main/resources/logback.xml ================================================ %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n logs/benchmark-rpc-server.log logs/benchmark-rpc-server.%d{yyyy-MM-dd}.log.gz %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n ================================================ FILE: undertow-client/.gitignore ================================================ /.apt_generated_tests/ ================================================ FILE: undertow-client/pom.xml ================================================ 4.0.0 benchmark.rpc undertow-client round-5 jar undertow-client http://maven.apache.org 11 11 UTF-8 round-5 benchmark.rpc benchmark-base ${version.benchmark-base} junit junit 4.12 test org.apache.maven.plugins maven-compiler-plugin 3.8.0 ${maven.compiler.source} ${maven.compiler.target} UTF-8 org.apache.maven.plugins maven-resources-plugin 3.1.0 UTF-8 maven-assembly-plugin 3.1.0 jar-with-dependencies benchmark.rpc.Client make-assembly package single src/main/resources ================================================ FILE: undertow-client/src/main/java/benchmark/rpc/Client.java ================================================ package benchmark.rpc; import java.util.concurrent.TimeUnit; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; import benchmark.bean.Page; import benchmark.bean.User; import benchmark.service.UserService; import benchmark.service.UserServiceJsonHttpClientImpl; @State(Scope.Benchmark) public class Client extends AbstractClient { public static final int CONCURRENCY = 32; private final UserService userService = new UserServiceJsonHttpClientImpl(CONCURRENCY); @Override protected UserService getUserService() { return userService; } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public boolean existUser() throws Exception { return super.existUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public boolean createUser() throws Exception { return super.createUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public User getUser() throws Exception { return super.getUser(); } @Benchmark @BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime }) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Override public Page listUser() throws Exception { return super.listUser(); } public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder()// .include(Client.class.getSimpleName())// .warmupIterations(3)// .warmupTime(TimeValue.seconds(10))// .measurementIterations(3)// .measurementTime(TimeValue.seconds(10))// .threads(CONCURRENCY)// .forks(1)// .build(); new Runner(opt).run(); } } ================================================ FILE: undertow-server/.gitignore ================================================ /.apt_generated_tests/ ================================================ FILE: undertow-server/pom.xml ================================================ 4.0.0 benchmark.rpc undertow-server round-5 jar undertow-server http://maven.apache.org 11 11 UTF-8 round-5 2.0.17.Final benchmark.rpc benchmark-base ${version.benchmark-base} io.undertow undertow-core ${version.undertow} junit junit 4.12 test org.apache.maven.plugins maven-compiler-plugin 3.8.0 ${maven.compiler.source} ${maven.compiler.target} UTF-8 org.apache.maven.plugins maven-resources-plugin 3.1.0 UTF-8 maven-assembly-plugin 3.1.0 jar-with-dependencies benchmark.rpc.Server make-assembly package single src/main/resources ================================================ FILE: undertow-server/src/main/java/benchmark/rpc/Server.java ================================================ package benchmark.rpc; import benchmark.rpc.undertow.server.CreateUserHandler; import benchmark.rpc.undertow.server.UserExistHandler; import benchmark.rpc.undertow.server.GetUserHandler; import benchmark.rpc.undertow.server.ListUserHandler; import io.undertow.Undertow; import io.undertow.UndertowOptions; import io.undertow.server.HttpHandler; import io.undertow.server.handlers.PathHandler; public class Server { public static final String host = "benchmark-server"; public static final int port = 8080; public static void main(String[] args) { Undertow.builder()// .addHttpListener(port, host)// .setServerOption(UndertowOptions.ALWAYS_SET_KEEP_ALIVE, false)// .setServerOption(UndertowOptions.ALWAYS_SET_DATE, false)// .setHandler(paths())// .build()// .start(); } private static HttpHandler paths() { return new PathHandler()// .addExactPath("/user-exist", new UserExistHandler())// .addExactPath("/create-user", new CreateUserHandler())// .addExactPath("/get-user", new GetUserHandler())// .addExactPath("/list-user", new ListUserHandler())// ; } } ================================================ FILE: undertow-server/src/main/java/benchmark/rpc/undertow/server/CreateUserHandler.java ================================================ package benchmark.rpc.undertow.server; import java.nio.ByteBuffer; import com.fasterxml.jackson.databind.ObjectMapper; import benchmark.bean.User; import benchmark.rpc.util.ByteBufferUtils; import benchmark.rpc.util.JsonUtils; import benchmark.service.UserService; import benchmark.service.UserServiceServerImpl; import io.undertow.server.HttpHandler; import io.undertow.server.HttpServerExchange; public class CreateUserHandler implements HttpHandler { private final ByteBuffer trueResult = ByteBufferUtils.allocateDirect("true"); private final ByteBuffer falseResult = ByteBufferUtils.allocateDirect("false"); private final ObjectMapper objectMapper = JsonUtils.objectMapper; private final UserService userService = new UserServiceServerImpl(); @Override public void handleRequest(HttpServerExchange _exchange) throws Exception { _exchange.getRequestReceiver().receiveFullBytes(// (exchange, data) -> {// do stuff with the data try { User user = objectMapper.readValue(data, User.class); userService.createUser(user); exchange.getResponseSender().send(trueResult.duplicate()); } catch (Exception e) { e.printStackTrace(); exchange.setStatusCode(500); exchange.getResponseSender().send(falseResult.duplicate()); } }, // (exchange, exception) -> {// optional error handler exchange.setStatusCode(500); exchange.getResponseSender().send(falseResult.duplicate()); }); } } ================================================ FILE: undertow-server/src/main/java/benchmark/rpc/undertow/server/GetUserHandler.java ================================================ package benchmark.rpc.undertow.server; import java.nio.ByteBuffer; import java.util.Deque; import java.util.Map; import com.fasterxml.jackson.databind.ObjectMapper; import benchmark.bean.User; import benchmark.rpc.util.ByteBufferUtils; import benchmark.rpc.util.JsonUtils; import benchmark.service.UserService; import benchmark.service.UserServiceServerImpl; import io.undertow.server.HttpHandler; import io.undertow.server.HttpServerExchange; public class GetUserHandler implements HttpHandler { private final ObjectMapper objectMapper = JsonUtils.objectMapper; private final UserService userService = new UserServiceServerImpl(); @Override public void handleRequest(HttpServerExchange exchange) throws Exception { Map> params = exchange.getQueryParameters(); String idStr = params.get("id").getFirst(); long id = Integer.parseInt(idStr); User user = userService.getUser(id); byte[] bytes = objectMapper.writeValueAsBytes(user); ByteBuffer buffer = ByteBufferUtils.allocate(bytes); exchange.getResponseSender().send(buffer); } } ================================================ FILE: undertow-server/src/main/java/benchmark/rpc/undertow/server/ListUserHandler.java ================================================ package benchmark.rpc.undertow.server; import java.nio.ByteBuffer; import java.util.Deque; import java.util.Map; import com.fasterxml.jackson.databind.ObjectMapper; import benchmark.bean.Page; import benchmark.bean.User; import benchmark.rpc.util.ByteBufferUtils; import benchmark.rpc.util.JsonUtils; import benchmark.service.UserService; import benchmark.service.UserServiceServerImpl; import io.undertow.server.HttpHandler; import io.undertow.server.HttpServerExchange; public class ListUserHandler implements HttpHandler { private final ObjectMapper objectMapper = JsonUtils.objectMapper; private final UserService userService = new UserServiceServerImpl(); @Override public void handleRequest(HttpServerExchange exchange) throws Exception { Map> params = exchange.getQueryParameters(); String pageNoStr = params.get("pageNo").getFirst(); int pageNo = Integer.parseInt(pageNoStr); Page userList = userService.listUser(pageNo); byte[] bytes = objectMapper.writeValueAsBytes(userList); ByteBuffer buffer = ByteBufferUtils.allocate(bytes); exchange.getResponseSender().send(buffer); } } ================================================ FILE: undertow-server/src/main/java/benchmark/rpc/undertow/server/UserExistHandler.java ================================================ package benchmark.rpc.undertow.server; import java.nio.ByteBuffer; import java.util.Deque; import java.util.Map; import benchmark.rpc.util.ByteBufferUtils; import benchmark.service.UserService; import benchmark.service.UserServiceServerImpl; import io.undertow.server.HttpHandler; import io.undertow.server.HttpServerExchange; public class UserExistHandler implements HttpHandler { private final ByteBuffer trueResult = ByteBufferUtils.allocateDirect("true"); private final ByteBuffer falseResult = ByteBufferUtils.allocateDirect("false"); private final UserService userService = new UserServiceServerImpl(); @Override public void handleRequest(HttpServerExchange exchange) throws Exception { Map> params = exchange.getQueryParameters(); String email = params.get("email").getFirst(); if (userService.existUser(email)) { exchange.getResponseSender().send(trueResult.duplicate()); } else { exchange.getResponseSender().send(falseResult.duplicate()); } } } ================================================ FILE: undertow-server/src/main/resources/logback.xml ================================================ %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n logs/benchmark-rpc-server.log logs/benchmark-rpc-server.%d{yyyy-MM-dd}.log.gz %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n