我正在使用datastax(https://github.com/datastax/cpp-driver)中的cassandra-cpp-driver处理项目。我现在正在写一个访问者。几天前它正在运行,但现在每当我尝试执行查询时,我都会收到错误
1497993874.207 [ERROR] (src/pool.cpp:388:virtual void
cass::Pool::on_close(cass::Connection*)): Connection pool was unable to
connect to host xx.xx.xx.160 because of the following error: Connect error
'host is unreachable'
我的问题是我的代码或cassandra配置中没有任何地方连接到IP地址为xx.xx.xx.160的任何内容。我有一个四节点集群,IP地址为211,212,213和159. 211和213是种子。据我所知,我已正确设置群集。我可以使用CQLSH和python驱动程序访问它。
connect_future = NULL;
cluster = cass_cluster_new();
session = cass_session_new();
cass_cluster_set_contact_points(d_cluster,"xx.xx.xx.211,xx.xx.xx.213");
connect_future = cass_session_connect_keyspace(session, cluster, "test");
if (cass_future_error_code(connect_future) != CASS_OK) {
std::cout << "Unable to connect";
}
CassError rc = CASS_OK;
CassStatement* statement = cass_statement_new(
"INSERT INTO users (id, name) VALUES
(bigintAsBlob(8943750892347), 'George');", 0);
CassFuture* future = NULL;
future = cass_session_execute(session, statement);
cass_future_wait(future);
rc = cass_future_error_code(future);
if (rc != CASS_OK) {
std::cout << "Error in query";
}
cass_future_free(future);
cass_statement_free(statement);
cass_future_free(connect_future);
cass_cluster_free(cluster);
cass_session_free(session);
任何帮助将不胜感激。