CassSessionPtr create_session(CassCluster* cluster, CassError* code, cass_duration_t timeout) { test_utils::CassSessionPtr session(cass_session_new()); test_utils::CassFuturePtr connect_future(cass_session_connect(session.get(), cluster)); if (code) { *code = test_utils::wait_and_return_error(connect_future.get(), timeout); } return session; }
CassFuture* cass_session_connect_keyspace_n(CassSession* session, const CassCluster* cluster, const char* keyspace, size_t keyspace_length) { cass::SessionFuture::Ptr connect_future(new cass::SessionFuture()); session->connect_async(cluster->config(), std::string(keyspace, keyspace_length), connect_future); connect_future->inc_ref(); return CassFuture::to(connect_future.get()); }
void prepare_alter_schema_version_session() { // Create a new session for altering node2 and node3 system tables std::string ip_prefix = inst.ccm->get_ip_prefix(); std::stringstream whitelist_hosts; whitelist_hosts << ip_prefix << "2," << ip_prefix << "3"; cass_cluster_set_whitelist_filtering(inst.cluster, whitelist_hosts.str().c_str()); schema_alter_session = cass_session_new(); test_utils::CassFuturePtr connect_future(cass_session_connect(schema_alter_session, inst.cluster)); test_utils::wait_and_check_error(connect_future.get()); std::string update_peer("UPDATE system.peers SET schema_version=? WHERE peer='" + ip_prefix + "1'"); test_utils::CassFuturePtr prepared_future(cass_session_prepare_n(schema_alter_session, update_peer.data(), update_peer.size())); test_utils::wait_and_check_error(prepared_future.get()); schema_alter_prepared = test_utils::CassPreparedPtr(cass_future_get_prepared(prepared_future.get())); }
/** * Create the session * * @param is_timeout True if for timeout tests; false otherwise */ void create_session(bool is_timeout = false) { close_session(); test_utils::CassSessionPtr session(cass_session_new()); test_utils::CassFuturePtr connect_future(cass_session_connect(session.get(), cluster_.get())); CassError error_code = test_utils::wait_and_return_error(connect_future.get()); session_ = test_utils::create_session(cluster_.get(), &error_code); if (error_code != CASS_OK) { if (is_timeout) { if (error_code == CASS_ERROR_LIB_NO_HOSTS_AVAILABLE) { return; } } CassString message; cass_future_error_message(connect_future.get(), &message.data, &message.length); BOOST_FAIL(std::string(message.data, message.length) << "' (" << cass_error_desc(error_code) << ")"); } }
void new_session() { close_session(); session = cass_session_new(); test_utils::CassFuturePtr connect_future(cass_session_connect(session, inst.cluster)); test_utils::wait_and_check_error(connect_future.get()); }
CassSessionPtr create_session(CassCluster* cluster, cass_duration_t timeout) { test_utils::CassSessionPtr session(cass_session_new()); test_utils::CassFuturePtr connect_future(cass_session_connect(session.get(), cluster)); test_utils::wait_and_check_error(connect_future.get(), timeout); return session; }
void SingleSessionTest::create_session() { session = cass_session_new(); test_utils::CassFuturePtr connect_future(cass_session_connect(session, cluster)); test_utils::wait_and_check_error(connect_future.get()); }