7

我正在尝试使用 astyanax 连接到本地 cassandra,但不断收到 PoolTimeoutException。我可以使用 cli 或 hector 客户端连接到 cassandra。知道我在做什么错吗?

谢谢。

我的代码:

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)
4

5 回答 5

3

另一个问题是,如果您将数据猛灌到一个节点并且您有 50 个线程池并且每个主机只有 1 个连接,您将得到相同的结果,因此在某些情况下您还必须平衡线程/主机的数量。

于 2012-09-10T02:37:04.360 回答
2

我们也遇到了这个问题。对我们来说,原来是 libthrift 的版本问题。版本 0.7.0 工作。0.6.1 版没有。检查你的类路径,看看......祝你好运。

-td

于 2012-08-08T20:30:57.910 回答
1

尝试通过错误的端口连接也会出现此错误。请参阅讨论。

于 2013-06-11T18:23:07.783 回答
0

您需要安装Apache Thrift,对我来说它可以安装此应用程序:

提升
libevent
Thrift

快乐编码:)

于 2016-05-01T23:40:46.943 回答
0

在 cassandra.yaml 中执行以下操作

  1. 检查rpc_address
  2. 检查 rpc_port
  3. 设置start_rpctrue
于 2017-04-18T09:17:30.753 回答