2016-11-06 6 views
0

私はMacのドッカー内で最新バージョンのcassandraを実行しています。私はMacにcassandra開発センターをインストールしました。そして、私はdevcenterを使ってcassandraに接続することができ、簡単にテーブルを照会することができます。Astyanaxを使用してCassandraに接続できません

http://i.imgur.com/48MztBM.png

http://i.imgur.com/jPKblly.png

私はカサンドラのために必要なすべてのポートも開いていることがわかります。私はまた私のカサンドラ容器に、ログインし、私は

val configImpl = new AstyanaxConfigurationImpl() 
configImpl.setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE) 
configImpl.setCqlVersion("3.4.2") 
configImpl.setTargetCassandraVersion("3.7") 
val poolConfig = new ConnectionPoolConfigurationImpl("MyConnectionPool") 
poolConfig.setPort(9160) 
poolConfig.setMaxConnsPerHost(1) 
poolConfig.setSeeds("192.168.1.169") 

val context = new AstyanaxContext.Builder() 
    .forCluster("localhost") 
    .forKeyspace("movielens_small") 
    .withAstyanaxConfiguration(configImpl) 
    .withConnectionPoolConfiguration(poolConfig) 
    .withConnectionPoolMonitor(new CountingConnectionPoolMonitor()) 
    .buildKeyspace(ThriftFamilyFactory.getInstance()) 
context.start() 
val keyspace = context.getClient() 
val cf = new ColumnFamily[UUID, String]("cf", UUIDSerializer.get, StringSerializer.get()) 
val result = keyspace.prepareQuery(cf).withCql("select name from movies").execute() 
val data = result.getResult.getRows() 
for { 
    row <- data 
    col <- row.getColumns 
} { 
    println(col) 
} 
context.shutdown() 

以下のコードを実行したときしかし、私は取得するには、次のコマンド

[email protected]:/# nodetool -h 127.0.0.1 enablethrift 
[email protected]:/# nodetool -h 127.0.0.1 statusthrift 
running 

を実行

CONTAINER ID  IMAGE    COMMAND     CREATED    STATUS    PORTS                          NAMES 
e698e61e3bac  cassandra:latest "/docker-entrypoint.s" 9 

minutes ago  Up 9 minutes  0.0.0.0:7000->7000/tcp, 0.0.0.0:7199- 
>7199/tcp, 0.0.0.0:9042->9042/tcp, 0.0.0.0:9160->9160/tcp, 7001/tcp cassandra 

(下図のように)次のエラー

07:32:10,606 INFO ConnectionPoolMBeanManager:53 - Registering mbean: com.netflix.MonitoredResources:type=ASTYANAX,name=MyConnectionPool,ServiceType=connectionpool 
07:32:10,625 INFO CountingConnectionPoolMonitor:194 - AddHost: 192.168.1.169 
07:32:10,748 INFO CountingConnectionPoolMonitor:194 - AddHost: 172.17.0.2 
07:32:10,748 INFO CountingConnectionPoolMonitor:205 - RemoveHost: 192.168.1.169 
[error] (run-main-0) com.netflix.astyanax.connectionpool.exceptions.PoolTimeoutException: PoolTimeoutException: [host=172.17.0.2(172.17.0.2):9160, latency=2003(2003), attempts=1]Timed out waiting for connection 
com.netflix.astyanax.connectionpool.exceptions.PoolTimeoutException: PoolTimeoutException: [host=172.17.0.2(172.17.0.2):9160, latency=2003(2003), attempts=1]Timed out waiting for connection 
    at com.netflix.astyanax.connectionpool.impl.SimpleHostConnectionPool.waitForConnection(SimpleHostConnectionPool.java:231) 
    at com.netflix.astyanax.connectionpool.impl.SimpleHostConnectionPool.borrowConnection(SimpleHostConnectionPool.java:198) 
    at com.netflix.astyanax.connectionpool.impl.RoundRobinExecuteWithFailover.borrowConnection(RoundRobinExecuteWithFailover.java:84) 
    at com.netflix.astyanax.connectionpool.impl.AbstractExecuteWithFailoverImpl.tryOperation(AbstractExecuteWithFailoverImpl.java:117) 
    at com.netflix.astyanax.connectionpool.impl.AbstractHostPartitionConnectionPool.executeWithFailover(AbstractHostPartitionConnectionPool.java:352) 
    at com.netflix.astyanax.thrift.AbstractThriftCqlQuery.execute(AbstractThriftCqlQuery.java:41) 
    at com.abhi.CassandraScanner$.delayedEndpoint$com$abhi$CassandraScanner$1(CassandraScanner.scala:41) 
    at com.abhi.CassandraScanner$delayedInit$body.apply(CassandraScanner.scala:19) 
    at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12) 
    at scala.App.$anonfun$main$1$adapted(App.scala:76) 
    at scala.collection.immutable.List.foreach(List.scala:378) 
    at scala.App.main(App.scala:76) 
    at scala.App.main$(App.scala:74) 

答えて

0

私はこの問題を解決することができました。問題はNodeDiscoveryTypeにありました。コードをNodeDiscoveryType.NONEに変更したところ、完全に機能しました。 NodeDiscoveryTypeがNULLでなければならない理由とRING_DESCRIBEと一緒に動作しない理由はまだ分かりませんが、

誰かがさらに詳しく説明します。

関連する問題