thrift-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Avinash Dongre <dongre.avin...@gmail.com>
Subject Single Connection and Multiple threads
Date Thu, 25 Apr 2013 11:16:32 GMT
I have Thrift Server Implemented with TThreadPoolServer.
But When I am calling my reuqest API from multi-threaded client, I am get
exception always:


org.apache.thrift.transport.TTransportException: java.net.SocketException:
Connection reset
at
org.apache.thrift.transport.TIOStreamTransport.read(TIOStreamTransport.java:129)
at org.apache.thrift.transport.TTransport.readAll(TTransport.java:84)
at
org.apache.thrift.protocol.TBinaryProtocol.readAll(TBinaryProtocol.java:378)
at
org.apache.thrift.protocol.TBinaryProtocol.readI32(TBinaryProtocol.java:297)
at
org.apache.thrift.protocol.TBinaryProtocol.readMessageBegin(TBinaryProtocol.java:204)
at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:69)
at
com.abc.xyz.thrift.generated.MyService$Client.recv_openConnection(MyService.java:123)
at
com.abc.xyz.thrift.generated.MyService$Client.openConnection(MyService.java:110)
at com.thrift.java.TestThriftPerf$1.run(TestThriftPerf.java:169)
at java.lang.Thread.run(Thread.java:679)
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:185)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:275)
at java.io.BufferedInputStream.read(BufferedInputStream.java:334)
at
org.apache.thrift.transport.TIOStreamTransport.read(TIOStreamTransport.java:127)
... 9 more
org.apache.thrift.transport.TTransportException: java.net.SocketException:
Broken pipe
at
org.apache.thrift.transport.TIOStreamTransport.flush(TIOStreamTransport.java:161)
at org.apache.thrift.TServiceClient.sendBase(TServiceClient.java:65)
at
com.abc.xyz.thrift.generated.MyService$Client.send_openConnection(MyService.java:117)
at
com.abc.xyz.thrift.generated.MyService$Client.openConnection(MyService.java:109)
at com.thrift.java.TestThriftPerf$1.run(TestThriftPerf.java:169)
at java.lang.Thread.run(Thread.java:679)


Folllowing is how I am calling the thrift api



public class TestThriftPerf {
public static void main(String[] args) {
try {
final TTransport transportMain = new TSocket("my_machine", 1527);
TProtocol protocolMain = new TBinaryProtocol(transportMain, true,true);
final MyService.Client clientMain = new MyService.Client(protocolMain);

final OpenConnectionArgs oca = new OpenConnectionArgs();
transportMain.open();
long connId = clientMain.openConnection(oca);
connId = clientMain.openConnection(oca);
                        final int numThreads = 10;
final CyclicBarrier barrier = new CyclicBarrier(numThreads);
Thread[] threads = null;
if (numThreads > 1) {
threads = new Thread[numThreads - 1];
for (int i = 0; i < (numThreads - 1); i++) {
Thread t = new Thread(new Runnable() {
public void run() {
try {
long connId = clientMain.openConnection(oca);
                                                         }
                         ...................

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message