diff --git a/CMakeLists.txt b/CMakeLists.txt index f3dd0e5c..c11bd120 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -411,19 +411,31 @@ endif() ## scylladb set(BEHH_USING_SCYLLADB false) set(BEHH_CASSANDRA_HEADER) -set(BEHH_SCYLLA_EXECUTEABLE) +set(BEHH_SCYLLA_CPP_LIB) -if(LINUX) - find_file(BEHH_CASSANDRA_HEADER "cassandra.h") - find_file(BEHH_SCYLLA_EXECUTEABLE "scylla") +find_file(BEHH_CASSANDRA_HEADER "cassandra.h") - if(BEHH_CASSANDRA_HEADER AND BEHH_SCYLLA_EXECUTEABLE) - set(BEHH_USING_SCYLLADB true) - message(NOTICE "-- ${PROJECT_NAME}: adding scylladb since deps found") - endif() +if(WIN32) + find_file(BEHH_SCYLLA_CPP_LIB "scylla-cpp-driver.lib") else() - message(NOTICE "-- ${PROJECT_NAME}: skipping scylladb deps, system not supported") + find_file(BEHH_SCYLLA_CPP_LIB "libscylla-cpp-driver.so") +endif() + +if(BEHH_CASSANDRA_HEADER AND BEHH_SCYLLA_CPP_LIB) + set(BEHH_USING_SCYLLADB true) + message(NOTICE "-- ${PROJECT_NAME}: adding scylladb since deps found") endif() + +if(BEHH_USING_SCYLLADB) + get_filename_component(BEHH_SCYLLA_CPP_LIB_DIR "${BEHH_SCYLLA_CPP_LIB}" DIRECTORY) + get_filename_component(BEHH_CASSANDRA_HEADER_DIR "${BEHH_CASSANDRA_HEADER}" DIRECTORY) + + include_directories(${BEHH_SCYLLA_CPP_LIB_DIR}) + include_directories(${BEHH_CASSANDRA_HEADER_DIR}) + + link_directories(BEFORE "${BEHH_SCYLLA_CPP_LIB_DIR}") + link_directories(BEFORE "${BEHH_CASSANDRA_HEADER_DIR}") +endif(BEHH_USING_SCYLLADB) ## ## stb set(BEHH_USING_STB false) diff --git a/src/iscylladb_core_interface.cc b/src/iscylladb_core_interface.cc index beb2cf51..4dd5f679 100644 --- a/src/iscylladb_core_interface.cc +++ b/src/iscylladb_core_interface.cc @@ -65,7 +65,7 @@ void IScyllaDbCoreInterface::_IScyllaDb::print_error(CassFuture* pCassFuture, co cass_future_error_message(pCassFuture, &message, &messageSize); - std::fprintf(stderr, "ERROR: \"%s\":\n%.*s\n", info, (int)messageSize, message); + std::fprintf(stderr, "\nERROR: \"%s\":\n%.*s\n", info, (int)messageSize, message); } int32_t IScyllaDbCoreInterface::_IScyllaDb::initialize_constructor(const scylladb_connection_t& connection, const char* extra_info) { diff --git a/tests/test_database_couchbase_rw.cc b/tests/test_database_couchbase_rw.cc index 7d7f30d4..eced028e 100644 --- a/tests/test_database_couchbase_rw.cc +++ b/tests/test_database_couchbase_rw.cc @@ -81,8 +81,7 @@ class BasicDbTable : public behh::ICouchbaseCoreInterface { ///////////////////////////////////////////////////////////////// - PRAGMA_MESSAGE("TODO: initialize_table / initialize_bucket") - + // equivalent initialize_bucket void initialize_table_index() { /* not implemented */ } diff --git a/tests/test_database_scylla_rw.cc b/tests/test_database_scylla_rw.cc index 84201973..02e631b2 100644 --- a/tests/test_database_scylla_rw.cc +++ b/tests/test_database_scylla_rw.cc @@ -68,7 +68,8 @@ create table if not exists {KEYSPACE}.{TABLE_NAME} ( auto this_host = host.asString() + ","; conn.host += this_host; } - conn.host.resize(conn.host.size() - 1); // remove last , (coma) + std::cout << "conn.host: " << conn.host << "\n"; + conn.host.resize(conn.host.size() - 1); // remove last , (coma) // error in msvc, it said conn.username = CONFIG["connection"]["username"].asString(); conn.password = CONFIG["connection"]["password"].asString(); @@ -83,9 +84,6 @@ create table if not exists {KEYSPACE}.{TABLE_NAME} ( IScyllaDb.initialize_constructor(conn); - // // check table gen - // std::cout << "table gen: " << TABLE_GEN_1ST << "\n"; - // finally m_conn = conn; } @@ -93,8 +91,9 @@ create table if not exists {KEYSPACE}.{TABLE_NAME} ( void initialize() { // create keyspace if not exists + // - SimpleStrategy: required replication factor // - std::string query = "create keyspace if not exists {KEYSPACE} with replication = { 'class': '{TOPOLOGY_STRATEGY}' };"; + std::string query = "create keyspace if not exists {KEYSPACE} with replication = { 'class': '{TOPOLOGY_STRATEGY}', 'replication_factor': 3 };"; behh::utility_functions::find::and_replace_all(query, "{KEYSPACE}", m_conn.keyspace); behh::utility_functions::find::and_replace_all(query, "{TOPOLOGY_STRATEGY}", behh::scylladb_topology_strat_to_string(m_conn.strategy)); @@ -111,7 +110,9 @@ create table if not exists {KEYSPACE}.{TABLE_NAME} ( ); } - cleanup(); + // note: multiple_datacenters might need to check + + cleanup(); // remove existing table } void initialize_table() { diff --git a/tests/test_database_scylla_rw.json.debug b/tests/test_database_scylla_rw.json.debug index 6e7e4086..5f76b83c 100644 --- a/tests/test_database_scylla_rw.json.debug +++ b/tests/test_database_scylla_rw.json.debug @@ -1,49 +1,46 @@ { - "behh_test_scylladb": + "keyspace": "scope_behh_test", + // 0:undefined 1:SimpleStrategy 2:NetworkTopologyStrategy 3:LocalStrategy 4:EverywhereStrategy + "strategy": 3, + "connection": { - "keyspace": "behh_test_scylladb", - // 0:undefined 1:SimpleStrategy 2:NetworkTopologyStrategy 3:LocalStrategy 4:EverywhereStrategy - "strategy": 3, - "connection": - { - // 0:undefined 1:AllowAllAuthenticator 2:PasswordAuthenticator 3:com.scylladb.auth.TransitionalAuthenticator - "auth": 2, - "hosts": - [ - "127.0.0.1" - ], - // CHANGE_THIS_IF_REQUIRED_OR_LET_IT_EMPTY - "username": "", - // CHANGE_THIS_IF_REQUIRED_OR_LET_IT_EMPTY - "password": "" - }, - "factors_configs": // array index is set by strategy + // 0:undefined 1:AllowAllAuthenticator 2:PasswordAuthenticator 3:com.scylladb.auth.TransitionalAuthenticator + "auth": 2, + "hosts": [ - // expected for: undefined - [ - "" - ], - // expected for: SimpleStrategy - [ - "'replication_factor': 3" - ], - // expected for: NetworkTopologyStrategy - [ - "'replication_factor': 1" - ], - // expected for: LocalStrategy - [ - "'replication_factor': 3" - ], - // expected for: EverywhereStrategy - [ - "'replication_factor': 3" - ] + "127.0.0.1" ], - // if true, factors_configs_extra will be use - // replication factor need to be specific across datacenter/s - "multiple_datacenters": false, - // will ignore if length is 0 & only applied with multiple data center - "factors_configs_extra": "'dc1': 3, 'dc2': 3, 'dc3': 3" - } -} + // CHANGE_THIS_IF_REQUIRED_OR_LET_IT_EMPTY + "username": "", + // CHANGE_THIS_IF_REQUIRED_OR_LET_IT_EMPTY + "password": "" + }, + "factors_configs": // array index is set by strategy + [ + // expected for: undefined + [ + "" + ], + // expected for: SimpleStrategy + [ + "'replication_factor': 3" + ], + // expected for: NetworkTopologyStrategy + [ + "'replication_factor': 1" + ], + // expected for: LocalStrategy + [ + "'replication_factor': 3" + ], + // expected for: EverywhereStrategy + [ + "'replication_factor': 3" + ] + ], + // if true, factors_configs_extra will be use + // replication factor need to be specific across datacenter/s + "multiple_datacenters": false, + // will ignore if length is 0 & only applied with multiple data center + "factors_configs_extra": "'dc1': 3, 'dc2': 3, 'dc3': 3" +} \ No newline at end of file