首页 \ 问答 \ 使用Apache Thrift进行服务多路复用(Service Multiplexing using Apache Thrift)

使用Apache Thrift进行服务多路复用(Service Multiplexing using Apache Thrift)

服务器代码:

            TMultiplexedProcessor processor = new TMultiplexedProcessor();

            processor.registerProcessor(
                "AddService",
                new AddService.Processor(new AddHandler()));

            processor.registerProcessor(
                "MultiplyService",
                new MultiplyService.Processor(new MultiplyHandler()));

            TServerTransport serverTransport = new TServerSocket(7911);



            TSimpleServer server = new TSimpleServer(new TSimpleServer.Args(serverTransport).
                   processor(processor));

            System.out.println("Starting server on port 7911 ...");
            server.serve();

客户代码:

    TFramedTransport transport;

   transport = new TFramedTransport(new TSocket("localhost", 7911));  
   transport.open();  


   TProtocol protocol = new TBinaryProtocol(transport);

   System.out.println("1");
   TMultiplexedProtocol mp = new TMultiplexedProtocol(protocol, "AddService");
   AddService.Client service = new AddService.Client(mp);

   System.out.println("2");
   TMultiplexedProtocol mp2 = new TMultiplexedProtocol(protocol, "MultiplyService");
   MultiplyService.Client service2 = new MultiplyService.Client(mp2);

   System.out.println("3");

   System.out.println(service.add(2,2));
   System.out.println(service2.multiply(2000,200));

但是当我运行服务器(侦听端口7911)和客户端时,客户端不处理对add / multiply函数的最后两次调用。

我可以调试参数已发送到服务器,但服务器无法处理它们。

关于我缺少什么的任何指示?


Server code:

            TMultiplexedProcessor processor = new TMultiplexedProcessor();

            processor.registerProcessor(
                "AddService",
                new AddService.Processor(new AddHandler()));

            processor.registerProcessor(
                "MultiplyService",
                new MultiplyService.Processor(new MultiplyHandler()));

            TServerTransport serverTransport = new TServerSocket(7911);



            TSimpleServer server = new TSimpleServer(new TSimpleServer.Args(serverTransport).
                   processor(processor));

            System.out.println("Starting server on port 7911 ...");
            server.serve();

Client Code:

    TFramedTransport transport;

   transport = new TFramedTransport(new TSocket("localhost", 7911));  
   transport.open();  


   TProtocol protocol = new TBinaryProtocol(transport);

   System.out.println("1");
   TMultiplexedProtocol mp = new TMultiplexedProtocol(protocol, "AddService");
   AddService.Client service = new AddService.Client(mp);

   System.out.println("2");
   TMultiplexedProtocol mp2 = new TMultiplexedProtocol(protocol, "MultiplyService");
   MultiplyService.Client service2 = new MultiplyService.Client(mp2);

   System.out.println("3");

   System.out.println(service.add(2,2));
   System.out.println(service2.multiply(2000,200));

But when I am running the server(listening on port 7911) and the client, the client doesnt process the last two calls to the add/multiply functions.

I could debug that the arguments have been sent to the server, but the server is not able to process them.

Any pointers as to what i am missing?


原文:https://stackoverflow.com/questions/19614648
更新时间:2023-09-13 14:09

最满意答案

这是你想要的JSFiddle: https ://jsfiddle.net/3qypL8gb/

我删除了你的<a>标签,因为有人在评论中说他们不能成为<ul>直接孩子而且你无论如何都没有做任何事。

我利用了你想删除的单词是<li>中的最后一个文本。 我存储了html的长度,然后存储了文本的长度,并创建了html.length - text.length的子字符串。

然后我用新的子字符串替换了<li> html。


Here is a JSFiddle of what you want: https://jsfiddle.net/3qypL8gb/

I removed your <a> tags because as someone said in the comments they cannot be direct child of a <ul> and you weren't doing anything with them anyway.

I took advantage of how the words you wanted to remove were the last text in the <li>. I stored the length of the html and then stored the length of the text and made a substring of the html.length - text.length.

I then replaced the <li> html with that new substring.

相关问答

更多
  • 向anchor添加click event handler ,而不是编写内联函数,如下所示: $('.ach').on('click', function() { $('li').removeClass('active'); $(this).closest('li').addClass('active'); }); .detail-sidemenu li a:hover { background-color: #ed1b23; color: #ffffff; } .active ...
  • $("li span:has(a)").after("
    "); 现场演示: http : //jsfiddle.net/LkeVE/1 $("li span:has(a)").after("
    "); Live Demo: http://jsfiddle.net/LkeVE/1
  • 相关文章

    更多
  • Hadoop的thrift server配置
  • Storm-源码分析- Thrift的使用
  • Apache Nutch(一)
  • Apache Flume 简介
  • apache solr之我们的应用
  • Apache Solr 介绍
  • Apache Solr 介绍(1)
  • Apache Solr questions
  • Apache Solr 介绍
  • 实践:使用 Apache Hadoop 处理日志
  • 最新问答

    更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。