2012-07-22 42 views
6

我嘗試使用astyanax連接到本地cassandra,但不斷獲取PoolTimeoutException。我能夠使用cli或hector客戶端連接到cassandra。 任何想法我做錯了什麼?當通過Astyanax連接到Cassandra時出現PoolTimeoutException

謝謝。

我的代碼:

val context = new AstyanaxContext.Builder() 
     .forCluster("cluster") 
     .forKeyspace(keyspace) 
     .withAstyanaxConfiguration(
       new AstyanaxConfigurationImpl() 
        .setDiscoveryType(NodeDiscoveryType.NONE) 
     ) 
     .withConnectionPoolConfiguration(
       new ConnectionPoolConfigurationImpl("ConnPool") 
        .setPort(9160) 
        .setMaxConnsPerHost(1) 
        .setMaxBlockedThreadsPerHost(1) 
        .setSeeds("127.0.0.1:9160") 
        .setConnectTimeout(10000) 
     ) 
     .withConnectionPoolMonitor(new CountingConnectionPoolMonitor()) 
     .buildKeyspace(ThriftFamilyFactory.getInstance()) 
    context.start() 
    return context.getEntity() 

例外:

Exception in thread "main" java.lang.RuntimeException: com.netflix.astyanax.connectionpool.exceptions.PoolTimeoutException: PoolTimeoutException: [host=127.0.0.1(127.0.0.1):9160, latency=10004(10004), attempts=1] Timed out waiting for connection 
at com.netflix.astyanax.thrift.ThriftColumnFamilyQueryImpl$7.getNextBlock(ThriftColumnFamilyQueryImpl.java:652) 
at com.netflix.astyanax.thrift.ThriftAllRowsImpl$1.hasNext(ThriftAllRowsImpl.java:61) 
at scala.collection.JavaConversions$JIteratorWrapper.hasNext(JavaConversions.scala:574) 
at scala.collection.Iterator$class.foreach(Iterator.scala:772) 
at scala.collection.JavaConversions$JIteratorWrapper.foreach(JavaConversions.scala:573) 
at scala.collection.IterableLike$class.foreach(IterableLike.scala:73) 
at scala.collection.JavaConversions$JIterableWrapper.foreach(JavaConversions.scala:587) 
at at scala.Function0$class.apply$mcV$sp(Function0.scala:34) 
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12) 
at scala.App$$anonfun$main$1.apply(App.scala:60) 
at scala.App$$anonfun$main$1.apply(App.scala:60) 
at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59) 
at scala.collection.immutable.List.foreach(List.scala:76) 
at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:30) 
at scala.App$class.main(App.scala:60) 
at Caused by: com.netflix.astyanax.connectionpool.exceptions.PoolTimeoutException: PoolTimeoutException: [host=127.0.0.1(127.0.0.1):9160, latency=10004(10004), attempts=1] Timed out waiting for connection 
at com.netflix.astyanax.connectionpool.impl.SimpleHostConnectionPool.waitForConnection(SimpleHostConnectionPool.java:201) 
at com.netflix.astyanax.connectionpool.impl.SimpleHostConnectionPool.borrowConnection(SimpleHostConnectionPool.java:158) 
at com.netflix.astyanax.connectionpool.impl.RoundRobinExecuteWithFailover.borrowConnection(RoundRobinExecuteWithFailover.java:60) 
at com.netflix.astyanax.connectionpool.impl.AbstractExecuteWithFailoverImpl.tryOperation(AbstractExecuteWithFailoverImpl.java:50) 
at com.netflix.astyanax.connectionpool.impl.AbstractHostPartitionConnectionPool.executeWithFailover(AbstractHostPartitionConnectionPool.java:229) 
at com.netflix.astyanax.thrift.ThriftColumnFamilyQueryImpl$7.getNextBlock(ThriftColumnFamilyQueryImpl.java:623) 

回答

2

我們有這個問題爲好。對我們來說,它變成libthrift的版本問題。版本0.7.0工作。版本0.6.1沒有。檢查你的班級路徑,看看...祝你好運。

-td

+0

「湯姆d」 好抓,謝謝!任何人在沒有maven的情況下將astyanax jar升級到v1.0.6時,不要忘記將libthrift升級到0.7.0 – 2012-08-09 13:38:32

2

的另一個問題是,如果你踩住數據到一個節點,你有50線程池,每個主機只有1個連接,你會得到同樣的事情,所以你必須要平衡的線程數/在某些情況下也是主持人。

1

試圖通過錯誤的端口連接也會出現此錯誤。請參閱this討論。

0

不要在cassandra.yaml以下

  1. 檢查rpc_address
  2. 檢查rpc_port
  3. 設置start_rpctrue
相關問題