void PolicyTool::query(CassSession* session, int n, CassConsistency cl) { std::string select_query = str(boost::format("SELECT * FROM %s WHERE k = 0") % test_utils::SIMPLE_TABLE); for (int i = 0; i < n; ++i) { test_utils::CassStatementPtr statement(cass_statement_new_n(select_query.data(), select_query.size(), 0)); cass_statement_set_consistency(statement.get(), cl); test_utils::CassFuturePtr future(cass_session_execute(session, statement.get())); test_utils::wait_and_check_error(future.get()); add_coordinator(cass::get_host_from_future(future.get())); } }
int query( boost::shared_ptr<cql::cql_session_t> session, int n, cql::cql_consistency_enum cl) { for (int i = 0; i < n; ++i) { boost::shared_ptr<cql::cql_query_t> _query( new cql::cql_query_t(str(boost::format("SELECT * FROM %s WHERE k = 0") % test_utils::SIMPLE_TABLE),cl)); boost::shared_future<cql::cql_future_result_t> query_future; query_future = session->query(_query); if (!(query_future.timed_wait(boost::posix_time::seconds(20)))) { BOOST_FAIL("Query timed out"); } try { cql::cql_future_result_t query_result = query_future.get(); if (query_future.has_value()) { std::cout << "Queried endpoint: " << query_result.client->endpoint().to_string() << std::endl; add_coordinator(query_result.client->endpoint().address()); if(query_result.error.code != 0) { return query_result.error.code; } } } catch (...) { BOOST_MESSAGE("Response contains EXCEPTION"); throw; } } return 0; }