超时cassandra hector

时间:2012-07-03 14:06:15

标签: cassandra hector

我开始使用cassandra。因此我将cassandra(1.1.1)下载到我的Windows PC并启动它。一切正常。 因此,我开始重新实现一个旧的应用程序(在java中使用hector 1.1),它为4个表导入大约200.000.000,这应该插入4个列的家庭。导入大约2.000.000条记录后,我收到超时异常,cassandra对请求没有响应:

2012-07-03 15:35:43,299 WARN  - Could not fullfill request on this host CassandraClient<localhost:9160-16>
2012-07-03 15:35:43,300 WARN  - Exception: me.prettyprint.hector.api.exceptions.HTimedOutException: TimedOutException()
....
Caused by: TimedOutException()
at org.apache.cassandra.thrift.Cassandra$batch_mutate_result.read(Cassandra.java:20269)
at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:78)
at org.apache.cassandra.thrift.Cassandra$Client.recv_batch_mutate(Cassandra.java:922)
at org.apache.cassandra.thrift.Cassandra$Client.batch_mutate(Cassandra.java:908)
at me.prettyprint.cassandra.model.MutatorImpl$3.execute(MutatorImpl.java:246)
at me.prettyprint.cassandra.model.MutatorImpl$3.execute(MutatorImpl.java:243)
at me.prettyprint.cassandra.service.Operation.executeAndSetResult(Operation.java:103)
at me.prettyprint.cassandra.connection.HConnectionManager.operateWithFailover(HConnectionManager.java:258)

日志文件中的最后一个条目是:

INFO 15:35:31,678 Writing Memtable-cf2@678837311(7447722/53551072 serialized/live bytes, 262236 ops)
INFO 15:35:32,810 Completed flushing \var\lib\cassandra\data\keySpaceName\cf2\keySpaceName-cf2-hd-205-Data.db (3292685 bytes) for commitlog position ReplayPosition(segmentId=109596147695328, position=131717208)
INFO 15:35:33,282 Compacted to [\var\lib\cassandra\data\keySpaceName\cf3\keySpaceName-cf3-hd-29-Data.db,].  33.992.615 to 30.224.481 (~88% of original) bytes for 282.032 keys at 1,378099MB/s.  Time: 20.916ms.
INFO 15:35:33,286 Compacting [SSTableReader(path='\var\lib\cassandra\data\keySpaceName\cf4\keySpaceName-cf4-hd-8-Data.db'), SSTableReader(path='\var\lib\cassandra\data\keySpaceName\cf4\keySpaceName-cf4-hd-6-Data.db'), SSTableReader(path='\var\lib\cassandra\data\keySpaceName\cf4\keySpaceName-cf4-hd-7-Data.db'), SSTableReader(path='\var\lib\cassandra\data\keySpaceName\cf4\keySpaceName-cf4-hd-5-Data.db')]
INFO 15:35:34,871 Compacted to [\var\lib\cassandra\data\keySpaceName\cf4\keySpaceName-cf4-hd-9-Data.db,].  4.249.270 to 2.471.543 (~58% of original) bytes for 30.270 keys at 1,489916MB/s.  Time: 1.582ms.
INFO 15:35:41,858 Compacted to [\var\lib\cassandra\data\keySpaceName\cf2\keySpaceName-cf2-hd-204-Data.db,].  48.868.818 to 24.033.164 (~49% of original) bytes for 135.367 keys at 2,019011MB/s.  Time: 11.352ms.

我创建了4个列系列,如下所示:

ColumnFamilyDefinition cf1 = HFactory.createColumnFamilyDefinition(
“keyspacename”,
“cf1”,
ComparatorType.ASCIITYPE);

列族具有以下列数:

  1. 16栏
  2. 14栏
  3. 7 colmuns
  4. 5列
  5. 使用复制因子1和默认策略(简单)创建键空间 我用'Mutator#AddInsertion'

    插入记录(行)

    避免此例外的任何建议?

    此致 WM

1 个答案:

答案 0 :(得分:1)

这个例外基本上是Cassandra说它远远落后于突变,它不会在超时之前完成你的请求。假设您的PC不是野兽,您应该限制您的请求。我建议在捕获该异常然后重试后暂停一段时间;两次不小心写同一行没有什么害处,而Cassandra应该很快赶上写作。

如果您处于生产环境中,我会更仔细地研究节点可能表现不佳的其他原因。