数据存储驱动程序3.0中发生NoHostAvailableException

时间:2016-05-11 12:52:31

标签: cassandra spark-cassandra-connector cassandra-3.0

我使用多个线程来查询数据,这些线程对同一个Session是通用的,将发生如下

com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (no host was tried)
 at com.datastax.driver.core.exceptions.NoHostAvailableException.copy(NoHostAvailableException.java:84)
 at com.datastax.driver.core.exceptions.NoHostAvailableException.copy(NoHostAvailableException.java:37)
 at com.datastax.driver.core.DriverThrowables.propagateCause(DriverThrowables.java:37)
 at com.datastax.driver.core.DefaultResultSetFuture.getUninterruptibly(DefaultResultSetFuture.java:245)
 at com.datastax.driver.core.AbstractSession.execute(AbstractSession.java:63)
 at com.datastax.driver.core.AbstractSession.execute(AbstractSession.java:47)
 at com.tss.storage.LuceneTask.run(LuceneTask.java:51)
 at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
 at java.util.concurrent.FutureTask.run(FutureTask.java:266)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
 at java.lang.Thread.run(Thread.java:745)
Caused by: com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (no host was tried)
 at com.datastax.driver.core.RequestHandler.reportNoMoreHosts(RequestHandler.java:211)
 at com.datastax.driver.core.RequestHandler.access$1000(RequestHandler.java:43)
 at com.datastax.driver.core.RequestHandler$SpeculativeExecution.sendRequest(RequestHandler.java:277)
 at com.datastax.driver.core.RequestHandler.startNewExecution(RequestHandler.java:115)
 at com.datastax.driver.core.RequestHandler.sendRequest(RequestHandler.java:91)
 at com.datastax.driver.core.SessionManager.executeAsync(SessionManager.java:132)
... 8 more

任何人都可以帮助我吗?

谢谢!

1 个答案:

答案 0 :(得分:0)

ExecutorService运行:

RangeCondition range = range("time").lower(start).upper(end);
    String param = search().filter(range).build();
    Stopwatch start = Stopwatch.createStarted();
    ResultSet result = null;
    try {
        Session session = storageClient.getSession();
        result = session.execute("SELECT * FROM demo.tweets WHERE expr(tweets_idx, ?)", param);
    } catch (Exception e) {
        e.printStackTrace();
    }