【发布时间】:2015-10-22 07:42:15
【问题描述】:
我正在尝试使用 Hector 的基本定义来创建 Cassandra 集群。这是我的代码(只有连接和架构部分)。
CassandraHostConfigurator chc = new CassandraHostConfigurator(
"localhost");
chc.setMaxActive(20);
chc.setCassandraThriftSocketTimeout(3000);
chc.setMaxWaitTimeWhenExhausted(4000);
Cluster cluster = HFactory.getOrCreateCluster("mycluster", chc);
System.out.println("cluster: " + cluster.getKnownPoolHosts(false));
try{
KeyspaceDefinition keyspaceDef = cluster.describeKeyspace("sensornetwork");
} catch (HectorException he){
ColumnFamilyDefinition cfDef = HFactory.createColumnFamilyDefinition("sensornetwork",
"ColumnFamilyName",
ComparatorType.BYTESTYPE);
KeyspaceDefinition newKeyspace = HFactory.createKeyspaceDefinition("sensornetwork",
ThriftKsDef.DEF_STRATEGY_CLASS,
1,
Arrays.asList(cfDef));
cluster.addKeyspace(newKeyspace, true);
}
// If keyspace does not exist, the CFs don't exist either. => create them.
Keyspace keyspace = HFactory.createKeyspace("sensornetwork", cluster);
我基本上是按照 Hector 自己网站上的文档来做到这一点的。
我得到的错误是这个:
线程“main”中的异常 me.prettyprint.hector.api.exceptions.HectorException:所有主机池 记下来。重试负担推给客户端。在 me.prettyprint.cassandra.connection.HConnectionManager.getClientFromLBPolicy(HConnectionManager.java:401) 在 me.prettyprint.cassandra.connection.HConnectionManager.operateWithFailover(HConnectionManager.java:232) 在 me.prettyprint.cassandra.service.ThriftCluster.addKeyspace(ThriftCluster.java:168) 在 com.mycompany.mavenpails2.SpeedLayer.CassandraPrepwork(SpeedLayer.java:62)
显然,我正在创建一个没有工作池连接的集群。我已经更改了端口并尝试了所有方法,但无法使其正常工作。有什么建议吗?
【问题讨论】: