3

我有以下代码:

StringSerializer ss = StringSerializer.get();
String cf = "TEST";
CassandraHostConfigurator conf = new CassandraHostConfigurator("localhost:9160");
conf.setCassandraThriftSocketTimeout(40000);
conf.setExhaustedPolicy(ExhaustedPolicy.WHEN_EXHAUSTED_BLOCK);
conf.setRetryDownedHostsDelayInSeconds(5);
conf.setRetryDownedHostsQueueSize(128);
conf.setRetryDownedHosts(true);
conf.setLoadBalancingPolicy(new LeastActiveBalancingPolicy());
String key = Long.toString(System.currentTimeMillis());
Cluster cluster = HFactory.getOrCreateCluster("TestCluster", conf);
Keyspace keyspace = HFactory.createKeyspace("TestCluster", cluster);
Mutator<String> mutator = HFactory.createMutator(keyspace, StringSerializer.get());    int count = 0;
while (!"q".equals(new Scanner( System.in).next())) {
    try{
        mutator.insert(key, cf, HFactory.createColumn("column_" + count, "v_" + count, ss, ss));
    count++;
    } catch (Exception e) {
        e.printStackTrace();
    }
}

我可以使用它编写一些值,但是当我重新启动 cassandra 时,它会失败。这是日志:

TIOStreamTransport.write(TIOStreamTransport.java:145) ... 9 更多 [15:11:17] 错误 [HConnectionManager] 将主机标记为已关闭主机 >localhost(127.0.0.1):9160 [15:11:17] 错误[HConnectionManager ] 关闭时的池状态:>:{localhost(127.0.0.1):9160}; IsActive?:真;主动:1;封锁:0;空闲:15;NumBeforeExhausted:49 [15:11:17] INFO [ConcurrentHClientPool] 关闭触发:{localhost(127.0.0.1):9160} [15:11:17] INFO [ConcurrentHClientPool] 关闭完成:{localhost(127.0.0.1) :9160} [15:11:17] INFO [CassandraHostRetryService] 检测到已关闭的主机已添加到重试队列:localhost(127.0.0.1):9160 [15:11:17] WARN [HConnectionManager] 无法在此主机上完成请求CassandraClient [15:11:17] 警告 [HConnectionManager] 例外:我。关闭。[15:11:17] 信息 [HConnectionManager] 客户端 CassandraClient 已释放到非活动或死池。关闭。[15:11:17] 信息 [HConnectionManager] 将主机 localhost(127.0.0.1):9160 添加到池中

4

1 回答 1

2

你已经设置 -

conf.setRetryDownedHostsDelayInSeconds(5);

尝试在重启后等待 5 秒以上。此外,您可能需要升级。

您设置的thrift_max_message_length_in_mb大小是多少?

亲切的问候。

于 2012-05-12T01:28:19.033 回答