2022年THRIFT开发教程 .pdf
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_05.gif)
《2022年THRIFT开发教程 .pdf》由会员分享,可在线阅读,更多相关《2022年THRIFT开发教程 .pdf(5页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、1 编写 thrift 文件(如 aa.thrift)namespacejava com.tv189.uc.thriftnamespacecpp thrift.vdbnamespacerb thrift.vdbnamespaceperl thrift.vdbnamespacecsharp thrift.vdbnamespacejs thrift.vdbnamespacest thrift.vdbnamespacepy thrift.vdbnamespacephp thriftservice UCThriftServicestring ucOperator(1:stringactionType,
2、2:string uid, 3:string data),2 生成 java 文件thrift-0.6.0.exe-r -gen java uc.thriftthrift-0.6.0.exe-r -gen java uc.thriftthrift-0.6.0.exe-r -gen php uc.thriftthrift-0.6.0.exe-r -gen py uc.thrift可以生成 php,py 等等的3 服务端编写1)实现 UCThriftService.Ifacepublic class UCThriftServiceImplimplementsUCThriftService.Ifac
3、epublic static Logger logger = Logger.getLogger(UCThriftServiceImpl.class);Overridepublic String ucOperator(StringactionType,String suid, String data)throws TExceptionSystem.out.println(test);2)运行的 main 编写public class UCServiceServerprivate static Logger logger = Logger.getLogger(UCServiceServer.cla
4、ss);public static void main(String.args) throws Exception /这个是用 properties编写的,可以自行决定String server = PropertiesUtil.getValue(tserver.properties,ucserver.nio,hahs);if (nio.equalsIgnoreCase(server)startNIO(); if (hahs.equalsIgnoreCase(server)名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心
5、整理 - - - - - - - 第 1 页,共 5 页 - - - - - - - - - startHAHS(); else start();private static void start() throws TTransportExceptionString address = PropertiesUtil.getValue(tserver.properties,ucserver.address,0.0.0.0);int port = Integer.parseInt(PropertiesUtil.getValue(tserver.properties,ucserver.port,55
6、55);int clientTimeout=Integer.parseInt(PropertiesUtil.getValue(tserver.properties,ucserver.clientTimeout,30000);int minWorkerThreads=Integer.parseInt(PropertiesUtil.getValue(tserver.properties,ucserver.minWorkerThreads,25);int maxWorkerThreads=Integer.parseInt(PropertiesUtil.getValue(tserver.propert
7、ies,ucserver.maxWorkerThreads,25);String protocol = PropertiesUtil.getValue(tserver.properties,ucserver.protocol,binary);TServerSocketsocket = new TServerSocket(newInetSocketAddress(address,port), clientTimeout);UCThriftService.Processorprocess = new UCThriftService.Processor(UCThriftServiceImpl.ins
8、tance();TThreadPoolServer.Argsarg = new TThreadPoolServer.Args(socket);if(compact.equalsIgnoreCase(protocol)arg.protocolFactory(newTCompactProtocol.Factory();else if(binary.equalsIgnoreCase(protocol)arg.protocolFactory(newTBinaryProtocol.Factory();elsearg.protocolFactory(newTBinaryProtocol.Factory()
9、;arg.transportFactory(newTFramedTransport.Factory();arg.maxWorkerThreads(maxWorkerThreads);arg.minWorkerThreads(minWorkerThreads);/ arg.processor(process);arg.processorFactory(newTProcessorFactory(process);TServer server = new TThreadPoolServer(arg);Logger.getLogger(UCServiceServer.class).info(UCSer
10、viceServer.class.getSimpleName()+ Listen at + port);while(true)try server.serve(); catch (Exception e) logger.error(e.getMessage(),e);server.stop();Logger.getLogger(UCServiceServer.class).info(UCServiceServer.class.getSimpleName()+ Reload);名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精
11、心整理 - - - - - - - 第 2 页,共 5 页 - - - - - - - - - server = new TThreadPoolServer(arg);private static void startNIO()throws TTransportExceptionString address = PropertiesUtil.getValue(tserver.properties,ucserver.address,0.0.0.0);int port = Integer.parseInt(PropertiesUtil.getValue(tserver.properties,ucs
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 2022年THRIFT开发教程 2022 THRIFT 开发 教程
![提示](https://www.taowenge.com/images/bang_tan.gif)
限制150内