实现Thrift API时出错(Error implementing the Thrift API)

我正在用Java实现Thrift Remote Procedure调用框架。 我设置了thrift并生成了我的框架代码而没有太多问题,但是现在我实际上在使用API​​方法,我得到了奇怪的错误。

以下是我得到的错误:

Exception in thread "main" org.apache.thrift.transport.TTransportException: Cannot write to null outputStream
at org.apache.thrift.transport.TIOStreamTransport.write(TIOStreamTransport.java:142)
at org.apache.thrift.protocol.TBinaryProtocol.writeI32(TBinaryProtocol.java:163)
at org.apache.thrift.protocol.TBinaryProtocol.writeMessageBegin(TBinaryProtocol.java:91)
at SimonSays$Client.send_registerClient(SimonSays.java:102)
at SimonSays$Client.registerClient(SimonSays.java:96)
at simon.main(testClass.java:16)

我不认为我没有犯任何错误,但只是为了确保,这是导致错误的代码:

TProtocol prot = new TBinaryProtocol(new TSocket("http://thriftpuzzle.facebook.com",9030));
    SimonSays.Client client = new SimonSays.Client(prot);

    client.registerClient("userEmailAddress@gmail.com");

该错误据说是从client.registerClient()调用生成的,但这是对Thrift生成的代码的调用,这让我觉得我在设置连接本身时做错了。

关于制作TProtocol实例的部分我自己也包括在内,这可能就是问题所在。

我希望有人能更多地了解我做错了什么。

如果需要更多信息或说明,请告诉我。

编辑:我从Cassandra Wiki找到了TProtocol实例化语句


I'm implementing the Thrift Remote Procedure call framework in Java. I set up thrift and generated my skeleton code without a lot of issues, but now that I'm actually using the API methods, I get strange errors.

Here are the errors I get:

Exception in thread "main" org.apache.thrift.transport.TTransportException: Cannot write to null outputStream
at org.apache.thrift.transport.TIOStreamTransport.write(TIOStreamTransport.java:142)
at org.apache.thrift.protocol.TBinaryProtocol.writeI32(TBinaryProtocol.java:163)
at org.apache.thrift.protocol.TBinaryProtocol.writeMessageBegin(TBinaryProtocol.java:91)
at SimonSays$Client.send_registerClient(SimonSays.java:102)
at SimonSays$Client.registerClient(SimonSays.java:96)
at simon.main(testClass.java:16)

I don't think I'm not making any mistakes, but just to make sure, here's the code that's leading to the errors:

TProtocol prot = new TBinaryProtocol(new TSocket("http://thriftpuzzle.facebook.com",9030));
    SimonSays.Client client = new SimonSays.Client(prot);

    client.registerClient("userEmailAddress@gmail.com");

The error is said to be generated from the client.registerClient() call, but that is a call to the code generated by Thrift, which makes me feel that I'm doing something wrong in setting up the connection itself.

The part about making a TProtocol instance I included myself, and it's likely that that's where the problem lies.

I was hoping that someone would have more of an idea about what's going wrong that I do.

Please let me know if more information or clarification is needed.

Edit: I found the TProtocol instantiation statement from the Cassandra Wiki

2023-02-06 15:02

满意答案

您需要在TSocket实例上调用open()方法,以便连接并获取所需的输入/输出流。

资料来源: TSocket.java


You need to call the open() method on your TSocket instance in order for it to connect and obtain the input/output streams it needs.

Source: TSocket.java

相关问答

更多

相当于Twitter的Thrift API for .NET(Equivalent of Twitter Thrift API for .NET)

看起来没有等价物。 我必须自己开发: https : //github.com/vyakhir/pooling Looks like there're no equivalents. I had to develop on my own: https://github.com/vyakhir/pooling

实现Thrift API时出错(Error implementing the Thrift API)

您需要在TSocket实例上调用open()方法,以便连接并获取所需的输入/输出流。 资料来源: TSocket.java You need to call the open() method on your TSocket instance in order for it to connect and obtain the input/output streams it needs. Source: TSocket.java

使用Thrift和php在Cassandra中创建二级索引(Creating Secondary Indexes in Cassandra using Thrift and php)

如果您使用的是phpcassa,则可以使用SystemManager.create_index() 。 如果您使用的是PHP CQL驱动程序 ,它将如下所示: http : //www.datastax.com/docs/0.8/references/cql#create-index phpcassa或CQL驱动程序的性能开销非常小,仅在最极端的情况下值得担心。 通常,查询的网络延迟和数据库延迟要大得多。 If you're using phpcassa, you can use SystemMa...

Thrift RPC从c#中的thrift客户端故障转移到通过HBase服务器转换的thrift服务器(Thrift RPC failing from a thrift client in c# to a thrift server spinned over HBase server)

我在EMR上使用AWS HBase,然后通过HBase服务器调整thrift服务器。 在设置thrift服务器时,AWS管理控制台中有一个选项可用于设置允许的IP地址和端口号。 我允许端口号为9000,但是thrift服务器侦听端口号9090.一旦我将端口号9090添加到允许的端口号列表,我就可以连接到它。 I was using AWS HBase over EMR and then thrift server spinned over the HBase server. while setti...

出于什么原因,使用Thrift API进行Cassandra访问是不可取的?(For what reasons it is not preferable to use Thrift API for Cassandra access?)

如果你使用原始的Thrift apis,那么缺点是: 没有连接池 没有监控 没有面向对象的接口(不完全正确) 没有故障转移支持 If you use the raw Thrift apis the cons will be: no connection pooling no monitoring no object oriented interface (not entirely true) no failover support

在Thrift API和CQL之间混淆(Confusing between Thrift API and CQL)

是。 在不破坏现有应用程序的情况下,无法将Thrift API更新为CQL感知。 因此,如果您使用CQL,那么您只会像使用Java驱动程序一样使用CQL客户端,而不是Astyanax,Hector等。 但这不是一个很大的牺牲,因为CQL更有用。 对于简单的PK(即单列),是的。 对于复合PK, 它有点复杂 。 不可以.Thrift API按设计运行在较低级别。 (例如,您将看到组成Map的各个存储单元。) 我不明白这个问题。 使用CQL,您可以使用Thrift完成所有操作,但更容易。 简单; 不要...

在iOS中实现Thrift服务器(Implementing Thrift Server in iOS)

AFAIK您不能在Objective C中拥有服务器,因为只支持客户端绑定。 但是,您可以使用C / C ++服务器绑定。 你的用例是什么? 在iOS设备上安装服务器似乎很奇怪。 这是C ++用法文档的链接 。 AFAIK You can't have the server in Objective C as only the client bindings are supported. You can however use the C/C++ server bindings. What is ...

使用Thrift和Delphi Win32(Using Thrift with Delphi Win32)

旧答案取代了Leo: Thrift拥有Delphi ,C ++,C#,Erlang,Haskell,Java,Objective C / Cocoa,OCaml,Perl,PHP,Python,Ruby和Squeakr的生成器 Thrift的生成器可以在SVN这里找到 Old Answer Replaced thanks to Leo: Thrift has generators for Delphi, C++, C#, Erlang, Haskell, Java, Objective C/Coc...

Apache Thrift api采取cassandra快照[关闭](Apache Thrift api to take cassandra snapshot [closed])

不可以。只有通过cassandra公开的JMX界面才能拍摄快照。 这是nodetool使用的接口,但您也可以编写自定义Java工具来访问JMX接口。 No. Taking a snapshot is only possible through cassandra's exposed JMX interface. This is the interface that nodetool uses, but you could write a custom java tool to access the...

使用Apache Thrift和TServlet执行服务多路复用(Perform service multiplexing with Apache Thrift and TServlet)

好吧,想通了。 可能不是最好的方式,所以我欢迎批评。 这是我的粗略步骤: 保持处理程序类的方式。 创建一个扩展TMultiplexedProcessor的新类 创建一个扩展TServlet的新类 所有处理器(例如UserServiceProcessor都有一个handler属性和相应的getter和setter 这是我的ApiMultiplexingProcessor : @Component public class ApiMultiplexingProcessor extends TMulti...

相关文章

更多

Hadoop的thrift server配置

说明:Hadoop版本:hadoop-1.2.1.tar.gz。linux系统12.04,不过这里跟系 ...

Storm-源码分析- Thrift的使用

1 IDL 首先是storm.thrift, 作为IDL里面定义了用到的数据结构和service ...

POI 操作 Excel的主要API

Java Aspose Cells 是一种纯粹的Java授权的Excel API

java API 操作 Zookeeper

ZooKeeper有一个绑定Java和C的官方API。Zookeeper社区为大多数语言(.NET,p ...

微信API 引用

最近一直在调用微信的API,却发现一直调用不成功,纠结了好久,各方面找教程,现在晒出来和大家分享一下 ...

分享一个免费的聊天api

很多人都接触过微信公众平台的开发,很多微信公众帐号都希望能实现智能交互聊天的效果,但是这件事对于我们普 ...

快速预览 Jsoup API

static Document parse(String html

POI核心API

setCellValue(boolean value)设置单元格一个布尔值

JFreeChart核心API

boolean urls)此方法使用默认设置创建一个折线图

最新问答

更多

Python / IPython奇怪的不可重现列表索引超出范围错误(Python/IPython strange non reproducible list index out of range error)

你得到IndexError的原因是你的输入文件显然不是完全用制表符分隔的。 这就是为什么当您尝试访问它时, splits[1]没有任何内容。 您的代码可以使用一些重构。 首先,你正在重复使用if -checks,这是不必要的。 这只是将cds0到7个字符,这可能不是你想要的。 我将以下内容放在一起,以演示如何重构您的代码,使其变得更加pythonic和干燥。 我无法保证它能够与您的数据集一起使用,但我希望它可以帮助您了解如何以不同的方式执行操作。 to_sort = [] # W

故事板从表格单元中延伸出来并显示其详细信息披露按钮(storyboard segue from a tablecell an its Detail Disclosure Button)

我不认为你可以链接一个特定的细节披露按钮瓦特/赛格。 我的故事板是非常程序化的B / C我使用了很多定制CGRect等。 所以我倾向于使用这样的东西: -(void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath { [self performSegueWithIdentifier:@"ViewControllerIdentifer"

我们可以将Gherkin功能文件与testcomplete集成(Can we integrate Gherkin feature files with testcomplete)

TestComplete不支持Gherkin功能文件。 但是,TestComplete具有SDK,因此可以自己为此创建扩展。 TestComplete does not support Gherkin feature files. However, TestComplete has SDK so it is possible to create an extension for this by yourself.

TrustAllCertificatesCallback被忽略(TrustAllCertificatesCallback is ignored)

我没有做过这样的事情,但看看我认为可以看出错误的例子。 试试这个代码: static class Program { static void Main() { var tcpclient = new TcpClient("remote.example.com", 443); var tcpstream = tcpclient.GetStream(); var sslstream = new SslStream(tcpstream,

返回嵌套元素的索引(Return index of nested element)

您需要获取父li元素的索引。 否则,您将获得列表项内锚点的索引,该索引始终为零。 $(this.parentNode).index(); You need to get the index of the parent li element. Otherwise you are getting the index of the anchor inside the list item, which will always be zero. $(this.parentNode).index();

在数组中重新编号元素的有效方法(Efficient way of re-numbering elements in an array)

您需要多次迭代列表,我认为没有办法解决这个问题。 毕竟,在开始更改元素(第二遍)之前,首先必须确定不同元素的数量(第一遍)。 但是请注意,由于对index的重复调用而not in列表中具有O(n),因此可能具有最多O(n ^ 2)的不同元素的数量。 或者,您可以使用dict而不是value_map的list 。 字典比列表具有更快的查找速度,因此,复杂性应该确实在O(n)的数量级上。 您可以使用(1)字典理解来确定旧值到新值的映射,以及(2)用于创建更新子项的列表理解。 value_map =

Express app定义的`static`文件夹无法正常工作(Express app defined `static` folder not working properly)

选项1 你可以改变这一行: app.use( express.static(__dirname + '/puplic')); //my public folder. 至 app.use('/oneTime', express.static(__dirname + '/puplic')); //my public folder 选项2 我假设你在公共文件夹中有一个js文件夹,然后你需要更改你的HTML代码:

使用node.js和socket.io每秒广播一次(Using node.js and socket.io to broadcast every second)

对于计时器值,请在服务器端本身每秒更新本地计时器。 每当有任何用户进来时,给他这个值以及计时器的总值。 然后客户端将根据dandavis评论在本地启动自己的计时器,但在服务器端保留一些间隔,如15或10秒,服务器将广播当前计时器值,以便客户端相应地进行同步。 简而言之,服务器将每隔10(n:你决定)秒后广播,但它将在本地每秒更新定时器变量。 每当客户端进入时,它将获得总计时器值和当前计时器值。 广播当前出价的休息功能可以以正常方式完成。 For timer value, keep updatin

如何让XMLSerializer将命名空间添加到嵌套对象中的属性?(How do I get the XMLSerializer to add namespaces to attributes in nested objects?)

IXmlSerializable也许? 注意我还添加了(对A ): [XmlElement("A", Namespace = "http://www.example.com/namespace")] public TestSoapHeaderTypeValuePair A {...} 代码如下: public class TestSoapHeaderTypeValuePair : IXmlSerializable { private string _type; private