incubator-cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Richard Grossman <richie...@gmail.com>
Subject MultiThread Client problem with thrift
Date Tue, 22 Dec 2009 09:47:00 GMT
Hi

As advised by jonathan  you need  to write a multithreaded client to insert
data quicker into cassandra. Now I've a problem regarding thrift TTransport.
As required I open a tSocket in each thread and create a cassandra client on
this socket.

the code is simple :
public void run() {
TSocket tSocket = null;
try {
    tSocket = new TSocket(server, port);
TBinaryProtocol transport = new TBinaryProtocol(tSocket);

clientCassandra = new Client(transport);
tSocket.open();
 updateCassandra(clientCassandra);
                catch (Exception e)
                        log something
                finally
                        tSocket.close();
                        countDownLatch.getDown();
      }


*After some thousand of insert I get always :*

... 7 more
org.apache.thrift.transport.TTransportException:
java.net.NoRouteToHostException: Can't assign requested address
at org.apache.thrift.transport.TSocket.open(TSocket.java:185)
at tv.bee.hiveplus.crud.CassandraThread.call(CassandraThread.java:297)
at tv.bee.hiveplus.crud.CassandraThread.call(CassandraThread.java:1)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:637)
Caused by: java.net.NoRouteToHostException: Can't assign requested address
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:432)
at java.net.Socket.connect(Socket.java:525)
at java.net.Socket.connect(Socket.java:475)
at org.apache.thrift.transport.TSocket.open(TSocket.java:180)
... 7 more

I've search and it seems that you get this when you've no more port to open
on the machine but I close the connection each time I open it. I've also
played with multithread to prevent a flooding thread I control the list of
submited task and wait unti these tasks finished here is my code

       CassandraThread cassandraThread = new CassandraThread(server, port,
operation, rowData, countDownLatch);
               listOfTask.add(cassandraThread);

if (listOfTask.size() == 1000) {
try {
System.out.println("Invoke");
executor.invokeAll(listOfTask);
 try {
countDownLatch.await();
if (countDownLatch.getCount() == 0) {
countDownLatch = new CountDownLatch(1000);
listOfTask.clear();
}
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}

The number of connection is not high so why I get this error ? Thanks for
any help

Best Regards

Richard

Mime
View raw message